Requirements
- Target platform
- OpenClaw
- Install method
- Manual import
- Extraction
- Extract archive
- Prerequisites
- OpenClaw
- Primary doc
- SKILL.md
Runs autonomous iterative AI loops for requirements, planning, or building phases using structured prompts and fresh context per iteration.
Runs autonomous iterative AI loops for requirements, planning, or building phases using structured prompts and fresh context per iteration.
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
First time? Read SETUP.md first to install dependencies and verify your setup. Autonomous AI agent loops for iterative development. Based on Geoffrey Huntley's Ralph Wiggum technique, as documented by Clayton Farr. Script: skills/ralph-loops/scripts/ralph-loop.mjs Dashboard: skills/ralph-loops/dashboard/ (run with node server.mjs) Templates: skills/ralph-loops/templates/ Archive: ~/clawd/logs/ralph-archive/
Claude Code 2.1.29 has a critical bug that spawns orphaned sub-agents consuming 99% CPU. Iterations fail with "exit code null" on first run. Fix: Downgrade to 2.1.25: npm install -g @anthropic-ai/claude-code@2.1.25 Verify: claude --version # Should show 2.1.25 This was discovered 2026-02-01. Check if newer versions fix the issue before upgrading.
When running a Ralph loop, don't monitor it synchronously. The loop runs as a separate Claude CLI process β you can keep chatting. β Wrong (blocks conversation): Start loop β sleep 60 β poll β sleep 60 β poll β ... (6 minutes of silence) β Right (stays responsive): Start loop β "It's running, I'll check periodically" β keep chatting β check on heartbeats How to monitor without blocking: Start the loop with node ralph-loop.mjs ... (runs in background) Tell human: "Loop running. I'll check progress periodically or you can ask." Check via process poll <sessionId> when asked or during heartbeats Use the dashboard at http://localhost:3939 for real-time visibility The loop is autonomous β that's the whole point. Don't babysit it at the cost of ignoring your human.
When human says: PhraseAction"Interview me about system X"Start Phase 1 requirements interview"Start planning system X"Run ./loop.sh plan (needs specs first)"Start building system X"Run ./loop.sh build (needs plan first)"Ralph loop over X"ASK which phase (see below)
Don't assume which phase. Ask: "Which type of Ralph loop are we doing? 1οΈβ£ Interview β I'll ask you questions to build specs (Phase 1) 2οΈβ£ Planning β I'll iterate on an implementation plan (Phase 2) 3οΈβ£ Building β I'll implement from a plan, one task per iteration (Phase 3) 4οΈβ£ Generic β Simple iterative refinement on a single topic" Then proceed based on their answer: ChoiceActionInterviewUse templates/requirements-interview.md protocolPlanningNeed specs first β run planning loop with PROMPT_plan.mdBuildingNeed plan first β run build loop with PROMPT_build.mdGenericCreate prompt file, run ralph-loop.mjs directly
For simple iterative refinement (not full system builds): Clarify the task β What exactly should be improved/refined? Create a prompt file β Save to /tmp/ralph-prompt-<task>.md Set completion criteria β What signals "done"? Run the loop: node skills/ralph-loops/scripts/ralph-loop.mjs \ --prompt "/tmp/ralph-prompt-<task>.md" \ --model opus \ --max 10 \ --done "RALPH_DONE" Or spawn as sub-agent for long-running tasks
"Human roles shift from 'telling the agent what to do' to 'engineering conditions where good outcomes emerge naturally through iteration." β Clayton Farr Three principles drive everything: Context is scarce β With ~176K usable tokens from a 200K window, keep each iteration lean Plans are disposable β A drifting plan is cheaper to regenerate than salvage Backpressure beats direction β Engineer environments where wrong outputs get rejected automatically
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Phase 1: REQUIREMENTS β β Human + LLM conversation β JTBD β Topics β specs/*.md β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β Phase 2: PLANNING β β Gap analysis (specs vs code) β IMPLEMENTATION_PLAN.md β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β Phase 3: BUILDING β β One task per iteration β fresh context β backpressure β commit β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Goal: Understand what to build BEFORE building it. This is the most important phase. Use structured conversation to: Identify Jobs to Be Done (JTBD) What user need or outcome are we solving? Not features β outcomes Break JTBD into Topics of Concern Each topic = one distinct aspect/component Use the "one sentence without 'and'" test β "The color extraction system analyzes images to identify dominant colors" β "The user system handles authentication, profiles, and billing" β 3 topics Create Specs for Each Topic One markdown file per topic in specs/ Capture requirements, acceptance criteria, edge cases Template: templates/requirements-interview.md
Goal: Create a prioritized task list without implementing anything. Uses PROMPT_plan.md in the loop: Study all specs Study existing codebase Compare specs vs code (gap analysis) Generate IMPLEMENTATION_PLAN.md with prioritized tasks NO implementation β planning only Usually completes in 1-2 iterations.
Goal: Implement tasks one at a time with fresh context. Uses PROMPT_build.md in the loop: Read IMPLEMENTATION_PLAN.md Pick the most important task Investigate codebase (don't assume not implemented) Implement Run validation (backpressure) Update plan, commit Exit β fresh context β next iteration Key insight: One task per iteration keeps context lean. The agent stays in the "smart zone" instead of accumulating cruft. Why fresh context matters: No accumulated mistakes β Each iteration starts clean; previous errors don't compound Full context budget β 200K tokens for THIS task, not shared with finished work Reduced hallucination β Shorter contexts = more grounded responses Natural checkpoints β Each commit is a save point; easy to revert single iterations
project/ βββ loop.sh # Ralph loop script βββ PROMPT_plan.md # Planning mode instructions βββ PROMPT_build.md # Building mode instructions βββ AGENTS.md # Operational guide (~60 lines max) βββ IMPLEMENTATION_PLAN.md # Prioritized task list (generated) βββ specs/ # Requirement specs βββ topic-a.md βββ topic-b.md βββ ...
FilePurposeWho Createsspecs/*.mdSource of truth for requirementsHuman + Phase 1PROMPT_plan.mdInstructions for planning modeCopy from templatePROMPT_build.mdInstructions for building modeCopy from templateAGENTS.mdBuild/test/lint commandsHuman + RalphIMPLEMENTATION_PLAN.mdTask list with prioritiesRalph (Phase 2)
For Clawdbot systems, each Ralph project lives in <workspace>/systems/<name>/: systems/ βββ health-tracker/ # Example system β βββ specs/ β β βββ daily-tracking.md β β βββ test-scheduling.md β βββ PROMPT_plan.md β βββ PROMPT_build.md β βββ AGENTS.md β βββ IMPLEMENTATION_PLAN.md # β exists = past Phase 1 β βββ src/ βββ activity-planner/ βββ specs/ # β empty = still in Phase 1 βββ ...
Detect current phase by checking what files exist: What ExistsCurrent PhaseNext ActionNothing / empty specs/Phase 1: RequirementsRun requirements interviewspecs/*.md but no IMPLEMENTATION_PLAN.mdReady for Phase 2Run ./loop.sh planspecs/*.md + IMPLEMENTATION_PLAN.mdPhase 2 or 3Review plan, run ./loop.sh buildPlan shows all tasks completeDoneArchive or iterate Quick check: # What phase are we in? [ -z "$(ls specs/ 2>/dev/null)" ] && echo "Phase 1: Need specs" && exit [ ! -f IMPLEMENTATION_PLAN.md ] && echo "Phase 2: Need plan" && exit echo "Phase 3: Ready to build (or done)"
The hierarchy matters: JTBD (Job to Be Done) βββ Topic of Concern (1 per spec file) βββ Tasks (many per topic, in IMPLEMENTATION_PLAN.md) Example: JTBD: "Help designers create mood boards" Topics: Image collection β specs/image-collection.md Color extraction β specs/color-extraction.md Layout system β specs/layout-system.md Sharing β specs/sharing.md Tasks: Each spec generates multiple implementation tasks
Can you describe the topic in one sentence without "and"? If you need "and" or "also", it's probably multiple topics. Split it. When to split: Multiple verbs in the description β separate topics Different user personas involved β separate topics Could be implemented by different teams β separate topics Has its own failure modes β probably its own topic Example split: β "User management handles registration, authentication, profiles, and permissions" β Split into: - "Registration creates new user accounts from email/password" - "Authentication verifies user identity via login flow" - "Profiles let users view and edit their information" - "Permissions control what actions users can perform" Counter-example (don't split): β Keep together: "Color extraction analyzes images and returns dominant color palettes" Why: "analyzes" and "returns" are steps in one operation, not separate concerns.
Autonomous loops converge when wrong outputs get rejected. Three layers:
Existing code patterns guide the agent. It discovers conventions through exploration.
For subjective criteria (tone, UX, aesthetics), use another LLM call with binary pass/fail. Start with hard gates. Add LLM-as-judge for subjective criteria only after mechanical backpressure works.
Geoffrey's prompts follow a numbered pattern: SectionPurpose0a-0dOrient: Study specs, source, current plan1-4Main instructions: What to do this iteration999+Guardrails: Invariants (higher number = more critical)
Guardrails use escalating numbers (99999, 999999, 9999999...) to signal priority: 99999. Important: Capture the why in documentation. 999999. Important: Single sources of truth, no migrations. 9999999. Create git tags after successful builds. 99999999. Add logging if needed to debug. 999999999. Keep IMPLEMENTATION_PLAN.md current. Why this works: Visual prominence β Large numbers stand out, harder to skip Implicit priority β More 9s = more critical (like DEFCON levels in reverse) No collisions β Sparse numbering lets you insert new rules without renumbering Mnemonic β Claude treats these as invariants, not suggestions The "Important:" prefix is deliberate β it triggers Claude's attention.
Use Geoffrey's specific phrasing β it matters: "study" (not "read" or "look at") "don't assume not implemented" (critical!) "using parallel subagents" / "up to N subagents" "only 1 subagent for build/tests" (backpressure control) "Ultrathink" (deep reasoning trigger) "capture the why" "keep it up to date" "resolve them or document them"
mkdir -p myproject/specs cd myproject git init # Ralph expects git for commits # Copy templates cp .//templates/PROMPT_plan.md . cp .//templates/PROMPT_build.md . cp .//templates/AGENTS.md . cp .//templates/loop.sh . chmod +x loop.sh
PROMPT_plan.md β Replace [PROJECT_GOAL] with your actual goal: # Before: ULTIMATE GOAL: We want to achieve [PROJECT_GOAL]. # After: ULTIMATE GOAL: We want to achieve a fully functional mood board app with image upload and color extraction. PROMPT_build.md β Adjust source paths if not using src/: # Before: 0c. For reference, the application source code is in `src/*`. # After: 0c. For reference, the application source code is in `lib/*`. AGENTS.md β Update build/test/lint commands for your stack.
This phase happens WITH the human. Use the interview template: cat .//templates/requirements-interview.md The workflow: Discuss the JTBD (Job to Be Done) β outcomes, not features Break into Topics of Concern (each passes the "one sentence" test) Write a spec file for each topic: specs/topic-name.md Human reviews and approves specs Example output: specs/ βββ image-collection.md βββ color-extraction.md βββ layout-system.md βββ sharing.md
./loop.sh plan Wait for IMPLEMENTATION_PLAN.md to be generated (usually 1-2 iterations). Review it β this is your task list.
./loop.sh build 20 # Max 20 iterations Watch it work. Add backpressure (tests, lints) as patterns emerge. Check commits for progress.
./loop.sh # Build mode, unlimited ./loop.sh 20 # Build mode, max 20 iterations ./loop.sh plan # Plan mode, unlimited ./loop.sh plan 5 # Plan mode, max 5 iterations Or use the Node.js wrapper for more control: node skills/ralph-loops/scripts/ralph-loop.mjs \ --prompt "./PROMPT_build.md" \ --model opus \ --max 20 \ --done "RALPH_DONE"
Plans drift. Regenerate when: Ralph is going off track (implementing wrong things) Plan feels stale or doesn't match current state Too much clutter from completed items You've made significant spec changes You're confused about what's actually done Just switch back to planning mode: ./loop.sh plan Regeneration cost is one Planning loop. Cheap compared to Ralph going in circles.
Ralph requires --dangerously-skip-permissions to run autonomously. This bypasses Claude's permission system entirely. Philosophy: "It's not if it gets popped, it's when. And what is the blast radius?" Protections: Run in isolated environments (Docker, VM) Only the API keys needed for the task No access to private data beyond requirements Restrict network connectivity where possible Escape hatches: Ctrl+C stops the loop; git reset --hard reverts uncommitted changes
Task TypeModelIterationsEst. CostGenerate planOpus1-2$0.50-1.00Implement simple featureOpus3-5$1.00-2.00Implement complex featureOpus10-20$3.00-8.00Full project buildoutOpus50+$15-50+ Tip: Use Sonnet for simpler tasks where plan is clear. Use Opus for planning and complex reasoning.
From Geoffrey Huntley: 6 repos generated overnight at YC hackathon $50k contract completed for $297 in API costs Created entire programming language over 3 months
For long loops, spawn as sub-agent so main session stays responsive: sessions_spawn({ task: `cd /path/to/project && ./loop.sh build 20 Summarize what was implemented when done.`, label: "ralph-build", model: "opus" }) Check progress: sessions_list({ kinds: ["spawn"] }) sessions_history({ label: "ralph-build", limit: 5 })
Plan is stale β regenerate with ./loop.sh plan Backpressure missing β add tests that catch duplicates
Add more specific guardrails to prompts Check if specs are ambiguous Regenerate plan
Ensure one task per iteration (check prompt) Keep AGENTS.md under 60 lines Move status/progress to IMPLEMENTATION_PLAN.md, not AGENTS.md
Check AGENTS.md has correct validation commands Ensure backpressure section in prompt references AGENTS.md
The loop script expects git for commits and pushes. For projects without version control: Option 1: Initialize git anyway (recommended) git init git add -A git commit -m "Initial commit before Ralph" Option 2: Modify the prompts Remove git-related guardrails from PROMPT_build.md Remove the git push section from loop.sh Use file backups instead: add cp -r src/ backups/iteration-$ITERATION/ to loop.sh Option 3: Use tarball snapshots # Add to loop.sh before each iteration: tar -czf "snapshots/pre-iteration-$ITERATION.tar.gz" src/
For codebases with 100K+ lines: Reduce subagent parallelism: Change "up to 500 parallel Sonnet subagents" to "up to 50" in prompts Scope narrowly: Use focused specs that target specific directories Add path restrictions: In AGENTS.md, note which directories are in-scope Consider workspace splitting: Treat large modules as separate Ralph projects
The methodology works with any Claude interface: Claude API directly: # Replace loop.sh with API calls using curl or a script curl https://api.anthropic.com/v1/messages \ -H "x-api-key: $ANTHROPIC_API_KEY" \ -H "content-type: application/json" \ -d '{"model": "claude-sonnet-4-20250514", "max_tokens": 8192, "messages": [...]}' Alternative agents: Aider: aider --opus --auto-commits Continue.dev: Use with Claude API key Cursor: Composer mode with PROMPT files as context The key principles (one task per iteration, fresh context, backpressure) apply regardless of tooling.
Adapt AGENTS.md for your stack: StackBuildTestLintPythonpip install -e .pytestruff .Gogo build ./...go test ./...golangci-lint runRustcargo buildcargo testcargo clippyRubybundle installrspecrubocop Also update path references in prompts (src/* β your source directory).
Geoffrey Huntley: https://ghuntley.com/ralph/ Clayton Farr's Playbook: https://github.com/ClaytonFarr/ralph-playbook Geoffrey's Fork: https://github.com/ghuntley/how-to-ralph-wiggum
Built by Johnathan & Q β a human-AI dyad. Twitter: @spacepixel ClawdHub: clawhub.ai/skills/ralph-loops
Agent frameworks, memory systems, reasoning layers, and model-native orchestration.
Largest current source with strong distribution and engagement signals.