Overview
Ralph is a development methodology based on continuous AI agent loops. As Geoffrey Huntley describes it: “Ralph is a Bash loop” - Claude repeatedly works on the same prompt, seeing its previous work in files, until the task is complete. The technique is named after Ralph Wiggum from The Simpsons, embodying the philosophy of persistent iteration despite setbacks.How It Works
Ralph uses a Stop hook that intercepts Claude’s exit attempts:Self-Referential Feedback Loop
The magic happens because:- The prompt never changes between iterations
- Claude’s previous work persists in files and git history
- Each iteration sees modified files from the last attempt
- Claude autonomously improves by reading its own past work
Installation
This plugin is bundled with Claude Code. To enable it:Commands
/ralph-loop
Start a Ralph iteration loop.The task description (never changes between iterations)
Stop after N iterations (default: unlimited)Always recommended as a safety net
Exact phrase that signals task completionExample:
"COMPLETE", "DONE", "SUCCESS"/cancel-ralph
Cancel the active Ralph loop.Quick Start
Iteration 2
Claude sees failed tests in terminal output, fixes validation bugs, reruns tests. Some pass.
Prompt Writing Best Practices
1. Clear Completion Criteria
❌ Bad: “Build a todo API and make it good.” ✅ Good:2. Incremental Goals
❌ Bad: “Create a complete e-commerce platform.” ✅ Good:3. Self-Correction Instructions
❌ Bad: “Write code for feature X.” ✅ Good:4. Always Use Escape Hatches
Always set--max-iterations as a safety net:
Philosophy
Ralph embodies these principles:Iteration > Perfection
Don’t aim for perfect on first try. Let the loop refine the work.
Failures Are Data
Failures are predictable and informative. Use them to tune prompts.
Operator Skill Matters
Success depends on writing good prompts, not just having a good model.
Persistence Wins
Keep trying until success. The loop handles retry logic automatically.
When to Use Ralph
Good For
- Well-defined tasks with clear success criteria
- Iterative refinement (e.g., getting tests to pass)
- Greenfield projects where you can step away
- Tasks with automatic verification (tests, linters, builds)
Not Good For
- Tasks requiring human judgment or design decisions
- One-shot operations
- Tasks with unclear success criteria
- Production debugging (use targeted debugging instead)
Real-World Results
From the community:6 Repositories
Generated overnight during Y Combinator hackathon testing
$50k Contract
Completed for $297 in API costs
Programming Language
Created entire language (“cursed”) over 3 months
Technical Details
How the Stop Hook Works
Fromhooks/stop-hook.sh:
- Original prompt from
/ralph-loopinvocation - All conversation history
- File system state
- Git history
Examples
Example 1: Build and Test
Example 2: Bug Fixing Loop
Example 3: Documentation Generation
Troubleshooting
Loop Runs Forever
Cause: Completion promise never appears or max iterations not set. Solution:Task Not Making Progress
Cause: Prompt lacks self-correction instructions. Solution: Add explicit iteration steps:Completion Promise Not Detected
Cause: String mismatch (case-sensitive, whitespace matters). Solution: Use simple, unique strings:Learn More
- Original Ralph Technique - Geoffrey Huntley’s blog
- Ralph Orchestrator - External tooling
Details
Plugin Information
Plugin Information
Name: ralph-wiggumType: Stop Hook + CommandsAuthor: Daisy Hollman ([email protected])Version: 1.0.0Commands:
/ralph-loop, /cancel-ralphHook: hooks/stop-hook.shRelated
Task Automation
Other automation patterns
Hook Development
Build your own Stop hooks