This is autonomous loop mode for Claude Code that keeps running the same prompt until your task is done. You set up a state file with clear completion criteria (usually a TODO.md checklist), and it iterates until it hits ALL_TASKS_COMPLETE or your max iteration cap. Named after Ralph Wiggum because it never stops despite confusion. Best for well-defined work like migrations, refactoring, or getting tests to pass. Not for exploratory work where you need judgment calls. The state file tracks iterations and you get checkpoint reminders every 5 loops to review progress. Basically supervised autonomy: you can let it run overnight on clear tasks, but you're meant to check in periodically. Includes safety caps and git tracking so nothing goes off the rails permanently.
npx -y skills add belumume/claude-skills --skill ralph-loop --agent claude-codeInstalls into .claude/skills of the current project.
Named after the Simpsons character who "never stops despite being confused," this technique runs Claude Code in a loop where the prompt stays the same but the codebase accumulates changes. Each iteration reads previous work and continues until completion.
Ideal for:
Not ideal for:
Before activating, confirm:
Create .claude/ralph-loop.local.md with the following structure:
---
active: true
iteration: 0
max_iterations: 20
completion_promise: null
---
# Your Task Prompt Here
## Objective
[Clear statement of what needs to be accomplished]
## Completion Criteria
Complete when TODO.md shows [x] ALL_TASKS_COMPLETE
## Verification Commands
Run these to check progress:
- `[test command]`
- `[build command]`
## Context
- Read [relevant files] for specifications
- Follow [conventions file] for code style
Create TODO.md in your project root:
# Task Checklist
## Tasks
- [ ] Task 1
- [ ] Task 2
- [ ] Task 3
## Completion
- [ ] ALL_TASKS_COMPLETE
Simply run Claude normally. The Stop hook will detect the state file and keep the loop running until completion is detected.
claude
The hook checks TODO.md for [x] ALL_TASKS_COMPLETE. This is more reliable because:
Set completion_promise in the state file and output <promise>YOUR_TEXT</promise> when complete.
---
active: true
iteration: 0
max_iterations: 20
completion_promise: "feature implemented"
---
When Claude outputs <promise>feature implemented</promise>, the loop ends.
In .claude/ralph-loop.local.md frontmatter:
| Option | Default | Description |
|---|---|---|
active | true | Set to false to disable loop |
iteration | 0 | Current iteration count (auto-incremented) |
max_iterations | 20 | Safety cap (0 = unlimited) |
completion_promise | null | Text to match for promise completion |
Every iteration shows:
Every 5 iterations, you'll see a checkpoint reminder to:
git log --oneline -10To pause the loop:
# Edit the state file
# Change active: true → active: false
To stop immediately:
rm .claude/ralph-loop.local.md
To resume:
# Re-create or edit the state file
# Set active: true
claude
---
active: true
iteration: 0
max_iterations: 25
completion_promise: null
---
# MetricFlow Phase 7-8: Educator Agent
## Objective
Implement the Educator Agent that uses Claude API to generate educational
explanations for code metrics.
## Completion Criteria
Complete when TODO.md shows [x] ALL_TASKS_COMPLETE
## Verification Commands
- `cd backend && python -m pytest tests/test_educator.py -v`
- `cd backend && python -c "from app.agents.educator import EducatorAgent; print('OK')"`
## Context
- Read docs/plans/MASTER_PLAN.md sections 5.3 (Educator Agent)
- Follow CLAUDE.md for project conventions
- Analyzer and Pattern agents already complete (use their output formats)
## Instructions
1. Check TODO.md for current task list
2. Implement next incomplete task
3. Write tests as you go
4. Run verification after each change
5. Mark [x] ALL_TASKS_COMPLETE when done
And corresponding TODO.md:
# Phase 7-8: Educator Agent
## Tasks
- [ ] Create EducatorAgent class skeleton in backend/app/agents/educator.py
- [ ] Add Claude API client initialization
- [ ] Implement explain_complexity() method
- [ ] Implement explain_maintainability() method
- [ ] Implement explain_code_smells() method
- [ ] Add course concept mapping
- [ ] Write unit tests for all methods
- [ ] Integration test with Analyzer output
## Completion
- [ ] ALL_TASKS_COMPLETE
Loop won't start:
.claude/ralph-loop.local.md existsactive: true is set in frontmatterLoop won't stop:
[x] ALL_TASKS_COMPLETE (case-insensitive)completion_promise matches your output tagmax_iterations isn't set to 0 (unlimited)rm .claude/ralph-loop.local.mdStuck on same error:
Costs too high:
max_iterations| Task Complexity | Iterations | Estimated Cost |
|---|---|---|
| Simple (single feature) | 5-10 | $5-15 |
| Medium (multi-file changes) | 10-20 | $15-30 |
| Complex (full phase) | 20-50 | $30-75 |
# 1. Create state file
mkdir -p .claude
cat > .claude/ralph-loop.local.md << 'EOF'
---
active: true
iteration: 0
max_iterations: 20
completion_promise: null
---
# Your Task
## Objective
[What you want to accomplish]
## Completion
Check TODO.md for [x] ALL_TASKS_COMPLETE
EOF
# 2. Create TODO.md
cat > TODO.md << 'EOF'
# Tasks
- [ ] First task
- [ ] Second task
## Completion
- [ ] ALL_TASKS_COMPLETE
EOF
# 3. Start Ralph loop
claude
juliusbrussee/caveman
mattpocock/skills
shadcn/improve
obra/superpowers
forrestchang/andrej-karpathy-skills
vercel-labs/skills