Ralph loop (Ralph Wiggum technique)
Running the same prompt against a coding agent again and again, each time with a fresh context, while progress lives in files and tests decide when it is done.
Geoffrey Huntley named the technique after the Simpsons character who keeps going whatever happens. At its simplest it is a shell loop that pipes one prompt file into the agent. Each run starts with an empty context, reads the plan, todo and notes files, does one piece of work and writes its progress back, so it avoids context rot in long sessions. What makes it converge is the verifier: tests, a linter or an audit that fails until the work is right. The wider practice of designing such loops, instead of prompting agents by hand, is sometimes called loop engineering.
Related terms
- Agentic loop: The cycle of model call, tool call and result that an agent repeats until it stops.
- Context rot: Model quality drops as the context fills with old, irrelevant or conflicting material.
- Hooks: Scripts the harness runs automatically at fixed points, such as before a tool call or after an edit.
- Audit-driven development: A loop for code you maintain: an AI agent audits it against a checklist, the findings become small fixes, and it audits again until nothing is left.
- Software factory (AI agents): A pipeline where agents write and fix most of the code while people write specs, set guardrails, design the checks and decide what ships.
