Home / Patterns

WTF is Ralph Wiggum Loop?

emergingFirst seen 14 Jul 2025

Running a coding agent in a dumb bash loop, with a fresh context each time, until the spec is satisfied.

Also called: ralph loop, ralph, ralph wiggum technique

TL;DR

Named after the Simpsons character who keeps cheerfully trying. Instead of one long agent session that fills up with history, you restart the agent over and over with the same prompt file. Each run starts clean, reads the spec and the plan, does one thing, and leaves its work in the repo for the next run to build on.

How it works

The whole technique is roughly `while :; do cat PROMPT.md | coding-agent; done`. Its principles: one task per iteration; a fresh context window each loop so context rot never sets in; state lives in files, not in the conversation (specs, a fix plan, tests, logs); failures are "deterministically bad", meaning the agent fails the same way each time, so you fix the prompt or spec rather than the output. Huntley allows subagents for cheap parallel work like search but keeps validation in a single agent. Critics note it burns tokens and depends entirely on good specs and tests to stop.

Example

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

Origin

Coined / introduced by
Geoffrey Huntley
When
14 Jul 2025
Story
Described on his blog as 'the Ralph Wiggum technique'; became a popular pattern for long autonomous coding runs.

Related jargons

Sources