Version: 3.1.0
Ralphing is an autonomous AI coding agent that reads tasks from a Product Requirements Document (PRD), implements them one by one, and marks them complete. It supports multiple AI engines (Claude API, OpenCode, Cursor, Codex) and can run tasks sequentially or in parallel.
Ralphing comes in two versions optimized for different use cases:
| Script | AI Engine | Best For | Default Model |
|---|---|---|---|
| ralphing.sh | Claude API | Production use with Claude API | Claude (Anthropic API) |
| ralphing_z_ai.sh | z.ai zclaude | Cost-effective development with z.ai | GLM-4-Flash |
Quick Start:
- For Claude API users: Use
./ralphing.sh(default) - For z.ai users: Use
./ralphing_z_ai.sh(optimized for z.ai's GLM-4-Flash model)
Both versions support all the same features (parallel execution, branch-per-task, PR creation, etc.) - the only difference is the AI engine.
- Features
- Prerequisites
- Installation
- Quick Start
- Usage
- PRD Formats
- Configuration
- Examples
- How It Works
- Advanced Features
- Troubleshooting
- Best Practices
- Autonomous Task Execution: Reads tasks from PRD and executes them automatically
- Multiple AI Engines: Supports Claude Code (zclaude), OpenCode, Cursor, and Codex
- Sequential & Parallel Modes: Run tasks one at a time or concurrently (up to N parallel agents)
- Git Integration: Optional branch-per-task workflow with automated PR creation
- Real-time Progress Monitoring: Colorful status indicators and 30-second detailed updates
- Automatic Task Completion Tracking: Marks tasks complete in PRD after successful implementation
- Token Tracking: Monitors API usage and costs across all supported engines
- Retry Logic: Automatic retries on failures with configurable delay
- Colorful Blinking Indicators: Visual feedback with rotating colored βΊ indicators
- 30-Second Status Updates: Detailed progress reports every 30 seconds
- Reliable Task Completion: Script-level verification ensures PRD is always updated
- Per-Agent Indicators: In parallel mode, see status of each agent with unique colors
- Improved Error Handling: Better detection and reporting of stuck agents
- Bash 4.0+ (macOS and Linux supported)
- jq - JSON parsing (installation)
- Git - Version control
- One of the following AI engines:
- Claude API via
claudeCLI (default for ralphing.sh) - z.ai zclaude for GLM-4-Flash model (default for ralphing_z_ai.sh)
- OpenCode
- Cursor agent
- Codex CLI
- Claude API via
- GitHub CLI (gh) - For PR creation and GitHub issues (installation)
- yq - YAML parsing for YAML task files (installation)
- bc - Better precision for cost calculations (usually pre-installed)
# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install dependencies
brew install jq gh yq bc
# Install Claude Code (recommended)
npm install -g @anthropic/claude-code# Install dependencies
sudo apt update
sudo apt install jq bc curl
# Install GitHub CLI
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh
# Install yq
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
# Install Claude CLI (for ralphing.sh)
npm install -g @anthropic/claude-cli
# OR install z.ai zclaude (for ralphing_z_ai.sh)
# Follow z.ai setup instructions at https://z.ai/Choose which version to download based on your AI engine:
# Download ralphing.sh
curl -o ralphing.sh https://raw.githubusercontent.com/arslandevs/ralphing/master/ralphing.sh
# Make it executable
chmod +x ralphing.sh# Download ralphing_z_ai.sh
curl -o ralphing_z_ai.sh https://raw.githubusercontent.com/arslandevs/ralphing/master/ralphing_z_ai.sh
# Make it executable
chmod +x ralphing_z_ai.sh# Clone the repository to get both
git clone https://github.com/arslandevs/ralphing.git
cd ralphing
chmod +x ralphing.sh ralphing_z_ai.sh# Install Claude CLI
npm install -g @anthropic/claude-cli
# Set your Anthropic API key
export ANTHROPIC_API_KEY="your-api-key-here"
# Or add to ~/.bashrc or ~/.zshrc
echo 'export ANTHROPIC_API_KEY="your-api-key-here"' >> ~/.bashrc# Install z.ai zclaude
# Follow instructions at https://z.ai/
# The GLM-4-Flash model is configured by default
# No additional API key needed if using z.ai# Follow OpenCode setup instructions
# https://opencode.ai/docs/# Install Cursor and ensure 'agent' is in your PATH
# https://cursor.com/Create a PRD.md file in your project root:
# Project Tasks
## Features
- [ ] Add user authentication
- [ ] Create database schema
- [ ] Build API endpoints
- [ ] Add frontend components
- [ ] Write tests
- [ ] Deploy to productiontouch progress.txt# Basic run (sequential mode)
./ralphing.sh
# Run with verbose output
./ralphing.sh --verbose
# Run with parallel execution (3 agents)
./ralphing.sh --parallel --max-parallel 3
# Run with branch-per-task and PR creation
./ralphing.sh --branch-per-task --create-pr# Basic run (sequential mode)
./ralphing_z_ai.sh
# Run with verbose output
./ralphing_z_ai.sh --verbose
# Run with parallel execution (3 agents)
./ralphing_z_ai.sh --parallel --max-parallel 3
# Run with branch-per-task and PR creation
./ralphing_z_ai.sh --branch-per-task --create-pr# Show help
./ralphing.sh --help
# Show version
./ralphing.sh --version
# Dry run (see what would be executed)
./ralphing.sh --dry-run
# Verbose mode (debug output)
./ralphing.sh --verbose# Use Claude API (default)
./ralphing.sh --claude
# Use OpenCode
./ralphing.sh --opencode
# Use Cursor agent
./ralphing.sh --cursor
# Use Codex
./ralphing.sh --codex
# Use z.ai zclaude
./ralphing.sh --zclaude# Always uses z.ai zclaude with GLM-4-Flash
# No engine selection needed - it's optimized for z.ai
./ralphing_z_ai.sh# Skip tests
./ralphing.sh --no-tests
# Skip linting
./ralphing.sh --no-lint
# Skip both tests and linting (fast mode)
./ralphing.sh --fast
# Limit iterations
./ralphing.sh --max-iterations 5
# Configure retries
./ralphing.sh --max-retries 5 --retry-delay 10Runs tasks one at a time in order:
./ralphing.shRuns multiple tasks concurrently using isolated git worktrees:
# Run 3 tasks in parallel
./ralphing.sh --parallel --max-parallel 3
# Run 5 tasks in parallel with verbose output
./ralphing.sh --parallel --max-parallel 5 --verboseHow Parallel Mode Works:
- Creates isolated git worktrees for each agent
- Each agent works independently on a separate task
- Agents run concurrently without conflicts
- Completed branches are merged back to base branch
- Handles merge conflicts with interactive resolution
# Create a branch for each task
./ralphing.sh --branch-per-task
# Specify base branch
./ralphing.sh --branch-per-task --base-branch main
# Create PRs automatically
./ralphing.sh --branch-per-task --create-pr
# Create draft PRs
./ralphing.sh --branch-per-task --create-pr --draft-prBranch Naming:
- Sequential:
ralphing/task-name-slugified - Parallel:
ralphing/agent-N-task-name-slugified
./ralphing.sh --prd PRD.md./ralphing.sh --yaml tasks.yaml# Fetch tasks from GitHub issues
./ralphing.sh --github owner/repo
# Filter by label
./ralphing.sh --github owner/repo --github-label enhancement# Product Requirements Document
## Phase 1: Core Features
- [ ] Implement user authentication
- [ ] Create database schema for users
- [ ] Build REST API endpoints
- [ ] Add input validation
## Phase 2: Frontend
- [ ] Create login page
- [ ] Build dashboard component
- [ ] Add user profile editing
## Phase 3: Testing
- [ ] Write unit tests for API
- [ ] Add integration tests
- [ ] Set up CI/CD pipelineFormat:
- Use
- [ ]for incomplete tasks - Tasks are automatically marked
- [x]when complete - Supports any heading structure
tasks:
- title: "Set up project structure"
completed: false
parallel_group: 1
- title: "Create database models"
completed: false
parallel_group: 1
- title: "Build API endpoints"
completed: false
parallel_group: 2
- title: "Add authentication middleware"
completed: false
parallel_group: 2
- title: "Write tests"
completed: false
parallel_group: 3Features:
title: Task descriptioncompleted: Boolean statusparallel_group: Optional grouping (tasks with same group run in parallel)
# All open issues
./ralphing.sh --github myorg/myrepo
# Only issues labeled "ralphy"
./ralphing.sh --github myorg/myrepo --github-label ralphyFeatures:
- Fetches open issues from repository
- Closes issues when tasks complete
- Includes issue body as task context
# API Keys
export ANTHROPIC_API_KEY="sk-ant-..." # For Claude Code
export OPENAI_API_KEY="sk-..." # For OpenCode/Codex
export CURSOR_API_KEY="..." # For Cursor
# Git Configuration (optional)
export GIT_AUTHOR_NAME="Ralphing Bot"
export GIT_AUTHOR_EMAIL="ralphing@example.com"your-project/
βββ PRD.md # Task list (markdown)
βββ progress.txt # Task progress log
βββ ralphing.sh # The script
βββ .git/ # Git repository
βββ your-code/ # Your project files
./ralphing.sh --verboseOutput:
[INFO] Found 5 tasks to process
[INFO] Base branch: main
>>> Task 1
Completed: 0 | Remaining: 5
--------------------------------------------
βΊ β Implementing β Add user authentication [00:15]
=== Agent Status Update (0m 30s) ===
Recent activity:
Tool: Write
File: auth.js
Tool: Edit
File: server.js
Current step: Implementing
β Done β Add user authentication
β All tasks complete!
./ralphing.sh --parallel --max-parallel 3 --verboseOutput:
[INFO] Running 3 parallel agents (each in isolated worktree)...
[INFO] Found 6 tasks to process
[INFO] Base branch: main
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Batch 1: Spawning 3 parallel agents
Each agent runs in its own git worktree with isolated workspace
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Agent 1: Add user authentication
β Agent 2: Create database schema
β Agent 3: Build API endpoints
β [βΊ βΊ βΊ ] 0 setup | 3 running | 0 done | 0 failed | 01:23
=== Parallel Agent Status Update (1m 30s) ===
Agent 1: βΊ Running β Add user authentication
Agent 2: βΊ Running β Create database schema
Agent 3: βΊ Running β Build API endpoints
Batch 1 Results:
β Agent 1: Add user authentication β ralphing/agent-1-add-user-authentication
β Agent 2: Create database schema β ralphing/agent-2-create-database-schema
β Agent 3: Build API endpoints β ralphing/agent-3-build-api-endpoints
./ralphing.sh --branch-per-task --create-pr --base-branch mainCreates:
- Branch:
ralphing/add-user-authentication - PR: "Add user authentication" β
main - Automatic merge after completion
./ralphing.sh --github myorg/myrepo --github-label sprint-1 --parallel --max-parallel 2Fetches:
- All open issues labeled "sprint-1"
- Implements each issue
- Closes issues when complete
tasks.yaml:
tasks:
# Group 1 - Independent setup tasks
- title: "Initialize project structure"
parallel_group: 1
- title: "Set up database connection"
parallel_group: 1
# Group 2 - Core features (run after group 1)
- title: "Implement user service"
parallel_group: 2
- title: "Implement auth service"
parallel_group: 2
# Group 3 - Tests (run after group 2)
- title: "Write user service tests"
parallel_group: 3
- title: "Write auth service tests"
parallel_group: 3./ralphing.sh --yaml tasks.yaml --parallel --max-parallel 2Execution:
- Runs group 1 tasks (2 in parallel)
- Then group 2 tasks (2 in parallel)
- Finally group 3 tasks (2 in parallel)
- Read PRD: Parses PRD.md/tasks.yaml/GitHub issues
- Get Next Task: Finds first incomplete task
- Create Branch (if
--branch-per-task): Creates feature branch - Build Prompt: Generates instructions for AI including:
- Task description
- Testing requirements (if not skipped)
- Linting requirements (if not skipped)
- PRD update instructions
- Progress logging
- Run AI Agent: Executes chosen AI engine
- Monitor Progress: Shows colorful spinner with status updates
- Mark Complete: Script marks task complete in PRD (reliable!)
- Create PR (if requested): Pushes branch and creates PR
- Repeat: Goes to next task until all complete
- Read PRD: Gets all pending tasks
- Group Tasks (YAML only): Groups tasks by
parallel_group - Create Worktrees: For each parallel agent, creates isolated git worktree
- Spawn Agents: Runs N agents concurrently (each in own worktree)
- Monitor All Agents: Shows per-agent status with colorful indicators
- Collect Results: Waits for all agents to complete
- Merge Branches: Merges completed branches back to base
- Conflict Resolution (if needed): Interactive menu for conflicts
- Cleanup Worktrees: Removes temporary worktrees
- Repeat Batch: Processes next batch of tasks
Sequential Mode:
βΊ β Implementing β Add user authentication [00:15]
- βΊ: Colorful blinking indicator (rotates through colors)
- β : Spinner animation
- Implementing: Current step (auto-detected from AI output)
- Add user authentication: Task name (truncated)
- [00:15]: Elapsed time
Parallel Mode:
β [βΊ βΊ β ] 0 setup | 2 running | 1 done | 0 failed | 01:23
- [βΊ βΊ β]: Per-agent indicators
β= Setting up (colored by agent)βΊ= Running (colored by agent)β= Done (green)β= Failed (red)Β·= Waiting (dim)
30-Second Status Updates: Every 30 seconds, detailed status is printed:
=== Agent Status Update (0m 30s) ===
Recent activity:
Tool: Write
File: auth.js
Tool: Edit
File: server.js
Current step: Implementing
Reliable Completion (New in 3.1.0):
- AI completes task and attempts to mark PRD
- Script ALWAYS marks task complete (doesn't rely on AI)
- Script verifies PRD was updated correctly
- If verification fails, uses fallback prefix matching
- Result: Tasks are never left incomplete
Ralphing detects what the AI is doing by analyzing its output:
| Detected Action | Step Label | Color |
|---|---|---|
| Reading files, searching | Reading code |
Cyan |
| Writing/editing files | Implementing |
Magenta |
| Writing test files | Writing tests |
Magenta |
| Running tests | Testing |
Yellow |
| Running linters | Linting |
Yellow |
| Git staging | Staging |
Green |
| Git committing | Committing |
Green |
| Updating PRD | Updating PRD |
Blue |
| Logging progress | Logging |
Blue |
Ralphing tracks token usage across all AI engines:
=== Session Summary ===
Tasks completed: 5
Total input tokens: 45,230
Total output tokens: 12,890
Estimated cost: $0.87
Total time: 12m 34s
Cost Calculation:
- Claude (Sonnet): $3/M input, $15/M output
- Actual costs shown for OpenCode (API provides real cost)
- Duration shown for Cursor (instead of tokens)
Automatic retry on failures:
- Empty responses: Retries up to
--max-retriestimes - API errors: Retries with
--retry-delayseconds between attempts - Task failures: Can retry failed tasks manually
When parallel branches have conflicts, interactive menu appears:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β π Merge conflicts detected in 2 branch(es) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β’ ralphing/agent-1-feature-a β
β β’ ralphing/agent-2-feature-b β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β What would you like to do? β
β β
β [1] π€ Retry AI resolution for all (safest) β
β [2] π§ Resolve manually one-by-one (full control) β
β [3] ποΈ Delete all conflicting branches (destructive) β
β [4] β©οΈ Abort & reset to clean state (preserves branches) β
β [5] π Skip - keep branches for later (default) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Enter choice [1-5]:
Options:
- AI Resolution: Ralphing runs AI agent to resolve conflicts automatically
- Manual Resolution: Opens files in your editor for manual conflict resolution
- Delete Branches: Removes conflicting branches (destructive)
- Abort & Reset: Returns to clean state, preserves branches for later
- Skip: Keeps branches for manual resolution outside Ralphing
# Install Claude Code
npm install -g @anthropic/claude-code
# Verify installation
which zclaude# macOS
brew install jq
# Linux
sudo apt install jq- Ensure PRD.md exists in current directory
- Check task format:
- [ ] Task description - Verify there are incomplete tasks
- This should be fixed in v3.1.0 (script marks tasks)
- Check PRD.md format matches
- [ ] Task description - Try with
--verboseto see debug output
# Slow down execution
./ralphing.sh --max-iterations 3 --retry-delay 10- Wait for 30-second status update to see activity
- Check if AI is waiting for user input (shouldn't happen in autonomous mode)
- Press Ctrl+C to stop and check
progress.txt
- Use conflict resolution menu (option 1 for AI resolution)
- Reduce
--max-parallelto avoid conflicts - Use sequential mode if conflicts persist
# Run with maximum verbosity
./ralphing.sh --verbose 2>&1 | tee ralphy-debug.log
# Check what AI is doing
tail -f /tmp/ralphy-*.tmp
# Check git status
git status
git log --oneline -10Ralphing creates temporary files during execution:
/tmp/ralphy-*.tmp: AI output (auto-deleted after task)progress.txt: Permanent log of all task completionsPRD.md.bak: Backup before task marking (auto-deleted)
Good Task Descriptions:
- [ ] Add JWT authentication to login endpoint
- [ ] Create User model with email, password, and createdAt fields
- [ ] Implement password hashing using bcrypt
- [ ] Add input validation for email formatPoor Task Descriptions:
- [ ] Do auth stuff
- [ ] Fix the bug
- [ ] Make it better
- [ ] Add testsBest Practices:
- Be specific and actionable
- One clear objective per task
- Include acceptance criteria when helpful
- Keep tasks reasonably sized (1-3 files changed)
- Order dependencies correctly (DB models before API endpoints)
For Development:
# Start with sequential mode, verbose
./ralphing.sh --verbose --max-iterations 1
# Once confident, run more iterations
./ralphing.sh --verbose --max-iterations 5
# When stable, remove --max-iterations for full automation
./ralphing.sh --verboseFor Production PRs:
# Branch-per-task with draft PRs for review
./ralphing.sh --branch-per-task --create-pr --draft-pr --verboseFor Fast Prototyping:
# Parallel mode, skip tests/lint
./ralphing.sh --parallel --max-parallel 5 --fastRecommended Setup:
# Work on feature branch
git checkout -b feature/ralphy-automation
# Run Ralphing
./ralphing.sh --branch-per-task --base-branch feature/ralphy-automation
# Review changes
git log --oneline
# Merge to main when ready
git checkout main
git merge feature/ralphy-automation# Limit iterations to control costs
./ralphing.sh --max-iterations 10
# Use parallel mode to batch API calls
./ralphing.sh --parallel --max-parallel 3
# Skip tests/lint for cheaper runs
./ralphing.sh --fast --max-iterations 20# Always run tests in production
./ralphing.sh
# For prototypes, skip tests
./ralphing.sh --no-tests
# For final iteration, ensure quality
./ralphing.sh --max-iterations 1 # Then review before continuingyour-project/
βββ ralphing.sh # The main script
βββ PRD.md # Task list (markdown format)
βββ progress.txt # Completion log (auto-generated)
βββ .git/ # Git repository
βββ backend/
β βββ api/
β βββ models/
β βββ tests/
βββ frontend/
βββ components/
βββ pages/
βββ tests/
See the included PRD.md for a complete example.
See examples/tasks.yaml for YAML format examples.
- Run with
--verboseand capture output - Check
progress.txtfor task history - Include PRD.md contents (sanitized)
- Report at: GitHub Issues
Ralphing is actively developed. Requested features:
- Support for more AI engines
- Web UI for monitoring
- Slack/Discord notifications
- Cost optimization strategies
- Custom prompt templates
MIT License - See LICENSE file
- Author: Arsalan Amin
- Version: 3.1.0
- Last Updated: January 2026
- AI Engines: Claude (Anthropic), OpenCode, Cursor, Codex
# Quick start
./ralphing.sh
# Parallel mode
./ralphing.sh --parallel --max-parallel 3
# With branches and PRs
./ralphing.sh --branch-per-task --create-pr
# Fast prototyping
./ralphing.sh --fast --parallel --max-parallel 5
# GitHub issues
./ralphing.sh --github owner/repo --github-label sprint-1
# Dry run (test configuration)
./ralphing.sh --dry-run --verbose| Symbol | Meaning | Color |
|---|---|---|
| βΊ | Agent running | Rotating colors |
| β | Agent setting up | Agent-specific |
| β | Task complete | Green |
| β | Task failed | Red |
| Β· | Agent waiting | Dim |
| β β β Ήβ Έβ Όβ ΄β ¦β §β β | Spinner | Cyan |
| Code | Meaning |
|---|---|
| 0 | All tasks completed successfully |
| 1 | Error occurred (check logs) |
| 2 | All tasks already complete |
| 130 | User interrupted (Ctrl+C) |
For more examples, see the examples/ folder.