This guide walks you from zero to a functioning Ralph loop so you can author specs-as-code, watch the AI assistant execute them, and iterate quickly. You'll learn what the tool does, how to install it, how to prepare your repo, and how to guide the loop through its first real task.
Ralph is a simple loop: it keeps asking the AI assistant to work on your project, shows the conversation in a friendly terminal window, remembers how many tokens and dollars you have spent, and lets you pause whenever you want to make edits before resuming.
- macOS or Linux shell with 256-color support.
- Claude CLI installed and logged in (
claude whoamishould work). - Git.
brew tap agentic-metallurgy/tap
brew install ralphRun Ralph inside the repo that houses your code. Create a specs folder if it does not exist yet, and keep your spec files in there so Claude can find them.
Create specs/default.md with 5–10 punchy lines describing the product. Example:
# default.md
- Build an MCP server using fastmcp that stores simple text notes and reminders.
- Notes support add, list, search, and delete actions.
- Reminders contain a message + due timestamp and can be created, listed, or removed.
- Persist all data to local JSON files so it survives restarts.
- Expose minimal MCP tools like add_note, list_notes, search_notes, add_reminder, list_reminders, etc.
- Provide a `docker compose up` entry point.
- Make the MCP interface available at http://localhost:7878/mcp.Treat this file as the canonical truth. Because the default prompt explicitly tells Claude to "familiarize yourself with the specs in the specs/ directory," it will open this file at the start of every iteration.
From the project root:
ralph --iterations 10 # default prompt, specs/ folder, 10 passesRalph streams Claude's work into the TUI immediately; you can quit early with q or Ctrl+C. Stats persist to .ralph.claude_stats, so the next run resumes the elapsed-time counter and usage totals.
The interface has two major regions:
- Status + Activity Feed: The top panel shows
RUNNINGorSTOPPED. Inside, every message line is tagged with an emoji (🤖 assistant, 🔧 tool use, 📝 user, 💰 system/cost, 💭 thinking, 🚀 loop marker, 🛑 stop, 💤 rate-limit hibernation). You can watch when Claude enters/exits loops, issues shell commands, or runs tests. - Footer: Two side-by-side panels — "Usage & Cost" (tokens, per-direction counts, cumulative USD) on the left, "Loop Details" (progress e.g. 3/10, elapsed time) on the right. Below both panels sits a hotkey bar showing available controls.
- Press
pto pause the loop. Ralph cancels the in-flight iteration, swaps the status color to red, and freezes the timer. - Modify
specs/default.md, edit or deleteIMPLEMENTATION_PLAN.md, then save your changes. - Stage code changes manually if you want Claude to see a clean diff.
- Press
rorsto resume the loop. Ralph resumes from the same iteration number (it repeats the interrupted pass). You can also use+/-to adjust the remaining iteration count.
This workflow lets you steer Claude tightly: capture regressions, adjust specs, and rerun after manual fixes.
Ralph's default instructions already tell Claude to run tests and make commits for you. Expect local commits (but no pushes) to appear as the loop progresses. Keep any helper scripts (make test, etc.) ready so Claude can use them.
- Install Ralph and Claude CLI.
- Create
specs/default.md(Ralph will createIMPLEMENTATION_PLAN.mdthe first time it runs, and you can edit it afterward). - Run
ralph --iterations Nfrom the repo root. - Watch the TUI, pausing whenever you want to edit specs or code.
- Let Ralph run until a milestone lands, validate locally, and commit.
That's your first spec-as-code loop: write specs like regular code, keep them under version control, and let Ralph continuously translate them into working software.