Ship features while you sleep — using your Claude Pro or Max subscription.
An autonomous AI agent loop that runs Claude Code repeatedly until all PRD items are complete. Drop in a PRD, run the loop, wake up to a finished feature branch.
This is a port of snarktank/ralph for Claude Code CLI, so you can use your existing Claude Max subscription instead of Amp credits.
Based on Geoffrey Huntley's Ralph pattern.
The original Ralph uses Amp CLI which requires Amp credits. This port:
- ✅ Uses Claude Code CLI (
claude -p) - ✅ Works with your Claude Pro or Max subscription
- ✅ Same autonomous loop pattern
- ✅ Same PRD-driven workflow
- ✅ Includes browser verification for UI stories
- Claude Code CLI installed and authenticated
jqinstalled (brew install jqon macOS,apt install jqon Linux)- A git repository for your project
- Claude Max subscription (for token usage)
- Playwright for UI verification (optional, for frontend stories)
# Install Playwright for UI story verification
npm install -D playwright
npx playwright install chromiumCopy the ralph files to your project's scripts directory:
# From your project root
mkdir -p scripts
cd scripts
git clone https://github.com/RobinOppenstam/claude-ralph ralph
chmod +x ralph/*.sh
cd ..All ralph files (prd.json, progress.txt, ralph.log) stay in scripts/ralph/, while your project files (src/, package.json, etc.) remain in the project root. This keeps ralph self-contained and your project organized.
The skills in scripts/ralph/skills/ are available automatically when running ralph from your project directory.
To use ralph skills (prd, ralph, dev-browser) across all projects in interactive Claude Code sessions:
# Quick install (recommended)
./scripts/ralph/install-skills.sh
# Or manually copy skills
mkdir -p ~/.claude/skills
cp -r scripts/ralph/skills/prd ~/.claude/skills/
cp -r scripts/ralph/skills/ralph ~/.claude/skills/
cp -r scripts/ralph/skills/dev-browser ~/.claude/skills/Now you can use these skills in any project by loading them in Claude Code:
claude
# Then in the Claude conversation:
# "Load the prd skill and create a PRD for user authentication"
# "Load the ralph skill and convert tasks/prd-auth.md to prd.json"
# "Load the dev-browser skill and verify the login page"Note: Global installation is optional. Skills work from scripts/ralph/skills/ when running ralph autonomously.
Use the PRD skill to generate a detailed requirements document. Start Claude Code interactively:
# From your project root
claudeThen in the Claude conversation, explicitly load the skill and request a PRD:
Load the prd skill and create a PRD for [your feature description]
Example:
Load the prd skill and create a PRD for user authentication with email and password
Note: If the skill doesn't load, make sure you've installed skills globally (see Installation).
Claude will ask clarifying questions (framework, UI requirements, etc.). Answer them in the conversation. The skill saves output to tasks/prd-[feature-name].md.
Use the Ralph skill to convert the markdown PRD to JSON. In the same Claude session (or start a new one with claude):
Load the ralph skill and convert tasks/prd-[feature-name].md to prd.json
Example:
Load the ralph skill and convert tasks/prd-user-authentication.md to prd.json
This creates scripts/ralph/prd.json with user stories structured for autonomous execution. Each story has a passes: false flag that Ralph will update.
Exit Claude (Ctrl+C or type exit).
Now Ralph takes over. From your terminal (not in Claude):
./scripts/ralph/ralph.sh [max_iterations]Example:
./scripts/ralph/ralph.sh 10Default is 10 iterations. Run this from your project root directory.
Ralph will autonomously:
- Create a feature branch (from PRD
branchName) - Pick the highest priority story where
passes: false - Spawn a fresh Claude Code instance to implement that single story
- Run quality checks (typecheck, tests)
- Commit if checks pass
- Update
prd.jsonto mark story aspasses: true - Append learnings to
progress.txt - Repeat until all stories pass or max iterations reached
Key difference: Steps 1-2 are interactive (you guide Claude), Step 3 is autonomous (Ralph loops without you).
your-project/
├── scripts/
│ └── ralph/ # Ralph files (self-contained)
│ ├── ralph.sh # Main loop script
│ ├── ralph-once.sh # Single iteration script
│ ├── ralph-status.sh # Status checker
│ ├── prompt.md # Instructions for each Claude iteration
│ ├── prd.json # User stories with passes status
│ ├── prd.json.example # Example PRD format
│ ├── progress.txt # Append-only learnings log
│ ├── ralph.log # Execution log with timestamps
│ ├── .last-branch # Current branch tracker
│ ├── archive/ # Previous runs
│ └── skills/ # Claude Code skills
│ ├── prd/ # PRD generation skill
│ └── ralph/ # PRD to JSON conversion skill
│
└── [Project root] # Your project files
├── src/ # Source code (created by Ralph)
├── package.json # Dependencies (created by Ralph)
├── tsconfig.json # Config (created by Ralph)
└── ... # Other project files
| Feature | Original (Amp) | claude-ralph |
|---|---|---|
| CLI | amp |
claude |
| Non-interactive flag | --dangerously-allow-all |
-p --dangerously-skip-permissions |
| Pricing | Amp credits | Claude Max subscription |
| Skills location | ~/.config/amp/skills/ |
~/.claude/skills/ |
| Project config | AGENTS.md |
CLAUDE.md |
Each iteration spawns a new Claude Code instance with clean context. The only memory between iterations is:
- Git history (commits from previous iterations)
progress.txt(learnings and context)prd.json(which stories are done)
Each PRD item should be small enough to complete in one context window. If a task is too big, Claude runs out of context before finishing and produces poor code.
Right-sized stories:
- Add a database column and migration
- Add a UI component to an existing page
- Update a server action with new logic
- Add a filter dropdown to a list
Too big (split these):
- "Build the entire dashboard"
- "Add authentication"
- "Refactor the API"
After each iteration, Ralph updates the relevant CLAUDE.md files with learnings. This is key because Claude Code automatically reads these files, so future iterations benefit from discovered patterns.
When all stories have passes: true, Ralph outputs <promise>COMPLETE</promise> and the loop exits.
Run these commands from your project root:
# See which stories are done
cat scripts/ralph/prd.json | jq '.userStories[] | {id, title, passes}'
# See learnings from previous iterations
cat scripts/ralph/progress.txt
# Check ralph execution log
cat scripts/ralph/ralph.log
# Check git history
git log --oneline -10
# Run single iteration for debugging
./scripts/ralph/ralph-once.sh
# Check status with nice formatting
./scripts/ralph/ralph-status.shEdit scripts/ralph/prompt.md to customize Ralph's behavior for your project:
- Add project-specific quality check commands
- Include codebase conventions
- Add common gotchas for your stack
Ralph automatically archives previous runs when you start a new feature (different branchName). Archives are saved to scripts/ralph/archive/YYYY-MM-DD-feature-name/ and include the prd.json, progress.txt, and ralph.log from the previous run.
# Install Claude Code CLI
npm install -g @anthropic-ai/claude-code
# Authenticate
claudechmod +x scripts/ralph/*.sh# macOS
brew install jq
# Ubuntu/Debian
apt install jq
# Windows (WSL)
apt install jqIf Claude Code can't find the skills, make sure they're installed globally:
# Install skills globally
mkdir -p ~/.claude/skills
cp -r scripts/ralph/skills/prd ~/.claude/skills/
cp -r scripts/ralph/skills/ralph ~/.claude/skills/
cp -r scripts/ralph/skills/dev-browser ~/.claude/skills/
# Verify they're installed
ls -la ~/.claude/skills/Then load them explicitly:
Load the prd skill
Load the ralph skill
Load the dev-browser skill
Symptom: Ralph shows "✅ RALPH COMPLETE!" after only 2/11 tasks, or exits when stories remain incomplete.
Cause: Claude mentioned the completion tag <promise>COMPLETE</promise> in its reasoning or explanations (e.g., saying "I should NOT output <promise>COMPLETE</promise>"), which triggered the grep pattern in older versions.
Fixed in v1.1.0+: Ralph now uses dual verification:
- The prompt explicitly warns Claude not to quote the completion tag
- Ralph verifies BOTH tag presence AND that all PRD stories are actually complete before exiting
If you encounter this:
-
Update ralph.sh to the latest version from the repo (includes the dual verification fix)
-
Check the status:
./scripts/ralph/ralph-status.sh
-
Review the log:
tail -50 scripts/ralph/ralph.log
Look for the warning: "Claude output COMPLETE signal but PRD still has incomplete stories"
-
Other common causes:
- Quality checks failing (typecheck, tests)
- Story is too large for one iteration
- PRD file corruption
-
Debug with a single iteration:
./scripts/ralph/ralph-once.sh
This runs one iteration and shows what happened.
-
Check PRD manually:
cat scripts/ralph/prd.json | jq '.userStories[] | {id, title, passes}'
# Install ralph in a project
mkdir -p scripts && cd scripts
git clone https://github.com/RobinOppenstam/claude-ralph ralph
chmod +x ralph/*.sh && cd ..
# Install skills globally (one-time setup, recommended)
./scripts/ralph/install-skills.sh
# Interactive PRD creation
claude
# "Load the prd skill and create a PRD for [feature]"
# "Load the ralph skill and convert tasks/prd-[name].md to prd.json"
# Run ralph autonomously
./scripts/ralph/ralph.sh 10
# Check status
./scripts/ralph/ralph-status.sh
cat scripts/ralph/prd.json | jq '.userStories[] | {id, title, passes}'
# Debug single iteration
./scripts/ralph/ralph-once.sh
# See learnings
cat scripts/ralph/progress.txt- Original Ralph: snarktank/ralph by Ryan Carson
- Ralph Pattern: Geoffrey Huntley
- Claude Code: Anthropic
MIT License - See LICENSE for details.
