Autonomous loop (Ralph, governed)
The Ralph loop (popularized by Geoffrey Huntley) is the simplest agentic-coding pattern there is:
while :; do cat PROMPT.md | claude -p; doneRe-run the agent over and over; each pass makes a little more progress, using files as memory, until the job is done. It’s effective — and unsafe on its own, because an unsupervised loop will happily build the wrong thing at full speed.
SpecForge turns that raw loop into governed autonomy. It already has everything a good loop needs, plus the one thing the raw loop lacks — a stop the human controls:
| Ralph loop needs | SpecForge provides |
|---|---|
| A durable ledger of progress | tasks.md — a checklist of [ ]/[x] tasks, each traced to a requirement |
| File-based memory | the committed specforge/ store (state.md, audit.md, artifacts) |
| A resume point | /specforge:resume — “find the first unchecked item and continue” |
| A safety rail | the gate — code edits are blocked until a human approved the spec + plan |
Two ways to run it
Section titled “Two ways to run it”In-session — Claude works the task list one task at a time:
/specforge:loopHeadless — the classic outer loop, gate-checked and iteration-bounded:
"${CLAUDE_PLUGIN_ROOT}/scripts/ralph-loop.sh" 25 # re-invokes `claude` per task until doneThe headless runner refuses to start unless the spec + plan are approved, bounds itself with a max-iteration cap, and bails out when it stops making progress or a blocker is recorded.
Why this is the safe way to go fast
Section titled “Why this is the safe way to go fast”- Nothing runs before approval — the loop inherits the gate.
- It executes a contract, not a vibe — it follows
tasks.md; it can’t invent scope. - It’s fully auditable — every ticked task and every stop is written to
state.md/audit.md. - It stops, it doesn’t spin — ambiguity becomes a recorded blocker and a halt, not a wrong guess at machine speed.
The pitch in one line: the Ralph loop’s speed, with a gate that keeps a human in the loop.