**Purpose**: Start a self-referential AI development loop for tasks requiring multiple iterations
Runs an iterative development loop that repeatedly executes the same prompt until completion criteria are met.
/plugin marketplace add feedbackloopai-llc/optivai-claude-plugin/plugin install feedbackloopai-llc-chris-claude-toolkit@feedbackloopai-llc/optivai-claude-pluginPurpose: Start a self-referential AI development loop for tasks requiring multiple iterations
Usage: /ralph-loop PROMPT [--max-iterations N] [--completion-promise TEXT]
Claude SHOULD proactively suggest /ralph-loop when detecting these scenarios:
1. Test-Driven Development / Fix All Tests
2. Iterative Refinement Tasks
3. Complex Multi-Step Implementations
4. Bug Fixing Loops
5. User Explicitly Wants Autonomous Work
When detecting a trigger scenario, say something like:
"This task involves [iterative refinement/getting tests to pass/etc]. I can use the Ralph loop (
/ralph-loop) to work on this iteratively until completion. Ralph will:
- Keep me focused on the same task across iterations
- Let me see my previous work and improve on it
- Stop automatically when [tests pass/completion criteria met]
Would you like me to start a Ralph loop for this?"
Ralph is a development methodology based on continuous AI loops, pioneered by Geoffrey Huntley. The same prompt is fed repeatedly, and Claude sees its previous work in files, creating a self-referential feedback loop for iterative development.
Key insight: Each iteration, Claude reads the files it modified in previous iterations, allowing progressive improvement without losing context.
<promise>DONE</promise>/cancel-ralph is runTo start a Ralph loop, execute the setup script:
bash "$HOME/.claude/hooks/setup-ralph-loop.sh" $ARGUMENTS
The setup script will:
# Basic loop with iteration limit
/ralph-loop Build a REST API --max-iterations 20
# With completion promise (recommended)
/ralph-loop Fix all tests --completion-promise 'ALL TESTS PASSING' --max-iterations 30
# Test-driven development
/ralph-loop "Fix all failing tests in src/api/. Output <promise>ALL TESTS PASS</promise> when pytest returns 0 failures." --completion-promise "ALL TESTS PASS" --max-iterations 30
# Linting cleanup
/ralph-loop "Fix all ESLint errors. Output <promise>LINT CLEAN</promise> when eslint returns no errors." --completion-promise "LINT CLEAN" --max-iterations 20
To signal task completion, output the promise in XML tags:
<promise>YOUR_COMPLETION_PHRASE</promise>
CRITICAL RULE: Only output a promise when the statement is completely and unequivocally TRUE. Do not output false promises to escape the loop.
# Check current iteration
head -10 .claude/ralph-loop.local.md
# Cancel the loop
/cancel-ralph
/cancel-ralph - Cancel active Ralph loopUSER INVOCATION: /ralph-loop "Fix tests" --max-iterations 20
|
v
SETUP SCRIPT: setup-ralph-loop.sh
- Parses arguments
- Creates state file: .claude/ralph-loop.local.md
|
v
CLAUDE WORKS ON TASK
- Reads files, makes changes, runs tests
- May output <promise>COMPLETION_TEXT</promise>
|
v
STOP HOOK: stop-hook.sh (when Claude tries to exit)
1. Check if .claude/ralph-loop.local.md exists
2. Parse iteration count, max, completion promise
3. Check transcript for <promise> tags
4. If complete or max reached -> allow exit
5. Otherwise -> block exit, increment iteration, feed prompt
|
+----+----+
| |
v v
LOOP LOOP EXITS
CONTINUES - Completion promise detected
- Max iterations reached
- /cancel-ralph executed
/ralph-loopStart Ralph Wiggum loop in current session
/ralph-loopStart Ralph Loop in current session