Guide for using /ralph-loop command for long-running autonomous tasks. Use when starting iterative development loops, implementing Bedrock plugins, or running test-fix cycles. (project)
Guide users on effectively using /ralph-loop for long-running autonomous tasks in the mineflayer-bedrock project.
The Ralph Wiggum plugin implements an iterative AI development loop. It uses a Stop hook that intercepts Claude's exit attempts, feeding the same prompt back to continue working until completion criteria are met.
Core mechanism: You run /ralph-loop "task" once. Claude works, tries to exit, the hook blocks it, re-feeds the prompt, and repeats until done.
CLI arguments cannot contain newlines due to Bash security restrictions. These GitHub issues track this:
Workaround: Keep prompts single-line or use phased execution (see below).
--completion-promise uses exact string matching. You cannot use regex or multiple conditions like "SUCCESS OR BLOCKED". Use the <promise>TAG</promise> pattern for clarity.
Each iteration consumes full context window tokens. A 50-iteration loop on a large codebase can cost $50-100+ in API credits.
This is your primary safety mechanism. Never rely solely on completion promises.
/ralph-loop "Your task..." --max-iterations 30
Wrap completion signals in tags for clear detection:
/ralph-loop "Build feature X. Output <promise>COMPLETE</promise> when done." --completion-promise "COMPLETE" --max-iterations 25
Add escape instructions for when Claude gets stuck:
/ralph-loop "Implement feature. After 10 iterations without progress: document blockers, list attempts, suggest alternatives. Output <promise>BLOCKED</promise> if truly stuck, <promise>DONE</promise> if complete." --max-iterations 20
Break large tasks into phases instead of one massive prompt:
# Phase 1
/ralph-loop "Phase 1: Create data models. Output <promise>P1_DONE</promise>" --max-iterations 15
# Phase 2
/ralph-loop "Phase 2: Implement API endpoints. Output <promise>P2_DONE</promise>" --max-iterations 20
# Phase 3
/ralph-loop "Phase 3: Add tests, ensure all pass. Output <promise>P3_DONE</promise>" --max-iterations 25
/ralph-loop "Implement inventory.mts Bedrock plugin in lib/bedrockPlugins/ matching the Java API in lib/plugins/inventory.js. Map Bedrock packets to same bot behavior. Run 'npm run mocha_test' after changes. Output <promise>PLUGIN_COMPLETE</promise> when tests pass." --max-iterations 30
/ralph-loop "Run 'npm run test:bedrock'. Fix any failing tests. Do not skip tests. Output <promise>TESTS_PASS</promise> when all tests green." --max-iterations 20
/ralph-loop "Compare lib/bedrockPlugins/health.mts with lib/plugins/health.js. Ensure Bedrock version exposes same API (functions, events, properties). Fix discrepancies. Run tests. Output <promise>API_MATCH</promise> when compatible." --max-iterations 15
/ralph-loop "Run 'npx tsc --noEmit'. Fix all TypeScript errors. Do not use 'any' type. Output <promise>TYPES_CLEAN</promise> when no errors." --max-iterations 25
| Iterations | Estimated Cost | |------------|----------------| | 10-20 | $10-25 | | 30-50 | $30-75 | | 50+ | $50-150+ |
Tips to reduce costs:
--max-iterations and increase if neededStart an iterative development loop.
/ralph-loop "<prompt>" --max-iterations <n> --completion-promise "<text>"
Options:
--max-iterations <n>: Stop after N iterations (required for safety)--completion-promise <text>: Exact string that signals completionCancel an active Ralph loop immediately.
/cancel-ralph
| Mistake | Prevention |
|---------|------------|
| No iteration limit | Always use --max-iterations |
| Vague completion criteria | Use specific, testable conditions |
| Multiline prompts | Keep single-line or use phases |
| Relying only on promise | Set iteration limit as backup |
| Too many iterations at once | Start small, increase if needed |
skill-builder: For creating new Claude Code skillscreate-analyzer: For packet analysis tasksSearch for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer