원클릭으로
prp-ralph
Start autonomous Ralph loop to execute PRP plan until all validations pass. Self-referential feedback loop with iteration tracking.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Start autonomous Ralph loop to execute PRP plan until all validations pass. Self-referential feedback loop with iteration tracking.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Multi-agent PR review — spawns parallel specialized agents for deep code review.
Multi-agent PR review — spawns parallel specialized agents for deep code review.
Execute an implementation plan with rigorous validation loops — typecheck, lint, test, and build after every change. TDD approach with automatic failure recovery.
Create a comprehensive implementation plan by analyzing the codebase, discovering patterns, and producing a step-by-step actionable plan document.
Execute an implementation plan with rigorous validation loops — typecheck, lint, test, and build after every change. TDD approach with automatic failure recovery.
Create a comprehensive implementation plan by analyzing the codebase, discovering patterns, and producing a step-by-step actionable plan document.
| name | prp-ralph |
| description | Start autonomous Ralph loop to execute PRP plan until all validations pass. Self-referential feedback loop with iteration tracking. |
| metadata | {"short-description":"Autonomous implementation loop"} |
Input: $ARGUMENTS
Start an autonomous Ralph loop that executes a PRP plan iteratively until all validations pass.
Core Philosophy: Self-referential feedback loop. Each iteration, you see your previous work in files and git history. You implement, validate, fix, repeat - until complete.
Skill Reference: The prp-ralph-loop skill provides detailed execution guidance. It will be automatically available during loop iterations.
Extract from input:
.plan.md or .prd.md--max-iterations N (default: 20)| Input | Action |
|---|---|
Ends with .plan.md | Valid - use as plan file |
Ends with .prd.md | Valid - will select next phase |
| Free-form text | STOP with message below |
| No input | STOP with message below |
If invalid input:
Ralph requires a PRP plan or PRD file.
Create one first:
$prp-plan "your feature description" # Creates plan from description
$prp-prd "your product idea" # Creates PRD with phases
Then run:
/prp-ralph .prp-output/plans/your-feature.plan.md --max-iterations 20
test -f "{file_path}" && echo "EXISTS" || echo "NOT_FOUND"
If NOT_FOUND: Stop with error message.
If input is a .prd.md file:
Status: pending where dependencies are completePHASE_1_CHECKPOINT:
Create .prp-output/state/ralph.state.md:
mkdir -p .prp-output/state
mkdir -p .prp-output/ralph-archives
Write state file using Bash with heredoc (cat > file << 'EOF') — these are machine-generated tracking files, not source code:
---
iteration: 1
max_iterations: {N}
plan_path: "{file_path}"
input_type: "{plan|prd}"
started_at: "{ISO timestamp}"
---
# PRP Ralph Loop State
## Codebase Patterns
(Consolidate reusable patterns here - future iterations read this first)
## Current Task
Execute PRP plan and iterate until all validations pass.
## Plan Reference
{file_path}
## Instructions
1. Read the plan file
2. Implement all incomplete tasks
3. Run ALL validation commands from the plan
4. If any validation fails: fix and re-validate
5. Update plan file: mark completed tasks, add notes
6. When ALL validations pass: output <promise>COMPLETE</promise>
## Progress Log
(Append learnings after each iteration)
---
## PRP Ralph Loop Activated
**Plan**: {file_path}
**Iteration**: 1
**Max iterations**: {N}
The stop hook is now active. When you try to exit:
- If validations incomplete → same prompt fed back
- If all validations pass → loop exits
To monitor: `cat .prp-output/state/ralph.state.md`
To cancel: `/prp-ralph-cancel`
---
CRITICAL REQUIREMENTS:
- Work through ALL tasks in the plan
- Run ALL validation commands
- Fix failures before proceeding
- Only output <promise>COMPLETE</promise> when ALL validations pass
- Do NOT lie to exit - the loop continues until genuinely complete
---
Starting iteration 1...
PHASE_2_CHECKPOINT:
Before implementing anything:
From the plan, identify:
For each incomplete task:
Run ALL validation commands from the plan:
# Typical validation levels (adapt to plan)
bun run type-check || npm run type-check
bun run lint || npm run lint
bun test || npm test
bun run build || npm run build
After tests pass, verify coverage on new/changed code:
# Get changed source files (exclude tests)
CHANGED_FILES=$(git diff --name-only origin/main...HEAD | grep -E '\.(ts|tsx|js|jsx|py|rs|go)$' | grep -v -E '(test|spec|__test__)')
Run coverage tool (auto-detect: jest --coverage, vitest --coverage, pytest --cov, go test -cover, cargo tarpaulin).
| Result | Action |
|---|---|
| Coverage >= 90% on new code | Proceed |
| Coverage < 90% on new code | Write additional tests, re-run until >= 90% |
| No coverage tool available | Skip with note in results |
| Check | Result | Notes |
|---|---|---|
| Type check | PASS/FAIL | {details} |
| Lint | PASS/FAIL | {details} |
| Tests | PASS/FAIL | {details} |
| Coverage | PASS/FAIL/SKIP | {percentage on new code, target: 90%} |
| Build | PASS/FAIL | {details} |
After each significant change:
Append to Progress Log section using this format:
## Iteration {N} - {ISO timestamp}
### Completed
- {Task 1 summary}
- {Task 2 summary}
### Validation Status
- Type-check: PASS/FAIL ({error count if failing})
- Lint: PASS/FAIL
- Tests: PASS/FAIL ({X/Y passing})
- Build: PASS/FAIL
### Learnings
- {Pattern discovered: "this codebase uses X for Y"}
- {Gotcha found: "don't forget to Z when doing W"}
- {Context: "the component X is in directory Y"}
### Next Steps
- {What still needs to be done}
- {Specific blockers to address}
---
If you discover a reusable pattern, add it to the "Codebase Patterns" section at the TOP of the state file:
## 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.
PHASE_3_CHECKPOINT:
ALL of these must be true:
Generate Implementation Report
Create .prp-output/reports/{plan-name}-report.md:
# Implementation Report
**Plan**: {plan_path}
**Completed**: {timestamp}
**Iterations**: {N}
## Summary
{What was implemented}
## Tasks Completed
{List from plan}
## Validation Results
| Check | Result |
|-------|--------|
| Type check | PASS |
| Lint | PASS |
| Tests | PASS |
| Build | PASS |
## Codebase Patterns Discovered
{From state file Codebase Patterns section}
## Learnings
{Consolidated from state file progress log}
## Deviations from Plan
{Any changes made}
Archive the Ralph Run
# Create archive directory
DATE=$(date +%Y-%m-%d)
PLAN_NAME=$(basename {plan_path} .plan.md)
ARCHIVE_DIR=".prp-output/ralph-archives/${DATE}-${PLAN_NAME}"
mkdir -p "$ARCHIVE_DIR"
# Copy state file (with all learnings)
cp .prp-output/state/ralph.state.md "$ARCHIVE_DIR/state.md"
# Copy the plan
cp {plan_path} "$ARCHIVE_DIR/plan.md"
# Extract consolidated learnings
# (The report serves as learnings.md)
cp .prp-output/reports/{plan-name}-report.md "$ARCHIVE_DIR/learnings.md"
Update CLAUDE.md with Permanent Patterns (if applicable)
If any patterns from "Codebase Patterns" section are significant enough to be permanent project knowledge:
Example addition:
## Patterns Discovered via Ralph
- {Pattern that should be permanent}
Archive Plan to Completed
mkdir -p .prp-output/plans/completed
mv {plan_path} .prp-output/plans/completed/
Generate Review Context File (enables token optimization when used via /prp-run-all --ralph)
BRANCH=$(git branch --show-current)
mkdir -p .prp-output/reviews
Create .prp-output/reviews/pr-context-{BRANCH}.md:
# PR Review Context
**Branch**: `{BRANCH}`
**Generated**: {YYYY-MM-DD HH:MM}
**Source Plan**: `{plan_path}`
**Ralph Iterations**: {N}
---
## Files Changed
{Run: git diff --name-only origin/main...HEAD}
| File | Action | Summary |
|------|--------|---------|
| `src/x.ts` | CREATE | {brief description} |
| `src/y.ts` | UPDATE | {brief description} |
---
## Implementation Summary
{Copy from the report's Summary section}
---
## Validation Status
| Check | Result |
|-------|--------|
| Type check | ✅ |
| Lint | ✅ |
| Tests | ✅ ({N} passed) |
| Build | ✅ |
---
## Key Changes for Review
### New Files
{List new files with brief purpose}
### Modified Files
{List modified files with what changed}
### Tests Added
{List test files and what they cover}
---
## Review Focus Areas
- {Area 1 that reviewers should focus on}
- {Gotchas or edge cases discovered during ralph iterations}
Clean Up State
rm .prp-output/state/ralph.state.md
Output Completion Promise
<promise>COMPLETE</promise>
If validations are not all passing:
Do NOT output the completion promise if validations are failing.
If iteration count reaches max_iterations:
If you notice you're stuck (same error multiple iterations):
If the plan itself has issues:
The Ralph loop captures learnings that can improve the system:
.prp-output/ralph-archives/Archives can be used to:
# List all Ralph archives
ls -la .prp-output/ralph-archives/
# Review learnings from a specific run
cat .prp-output/ralph-archives/2024-01-12-feature-name/learnings.md
.prp-output/reviews/pr-context-{BRANCH}.md