Skip to content

About

Ralph Autonomous AI development loop for Claude Code (adapted from snarktank/ralph)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Claude Ralph

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.

How It Works

┌─────────────────────────────────────────────┐
│              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:

  1. Reads prd.json to find next incomplete story
  2. Implements that single story
  3. Runs quality checks (typecheck, tests)
  4. Commits changes
  5. Updates prd.json to mark story complete
  6. Logs learnings to progress.txt
  7. Continues until all stories pass

Prerequisites

  • Claude Code CLI installed and authenticated
  • jq command-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)

Installation

Option 1: Clone and Setup

# 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.sh

Option 2: Global Alias

Add to your ~/.zshrc or ~/.bashrc:

alias ralph-setup="~/claude-ralph/setup.sh"

Then use anywhere:

cd ~/your-project
ralph-setup

Install Skills (Optional but Recommended)

Copy 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/

Quick Start

# 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 10

Usage

Step 1: Create a PRD

Use 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.

Step 2: Convert to prd.json

Use the /ralph skill:

/ralph

Convert tasks/prd-auth.md to prd.json

This creates prd.json with right-sized user stories.

Step 3: Run the Loop

./ralph.sh 10  # max 10 iterations

Watch as Ralph implements each story, runs tests, commits, and continues.

Files

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

prd.json Format

{
  "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": ""
    }
  ]
}

Story Sizing

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.

Differences from Original

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)

Troubleshooting

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.json exists with passes: false stories
  • Check you're on the correct git branch

License

MIT License - Same as original.

Credits

  • Original concept and architecture: snarktank/ralph
  • Claude Code adaptation: This repository

About

Ralph Autonomous AI development loop for Claude Code (adapted from snarktank/ralph)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages