
Ralph Loop
- 202 installs
- 47 repo stars
- Updated August 4, 2026
- belumume/claude-skills
Ralph Loop is a Claude Code skill that runs the agent in an autonomous loop, re-running the same prompt until a completion marker is reached, using a Stop hook and a state file.
About
Ralph Loop activates an autonomous iterative mode where Claude Code repeats the same prompt while the codebase accumulates changes, continuing until a completion marker is reached. A developer uses it for well-defined refactors, migrations, or test-driven cycles that benefit from unattended, overnight execution. Completion is detected via a TODO.md marker or a promise tag, and an iteration cap plus git tracking keep it safe.
- Runs Claude Code in an autonomous loop until a task is complete
- Uses a Stop hook plus a .claude/ralph-loop.local.md state file
- Safety cap defaults to 20 iterations with git-tracked, revertible changes
Ralph Loop by the numbers
- 202 all-time installs (skills.sh)
- Ranked #593 of 2,715 Automation & Workflows skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
ralph-loop capabilities & compatibility
- Capabilities
- orchestration · automation
- Works with
- github
- Use cases
- orchestration · refactoring · testing
What ralph-loop says it does
Activate autonomous Ralph Wiggum loop mode for iterative task completion.
runs Claude Code in a loop where the prompt stays the same but the codebase accumulates changes.
npx skills add https://github.com/belumume/claude-skills --skill ralph-loopAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 202 |
|---|---|
| repo stars | ★ 47 |
| Last updated | August 4, 2026 |
| Repository | belumume/claude-skills ↗ |
What it does
Run Claude Code autonomously in a loop until a well-defined task (refactor, migration, tests-pass) is complete.
Who is it for?
Well-defined refactors, migrations, and test-driven cycles run unattended until complete
Skip if: Tasks needing human judgment, design decisions, or where requirements may change mid-run
When should I use this skill?
Running Claude iteratively until a task with clear, programmatically verifiable completion criteria is done
What you get
An autonomous loop that iterates on the codebase until tests, build, or a TODO marker confirm completion
- Loop state file
- TODO.md checklist
By the numbers
- default max_iterations 20
- checkpoint reminder every 5 iterations
- 2 completion methods (TODO.md marker or promise tag)
Files
Ralph Wiggum Loop Mode
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.
When to Use Ralph Mode
Ideal for:
- Well-defined implementation tasks with clear completion criteria
- Refactoring or migration work (e.g., React v16 to v19)
- Test-driven development cycles (run until tests pass)
- Batch processing or repetitive tasks
- Overnight autonomous work sessions
Not ideal for:
- Tasks requiring design decisions or human judgment
- Exploratory work without clear end states
- Tasks where requirements may change mid-execution
- First-time implementations where you need to learn the code
Activation Protocol
Step 1: Validate Task Suitability
Before activating, confirm:
- [ ] Task has clear, measurable completion criteria
- [ ] Success can be verified programmatically (tests, build, specific file state)
- [ ] The work is in a git-tracked directory
- [ ] You understand what success looks like
Step 2: Create State File
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 styleStep 3: Create TODO.md (Recommended Completion Method)
Create TODO.md in your project root:
# Task Checklist
## Tasks
- [ ] Task 1
- [ ] Task 2
- [ ] Task 3
## Completion
- [ ] ALL_TASKS_COMPLETEStep 4: Start the Loop
Simply run Claude normally. The Stop hook will detect the state file and keep the loop running until completion is detected.
claudeTwo Completion Methods
Method 1: TODO.md Markers (Recommended)
The hook checks TODO.md for [x] ALL_TASKS_COMPLETE. This is more reliable because:
- It's visible in the file system
- It can be tracked in git
- Claude can easily update it
- You can see progress (X/Y tasks complete)
Method 2: Promise Tags (Legacy)
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.
Configuration Options
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 |
During Execution
Iteration Status
Every iteration shows:
- Current iteration number
- Task progress (from TODO.md)
- Completion criteria
- Max iterations remaining
Checkpoint Notifications
Every 5 iterations, you'll see a checkpoint reminder to:
- Review changes:
git log --oneline -10 - Verify progress is on track
- Consider adjusting the prompt if stuck
Manual Intervention
To pause the loop:
# Edit the state file
# Change active: true → active: falseTo stop immediately:
rm .claude/ralph-loop.local.mdTo resume:
# Re-create or edit the state file
# Set active: true
claudeSafety Features
- Iteration cap: Prevents infinite loops (default: 20)
- Git tracking: Every change is revertible
- Checkpoint notifications: Reminders to review progress
- Clear completion criteria: Loop only exits on explicit success
- Cost awareness: Track iterations to estimate API costs
Example: MetricFlow Phase 7-8
---
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 doneAnd 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_COMPLETETroubleshooting
Loop won't start:
- Check
.claude/ralph-loop.local.mdexists - Verify
active: trueis set in frontmatter
Loop won't stop:
- Ensure TODO.md contains exactly
[x] ALL_TASKS_COMPLETE(case-insensitive) - Or check
completion_promisematches your output tag - Check
max_iterationsisn't set to 0 (unlimited) - Manual stop:
rm .claude/ralph-loop.local.md
Stuck on same error:
- Review the error pattern
- Adjust the prompt with more specific guidance
- Consider breaking task into smaller subtasks
Costs too high:
- Reduce
max_iterations - Use shorter checkpoint intervals for early review
- Consider if task is too complex for Ralph mode
Tips for Success
1. Clear prompts reduce iterations by 40-60% - be specific 2. Start with small max_iterations (5-10) until confident 3. Git commit after every checkpoint - easy rollback 4. Use TODO.md completion - more reliable than promise tags 5. Monitor first few iterations - catch bad patterns early 6. Supervised autonomy - review at checkpoints for course projects
Cost Estimates
| 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 |
Quick Start Template
# 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
claudeRelated skills
FAQ
How does the loop know when to stop?
It checks TODO.md for [x] ALL_TASKS_COMPLETE or matches a completion_promise tag in the state file.
How do I stop it immediately?
Delete the state file with rm .claude/ralph-loop.local.md.