Skip to main content

A Python CLI tool that implements the Ralph autonomous iteration pattern for Claude Code

Project description

Ralph CLI

A Python CLI tool that implements the Ralph autonomous iteration pattern for Claude Code. Ralph enables AI-driven development by breaking down specifications into user stories and executing them autonomously.

Features

  • Project Scaffolding: Initialize any project with Ralph workflow files
  • PRD Generation: Create product requirements documents interactively with Claude
  • Task Breakdown: Convert specifications into structured user stories
  • Autonomous Iteration: Execute stories one at a time with quality checks
  • Loop Execution: Run multiple iterations automatically with failure detection
  • Skills Management: Sync custom Claude Code skills to your system
  • Code Review Skills: Built-in reviewers for Python, repo structure, GitHub Actions, and tests

Installation

Requires Python 3.11+ and uv package manager.

# Clone the repository
git clone https://github.com/jackemcpherson/ralph-cli.git
cd ralph-cli

# Install with dev dependencies
uv pip install -e ".[dev]"

# Verify installation
ralph --version

Quick Start

# 1. Initialize Ralph in your project
cd your-project
ralph init

# 2. Create a PRD interactively
ralph prd

# 3. Convert the PRD to tasks
ralph tasks plans/SPEC.md

# 4. Run autonomous iterations
ralph loop

Commands

Command Description
ralph init Scaffold a project for Ralph workflow
ralph prd Create a PRD interactively with Claude
ralph tasks <spec> Convert spec to TASKS.json
ralph once Execute single iteration
ralph loop [n] Run n iterations (default: 10)
ralph review Run the review pipeline with automatic configuration
ralph sync Sync skills to ~/.claude/skills/

ralph init

Scaffolds your project with Ralph workflow files:

ralph init                    # Auto-detect project type
ralph init --name MyProject   # Custom project name
ralph init --skip-claude      # Skip Claude Code enhancement
ralph init --force            # Overwrite existing files

If no PRD exists at plans/SPEC.md, you'll be prompted to create one interactively before proceeding.

Creates:

  • plans/SPEC.md - Specification template
  • plans/TASKS.json - Task list (empty)
  • plans/PROGRESS.txt - Progress log
  • CLAUDE.md - Project instructions with quality checks
  • AGENTS.md - Agent workflow instructions

ralph prd

Launches an interactive session with Claude to create a PRD:

ralph prd                     # Output to plans/SPEC.md
ralph prd --output custom.md  # Custom output path
ralph prd --verbose           # Verbose Claude output

ralph tasks

Converts a specification file to structured tasks:

ralph tasks plans/SPEC.md              # Default output
ralph tasks spec.md --output tasks.json # Custom output
ralph tasks spec.md --branch feature/x  # Custom branch name

ralph once

Executes a single iteration (one user story):

ralph once                      # Run one iteration
ralph once --verbose            # Show full Claude output
ralph once --max-fix-attempts 5 # Custom retry limit

ralph loop

Runs multiple iterations automatically:

ralph loop                      # Run up to 10 iterations
ralph loop 5                    # Run up to 5 iterations
ralph loop --verbose            # Verbose output
ralph loop --max-fix-attempts 5 # Custom retry limit per story

Stop conditions:

  • All stories complete
  • Max iterations reached
  • Persistent failure (same story fails twice)
  • Transient failure (Claude error)

ralph review

Runs the automated review pipeline:

ralph review                    # Auto-detect and configure reviewers
ralph review --force            # Re-detect and overwrite reviewer config
ralph review --strict           # Treat warnings as blocking
ralph review --verbose          # Verbose Claude output

On first run, detects project languages and configures reviewers in CLAUDE.md. On subsequent runs, uses the existing configuration and suggests any missing reviewers.

ralph sync

Syncs skills to Claude Code:

ralph sync                           # Sync from ./skills
ralph sync --skills-dir /path/to/skills  # Custom source
ralph sync --remove                  # Remove synced skills

Reviewer Skills

Ralph includes code review skills that can be invoked directly in Claude Code:

Skill Description
/python-code-reviewer Type hints, docstrings, logging, code quality
/bicep-reviewer Azure Bicep template best practices and security
/repo-structure-reviewer README, .gitignore, project organization
/github-actions-reviewer CI/CD completeness, security, best practices
/test-quality-reviewer Meaningful assertions, coverage, anti-patterns
/code-simplifier Code clarity and maintainability improvements
/release-reviewer Version consistency, changelog, release readiness

Each reviewer outputs a structured report with severity levels (error/warning/suggestion) and a verdict tag:

  • <ralph-review>PASS</ralph-review> - No blocking errors
  • <ralph-review>NEEDS_WORK</ralph-review> - Has errors that must be fixed

Project Structure

After running ralph init:

your-project/
├── CLAUDE.md           # Project instructions + quality checks
├── AGENTS.md           # Agent workflow instructions
└── plans/
    ├── SPEC.md         # Product specification
    ├── TASKS.json      # User stories with status
    └── PROGRESS.txt    # Iteration log

TASKS.json Format

{
  "project": "ProjectName",
  "branchName": "ralph/feature-name",
  "description": "Feature description",
  "userStories": [
    {
      "id": "US-001",
      "title": "Story title",
      "description": "As a user, I want...",
      "acceptanceCriteria": ["Criterion 1", "Criterion 2"],
      "priority": 1,
      "passes": false,
      "notes": ""
    }
  ]
}

Quality Checks

Define quality checks in CLAUDE.md:

<!-- RALPH:CHECKS:START -->
```yaml
checks:
  - name: typecheck
    command: uv run pyright
    required: true
  - name: lint
    command: uv run ruff check .
    required: true
  - name: test
    command: uv run pytest
    required: true

## Development

```bash
# Install dev dependencies
uv pip install -e ".[dev]"

# Run tests
uv run pytest

# Run type checking
uv run pyright

# Run linting
uv run ruff check .

# Format code
uv run ruff format .

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

License

MIT - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ralph_cli-2.2.0.tar.gz (186.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ralph_cli-2.2.0-py3-none-any.whl (121.4 kB view details)

Uploaded Python 3

File details

Details for the file ralph_cli-2.2.0.tar.gz.

File metadata

  • Download URL: ralph_cli-2.2.0.tar.gz
  • Upload date:
  • Size: 186.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ralph_cli-2.2.0.tar.gz
Algorithm Hash digest
SHA256 13a6bbf1f21360a5e5bd7e79e68f25ee1b3bd47cbba12c51d25101fb8cc3b8e1
MD5 8627fe9a040e1790d4aa70da9a2da169
BLAKE2b-256 3a3ab58734d6f0f5d7569601f52caf7c32fb911702175db32b0fbc24ddf4544c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ralph_cli-2.2.0.tar.gz:

Publisher: publish.yml on jackemcpherson/ralph-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ralph_cli-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: ralph_cli-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 121.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ralph_cli-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6996701ed2eafb727305ea9787d7b25cd174bd1a09c00f6d592b3f2876a91c5
MD5 508e305177d64600051f2c2b3ab0802a
BLAKE2b-256 14da889fe5d476c4f56f985f71601fb7bea7456ba06017d5dbd634b5f0b92717

See more details on using hashes here.

Provenance

The following attestation bundles were made for ralph_cli-2.2.0-py3-none-any.whl:

Publisher: publish.yml on jackemcpherson/ralph-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page