An autonomous AI development loop for Claude Code. Implements features from PRDs without manual intervention by spawning fresh Claude instances to complete user stories one at a time.
Attribution: This is a Claude Code adaptation of snarktank/ralph, originally designed for Amp. Full credit to the original authors for the concept and architecture.
┌─────────────────────────────────────────────┐
│ ralph.sh (loop) │
│ ┌───────────────────────────────────────┐ │
│ │ while not complete: │ │
│ │ claude -p prompt.md │ │
│ │ check for COMPLETE signal │ │
│ │ sleep 2 │ │
│ └───────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
↓ Each iteration ↓
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ prd.json │ │ progress.txt │ │ CLAUDE.md │
│ user stories │ │ learnings │ │ patterns │
└──────────────┘ └──────────────┘ └──────────────┘
Each iteration:
- Reads
prd.jsonto find next incomplete story - Implements that single story
- Runs quality checks (typecheck, tests)
- Commits changes
- Updates
prd.jsonto mark story complete - Logs learnings to
progress.txt - Continues until all stories pass
- Claude Code CLI installed and authenticated
jqcommand-line tool (brew install jq)- Playwright MCP for browser verification (optional, required for UI stories)
- Git repository for your project
- Project with quality commands (
npm run typecheck,npm test, or equivalent)
# Clone this repo
git clone https://github.com/LeslieCBarry/claude-ralph.git ~/claude-ralph
# Run setup in your project
cd ~/your-project
~/claude-ralph/setup.shAdd to your ~/.zshrc or ~/.bashrc:
alias ralph-setup="~/claude-ralph/setup.sh"Then use anywhere:
cd ~/your-project
ralph-setupCopy the skills for PRD generation:
mkdir -p ~/.claude/commands
cp ~/claude-ralph/skills/prd.md ~/.claude/commands/
cp ~/claude-ralph/skills/ralph.md ~/.claude/commands/# 1. Set up Ralph in your project
ralph-setup
# 2. Create a PRD (in Claude)
claude
> /prd
> [describe your feature]
# 3. Convert to prd.json
> /ralph
# 4. Exit Claude and run the loop
> exit
./ralph.sh 10Use the /prd skill in Claude:
/prd
Add a user authentication system with login, logout, and session management.
The skill asks clarifying questions and generates tasks/prd-[feature].md.
Use the /ralph skill:
/ralph
Convert tasks/prd-auth.md to prd.json
This creates prd.json with right-sized user stories.
./ralph.sh 10 # max 10 iterationsWatch as Ralph implements each story, runs tests, commits, and continues.
| File | Purpose |
|---|---|
ralph.sh |
Main loop script |
prompt.md |
Instructions for each Claude iteration |
setup.sh |
Sets up Ralph in a project |
prd.json |
User stories with completion status |
prd.json.example |
Example format |
progress.txt |
Accumulated learnings |
skills/prd.md |
PRD generator skill |
skills/ralph.md |
PRD-to-JSON converter skill |
{
"project": "MyApp",
"branchName": "ralph/feature-name",
"description": "Feature description",
"userStories": [
{
"id": "US-001",
"title": "Add database column",
"description": "As a developer, I need to store X",
"acceptanceCriteria": [
"Add column to table",
"Typecheck passes"
],
"priority": 1,
"passes": false,
"notes": ""
}
]
}Right-sized (one iteration):
- Add a database column
- Create a single UI component
- Add one API endpoint
Too big (split these):
- "Build entire dashboard"
- "Add authentication"
- "Refactor the API"
Rule: If you can't describe it in 2-3 sentences, split it.
| Feature | Original (Amp) | This Fork (Claude Code) |
|---|---|---|
| CLI | amp --dangerously-allow-all |
claude --dangerously-skip-permissions |
| Browser | dev-browser skill | Playwright MCP |
| Memory | AGENTS.md | CLAUDE.md (native support) |
| Thread URLs | Amp thread links | Removed (not applicable) |
Stories fail repeatedly
- Story might be too large - split it
- Check acceptance criteria are achievable
Typecheck/tests fail
- Ensure quality commands work manually first
- Check dependencies are installed
Nothing happens
- Verify
prd.jsonexists withpasses: falsestories - Check you're on the correct git branch
MIT License - Same as original.
- Original concept and architecture: snarktank/ralph
- Claude Code adaptation: This repository