An autonomous AI coding loop that runs AI assistants (Claude Code, OpenCode, Codex, or Cursor) to work through tasks until everything is complete.
This fork adds create-prd.sh - a script that generates PRD files using AI before running Ralphy.
# Clone this repo
git clone https://github.com/AliMejbar/ralphy.git ~/ai-scripts
# Make scripts executable
chmod +x ~/ai-scripts/ralphy.sh ~/ai-scripts/create-prd.sh
# Add to PATH (add this to your ~/.zshrc)
export PATH="$HOME/ai-scripts:$PATH"
# Reload shell
source ~/.zshrc
# Now use from any project
create-prd.sh "Add user authentication with OAuth"
ralphy.shOr run the install script:
~/ai-scripts/install.shGenerate a PRD file using AI before running Ralphy.
# Basic usage - generates PRD.md in current directory
create-prd.sh "Add user authentication with OAuth support"
# With a feature name (used for branch naming)
create-prd.sh --feature auth "Add user authentication"
# Use a specific AI engine
create-prd.sh --opencode "Add dashboard analytics"
create-prd.sh --cursor "Build API endpoints"
create-prd.sh --codex "Create database models"
# Skip branch creation
create-prd.sh --no-branch "Quick feature"
# Custom output paths
create-prd.sh --prd tasks.md --progress log.txt "My feature"- Creates a feature branch (e.g.,
feature/add-user-authentication) - Analyzes your codebase to understand file structure and patterns
- Generates a structured PRD with:
- Phased tasks with checkboxes
- Absolute file paths for each task
- Key file references
- Important patterns to follow
- Creates a blank
progress.txtfor Ralphy to log progress
| Flag | Description |
|---|---|
--claude |
Use Claude Code (default) |
--opencode |
Use OpenCode |
--cursor |
Use Cursor agent |
--codex |
Use Codex CLI |
--prompt TEXT |
Feature prompt (can also be passed as argument) |
--feature NAME |
Short feature name for branch slug |
--branch NAME |
Specific branch name to use/create |
--no-branch |
Skip branch checks/creation |
--prd PATH |
PRD output path (default: PRD.md) |
--progress PATH |
Progress file path (default: progress.txt) |
# Step 1: Generate the PRD
cd ~/my-project
create-prd.sh "Add a dark mode toggle to the settings page"
# Step 2: Review the generated PRD
cat PRD.md
# Step 3: Run Ralphy to implement it
ralphy.shAn autonomous AI coding loop that runs AI assistants to work through tasks.
- Reads tasks from a PRD file, YAML file, or GitHub Issues
- Sends each task to an AI assistant
- The AI implements the feature, writes tests, and commits changes
- Repeats until all tasks are done
# Create a PRD file with tasks (or use create-prd.sh)
cat > PRD.md << 'EOF'
# My Project
## Tasks
- [ ] Create user authentication
- [ ] Add dashboard page
- [ ] Build API endpoints
EOF
# Run Ralphy
ralphy.shThat's it. Ralphy will work through each task autonomously.
Required:
- One of: Claude Code CLI, OpenCode CLI, Codex CLI, or Cursor (with
agentin PATH) jq(for JSON parsing)
Optional:
yq- only if using YAML task filesgh- only if using GitHub Issues or--create-prbc- for cost calculation
ralphy.sh --prd PRD.mdFormat your PRD like this:
## Tasks
- [ ] First task
- [ ] Second task
- [x] Completed task (will be skipped)ralphy.sh --yaml tasks.yamlFormat:
tasks:
- title: First task
completed: false
- title: Second task
completed: falseralphy.sh --github owner/repo
ralphy.sh --github owner/repo --github-label "ready"Uses open issues from the repo. Issues are closed automatically when done.
Run multiple AI agents simultaneously, each in its own isolated git worktree:
ralphy.sh --parallel # 3 agents (default)
ralphy.sh --parallel --max-parallel 5 # 5 agentsEach agent gets:
- Its own git worktree (separate directory)
- Its own branch (
ralphy/agent-1-task-name,ralphy/agent-2-task-name, etc.) - Complete isolation from other agents
Agent 1 ─► worktree: /tmp/xxx/agent-1 ─► branch: ralphy/agent-1-create-user-model
Agent 2 ─► worktree: /tmp/xxx/agent-2 ─► branch: ralphy/agent-2-add-api-endpoints
Agent 3 ─► worktree: /tmp/xxx/agent-3 ─► branch: ralphy/agent-3-setup-database
Without --create-pr: Branches are automatically merged back to your base branch. If there are merge conflicts, AI will attempt to resolve them.
With --create-pr: Each completed task gets its own pull request. Branches are kept for review.
ralphy.sh --parallel --create-pr # Create PRs for each task
ralphy.sh --parallel --create-pr --draft-pr # Create draft PRsControl which tasks can run together:
tasks:
- title: Create User model
parallel_group: 1
- title: Create Post model
parallel_group: 1 # Runs with User model (same group)
- title: Add relationships
parallel_group: 2 # Runs after group 1 completesTasks without parallel_group default to group 0 and run before higher-numbered groups.
Create a separate branch for each task:
ralphy.sh --branch-per-task # Create feature branches
ralphy.sh --branch-per-task --base-branch main # Branch from main
ralphy.sh --branch-per-task --create-pr # Create PRs automatically
ralphy.sh --branch-per-task --create-pr --draft-pr # Create draft PRsBranch naming: ralphy/<task-name-slug>
Example: "Add user authentication" becomes ralphy/add-user-authentication
ralphy.sh # Claude Code (default)
ralphy.sh --codex # Codex CLI
ralphy.sh --opencode # OpenCode
ralphy.sh --cursor # Cursor agent| Engine | CLI Command | Permissions Flag | Output |
|---|---|---|---|
| Claude Code | claude |
--dangerously-skip-permissions |
Token usage + cost estimate |
| OpenCode | opencode |
OPENCODE_PERMISSION='{"*":"allow"}' |
Token usage + actual cost |
| Codex | codex |
N/A | Token usage (if provided) |
| Cursor | agent |
--force |
API duration (no token counts) |
Note: Cursor's CLI doesn't expose token usage, so Ralphy tracks total API duration instead.
| Flag | Description |
|---|---|
--claude |
Use Claude Code (default) |
--codex |
Use Codex CLI |
--opencode |
Use OpenCode |
--cursor, --agent |
Use Cursor agent |
| Flag | Description |
|---|---|
--prd FILE |
PRD file path (default: PRD.md) |
--yaml FILE |
Use YAML task file |
--github REPO |
Fetch from GitHub issues (owner/repo) |
--github-label TAG |
Filter GitHub issues by label |
| Flag | Description |
|---|---|
--parallel |
Run tasks in parallel |
--max-parallel N |
Max concurrent agents (default: 3) |
| Flag | Description |
|---|---|
--branch-per-task |
Create a branch for each task |
--base-branch NAME |
Base branch (default: current branch) |
--create-pr |
Create pull requests |
--draft-pr |
Create PRs as drafts |
| Flag | Description |
|---|---|
--no-tests |
Skip tests |
--no-lint |
Skip linting |
--fast |
Skip both tests and linting |
| Flag | Description |
|---|---|
--max-iterations N |
Stop after N tasks (0 = unlimited) |
--max-retries N |
Retries per task on failure (default: 3) |
--retry-delay N |
Seconds between retries (default: 5) |
--dry-run |
Preview without executing |
| Flag | Description |
|---|---|
-v, --verbose |
Debug output |
-h, --help |
Show help |
--version |
Show version |
# Basic usage
ralphy.sh
# Basic usage with Codex
ralphy.sh --codex
# Fast mode with OpenCode
ralphy.sh --opencode --fast
# Use Cursor agent
ralphy.sh --cursor
# Cursor with parallel execution
ralphy.sh --cursor --parallel --max-parallel 4
# Parallel with 4 agents and auto-PRs
ralphy.sh --parallel --max-parallel 4 --create-pr
# GitHub issues with parallel execution
ralphy.sh --github myorg/myrepo --parallel
# Feature branch workflow
ralphy.sh --branch-per-task --create-pr --base-branch main
# Limited iterations with draft PRs
ralphy.sh --max-iterations 5 --branch-per-task --create-pr --draft-pr
# Preview what would happen
ralphy.sh --dry-run --verboseWhile running, you'll see:
- A spinner with the current step (Thinking, Reading, Implementing, Testing, Committing)
- The current task name
- Elapsed time
In parallel mode:
- Number of agents setting up, running, done, and failed
- Final results with branch names
- Error logs for any failed agents
At completion, Ralphy shows different metrics depending on the AI engine:
| Engine | Metrics Shown |
|---|---|
| Claude Code | Input/output tokens, estimated cost |
| OpenCode | Input/output tokens, actual cost |
| Codex | Input/output tokens (if provided) |
| Cursor | Total API duration (tokens not available) |
All engines show branches created (if using --branch-per-task).
This fork tracks the original michaelshimeles/ralphy. To get updates:
cd ~/ai-scripts
git fetch upstream
git merge upstream/main
git push origin main- Added
create-prd.shfor PRD generation before running Ralphy - Added
install.shfor easy global installation - Updated documentation with both scripts
- Added Cursor agent support (
--cursoror--agentflag) - Cursor uses
--print --forceflags for non-interactive execution - Track API duration for Cursor (token counts not available in Cursor CLI)
- Improved task completion verification (checks actual PRD state, not just AI output)
- Fixed display issues with task counts
- Parallel agents now run in isolated git worktrees
- Auto-merge branches when not using
--create-pr - AI-powered merge conflict resolution
- Real-time parallel status display (setup/running/done/failed)
- Show error logs for failed agents
- Improved worktree creation with detailed logging
- Added parallel task execution (
--parallel,--max-parallel) - Added git branch per task (
--branch-per-task,--create-pr,--draft-pr) - Added multiple PRD formats (Markdown, YAML, GitHub Issues)
- Added YAML parallel groups
- Added OpenCode support (
--opencode) - Added retry logic
- Added
--max-iterations,--dry-run,--verbose - Cross-platform notifications
- Initial release
MIT
