Introduction
The Ralph technique is a deliberately crude agentic coding method: you run an AI coding agent in an infinite while loop that re-feeds essentially the same prompt on every iteration, and you let the filesystem — plan, todo and notes files — carry memory between runs. Named "Ralph Wiggum as a software engineer" by Australian engineer Geoffrey Huntley, it is the ancestor technique behind the 2026 wave of loop engineering: designing systems that prompt your agents instead of prompting them by hand.
Huntley's own motto for it is "deterministically bad in an undeterministic world" — the loop fails in predictable ways you can fix by editing the prompt, rather than in novel ways you cannot. This post explains how the Ralph loop actually works, the numbers people quote for it, how it relates to the newer loop-engineering movement and Anthropic's official Routines feature, and the sharp critiques that say brute-force looping is not the whole story.
What Is the Ralph Technique?
At its core the Ralph loop is one line of shell:
while :; do cat PROMPT.md | claude-code ; done
That is the whole trick. A coding agent reads a fixed prompt file, does one unit of work, exits, and the loop immediately restarts it with the same prompt. Nothing about the instruction changes between iterations — the world does. Because the agent keeps re-reading the repository and its own scratch files, each pass finds the codebase a little further along than the last.
How the Ralph loop keeps memory on disk
Ralph does not rely on a long chat history. State lives in the filesystem, which is what makes the loop restartable:
PROMPT.md— the core instructions fed in every iteration.fix_plan.md— a prioritized todo list the agent reads and updates.AGENT.md— learned build and execution knowledge (how to compile, how to test).specs/— technical specifications the agent works against.
Two rules make it hang together. Ralph does one task per loop iteration to protect its roughly 170k-token context window from filling with noise, and it is told to search before assuming something is unimplemented, so it does not rewrite work it already did. This is an agentic workflow stripped to its bones: no orchestration graph, no message bus, just a loop and some markdown.
Monolithic on purpose
Ralph is intentionally not a multi-agent system. Huntley describes it as "monolithic" — a single process working in a single repository. It can fan out up to 500 parallel subagents for cheap, non-critical work like filesystem search and code writing, but it deliberately funnels build-and-test validation through a single subagent to manage backpressure. The philosophy Huntley repeats is "sit on the loop, not in it": your job is to watch the loop and refine the prompt, not to babysit each step.
What Ralph Built, and the $297 Number
The headline artifact is Cursed, a self-hosting compiler and esoteric programming language Huntley has been building almost entirely by running Ralph. The most-quoted cost figure attached to the technique is stark: an engineer reported delivering an MVP — tested and reviewed, against a roughly $50,000-scope contract — for about $297 in API costs by putting the agent in a loop. A Y Combinator hackathon write-up captured the same energy in a headline: "We Put a Coding Agent in a While Loop and It Shipped 6 Repos Overnight."
Huntley is candid about the ceiling. He puts Ralph at roughly 90% completion on greenfield projects and calls it unsuitable for legacy codebases. The loop leaves behind "garbage, temporary files, and binaries", and when it goes off the rails the fix is often a git reset --hard and a rescue prompt. Ralph, in his framing, still needs a senior engineer steering it — it lowers the cost of iteration, not the cost of judgment.
The Ralph Ecosystem
The technique has grown a small ecosystem. A curated list at github.com/snwfdhmp/awesome-ralph collects resources and implementations, describing Ralph as "the AI coding technique that runs AI coding agents in automated loops until specifications are fulfilled." Community ports adapt the loop to different harnesses, including Cursor plugins such as ralph-wiggum-cursor and cursor-ralph that add token tracking and context rotation (for example, rotating context around the 80k-token mark). The reference harness in most write-ups is Claude Code, because Ralph works best with an agent that has no hard cap on tool calls per session.
What Is Loop Engineering?
If Ralph is the ancestor technique, loop engineering is the named movement it inspired. Addy Osmani gave the term its cleanest definition: "Loop engineering is replacing yourself as the person who prompts the agent. You design the system that does it instead." He frames it as a "recursive goal where you define a purpose and the AI iterates until complete", sitting "one floor above" the work of building a harness for a single agent.
The idea caught fire through practitioners, not vendors. Peter Steinberger's much-shared post argued "you shouldn't be prompting coding agents anymore — you should be designing loops that prompt your agents", and Boris Cherny, who leads Claude Code, echoed it plainly: "I don't prompt Claude anymore. I have loops running that prompt Claude... My job is to write loops." Ralph is the crude proof-of-concept; loop engineering is the discipline that grew up around watching agents mature enough to run unattended, verify their own work by running tests, and persist state across turns.
From Ralph to Anthropic Routines
The movement became an official feature in 2026. Anthropic shipped Routines for Claude Code and a matching vocabulary of loop commands:
/loop— runs a time-based loop on your machine; stop the machine and it stops./goal— a goal-based loop where you define a success condition (tests passing, lint clean, an end-to-end check going green); each time the agent tries to stop, a separate evaluator model checks the condition and sends it back to work until the goal is met or a turn limit you set is reached./schedule— promotes a loop into a Routine that runs on Anthropic-managed cloud infrastructure, so it keeps working after you close your laptop.
Teams use Routines for issue triage, deployment verification, alert analysis and documentation updates. The lineage matters for how you read the space: Ralph/Huntley is the ancestor hack, Osmani named the discipline, and Anthropic Routines is the productized feature — three different things that often get flattened into one. For the context-management practices that make any of these loops survivable, our write-ups on context engineering for agents and Claude Code best practices go deeper.
The Critique: Agent Loop vs. Harness Loop
The balanced view says Ralph is genuinely useful and also genuinely crude, and the most useful critique comes from Armin Ronacher's essay "The Coming Loop." Ronacher draws a distinction worth keeping straight. The agent loop is internal: the model calls a tool, reads the result, edits a file, runs tests, and eventually declares an answer. The harness loop is external: work enters a queue, a machine attempts it and stops, and "some harness decides whether that was actually the end" — re-injecting a message or starting a fresh session if not. Ralph is a harness loop, and Ronacher notes the pattern "is not new" — "we have been doing versions of this since early Claude Code days."
His warning is the important part. Loop-driven code tends to rot in a specific direction: "present-day models tend to produce code that is too defensive, too complex, too local in its reasoning. They avoid strong invariants." Each iteration observes a local failure and adds a local defense, so the system "slowly becomes less understandable while appearing more robust." Combine that with Ralph's own admissions — burned tokens, temp-file sprawl, a 90% ceiling — and the picture is clear: an unattended loop buys throughput, but it can quietly trade away architectural coherence.
Ralph vs. Structured Review
It is worth contrasting Ralph with the opposite school of prompting. Garry Tan's senior-engineer Claude Code prompt leans on Plan Mode: a single, heavily structured pass that forces the agent to research architecture, weigh trade-offs and commit to an opinionated recommendation before writing code. Ralph inverts that — it barely plans, and instead bets that a cheap iteration run thousands of times will converge. Structured review optimizes for a correct first draft; the Ralph loop optimizes for a correct thousandth draft. Neither is wrong, and mature teams increasingly do both: a plan-mode pass to set direction, then a bounded loop with a /goal stop condition to grind it out.
Conclusion
The Ralph technique matters less as a tool than as an idea that turned out to be right: give a capable agent a fixed prompt, durable file-based memory and permission to keep going, and it will build more than its crudeness suggests it should. That idea scaled from Huntley's while loop into loop engineering as a named practice and finally into Claude Code Routines as a shipped feature. But the honest version keeps the critique attached — loops burn tokens, drift toward defensive complexity, and still need a senior engineer to decide when the output is actually done. Use the loop for throughput; keep the judgment for yourself.
For contrasting ways to structure AI coding work, see Garry Tan's gstack setup and how coding agents actually work under the hood.