Executes PRP Ralph loops autonomously: reads .claude/prp-ralph.state.md, assesses plan progress, implements incremental changes, runs full validations until complete.
From prp-corenpx claudepluginhub dmmedia/prp-framework-embedded --plugin prp-coreThis skill uses the workspace's default tool permissions.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Executes pre-written implementation plans: critically reviews, follows bite-sized steps exactly, runs verifications, tracks progress with checkpoints, uses git worktrees, stops on blockers.
Guides idea refinement into designs: explores context, asks questions one-by-one, proposes approaches, presents sections for approval, writes/review specs before coding.
This skill provides the knowledge needed to correctly execute Ralph loop iterations. Ralph is an autonomous loop system that executes PRP plans iteratively until all tasks are complete and all validations pass.
Check for the state file: .claude/prp-ralph.state.md
If this file exists, you are in an active Ralph loop. Read it first to understand:
.claude/prp-ralph.state.md
The state file uses YAML frontmatter followed by a progress log:
---
iteration: 3
max_iterations: 10
plan_path: ".claude/PRPs/plans/add-feature.md"
started_at: "2024-01-12T10:00:00Z"
---
# Ralph Progress Log
## Codebase Patterns
[Consolidated learnings that apply across iterations]
## Iteration 1 - 2024-01-12T10:05:00Z
- Implemented X
- Files changed: a.ts, b.ts
- Learnings: Found that Y pattern is used for Z
- Still failing: type-check (3 errors)
## Iteration 2 - 2024-01-12T10:15:00Z
- Fixed type errors
- Added missing imports
- Learnings: Always import types from @/types
- Still failing: tests (1 failure in auth.test.ts)
---
| Field | Type | Description |
|---|---|---|
iteration | number | Current iteration (1-indexed) |
max_iterations | number | Maximum allowed iterations (0 = unlimited) |
plan_path | string | Path to the plan file being executed |
started_at | string | ISO timestamp when loop started |
plan_path) to understand all tasksRun every validation command. Do not skip any.
TypeScript/JavaScript:
bun run type-check || npm run type-check || npx tsc --noEmit
bun run lint || npm run lint
bun test || npm test
bun run build || npm run build
Python:
uv run ruff check --fix
uv run mypy .
uv run pytest
General:
git status # Check for uncommitted changes
Append to the state file's progress log (see Section 6).
| Failure | Common Cause | Fix |
|---|---|---|
| Type error | Missing import, wrong type | Add import, fix type annotation |
| Lint error | Formatting, unused var | Run auto-fix, remove unused code |
| Test failure | Logic bug, missing mock | Fix logic, add proper mocks |
| Build error | Missing dependency | Install dependency, fix imports |
<promise>COMPLETE</promise>
This exact string signals that the Ralph loop should end.
Output <promise>COMPLETE</promise> ONLY when ALL of these are true:
NEVER output the completion signal if:
When you output <promise>COMPLETE</promise>:
If you end your response without the completion signal:
Each iteration has limited context. Progress logs are how you communicate with future iterations (including yourself). Good logs = faster completion.
After each iteration, APPEND to the state file:
## Iteration N - [ISO timestamp]
Thread: [conversation reference if available]
### Completed
- [What was implemented this iteration]
- [Files changed: list them]
### Validation Status
- Type-check: [PASS/FAIL - details if failing]
- Lint: [PASS/FAIL - details if failing]
- Tests: [PASS/FAIL - details if failing]
- Build: [PASS/FAIL - details if failing]
### Learnings
- [Pattern discovered: "this codebase uses X for Y"]
- [Gotcha found: "don't forget to Z when doing W"]
- [Context: "the settings panel is in component X"]
### Next Steps
- [What the next iteration should focus on]
- [Specific files or functions to look at]
---
If you discover a reusable pattern that future iterations should know, add it to the ## Codebase Patterns section at the TOP of the progress log:
## Codebase Patterns
- Use `sql<number>` template for type-safe SQL aggregations
- Always use `IF NOT EXISTS` in migrations
- Export types from actions.ts for UI components
- Form validation uses zod schemas in /lib/validations
Only add patterns that are general and reusable, not iteration-specific details.
If you discover patterns that should be permanent project knowledge, update the project's CLAUDE.md:
Good additions:
Bad additions:
Check if edited directories have AGENTS.md files. Add learnings that help future work:
## Patterns
- When modifying X, also update Y
- This module uses pattern Z for all API calls
## Gotchas
- Tests require dev server on port 3000
- Field names must match template exactly
When a Ralph loop completes successfully, the learnings should be:
.claude/PRPs/ralph-archives/Archive format:
.claude/PRPs/ralph-archives/
└── YYYY-MM-DD-feature-name/
├── state.md # Final state file
├── plan.md # The executed plan
└── learnings.md # Consolidated patterns
Wrong: "Tests are probably passing, <promise>COMPLETE</promise>" Right: Run tests, verify they pass, THEN output completion
Wrong: Start implementing without checking what's done Right: Read state file first, understand current state
Wrong: Invent new patterns for common operations Right: Check patterns section, follow existing conventions
Wrong: "I'm confident this works, no need to run tests" Right: ALWAYS run ALL validations, every iteration
Wrong: Fix a tricky issue without documenting it Right: Log the gotcha so future iterations don't repeat it
Wrong: Try to complete 5 tasks in one iteration Right: Focus on one task, do it well, validate, commit
User invokes: /prp-ralph [plan.md] --max-iterations N
The command:
User invokes: /prp-ralph-cancel
This:
This skill is not user-invoked. It provides the knowledge Claude needs during loop execution. The command starts the loop, the hook maintains it, and this skill guides correct behavior.
.claude/prp-ralph.state.md
<promise>COMPLETE</promise>
# TypeScript/JavaScript
npm run type-check && npm run lint && npm test && npm run build
# Python
uv run ruff check && uv run mypy . && uv run pytest
## Iteration N - YYYY-MM-DDTHH:MM:SSZ
### Completed
- [What was done]
### Validation Status
- Type-check: PASS/FAIL
- Lint: PASS/FAIL
- Tests: PASS/FAIL
- Build: PASS/FAIL
### Learnings
- [Patterns, gotchas, context]
### Next Steps
- [What to do next]
---