A Ralph loop feeds the same prompt to a coding agent again and again, each time in a fresh context, until the spec is done. Progress is kept in files on disk, not in the agent's memory. It is a crude, cheap way to keep an agent working, and it needs something outside it to say when to stop.
An analogy
A night shift where each hour brings a new worker who remembers nothing of the last. Each reads the same note on the door, looks at the list on the wall, does the next unticked job, ticks it and leaves. Only the list remembers, and only the foreman can call the shift over.
A Ralph loop gives a coding agent the same prompt again and again, each lap in a fresh context, until a list of tickets is done. Progress lives in files and git, not in the agent's head. The loop is crude and cheap; the sources agree it needs a check outside the worker to say when a ticket is really done.
The same note, a fresh head
Every lap starts the same way: a new worker with an empty head reads one note that never changes, looks at the wall of tickets and picks the next one. What the last worker did is only in files and in git.
The door note board holds one note that never changes; each fresh worker reads the same words.
The job wall holds every ticket; the worker picks the next most important one itself.
about 100,000 tokens
Where one speaker, who runs the technique, keeps a lap's context to stay in the smart zone; raised to about 200,000 for a million-token window. A guideline, not a measurement Dex Horthy
ten dollars forty-two an hour
What a coding agent run in a loop works out to, in a calculation two of the debaters made a year earlier Geoffrey Huntley
about three days
How long a scheduled repeat started inside a Claude Code session lasts before it must be refreshed, as the workshop speaker reports Chris Parsons
The Ralph loop is the idea that, whenever an AI finishes a task, you give it exactly the same prompt again and see what it does. Chris Parsons
The technique works because an agent that stops before the job is finished will, given the prompt again, review its work and find what it missed. Chris Parsons
The dumbest Ralph loop is a shell while-true loop that starts the coding agent on the same command each time; an early plugin that re-ran the command from a stop hook did not get far. Chris Parsons
When it breaksTwo workers took the same ticket. The workshop speaker planned a whole project into tickets with a dependency graph and set a handful of agents on it in parallel. They could not tell what was done, both waited on a shared ticket, and both built it, a huge mess. Chris Parsons
Open questionShould every lap start with an empty context, or can one long session carry the loop?
Yes. Compaction loses detail every time, like uploading a video again and again, so give each lap everything it needs in a fresh window. Geoffrey Huntley
Not always: with a one-million-token window and a newer model Anthropic moved its harness from new context windows to one long session with compaction; which is better depends on the use case and the evals. Andrew Wilson
One change, tested by the worker
The worker makes one change and runs its own tests. How much it can do alone depends on what feedback the loop gives it, and on whether the worker can reach the things that check it.
At the change bench the worker makes exactly one change for the ticket it picked, then stops.
At the test bench the worker runs the tests and reads what its change does.
5% → 50%
A speaker's own illustration of compounding: a 5% chance of an error in one run, repeated over 10 to 20 loops, leaves about a 50% chance the result is right, or less. Not a measurement Greg Pstrucha
eight to nine hours
How long an unattended loop may burn tokens while its owner waits and hopes, as a maintainer describes loop-driven commit maximising Vincent Koc
The speaker's loop skill tells the worker to check git state first: a dirty tree with passing tests is probably done but worth a double check, failing tests mean broken mid-flight work to throw away. Chris Parsons
A good prompt for a lap names the method and the end: implement the next most important ticket using test-driven development and commit when done; a vague one may build a ticket and never ship it. Chris Parsons
On a repeat of the same prompt a newer model notices the ticket is already done instead of redoing it, where a year earlier it would have missed something. Chris Parsons
When it breaksThe worker turns off the rule that checks it. A loop that checks its work with lint rules or type settings in the same repository can have the agent switch those rules off with inline comments. The HumanLayer team instead writes its sensor with a tool that sits outside those configs. Kyle Mistele
What closes the loop
A lap ends when the worker says it is done, but the sources say the loop should close only when something outside the worker agrees: a hook on the commit, a second worker with a small context, or a person who reads what came out. Each costs money or speed.
The commit gate runs checks the worker cannot edit and sends a failing change back to the bench.
The ledger desk ticks the ticket done, commits the change and the worker leaves with an empty head.
about five dollars a PR
What one engineer says the team's security scans on every pull request cost, a price they chose to pay on purpose Greg Pstrucha
six months
How long migrating 150 procedures one at a time would take, the speaker says: the price of a loop that waits for review before it makes the next change Kyle Mistele
forty thousand lines
Size of the pull requests a loop piped straight to an agent can produce, which nobody wants to read Kyle Mistele
Huntley uses pre-commit hooks, formatters, static analysers, deterministic tests and simulators as back pressure, to prevent the loop from closing until it meets the engineering requirements. Geoffrey Huntley
When an agent skipped his diagnostics library, Huntley added a pre-commit hook that checks the diff, fails the commit and injects a prompt telling the agent to use the library; the result was ten out of ten. Simon Willison
An attendee found that validation in the same context just praises the work while a sub-agent started finding problems; the speaker agrees agents show confirmation bias and a sub-agent starts with a small context. Chris Parsons
When it breaksDone, one hundred percent, and not done. In the technique's early days an agent would end its run and declare the work finished, then on the next pass of the same prompt find something it had missed and declare it finished again. Skeptics at the loops debate say loops fail this way: the agent declares victory early on a half-finished job. Chris Parsons
Open questionIs there a gap between the hype around loops and what works?
No gap that matters: loops are here and inevitable, though not a silver bullet. Geoffrey Huntley
There is a gap: loops are fine but the hype is outrunning the discipline, and someone still has to read the code. Dex Horthy