Real software engineering experts will repeatedly stress this: human review of AI-generated code is super important! But there are definitely some checks (like unit tests) that are tedious and time-consuming, and you really want to hand them all over to AI. The dream scenario would be: you give AI a task before bed, and when you wake up the next morning, 6 brand new libraries are done and passing all tests!
This dream scenario is now real! Boris Cherny, Claude Code’s creator, personally shared how he actually uses AI. Ralph Wiggum Loop is one of his tips. Through Ralph Wiggum Loop, you can achieve this ‘fire-and-forget’ experience.
This article will introduce what the Ralph Wiggum plugin is in Claude Code and how to use it.

How Claude Code’s Founder Does It#
Boris Cherny is one of Claude Code’s founders. In his X.com share, he mentioned his own usage stats:
“In the last thirty days, I landed 259 PRs – 497 commits, 40k lines added, 38k lines removed.
Every single line was written by Claude Code + Opus 4.5."
“Claude consistently runs for minutes, hours, and days at a time (using Stop hooks).
Software engineering is changing, and we are entering a new period in coding history.”
Things have really changed dramatically recently. At the end of 2024, Claude was still struggling with bash command escape character issues, only able to run for seconds or minutes. Now at the start of 2026, it can work continuously for days, completing entire project development.
It’s specifically the phrase “Claude works continuously for days” that caught my attention.
Boris shared his Claude Code usage tips on Threads, explicitly mentioning he uses the Ralph Wiggum plugin to run super long tasks.

He shared real battle stories: at a Y Combinator hackathon, the Ralph Wiggum plugin produced 6 working libraries overnight. Another case: a clever engineer learned the Ralph Wiggum technique and used it for contract work, completing a $50,000 contract with just $297 in API costs.
Who Created Ralph Wiggum Loop? Not Claude Code! (click to expand ▼)
The creator of the Ralph Wiggum Loop method is Geoffrey Huntley. He created this method to overcome AI agents’ common “laziness” problem—where AI, when handling complex tasks (like building backends or debugging), often writes a few lines of code or ignores errors, then confidently declares the task done and exits the conversation prematurely.
Huntley’s core work philosophy is that “Iteration > Perfection.” He believes that in AI development, failures are data, and those deterministic errors (in other words, non-random errors) are actually extremely valuable information that can guide developers to tune prompts like tuning an instrument. He emphasizes developers must have strong conviction in “eventual consistency”—through AI’s stubborn and uninterrupted self-correction loop, the correct target state will eventually be reached.
Huntley mentioned when building the CURSED language:
“Building software with Ralph requires a great deal of faith and a belief in eventual consistency. Ralph will test you. Every time Ralph has taken a wrong direction in making CURSED, I haven’t blamed the tools; instead, I’ve looked inside. Each time Ralph does something bad, Ralph gets tuned - like a guitar.”
So what exactly is this powerful Ralph Wiggum method? Let’s start from “why” we need it.
Why Do We Need Ralph Wiggum Loop?#
Problem: AI Agents “Get Lazy”?#
Most AI-assisted development is like hiring an intern who gets lazy. You have to constantly track progress and point out mistakes, which actually increases management costs. Annoying situations include:
- Premature exit: For example, when building a backend system, AI might only write a few files, ignore the database schema, then confidently declare the task complete
- Illusion of success: To save tokens or simply thinking it’s done, AI creates a hallucination of “already succeeded,” forcing you to manually check and remind it to fix missing details
- Lack of self-correction: Once the conversation ends, AI won’t proactively check previous errors unless you intervene again
Solution: Force AI to Persist#
The core concept of Ralph Wiggum Loop is: Don’t let AI easily exit until the task is truly complete.
It achieves this through Claude Code’s Stop Hook mechanism:
- When Claude finishes work and tries to end the conversation, Stop Hook intercepts this exit action
- Checks if the output contains your pre-defined “completion promise” (like
DONEorFIXED) - If not found, feeds the same prompt back to Claude
- Claude reads the previous execution log, discovers errors (like test failures), then tries to improve code in a new loop
- Continues this process until truly completing the work (or reaching the pre-set max iterations)
Fun Naming: Why Ralph Wiggum?#
Ralph Wiggum is named after a character from The Simpsons. He’s a naive kid who often does silly things but is unusually persistent.

One of Ralph’s funny lines in the show is:
His “persist even when failing” spirit perfectly embodies this method’s core philosophy.
Just like Ralph the character often makes mistakes—even obviously terrible ones—yet through continuous iteration and improvement, eventually reaches the goal. This is exactly the mode AI development needs: In an uncertain world, achieve eventual success through predictable failure patterns.
What Exactly Is Ralph Wiggum Loop? How Does It Work?#
Core Definition#
Ralph Wiggum Loop (also called Ralph Loop) is a Force Persistence iterative development methodology. Ralph’s original form was simply a bash loop:
while :; do
cat PROMPT.md | npx --yes @sourcegraph/amp
done
In Claude Code, it’s elegantly implemented as a plugin, using the Stop Hook mechanism to create a self-referential feedback loop within a single session.
Using a simple metaphor, Ralph Loop is a sweatshop that won’t let AI employees clock out. Ralph Loop puts AI employees in an office where “the door stays locked unless work is done.” It might take 10, 20 tries to get it right, but eventually it will come out with the correct result (DONE). This mechanism ensures AI won’t get lazy and leave early. AI just keeps working until the task is truly complete.
How It Works#
Let’s understand Ralph Loop’s complete operational flow. As described above, it’s a bash loop that keeps using the same prompt:
1. Initialize#
/ralph-loop "Build REST API and pass all tests" --completion-promise "DONE" --max-iterations 20
You only execute the command once, then Claude Code will:
- Receive the task description
- Start the first attempt
- Activate Stop Hook monitoring
2. Iteration Loop#
Check output for DONE}; D -->|Yes| E[Task complete]; D -->|No| F[Re-feed same prompt]; F --> A; style E fill:#90EE90; style F fill:#FFE6D1;
3. Self-Correction#
This is Ralph Loop’s most magical part: Though the prompt stays the same, the environment state changes.
- 1st iteration: Claude writes code, but tests fail
- 2nd iteration: Claude sees failed test output, modifies code
- 3rd iteration: Claude sees new error messages, keeps adjusting
- …
- Nth iteration: All tests pass, outputs
DONE, loop ends
In each iteration, Claude can see:
- Modified file contents
- Git history
- Test execution results
- Error messages
This is key! The information along with the iteration lets Claude improve code based on actual execution results, not guesses.
wouldn't that just burn money-wasting tokens doing the \*same\* thing?
Table Summary: Ralph Wiggum Loop Characteristics#
| Typical AI-Assisted Dev | Ralph Wiggum Loop |
|---|---|
| One-shot attempt, ends either way | Keeps trying until success |
| Needs manual progress tracking | Auto-tracks and corrects |
| Errors need manual feedback | Auto-reads errors and improves |
| Suited for simple tasks | Suited for complex long-term tasks |
| Can’t work offline | Can run unattended |
Ralph Wiggum Loop Quick Start Guide#
Installation & Setup#
Step 1: Install Plugin
/plugin install ralph-loop@anthropics

/plugin commandStep 2: Start Your First Ralph Loop
/ralph-loop "Write a Python calculator module with add/subtract/multiply/divide functions and complete tests" \
--completion-promise "COMPLETE" \
--max-iterations 15
Key Parameter Explanations#
--completion-promise: Define a keyword representing “done” (likeDONE,COMPLETE,FIXED). The loop only stops when Claude outputs this string--max-iterations: Max iteration limit, setting an upper bound as a safety net to prevent AI from falling into infinite loops and consuming excessive tokens. This prevents your bill from exploding, so strongly recommended to set!
Writing Effective Prompts#
✅ Good Prompt Example#
Build a REST API for todo management
Requirements:
- CRUD endpoints (GET, POST, PUT, DELETE)
- Input validation
- SQLite database
- pytest tests (coverage > 80%)
- README documentation
Completion criteria:
- All tests pass
- Linter shows no errors
- API documentation complete
- Output: <promise>COMPLETE</promise>
Writing clear completion criteria is the most important key to using Ralph Loop effectively. We’ll discuss more below.
❌ Bad Prompt Example#
Build a todo API, make it kinda nice
When Should You Use Ralph Wiggum Loop?#
Best Use Cases#
1. Test-Driven Development (TDD)#
TDD is perfect for Ralph Loop execution because test results are clear binary states (pass vs. fail). With properly defined tests, AI can automatically and clearly judge and improve. TDD is Ralph Loop’s most powerful use case.
/ralph-loop "Implement user authentication module:
1. Write tests to establish failure criteria
2. Implement features to make tests pass
3. Refactor code
4. Repeat until all tests pass and coverage > 90%
Output DONE when complete" --max-iterations 30
2. Complex Bug Fixes#
Suited when the bug’s cause is clear but the fix path is complex.
/ralph-loop "Fix tax calculation error in payment processing module:
- Reproduce bug
- Analyze root cause
- Implement fix
- Ensure all regression tests pass
- Add tests to prevent this type of error
Output FIXED when complete" --max-iterations 20
3. Large-Scale Refactoring#
Suited for handling system migrations that take hours to complete.
/ralph-loop "Migrate database from MySQL to PostgreSQL:
- Update all ORM models
- Modify query syntax
- Update tests
- Ensure all existing features work normally
Output MIGRATED when complete" --max-iterations 50
4. Automated Development#
When you need to “let go” and let AI handle brand new projects (Greenfield Projects) overnight or over weekends:
# Run before bed
/ralph-loop "Build e-commerce backend API:
Phase 1: User authentication (JWT, tests)
Phase 2: Product catalog (list/search, tests)
Phase 3: Shopping cart (add/remove, tests)
Output ECOMMERCE-COMPLETE after all phases done" --max-iterations 100
How to Judge If You Should Use It?#
Use this checklist to decide:
☑ Can success criteria be judged by machines?
- Yes: Compilation success, linter clean, tests 100% pass
- No: “Make the page pretty,” “optimize user experience”
☑ Can the task accept iterative costs?
- If you pursue stable final results meeting objective standards, not one-shot perfection
- Willing to pay for multiple API calls in exchange for automated results
☑ Can you precisely define the DONE state?
- Yes: “All tests pass and coverage > 80%”
- No: “Good enough”
Important Warnings & Limitations#
⚠️ Must Set --max-iterations#
This is the most important safety net. Without it, AI might fall into infinite loops, causing high API costs.
Simple tasks can be set to 10-20 times, large projects can boldly set 50-100 times.
⚠️ Prompt Should Explain What to Do When “Stuck”#
Claude Code can’t solve all problems even with infinite loops. To prevent AI from falling into (useless) infinite loops when it can’t solve a problem, we need to set Stuck Handling Prompts—adding an “escape hatch” in the prompt to ensure valuable feedback even in failure.
If not completed after 15 attempts:
- Log issues blocking progress
- Suggest alternative approaches
- Output BLOCKED and explain why
⚠️ --completion-promise Must Be Precise#
This parameter uses exact string matching, so:
- ✅ Ensure prompt instructs AI to output exact matching keywords
- ❌ Can’t use for multiple completion conditions (like
SUCCESSvs.BLOCKED) - ✅ Must pair with
--max-iterationsas primary safety mechanism
Least Suited Scenarios#
❌ Needs Human Judgment or (Subjective) Aesthetic Standards#
Broadly speaking, any task that can’t be automatically verified by code isn’t suited for Ralph Loop. For example, “pretty” can’t be auto-verified—AI will guess randomly and immediately claim completion.
# Bad example
/ralph-loop "Make the homepage pretty" --completion-promise "DONE"
❌ Pursuing Immediate Results from One-Shot Operations#
If you need to see results immediately and interact, traditional chat mode is more efficient.
❌ Production Environments Shouldn’t Use This!#
In production environments, use targeted debugging. Never let AI randomly modify PROD’s critical infrastructure in a loop.
❌ Needs External Approval or Human Intervention#
If the process needs your approval midway, Ralph’s auto-loop advantage disappears.
Conclusion#
Ralph Wiggum Loop embodies several key principles:
- Deterministic failure: Predictably fail in an uncertain world
- Persistence over perfection: Don’t pursue one-shot perfection, achieve eventual consistency through iteration
- Human-AI collaboration: Allow human intervention for tuning, but don’t depend on continuous supervision
This technique’s success key is giving AI clear success criteria, automated verification mechanisms (like tests), and enough iteration space. I think Ralph Loop is very similar to Machine Learning workflows. The keys to success are both about defining good evaluation metrics, then letting the program learn in each iteration.
Now you understand the complete concept of Ralph Wiggum Loop. Try it yourself:
- Install plugin:
/plugin install ralph-loop@anthropics - Set a clear task with completion criteria
- Set reasonable
--max-iterationslimit - Start the loop, then confidently grab a coffee ☕
Then think about Ralph’s catchphrase: "I’m learnding!” Hope your AI agent can also truly learn how to complete tasks through continuous iteration.
References:
- Claude Code official Ralph Wiggum plugin
- Geoffrey Huntley: Ralph is a Bash Loop
- Ralph Orchestrator: Community-developed advanced tool for coordinating multiple Ralph Loops
- Y Combinator success story: Documents how a developer used Ralph loop to auto-deliver 6 project repos overnight
I hope this post helped you. I’ll keep sharing what I learn about Claude Code and AI.

