The most influential agent architecture of the past year is a bash one-liner that throws away everything the model learned on every single iteration.
while :; do cat PROMPT.md | claude-code; done. That's it. No memory, no orchestration framework, no vector store. Geoffrey Huntley published it on 14 July 2025 under the name "Ralph Wiggum as a 'software engineer'", and by mid-2026 the Ralph Wiggum loop had spawned 40+ community implementations, a Vercel Labs port, and an official Anthropic plugin for Claude Code.
TL;DR: The Ralph Wiggum loop re-feeds the same static prompt to a brand-new, stateless agent process on every iteration. All state lives in files and git commits, never in the context window. This deliberate context rotation trades in-context memory for something more valuable over hundreds of turns: failure modes you can actually inspect, bisect, and harden against.
Key takeaways
- Each iteration is a completely separate process. The agent's only "memory" is what it can read from disk: a
prd.jsontask list, aprogress.txtlog, and git history. - Huntley's core claim: "It's better to fail predictably than succeed unpredictably." Legible failure beats lucky success as an engineering substrate.
- The pattern wins on tasks with a deterministic acceptance signal (tests, migrations, specs) and loses on exploratory or ambiguous work.
- Anthropic, Vercel Labs, and dozens of community maintainers now ship implementations. The loop mechanics differ; the state model is nearly identical everywhere.
- The durable contribution isn't the bash loop. It's the externalized state model, which you can adopt without adopting the loop.
What is the Ralph Wiggum loop?
The Ralph Wiggum loop is an agent loop pattern that runs a coding agent as a stateless process: every iteration starts with an empty context window, reads its instructions and current state from files on disk, does one unit of work, commits it to git, and exits. The loop then starts a fresh agent and repeats until a completion sentinel appears or an iteration cap is hit.
The name carries two jokes. Ralph Wiggum is the lovably oblivious nine-year-old from The Simpsons who keeps going despite setbacks. And "ralph" is Australian slang for vomiting, Huntley's gloss on the volume of messy output the loop produces before it converges.
The jokes are doing real work. Each individual iteration is dumb on purpose. The intelligence lives in the harness around it.
Why would you wipe the context window on purpose?
Because context is a liability at scale, not an asset. A long-running conversational agent accumulates dead-end reasoning, failed tool-call transcripts, and stale assumptions, and the model pays attention tax on all of it every subsequent turn. Practitioners call this context rot, and the Ralph answer is context rotation: don't manage the rot, delete it.
The second reason is legibility. When the agent is forced to write its state to files, the operator can inspect that state, edit it, and version it independently of the model's reasoning.
The Anthropic plugin README puts it plainly: "Each iteration sees modified files and git history. Claude autonomously improves by reading its own past work in files."
Huntley's framing from the original post is the philosophical core:
"The technique is deterministically bad in an undeterministic world. It's better to fail predictably than succeed unpredictably."
A conversational agent that succeeds once is a black box. Its success might be luck, and the next task in the same session may fail in some unrelated way.
A Ralph loop that fails ten times before succeeding has left ten commits, ten log entries, and ten inspectable state snapshots behind. You can bisect those. You can add guardrails against them.
Huntley's metaphor is a child on a playground. Ralph falls off the slide, so you don't reach into his head; you add a sign next to the slide. Tuning happens through external signs (files, prompts, guardrails), never through mid-flight intervention.
The stateless agent's state model
If the context window holds nothing, where does everything live? Across implementations, the answer converges on a handful of files. The most thoroughly documented version is Ryan Carson's snarktank/ralph, the most-starred community implementation.
| File | What it holds | Who touches it |
|---|---|---|
PROMPT.md |
The static instruction re-fed every iteration | Human writes once |
AGENTS.md/CLAUDE.md |
Project conventions, build commands, do-not-touch lists | Human writes; agent reads each iteration |
prd.json |
User stories with acceptance criteria and apasses: boolflag each |
Human seeds it; agent flips flags |
progress.txt |
Append-only iteration log, plus a curated "Codebase Patterns" section at the top | Agent reads the top, appends below |
| Git history | The only durable cross-iteration memory | Agent commits per story |
Each iteration follows the same micro-cycle: pick the highest-priority story inprd.jsonwherepassesis false, implement it, verify against the acceptance criteria, commit with the story ID in the message, flip the flag, and append learnings toprogress.txt.
The "Codebase Patterns" sticky note is the cleverest piece. It's the agent's working memory that survives the reset, but curated rather than raw. Instead of dragging a full transcript forward, each iteration inherits a short digest of what previous iterations learned: conventions discovered, gotchas hit, approaches that worked.
And git does the rest. Commit messages encode story IDs, sogit logreads as a progress report. A session that dies at iteration 47 of 50 resumes from the log, because every completed story is already committed. mikeyobrien/ralph-orchestrator, a Rust implementation with separate planner, builder, and reviewer roles, codifies the whole stance as "Fresh Context Is Reliability."
One pattern, many harnesses
The implementations vary more than the idea does. The bash loop is the original. Anthropic's plugin replaces it with a Claude Code Stop hook that returns exit code 2, blocking the session from ending and re-feeding the prompt internally (the plugin was renamed from ralph-wiggum to ralph-loop, which tells you something about how seriously it's now taken).
Vercel Labs ported it to the AI SDK. There are variants for Cursor and Gemini CLI.
Four invariants hold everywhere: a loop, a fresh agent per iteration, a deterministic stop sentinel (snarktank greps stdout for<promise>COMPLETE</promise>; ralph-orchestrator usesLOOP_COMPLETE), and externalized state. Everything else is interchangeable.
That portability rests on AGENTS.md, the open convention for project-level agent instructions now stewarded by the Linux Foundation's Agentic AI Foundation and used by 60,000+ open-source projects. Because the loop couples to the file layout rather than to any vendor CLI, the agent at the bottom is swappable: Claude, Codex, Gemini, whatever reads the files.
When the dumb loop wins, and when it loses
Ralph is a trade, and the terms are explicit. You give up context accumulation and mid-execution steering. You get bounded cost per iteration, inspectable failures, and resumability.
The pattern wins when success is legible. TDD loops where a test runner is the judge. Greenfield builds from a written spec, like Huntley'scursedproject, a complete Gen Z programming language built end-to-end inside a Ralph loop. Migrations and large refactors where "all tests still green" fully specifies the goal state.
It loses when judgment is the work. Open-ended product design has no acceptance signal to iterate against; if theprd.jsonis wrong, the loop will faithfully build the wrong thing. Debugging that needs conversational back-and-forth dies at every reset, because the reset discards exactly the context the debugging needed.
Marc Puig's critique, "Ralph Loop Is Innovative. I Wouldn't Use It for Anything That Matters", lands on this: the determinism turns brittle when the acceptance signal itself is uncertain.
The Ralph camp's rebuttal is that this isn't a bug in the envelope, it's the envelope. Huntley's January 2026 follow-up, "everything is a ralph loop," explicitly scopes the technique to tasks with deterministic acceptance signals. Ralph is what you reach for after the spec exists, not the tool that produces the spec.
A note on cost, because the numbers floating around deserve skepticism. Huntley markets the technique as reducing software costs "to less than a fast food worker's wage," and practitioner reports put small completed sessions in the low single-digit dollars.
But these are self-reported figures, not benchmarks, and the widely circulated claim of a $50,000 contract done for $297 traces back to no findable primary source. The structural argument is sound (fresh-context iterations are cheap, and total cost scales with iteration count rather than context length).
The specific dollar figures are folklore until someone benchmarks them.
What this means for you
If you're running coding agents on long tasks, three things transfer immediately even if you never run the loop itself.
First, steal the state model. Aprd.jsonwith testable acceptance criteria, a curated learnings file, and story-ID commits make any agent workflow more resumable and more debuggable, conversational or not.
Second, write the acceptance signal before the prompt. The single biggest predictor of whether Ralph-style automation works is whether you can finish the sentence "this is done when X passes." If you can't, you're asking the loop to make a judgment call it's structurally incapable of making.
Third, treat guardrails as files, not interventions. Cap iterations (snarktank defaults to 10), run in a fresh git worktree, keep a do-not-touch list inAGENTS.md, and log every iteration to disk. The whole pattern works because tuning happens between runs, in version-controlled artifacts, instead of inside one fragile session.
The easiest on-ramp for Claude Code users is the official ralph-loop plugin; for a structured PRD-driven workflow, start from snarktank/ralph and its reference prompt files.
The Simpsons reference is a joke. The engineering underneath is not: by refusing to trust the model's memory, the Ralph Wiggum loop forces the hard parts of agentic engineering (state, acceptance criteria, failure legibility) out of the context window and into files you control.
That's not a workaround for dumb agents. It's a design principle that will outlast smart ones.
Sources
- Geoffrey Huntley's blog
- Inventing the Ralph Wiggum Loop | Creator Geoffrey Huntley (Dev Interrupted)
- snarktank/ralph (Ryan Carson's reference implementation)
- anthropics/claude-plugins-official: ralph-loop plugin
- Plugin rename PR #142: ralph-wiggum to ralph-loop
- vercel-labs/ralph-loop-agent
- mikeyobrien/ralph-orchestrator
- ghuntley/how-to-ralph-wiggum reference files
- snwfdhmp/awesome-ralph (curated implementation list)
- AGENTS.md convention
- Ralph Loop Is Innovative. I Wouldn't Use It for Anything That Matters (Marc Puig)
- The Ralph Wiggum Loop: Autonomous Code Generation with a Fresh Context (codecentric)
- Someone Put Claude in a Bash Loop Called Ralph Wiggum (Josh Owens)
- agrimsingh/ralph-wiggum-cursor
