Ralph Loops: autonomous coding on autopilot
Put the agent in a loop so that every time it thinks it's finished, it goes again. It's how an eight-minute task becomes an overnight build โ where the idea came from, how to run it, and when it's the wrong tool.
The finale for the day is genuinely a little crazy: put the agent in a loop so that whenever it thinks it's finished, it's nudged to start again and do more. This is a Ralph loop โ and it turns an eight-minute task into an eight-hour one.
01The idea: a loop around the loop
The agent already runs an inner loop โ think, act, observe, repeat โ until it decides the job is done. A Ralph loop wraps an outer loop around that: on "done," it re-prompts Claude (carefully, to keep the context from ballooning) to repeat the task from wherever it is and do it better, over and over, for a set number of iterations.
The Ralph loop is the brainchild of Australian engineer Geoffrey Huntley, named in homage to Ralph Wiggum from The Simpsons โ the endlessly optimistic character who just keeps going. Couple a Ralph loop with YOLO and you can set something running for hours, each pass building on the last.
02Running one โ via a plugin
Ralph loops ship as an official Anthropic plugin (we cover plugins properly next class). Install it, then call its command with a prompt and an iteration count.
# install the official plugin /plugin install ralph-loop@claude-plugins-official # then kick it off: prompt + how many times to loop /ralph-loop:ralph-loop "Significantly improve this project. Add users and user management, multiple Kanban boards per user, and other features to build a comprehensive PM app. Test thoroughly and keep strong coverage and integration tests." --max-iterations 10
It writes a ralph-loop-local.md file inside .claude and
sets off. Because the demo ran it without full YOLO, it paused for approvals โ always press
2 for things you're happy with, so you keep a hand on the wheel and avoid anything destructive.
Running a Ralph loop on plain YOLO with no sandbox is not a best practice โ it's a lot of unattended, unapproved action. Do it only inside a sandbox (covered next week), or stay present and approve as it goes.
03What an hour of looping produced
The demo ran for just under an hour and changed ~1,300 lines of code โ compacting itself along the way. The result was a real step-change: proper authentication with account creation, per-user multiple Kanban boards you can flip between, persistence across logout/login. It had crossed from "toy" toward "platform you could actually ship."
Single board
One hard-coded board, a demo login, no real persistence.
Multi-board app
Sign-up, auth, per-user boards, switch between them, data that survives logout.
Autonomy scales
Bigger iteration counts = overnight builds. Tens of thousands of lines, unattended.
04When to reach for Ralph loops โ and when not to
"Why not always use them?" Because you trade control for reach. The answer is the same one that runs through this whole course: match the tool to the job.
| Reach for a Ralph loop | Stick with a regimented process |
|---|---|
| Prototypes, MVPs, "out-there" experiments | Work needing predictable, reliable outcomes |
| You want maximum autonomy and reach | You want to play a primary, hands-on role |
| Overnight "just keep building" sessions (sandboxed) | Production code you'll own line by line |
Ralph loops are a first taste of multi-agent, autonomous coding. Over the next week and a half we'll make this robust โ with sub-agents in defined roles, testing baked into the process, and sandboxes for safety. This was the fun, slightly reckless preview.
โ Key takeaways
- A Ralph loop wraps an outer "not done โ go again" loop around the agent's normal loop, for N iterations.
- It's an official plugin:
/plugin install ralph-loop@claude-plugins-official, then/ralph-loop:ralph-loop "<prompt>" --max-iterations N. - Without YOLO you approve as it goes (press 2); with YOLO, only inside a sandbox.
- An hour turned a single-board toy into a multi-user, multi-board app โ scale the iterations for overnight builds.
- Great for prototypes and MVPs; use a regimented process when you need predictable, ownable results.
You drove the commands, learned the shortcut keys, mastered sessions / checkpoints / Git, ran real YOLO, and let a Ralph loop build for you. Next is an inflection point: MCP, Skills & Plugins โ the three building blocks that take your Claude Code expertise to a new level.