Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Autonomous execution loop that processes a Beads epic task-by-task with fresh subagents, two-stage review, and circuit breaker safety. Use after plan-to-epic creates the epic.
.claude/skills/majiayu000-ralph-execute/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 110% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 117% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 182% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 213% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 162% | 0% |
name: ralph-execute description: Execute iterative development loop through user stories. Implements one story at a time with quality gates, commits, and learning persistence. Ships features autonomously. allowed-tools: Read, Write, Edit, Bash, Glob, Grep, TodoWrite, Task user_invocable: true argument-hint: --max-iterations N] --story US-XXX] --dry-run] --skip-blocked]
Autonomously implement user stories from the PRD, running quality gates and committing after each successful story. Maintains progress across sessions. Ships features while you sleep.
Ralph is an autonomous AI coding loop that ships features while you sleep. Each iteration is a fresh context window (keeping context small). Memory persists via git history, progress.txt, prd.json, and AGENTS.md.
bash/ralph-execute [options]
Arguments:
--max-iterations N - Override max iterations (default: from prd.json or 10)--story US-XXX - Target a specific story instead of next priority--dry-run - Show what would be done without making changes--skip-blocked - Skip blocked stories without re-attemptingExamples:
bash/ralph-execute # Continue from where we left off /ralph-execute --max-iterations 5 # Run up to 5 stories /ralph-execute --story US-003 # Implement specific story /ralph-execute --dry-run # Preview next story
Read .ralph/prd.json. If not found:
ERROR: No PRD found at .ralph/prd.json
Run /ralph-plan first to generate a PRD with user stories.If current branch differs from prd.branchName, archive previous run:
bashmkdir -p .ralph/archive/[old-branch]-[timestamp] mv .ralph/prd.json .ralph/archive/[old-branch]-[timestamp]/ mv .ralph/progress.txt .ralph/archive/[old-branch]-[timestamp]/
bashgit branch --show-current
If not on the correct branch:
bashgit checkout [prd.branchName]
Read .ralph/progress.txt to understand:
CRITICAL: This context informs implementation decisions. Always read progress.txt before implementing.
Read root-level AGENTS.md and any directory-level AGENTS.md files for:
Sync prd.json stories to TodoWrite for visual progress tracking.
Select the highest-priority story where status === "pending":
javascriptconst nextStory = prd.userStories .filter(s => s.status === 'pending') .sort((a, b) => a.priority - b.priority)[0];
If no pending stories:
--skip-blocked not set)javascriptif (prd.summary.iterationsRun >= prd.config.maxIterations) { // Report: "Max iterations reached. Run with --max-iterations N to continue." // Exit gracefully }
STARTING ITERATION [N]
━━━━━━━━━━━━━━━━━━━━━━
Story: US-002 - Add registration form
Priority: 2 of 8
Previous Attempts: 0
Description:
As a new user, I want to register an account so that I can access the platform.
Implementation should follow the LoginForm pattern already established.
Acceptance Criteria:
□ Registration form with email, password, confirm password fields
□ Form validation using zod schema
□ Integration with existing auth context
□ TypeScript compiles without errors
Relevant Learnings from Progress:
- LoginForm pattern: src/components/auth/LoginForm.tsx
- Form validation: react-hook-form + zod
- Auth context: src/contexts/AuthContext.tsxEach story follows the Plan → Work → Review → Compound cycle:
Step 3.1: Mark Story In-Progress Update prd.json: status: "in_progress" Update TodoWrite to show current task
Step 3.2: Research Codebase
Step 3.3: Create Implementation Plan Before writing code, document:
Step 3.4: Implement the Story
CRITICAL IMPLEMENTATION RULES:
For UI Stories, Apply Frontend-Design Principles:
Step 3.5: Run Quality Gates (Fail-Fast)
Execute in order:
bash npm run check 2>&1 On failure: Parse error output, attempt fix, re-run (max 2 attempts)
bash npm run lint 2>&1 On failure: Run npm run lint -- --fix, then re-check
bash npm run test 2>&1 If configured in prd.json
bash npm run build 2>&1 If enabled in prd.json config
Step 3.6: Browser Verification (UI Stories)
For stories with requiresBrowserVerification: true:
visual-polish-inspector skill or Chrome extensionRequirements:
npm run dev)Step 3.7: Evaluate Quality Before committing, verify:
Step 3.8: Handle Failures
On quality gate failure:
javascriptstory.failureCount += 1; if (story.failureCount >= prd.config.maxFailuresPerStory) { story.status = 'blocked'; story.blockedReason = '[Specific error message]'; prd.summary.blocked += 1; prd.summary.pending -= 1; // Log to progress.txt // Continue to next story } else { // Retry this story }
Step 3.9: Commit Changes
If all quality gates pass:
bashgit add -A git commit -m "feat: US-XXX - [Story Title] [Brief description of implementation] Co-Authored-By: Claude <noreply@anthropic.com>"
Step 3.10: Update prd.json
javascriptstory.status = 'passed'; story.completedAt = new Date().toISOString(); story.commits.push(commitHash); prd.summary.passed += 1; prd.summary.pending -= 1; prd.summary.iterationsRun += 1; prd.updatedAt = new Date().toISOString();
Step 3.11: Update AGENTS.md
If reusable patterns were discovered, add to AGENTS.md:
markdown## Module: src/components/auth/ - Forms use react-hook-form + zod validation - Auth state from `@clerk/nextjs` - Follow LoginForm.tsx as pattern
Good AGENTS.md additions:
Don't add to AGENTS.md:
Step 3.12: Append to progress.txt
--- ITERATION [N] | US-XXX: [Title] ---
Timestamp: [ISO]
Status: PASSED
Learnings for future iterations:
- [Pattern discovered]
- [Gotcha avoided]
Files Modified:
- [file1] (created)
- [file2] (modified)
Quality Gates:
- typecheck: PASSED
- lint: PASSED (auto-fixed 2 issues)
- test: SKIPPED
- browser: VERIFIED
Commit: [hash] - feat: US-XXX - [Title]Step 3.13: Consolidate Codebase Patterns
Update the "CODEBASE PATTERNS (Consolidated)" section at the TOP of progress.txt with any new patterns discovered.
If pending stories remain AND iterations < max:
If all stories passed or blocked:
RALPH EXECUTION COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━
All [N] stories processed!
Summary:
- Iterations: [N]
- Stories Passed: [N]
- Stories Blocked: [N]
- Total Commits: [N]
Branch: [branch-name]
Ready for review and merge.
Key Learnings Captured:
1. [Learning 1]
2. [Learning 2]
Next Steps:
1. Review commits: git log --oneline -n [N]
2. Push branch: git push -u origin [branch-name]
3. Create PR: gh pr createSTORY BLOCKED: US-XXX
━━━━━━━━━━━━━━━━━━━━━
After 3 attempts, this story could not be completed.
Reason: [Specific blocker]
Recommended Action:
- [Suggestion based on error type]
Continuing with next priority story...--- ITERATION [N] | US-XXX: [Title] (ATTEMPT 2/3) ---
Timestamp: [ISO]
Status: FAILED
Error:
[Error output]
Attempted Fix:
- [What was tried]
Result: Still failing. Will retry next iteration.When /ralph-execute is run in a new session:
.ralph/prd.json for current state.ralph/progress.txt for learned contextAGENTS.md for reusable patternsThe loop is stateless - all state is in files, not memory.
progress.txt serves as persistent memory:
Always read progress.txt before implementing each story.
Must fit in one context window.
❌ Too big: "Build entire auth system"
✅ Right size: "Add login form", "Add email validation", "Add auth server action"Ralph needs fast feedback:
npm run check (typecheck)npm run lintnpm run testWithout these, broken code compounds.
❌ Vague: "Users can log in"
✅ Explicit:
- Email/password fields
- Validates email format
- Shows error on failure
- typecheck passes
- Verify at localhost:3000/loginBy story 10, Ralph knows patterns from stories 1-9.
Quality gates prevent error compounding across iterations.
Idempotent migrations:
sqlADD COLUMN IF NOT EXISTS email TEXT;
Interactive prompts:
bashecho -e "\n\n\n" | npm run db:generate
Schema changes: After editing schema, check: Server actions, UI components, API routes
Fixing related files is OK: If typecheck requires other changes, make them. Not scope creep.
bash# Story status cat .ralph/prd.json | jq '.userStories[] | {id, title, status}' # Learnings cat .ralph/progress.txt # Recent commits git log --oneline -10
json"config": { "maxIterations": 10, // Total iterations before stopping "maxFailuresPerStory": 3, // Attempts before blocking "autoCommit": true // Commit after each story }
json"qualityGates": { "typecheck": "npm run check", "lint": "npm run lint", "test": "npm run test", "build": null // Set to null to skip }
If ALL stories have status: "passed" or status: "blocked", report completion.
Otherwise, continue to next pending story.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-04 | fail→pass | 18,472 | 6,550 | -65% | 1 | 1 | 0% | 2,221 | 4,669 | +110% | 0 | 0 | — |
case-01 | fail→fail | 7,344 | 11,106 | +51% | 1 | 1 | 0% | 1,096 | 3,825 | +249% | 0 | 0 | — |
case-02 | fail→fail | 9,388 | 15,255 | +62% | 1 | 1 | 0% | 178 | 3,675 | +1965% | 0 | 0 | — |
case-03 | fail→fail | 4,524 | 10,542 | +133% | 1 | 1 | 0% | 191 | 3,664 | +1818% | 0 | 0 | — |
case-05 | fail→fail | 13,678 | 8,669 | -37% | 1 | 1 | 0% | 1,416 | 4,095 | +189% | 0 | 0 | — |
case-06 | fail→pass | 14,131 | 18,616 | +32% | 1 | 1 | 0% | 2,183 | 4,737 | +117% | 0 | 0 | — |
case-07 | fail→pass | 9,103 | 2,475 | -73% | 1 | 1 | 0% | 1,336 | 3,762 | +182% | 0 | 0 | — |
case-08 | fail→pass | 9,454 | 12,767 | +35% | 1 | 1 | 0% | 1,483 | 4,649 | +213% | 0 | 0 | — |
case-09 | fail→pass | 51,258 | 2,912 | -94% | 1 | 1 | 0% | 1,479 | 3,876 | +162% | 0 | 0 | — |
case-10 | fail→pass | 32,748 | 12,396 | -62% | 1 | 1 | 0% | 2,284 | 4,658 | +104% | 0 | 0 | — |
case-11 | pass→pass | 20,099 | 13,287 | -34% | 1 | 1 | 0% | 2,227 | 4,731 | +112% | 0 | 0 | — |
case-12 | fail→pass | 15,559 | 10,603 | -32% | 1 | 1 | 0% | 1,625 | 4,411 | +171% | 0 | 0 | — |
case-13 | fail→pass | 20,823 | 16,115 | -23% | 1 | 1 | 0% | 2,534 | 4,964 | +96% | 0 | 0 | — |
case-14 | pass→pass | 27,271 | 9,475 | -65% | 1 | 1 | 0% | 1,710 | 4,115 | +141% | 0 | 0 | — |
case-15 | fail→pass | 20,321 | 11,327 | -44% | 1 | 1 | 0% | 2,376 | 4,490 | +89% | 0 | 0 | — |
case-16 | pass→pass | 19,073 | 8,528 | -55% | 1 | 1 | 0% | 2,058 | 5,041 | +145% | 0 | 0 | — |
case-17 | fail→pass | 19,153 | 13,119 | -32% | 1 | 1 | 0% | 2,278 | 4,721 | +107% | 0 | 0 | — |
case-18 | pass→pass | 11,356 | 12,805 | +13% | 1 | 1 | 0% | 1,743 | 4,559 | +162% | 0 | 0 | — |
case-19 | pass→pass | 3,275 | 3,515 | +7% | 1 | 1 | 0% | 564 | 4,070 | +622% | 0 | 0 | — |
case-20 | pass→pass | 17,124 | 6,015 | -65% | 1 | 1 | 0% | 1,769 | 4,295 | +143% | 0 | 0 | — |
case-21 | pass→pass | 19,686 | 19,027 | -3% | 1 | 1 | 0% | 2,700 | 5,549 | +106% | 0 | 0 | — |
case-22 | fail→fail | 25,314 | 15,414 | -39% | 1 | 1 | 0% | 2,208 | 4,441 | +101% | 0 | 0 | — |
case-23 | fail→fail | 32,544 | 15,247 | -53% | 1 | 1 | 0% | 5,776 | 3,735 | -35% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 20 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +43 percentage points is the difference between those two pass rates over the 20 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.