Skip to main content

Iterative work/review loop for Claude Code

Project description

ralphkit

An iterative work/review loop for Claude Code. One model does the work, a different model reviews it. The loop continues until the reviewer says SHIP or max iterations are reached.

Inspired by Goose's Ralph pattern.

Install

pip install ralphkit

With uv:

uv tool install ralphkit

Or run directly without installing:

uvx ralphkit ralph-loop "your task here"

Quick Start

ralph-loop "Create a Python function in prime.py that checks if a number is prime. Include unit tests."

Usage

ralph-loop TASK [OPTIONS]

Arguments:

Argument Description Default
TASK Task description (string or path to .md file) required
--config PATH Load settings from a YAML config file none
--worker-model Model for the work phase opus
--reviewer-model Model for the review phase sonnet
--max-iterations Max work/review cycles 10
--worker-system-prompt Override the worker system prompt entirely built-in
--reviewer-system-prompt Override the reviewer system prompt entirely built-in
--worker-user-prompt Override the worker user prompt ({iteration} is substituted) built-in
--reviewer-user-prompt Override the reviewer user prompt built-in
--append-system-prompt Extra text appended to both system prompts none
-y / --yes Skip confirmation prompt off

Examples:

# Inline task
ralph-loop "Build a REST API"

# Task from a markdown file
ralph-loop task.md

# Override models
ralph-loop "Build a REST API" --worker-model sonnet --reviewer-model haiku

# Use a config file for shared settings
ralph-loop "Build a REST API" --config ralph.yaml

# Skip confirmation
ralph-loop "Build a REST API" -y

Config file

A config file is optional. When provided via --config, its values serve as defaults that CLI args can override.

# ralph.yaml
worker_model: opus
reviewer_model: sonnet
max_iterations: 10

# Optional: override system prompts entirely
# worker_system_prompt: "Your custom worker instructions..."
# reviewer_system_prompt: "Your custom reviewer instructions..."

# Optional: override user prompts (the -p argument to claude)
# worker_user_prompt: "Begin iteration {iteration}. Read .ralphkit/task.md and start."
# reviewer_user_prompt: "Review the work and write your verdict."

# Optional: append extra instructions to both system prompts
# append_system_prompt: "Always use pytest. Never modify the README."

Resolution order: built-in defaults → config file → CLI args.

How It Works

┌─────────────────────────────────────────┐
│  1. Read task                           │
│  2. Worker model does the work          │ ◄─── iteration N
│  3. Reviewer model reviews it           │
│  4. SHIP? -> done. REVISE? -> loop.     │
└─────────────────────────────────────────┘

Each iteration:

  1. Work phase — the worker model reads the task (and any prior review feedback), writes code, runs tests, and summarizes what it did.
  2. Review phase — the reviewer model examines all files, runs tests, and writes either SHIP (approve) or REVISE (with feedback).
  3. If REVISE, the feedback is passed to the next iteration. If SHIP, the loop exits successfully.

State Files

State is persisted in .ralphkit/ in the current working directory so each stateless claude -p invocation can pick up where the last left off.

File Purpose
task.md The task description
iteration.md Current iteration number
work-summary.md What the worker did this iteration
work-complete.md Created when the worker thinks it's done
review-result.md SHIP or REVISE
review-feedback.md Specific feedback from the reviewer
RALPH-BLOCKED.md Created by the worker if it cannot proceed

Requirements

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

ralphkit-0.1.1rc1.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

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

ralphkit-0.1.1rc1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file ralphkit-0.1.1rc1.tar.gz.

File metadata

  • Download URL: ralphkit-0.1.1rc1.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ralphkit-0.1.1rc1.tar.gz
Algorithm Hash digest
SHA256 c57b464a086f742da1ff69c813ed54688a2d5f06d82caeabb509ee78e9fc0718
MD5 8b30cf02f5a1857c6a5dd41552db58bb
BLAKE2b-256 317d28c5144eeff81ea3d642aa21dfc981c1b1de01c41ded1873d2e4b493e095

See more details on using hashes here.

File details

Details for the file ralphkit-0.1.1rc1-py3-none-any.whl.

File metadata

  • Download URL: ralphkit-0.1.1rc1-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ralphkit-0.1.1rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac078970b0f3110e35a5a78d300be09c347f5c6d5f694fdbf417004a1ba0665a
MD5 d9120a9fab6284098696996046e42ba5
BLAKE2b-256 895242c2b3a8959c88a9df8e4ba565d650640d7c8be0d67251f10d54b8f98d8e

See more details on using hashes here.

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