Implementation of the Ralph Wiggum technique for iterative, self-referential AI development loops in Claude Code. Ralph is a development methodology based on continuous AI agent loops. As Geoffrey Huntley describes it: "Ralph is a Bash loop" - a simple while true that repeatedly feeds an AI agent a prompt file, allowing it to iteratively improve its work until completion. The technique is named af
Add this skill
npx mdskills install anthropics/claude-codeImplements iterative AI development loops with clear instructions, examples, and safety mechanisms
Implementation of the Ralph Wiggum technique for iterative, self-referential AI development loops in Claude Code.
Ralph is a development methodology based on continuous AI agent loops. As Geoffrey Huntley describes it: "Ralph is a Bash loop" - a simple while true that repeatedly feeds an AI agent a prompt file, allowing it to iteratively improve its work until completion.
The technique is named after Ralph Wiggum from The Simpsons, embodying the philosophy of persistent iteration despite setbacks.
This plugin implements Ralph using a Stop hook that intercepts Claude's exit attempts:
# You run ONCE:
/ralph-loop "Your task description" --completion-promise "DONE"
# Then Claude Code automatically:
# 1. Works on the task
# 2. Tries to exit
# 3. Stop hook blocks exit
# 4. Stop hook feeds the SAME prompt back
# 5. Repeat until completion
The loop happens inside your current session - you don't need external bash loops. The Stop hook in hooks/stop-hook.sh creates the self-referential feedback loop by blocking normal session exit.
This creates a self-referential feedback loop where:
/ralph-loop "Build a REST API for todos. Requirements: CRUD operations, input validation, tests. Output COMPLETE when done." --completion-promise "COMPLETE" --max-iterations 50
Claude will:
Start a Ralph loop in your current session.
Usage:
/ralph-loop "" --max-iterations --completion-promise ""
Options:
--max-iterations - Stop after N iterations (default: unlimited)--completion-promise - Phrase that signals completionCancel the active Ralph loop.
Usage:
/cancel-ralph
❌ Bad: "Build a todo API and make it good."
✅ Good:
Build a REST API for todos.
When complete:
- All CRUD endpoints working
- Input validation in place
- Tests passing (coverage > 80%)
- README with API docs
- Output: COMPLETE
❌ Bad: "Create a complete e-commerce platform."
✅ Good:
Phase 1: User authentication (JWT, tests)
Phase 2: Product catalog (list/search, tests)
Phase 3: Shopping cart (add/remove, tests)
Output COMPLETE when all phases done.
❌ Bad: "Write code for feature X."
✅ Good:
Implement feature X following TDD:
1. Write failing tests
2. Implement feature
3. Run tests
4. If any fail, debug and fix
5. Refactor if needed
6. Repeat until all green
7. Output: COMPLETE
Always use --max-iterations as a safety net to prevent infinite loops on impossible tasks:
# Recommended: Always set a reasonable iteration limit
/ralph-loop "Try to implement feature X" --max-iterations 20
# In your prompt, include what to do if stuck:
# "After 15 iterations, if not complete:
# - Document what's blocking progress
# - List what was attempted
# - Suggest alternative approaches"
Note: The --completion-promise uses exact string matching, so you cannot use it for multiple completion conditions (like "SUCCESS" vs "BLOCKED"). Always rely on --max-iterations as your primary safety mechanism.
Ralph embodies several key principles:
Don't aim for perfect on first try. Let the loop refine the work.
"Deterministically bad" means failures are predictable and informative. Use them to tune prompts.
Success depends on writing good prompts, not just having a good model.
Keep trying until success. The loop handles retry logic automatically.
Good for:
Not good for:
Run /help in Claude Code for detailed command reference and examples.
Install via CLI
npx mdskills install anthropics/claude-codeRalph Wiggum Plugin is a free, open-source AI agent skill. Implementation of the Ralph Wiggum technique for iterative, self-referential AI development loops in Claude Code. Ralph is a development methodology based on continuous AI agent loops. As Geoffrey Huntley describes it: "Ralph is a Bash loop" - a simple while true that repeatedly feeds an AI agent a prompt file, allowing it to iteratively improve its work until completion. The technique is named af
Install Ralph Wiggum Plugin with a single command:
npx mdskills install anthropics/claude-codeThis downloads the skill files into your project and your AI agent picks them up automatically.
Ralph Wiggum Plugin works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Codex, Gemini Cli, Amp, Roo Code, Goose, Opencode, Trae, Qodo, Command Code. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.