CLI for running Ralph Wiggum loops with Claude Code.
Ralph is an autonomous AI agent loop that runs Claude Code repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context.
# Clone and install locally
git clone https://github.com/linuxlewis/ralph-cli.git
cd ralph-cli
npm install
npm run build
npm linkThis installs ralph globally on your PATH.
Requires:
- Claude Code installed and authenticated
- Node.js 18+
# Run Ralph on a PRD file
ralph run prd.json
# With context files
ralph run prd.json --context AGENTS.md --context docs/
# Check progress
ralph status prd.jsonRun the Ralph loop on a PRD file.
ralph run prd.json [options]Options:
-i, --iterations <n>- Maximum iterations (default: 10)-c, --context <paths...>- Context files or directories to include-p, --prompt <path>- Custom prompt template (default: built-in)--headed- Run Claude Code with visible output--dry-run- Show prompt without executing
Examples:
# Basic usage
ralph run tasks/auth.prd.json
# More iterations, with context
ralph run prd.json --iterations 20 --context ./docs --context AGENTS.md
# See what would be sent to Claude
ralph run prd.json --dry-runShow progress status for a PRD.
ralph status prd.jsonShows:
- Overall progress (X/Y stories complete)
- Each story with pass/fail status
- Sorted by priority
{
"project": "MyApp",
"branchName": "ralph/feature-name",
"description": "Feature description",
"userStories": [
{
"id": "US-001",
"title": "Add user login",
"description": "As a user, I want to log in...",
"acceptanceCriteria": [
"Login form with email/password",
"Validation errors shown",
"Typecheck passes"
],
"priority": 1,
"passes": false,
"notes": ""
}
]
}- Ralph reads
prd.jsonand picks the highest priority story wherepasses: false - Claude Code implements that single story
- Quality checks run (typecheck, lint, tests)
- If passing, commits and updates
prd.jsonto mark story complete - Appends learnings to
progress.txt - Loop repeats until all stories pass or max iterations reached
Each iteration spawns a fresh Claude Code instance. Memory persists via:
- Git history (commits from previous iterations)
progress.txt(learnings and context)prd.json(which stories are done)
The built-in prompt works for most projects. To customize:
ralph run prd.json --prompt my-prompt.mdSee the default prompt for the expected format.
Add context to help Claude understand your codebase:
# Single files
ralph run prd.json -c AGENTS.md -c docs/api.md
# Entire directory (loads all .md files)
ralph run prd.json -c ./docs
# Multiple sources
ralph run prd.json -c AGENTS.md -c ./docs -c ./architectureContext is appended to the prompt as ## Context: filename sections.
MIT