ralph-loop — Claude Code skill: iterate until the task is done
A skill that keeps feeding the same prompt back to the agent after every turn, so each pass builds on the previous one.
npx skills add cursor/plugins --skill ralph-loop -a claude-codeWhat ralph-loop does
Ralph Loop turns a single request into a repeating cycle. When a turn ends, the agent gets the same prompt again and can read what it produced last time, so work continues instead of restarting. Useful for tasks too large to finish in one pass.
The skill writes a state file at .cursor/ralph/scratchpad.md, creating the .cursor/ralph/ directory first. Its YAML header holds the iteration number, max_iterations, and completion_promise; your task prompt sits underneath. A stop hook does the looping: it catches the end of each turn and re-sends the prompt as a followup message tagged [Ralph loop iteration N.].
max_iterations defaults to 0, which means no cap. The skill recommends setting a limit anyway as a safety net. The only clean way out is <promise>TEXT</promise>, and it should appear when the condition is genuinely met — not as an escape hatch. Put the completion_promise value in quotes if it contains special characters.
What it helps with
- push a large task through many agent passes to completion
- keep context across iterations of the same job
- define a stop condition instead of looping forever
- cap the number of iterations so the agent does not spin
- run unattended refinement from one prompt
Example prompts for the agent
- Start a ralph loop to build a REST API for todos with CRUD, validation and tests, max 20 iterations, completion promise COMPLETE
- Run a ralph loop on the payments module refactor with no iteration limit
- Start an iterative loop to fix the failing tests in
tests/api, stop on promise DONE
How to install ralph-loop
1Skills CLI (Vercel)
npx skills add cursor/plugins --skill ralph-loop -a claude-code2Manually: put the files in place
~/.claude/skills/ralph-loop/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/ralph-loop/
1Skills CLI (Vercel)
npx skills add cursor/plugins --skill ralph-loop -a codex2Manually: put the files in place
.agents/skills/ralph-loop/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add cursor/plugins --skill ralph-loop -a cursor2Manually: put the files in place
.cursor/skills/ralph-loop/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install cursor/plugins ralph-loop2Manually: put the files in place
.github/skills/ralph-loop/SKILL.md1Skills CLI (Vercel)
npx skills add cursor/plugins --skill ralph-loop -a gemini-cli2Platform CLI
gemini skills install https://github.com/cursor/plugins --path ralph-loop/skills/ralph-loopManually: put the files in place
.devin/skills/ralph-loop/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add cursor/plugins --skill ralph-loop -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about ralph-loop
How do I install ralph-loop in Claude Code?
Run npx skills add cursor/plugins --skill ralph-loop -a claude-code. The skill lands at ~/.claude/skills/ralph-loop/SKILL.md.
What does ralph-loop do?
It creates .cursor/ralph/scratchpad.md holding your prompt and loop settings, then a stop hook returns that prompt at the end of every turn until the stop condition fires or the iteration limit runs out.
How does the loop know when to stop?
Through completion_promise: the agent emits <promise>TEXT</promise> only once the condition is truly satisfied. False promises to break out are off limits, and max_iterations acts as a backstop.