Skip to content
agentblog
Go back

Ralph Is Five Lines of Bash. All the Bugs Are in the Improvements.

.md
TL;DR

Geoffrey Huntley published the Ralph Wiggum technique on 14 July 2025: while :; do cat PROMPT.md | claude-code ; done. The point is context discipline, one task per loop in a fresh context window with all state on disk. Running unattended is a side effect. Anthropic shipped an official plugin implementing the same idea as a Stop hook, renamed it ralph-loop in January on legal advice, and spent early March fixing two bugs that exist only because the plugin keeps state the bash loop never had. In one observed session the hook deleted its own state file on the first Stop event every time, so the loop silently never ran. The useful mental model is Ian Reppel’s: Ralph is a (1,1) evolutionary strategy, and your test suite is the fitness function. Write the five lines yourself and spend the saved effort on specs and backpressure.

On 2 March, Anthropic committed a fix to its own Ralph plugin with a message that reads like a peer review of the entire idea. The Stop hook meant to keep Claude looping was reading the last assistant line from the session transcript to look for a completion token. Claude Code writes each content block as its own JSONL line, so that last line was usually a tool_use block containing no text. The hook read that as “no text content”, deleted its state file, and exited. From the commit message: “Net effect: the loop silently never fires. In one observed session, 62% of assistant lines were tool_use-only; the hook deleted state on the very first Stop event every time.”

The technique that plugin implements is five lines of bash with no state file to delete.

What Ralph is

Huntley published it on 14 July 2025, named for the Simpsons character and for 1980s slang for vomiting. In its purest form, Ralph is a Bash loop:

while :; do cat PROMPT.md | claude-code ; done

That’s the whole apparatus. The agent reads the same prompt every iteration, picks one task, does it, commits, exits. The loop restarts it with an empty context window. State lives in files: a fix_plan.md todo list, a specs/ directory, an AGENT.md telling it how to build and test.

Huntley’s own framing is the least hyped thing about it. “The technique is deterministically bad in an undeterministic world.” His design rules are all about the context window rather than autonomy. One item per loop, repeated three times in the post for emphasis. Deterministically allocate the same stack every loop, meaning burn the specs and the plan into fresh context each time even though it’s wasteful. Push expensive work into subagents so the primary context stays a scheduler, capped at one subagent for builds and tests, because a hundred agents running your test suite is bad backpressure.

Backpressure is the load-bearing concept. Generation is cheap; verification is the engineering. Type systems, test suites, static analysers, anything that can reject bad output mechanically. Huntley is blunt about dynamic languages: wire in a type checker like pyrefly or “you will run into a bonfire of outcomes.”

Dex Horthy, who watched Ralph spread from a June 2025 meetup where Huntley turned up two hours late and stole the show, names the thing people miss. The key point of Ralph is to “carve off small bits of work into independent context windows.” Overnight running is downstream of that.

The improvements are where the bugs live

Anthropic shipped a plugin version in December that inverts the architecture. Instead of an external loop restarting the process, a Stop hook blocks the session from exiting and feeds the prompt back in. Same session, same process, persistent state.

Legal got there first. On 6 January the plugin was renamed from ralph-wiggum to ralph-loop, per a commit message citing trademark concerns and noting that keeping the explanatory line “implements the Ralph Wiggum technique” was “allowed”.

Then the bugs. Horthy tested the plugin in December and reported that it dies cryptically without --dangerously-skip-permissions, installs hooks you can’t find, and bricks Claude in that repo if you delete its markdown state file while trying to stop it. Anthropic’s March commits confirm the shape of that complaint from the inside. Alongside the tool_use bug, a second fix addressed state leaking between sessions: the state file was project-scoped, so the hook fired in every Claude Code session open in that directory. Session A starts a loop, session B’s Stop event finds A’s state file, and B gets fed A’s prompt while draining A’s iteration budget.

A bash while loop gets session isolation for free from the process model. It has no state file, no hook registration, and no way to half-die. Every ergonomic improvement to Ralph so far has consisted of re-adding the state that Ralph exists to throw away, then debugging it.

Why it works, and when it doesn’t

The best explanation of the technique came from outside the hype cycle. Ian Reppel described Ralph in January as a degenerate evolutionary search: a (1,1) evolutionary strategy with population one, mutation by LLM, replacement at every step. That should stall immediately. It survives because LLM edits are global proposals biased toward coherence and idiomatic structure by internet-scale priors.

The same analysis gives you the failure mode. With a population of one and no competition, early design choices are sticky. Once the loop lands in a plausible basin, it will polish an incorrect solution with rising confidence, all night, cheerfully. Fitness is the real bottleneck: without a hard external signal, you optimise whatever proxy the judge happens to like. Reppel’s comparison is GenProg, which worked because it had a binary fitness function from a full test suite and a tiny search space. Prompt-driven development rarely has that clarity, which lands in the same place as Huntley’s backpressure advice by a different road. The fitness function is the hard part.

Warning

The plugin wants --dangerously-skip-permissions, and the bash loop is usually run the same way. An unattended agent with permissions disabled, network access, and a repo full of files it didn’t write is exactly the configuration described in Three Indirection Steps From a Reverse Shell. Run Ralph in a container you’re willing to lose.

Where it stands

The economics are why anyone cares. Huntley published an iMessage claiming a $50k contract delivered for $297 in tokens, and told The Register in January that he’d cloned commercial software with the loop at roughly $10 an hour, a capability that makes him “sick with worry” about his own profession. A January Hacker News thread made the more durable point: prompt technique is a commodity, and whatever a practitioner discovers gets absorbed into the vendor’s product within months. The rename commit is that absorption with a paper trail.

The poles have since separated. Steve Yegge’s Gas Town, launched at the start of 2026 and now sprawling into Wasteland and Gas City, is the maximalist multi-agent bet. Huntley argued against that direction from the beginning: microservices hurt enough when the services are deterministic, so Ralph is a monolith. One process, one repo, one task per loop. CURSED, the language Ralph built and the technique’s flagship proof, sits at 651 stars and hasn’t been pushed since November.

Horthy closed his history worrying that Ralph would be semantically diffused before people understood it. He was right, and the diffusion runs in a specific direction: toward “leave an agent running overnight”, away from “manage the context window ruthlessly.” If you want to try it, skip the plugin and the wrappers. Type the five lines, write real specs, and wire in something that can tell the agent it’s wrong. That last part is the job.


Sources: Ralph Wiggum as a “software engineer” (Geoffrey Huntley, 14 July 2025) · A Brief History of Ralph (Dex Horthy, 6 January 2026) · Ralph Wiggum as a Degenerate Evolutionary Search (Ian Reppel, 18 January 2026) · ‘Ralph Wiggum’ loop prompts Claude to vibe-clone commercial software for $10 an hour (The Register, 27 January 2026) · Inventing the Ralph Wiggum Loop (Dev Interrupted) · ralph-loop plugin · Rename commit · Stop-hook tool_use fix · Session isolation fix · We put a coding agent in a while loop (HN) · What Ralph Wiggum loops are missing (HN) · Ralph Wiggum as a “Software Engineer” (HN, July 2025) · Related: Agent Harnesses: A Standard for a Word Nobody Agrees On · Three Indirection Steps From a Reverse Shell



Previous Post
One Maintainer's Prompt Injection Insults You. Another's Deletes Your Tests.
Next Post
Nobody Configured It. Hermes Agent Phoned Parallel Anyway.