Autonomous task executor for Claude Code
Ralph reads a PRD (Product Requirements Document), picks tasks based on dependencies, executes them with Claude Code, and commits the results - all automatically. It's like having an autonomous developer that follows your project specification.
┌─────────────────────────────────────────────────────────────────────┐
│ RALPH LOOP │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Read PRD │ ───▶ │ Claude │ ───▶ │ Commit │ │
│ │ (JSON) │ │ executes │ │ work │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │ │ │
│ │ ┌───────────┐ │ │
│ └───────── │ Verify │ ◀─────────┘ │
│ │ (Claude) │ │
│ └───────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────┐ │
│ │ All complete? │ ──No──▶ Next iteration │
│ └────────────────┘ │
│ │ │
│ Yes │
│ ▼ │
│ ┌───────────────┐ │
│ │ SUCCESS! │ │
│ └───────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
| Feature | Description |
|---|---|
| PRD-driven | Define tasks in JSON, Ralph executes them in dependency order |
| Auto-generate PRD | Create tasks from a simple goal description with ralph init |
| Git as memory | Each task completion is committed, creating a clear history |
| Self-verifying | After each task, a verification step ensures proper completion |
| Auto-expansion | Complex tasks automatically break down into sub-PRDs |
| Live dashboards | Real-time visualization with ralph watch and ralph flow |
| Resilient | Timeouts, stuck detection, and auto-recovery keep things moving |
| Claude passthrough | Pass extra arguments to Claude with -- ARGS |
# Clone the repository
git clone https://github.com/anouar1991/ralph-engine.git
cd ralph-engine
# Install (to ~/.local by default)
./install.sh
# Or install to custom location
./install.sh --prefix /usr/local
# Verify installation
ralph --version| Dependency | Description | Install |
|---|---|---|
| claude | Claude Code CLI | claude.ai/code |
| jq | JSON processor | apt install jq or brew install jq |
| git | Version control | Usually pre-installed |
# 1. Generate a PRD from your goal
ralph init "Build a REST API for user management with authentication"
# 2. Review the generated tasks
cat prd.json | jq '.tasks[] | {id, name, complexity}'
# 3. Run Ralph to execute all tasks
ralph
# 4. (Optional) Watch progress in another terminal
ralph watchCreate a prd.json from a natural language goal description.
# From text argument
ralph init "Build a CLI tool for managing todos with priorities"
# From file
ralph init -f requirements.md
# With target complexity (number of tasks)
ralph init "Create an e-commerce backend" --complexity 30
# Preview without writing
ralph init "Build a blog engine" --dry-run
# Output to specific directory
ralph init "Create a web scraper" -d ~/my-project
# With extra Claude arguments (e.g., enable Chrome for web research)
ralph init "Build a web scraper for news sites" -- --chromeOptions:
| Option | Description |
|---|---|
-f, --file FILE |
Read goal from file |
-d, --dir DIR |
Output directory (default: current) |
-p, --prd FILE |
Output filename (default: prd.json) |
--complexity NUM |
Target number of tasks |
--dry-run |
Preview without writing |
-- ARGS |
Pass extra arguments to Claude |
Run the main Ralph loop to execute tasks. This is the default command.
# Run in current directory
ralph
# Run in specific project
ralph ~/my-project
# With options
ralph -n 100 -t 1800 # 100 iterations, 30min timeout
ralph --no-verify # Skip verification step
ralph --dry-run # Preview only
# Pass extra arguments to Claude
ralph -- --chrome # Enable Chrome access for web tasks
ralph -- --debug # Run Claude in debug modeOptions:
| Option | Description | Default |
|---|---|---|
-n, --max-iterations |
Maximum loop iterations | 50 |
-t, --timeout |
Seconds per iteration | 900 |
-p, --prd |
PRD filename | prd.json |
-o, --output |
Log directory | /tmp/ralph |
-q, --quiet |
Minimal output | false |
--no-verify |
Skip verification | false |
--no-expand |
Disable auto task expansion | false |
--expansion-threshold |
Complexity threshold for expansion | 4 |
--max-stack-depth |
Maximum nested sub-PRD depth | 3 |
--sudo-pass [VAR] |
Enable sudo password piping | RALPH_SUDO_PASS |
--dry-run |
Preview only | false |
-- ARGS |
Pass extra arguments to Claude | - |
Display current project status and progress.
ralph status # Current directory
ralph status ~/my-project # Specific projectShows:
- Project name and location
- Completion percentage with progress bar
- Completed vs pending tasks
- Next available task (based on dependencies)
Display the PRD expansion stack status when working with sub-PRDs.
ralph stack # Current directory
ralph stack ~/my-project # Specific projectShows:
- Current stack depth
- Active PRD file (main or sub-PRD)
- Parent tasks that have been expanded
- When each expansion was started
- Sub-PRD files in the project
Real-time task visualization dashboard showing overall progress.
ralph watch # Watch current project
ralph watch -r 5 # Refresh every 5 seconds
ralph watch & ralph # Run dashboard alongside ralphOptions:
| Option | Description | Default |
|---|---|---|
-r, --refresh |
Refresh interval (seconds) | 2 |
-p, --prd |
PRD filename | prd.json |
Task Status Icons:
| Icon | Status | Description |
|---|---|---|
| ✓ | Done | Task completed successfully |
| ◉ | Working | Task currently in progress |
| ○ | Ready | Task ready to start (dependencies met) |
| ◌ | Blocked | Waiting on dependencies |
| ↳ | Expanding | Task expanded into sub-PRD |
Real-time dependency tree visualization showing task relationships from goal to leaf tasks.
ralph flow # View dependency flow
ralph flow -r 5 # Refresh every 5 seconds
ralph flow ~/my-project # Specific projectOptions:
| Option | Description | Default |
|---|---|---|
-r, --refresh |
Refresh interval (seconds) | 2 |
-p, --prd |
PRD filename | prd.json |
Example output:
═══════════════════════════════════════════════════
DEPENDENCY FLOW
═══════════════════════════════════════════════════
GOAL: Build a REST API
═══════════════════════════════════════════════
[✓] T-100 Setup project structure
├── [✓] T-200 Add user model
│ └── [◉] T-210 User authentication
└── [○] T-300 Add API endpoints
═══════════════════════════════════════════════
Ralph supports passing extra arguments to Claude Code using the -- separator (POSIX convention).
# Enable Chrome for web-based tasks
ralph init "Scrape product prices from e-commerce sites" -- --chrome
ralph -- --chrome
# Multiple arguments
ralph -- --chrome --verbose
# Via environment variable
export RALPH_CLAUDE_ARGS="--chrome"
ralph # Will use --chrome automaticallyThis is useful when Claude needs:
--chrome: Browser access for web scraping, testing web UIs--debug: Debugging mode- Custom MCP servers: Additional tool integrations
| Variable | Description |
|---|---|
RALPH_MAX_ITERATIONS |
Override default max iterations |
RALPH_TIMEOUT |
Override default timeout |
RALPH_OUTPUT_DIR |
Override default output directory |
RALPH_NO_EXPAND |
Disable automatic expansion (true/false) |
RALPH_EXPANSION_THRESHOLD |
Complexity threshold for expansion |
RALPH_MAX_STACK_DEPTH |
Maximum nested sub-PRD depth |
RALPH_CLAUDE_ARGS |
Extra arguments to pass to Claude |
RALPH_SUDO_PASS |
Sudo password for privileged commands |
NO_COLOR |
Disable colored output |
Ralph expects a prd.json file with a tasks array:
{
"name": "My Project",
"description": "Brief project description",
"tasks": [
{
"id": "T-100",
"name": "Setup project structure",
"description": "Create directories and initialize package.json",
"pass": false,
"dependencies": [],
"complexity": 1,
"actions": [
"Create src/, tests/, docs/ directories",
"Initialize package.json with dependencies"
],
"guarantees": [
"All directories exist",
"package.json is valid"
],
"validation": "npm install succeeds"
},
{
"id": "T-110",
"name": "Add authentication",
"pass": false,
"dependencies": ["T-100"],
"complexity": 3
}
],
"ralph": {
"currentTaskId": null,
"history": [],
"startedAt": null
}
}| Field | Required | Description |
|---|---|---|
id |
Yes | Unique identifier (e.g., "T-100") |
name |
Yes | Human-readable name |
pass |
Yes | Completion status (true/false) |
description |
No | Detailed description |
dependencies |
No | Array of task IDs that must complete first |
complexity |
No | Difficulty rating 1-5 (Ralph prefers lower first) |
actions |
No | Steps to complete the task |
guarantees |
No | What must be true when complete |
validation |
No | Command or check to verify completion |
expand |
No | Force expansion into sub-PRD |
expandGoal |
No | Goal description for sub-PRD |
| Range | Purpose |
|---|---|
| T-100s | Setup tasks (project structure, dependencies) |
| T-200s | Core functionality |
| T-300s | Features and enhancements |
| T-400s | Integration tasks |
| T-500s | Polish (error handling, edge cases) |
| T-600s | Testing and documentation |
Ralph can automatically expand complex tasks into sub-PRDs. This happens when:
- A task has
expand: trueset explicitly - A task has complexity >= 4 AND >= 5 actions
- Claude signals expansion is needed during execution
{
"id": "T-200",
"name": "Implement authentication system",
"complexity": 5,
"expand": true,
"expandGoal": "Build JWT auth with login, tokens, and password reset",
"guarantees": [
"Users can log in",
"JWT tokens are generated",
"Password reset works"
]
}Main PRD → detect complex task → push stack → generate sub-PRD → iterate
↑ ↓
└──────── pop stack ← mark parent done ← sub-PRD complete ←───┘
When expanded, Ralph creates prd-T-200.json with sub-tasks like T-200-100, T-200-200, etc.
Use ralph stack to view the current expansion state.
Ralph reads prd.json and picks ONE task where:
pass: false(not yet complete)- All
dependenciesare complete (pass: true) - Lower
complexitypreferred (builds momentum)
Claude Code executes the task:
- Follows
actionsif specified - Implements requirements
- Runs
validationchecks
Work is committed to git:
Complete T-100: Setup project structure
- Created src/, tests/, docs/ directories
- Initialized package.json with dependencies
- Configured TypeScript
A second Claude call verifies:
- Commit was made with correct format
prd.jsonupdated withpass: true- Any missed steps are fixed
- If tasks remain: continue to next iteration
- If all complete: show success and exit
Ralph encourages Claude to create AGENTS.md files in project directories. These capture:
- Directory purpose
- Patterns and conventions
- Lessons learned from tasks
- Gotchas and warnings
This builds a knowledge base that helps in future iterations.
- Ensure Claude Code is installed:
claude --help - Check your goal is clear and specific
- Try
--dry-runto see what would be generated
- Check that
prd.jsonexists and is valid JSON:jq . prd.json - Ensure
tasksarray exists with at least one task - Verify dependencies are satisfiable (no circular dependencies)
- Increase timeout:
ralph -t 1800 - Break large tasks into smaller ones (lower complexity)
- Check Claude Code is working:
claude "hello"
- Check
/tmp/ralph/for output logs - Review
prd.jsonfor circular dependencies - Ensure validation commands are correct
- Verify git is initialized:
git status - Check file permissions
- Review output for error messages
- Pass
--chrometo Claude:ralph -- --chrome - Or set environment:
export RALPH_CLAUDE_ARGS="--chrome"
Ralph includes shell completions for enhanced CLI experience.
Bash:
# Add to ~/.bashrc
source /path/to/ralph-engine/completions/ralph.bashZsh:
# Add to ~/.zshrc
source /path/to/ralph-engine/completions/ralph.zsh./install.sh --uninstallMIT License - See LICENSE for details.
Noreddine Belhadj Cheikh
Let Ralph handle the tasks while you focus on the vision.