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:
- Work phase — the worker model reads the task (and any prior review feedback), writes code, runs tests, and summarizes what it did.
- Review phase — the reviewer model examines all files, runs tests, and writes either
SHIP(approve) orREVISE(with feedback). - If
REVISE, the feedback is passed to the next iteration. IfSHIP, 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
- Claude Code CLI (
claudemust be on your PATH) - Python 3.10+
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ralphkit-0.1.1rc2.tar.gz.
File metadata
- Download URL: ralphkit-0.1.1rc2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
991c8711923c7ffdb8db844e644d4bfd7f072b529c89c94338d7f19c084b243c
|
|
| MD5 |
29050d4ea1ea9488d0fbf85381dc7205
|
|
| BLAKE2b-256 |
48c31d5e459fb17bc2eb337fec1e656959e9108b910e45fb6376fa63a5b961c3
|
File details
Details for the file ralphkit-0.1.1rc2-py3-none-any.whl.
File metadata
- Download URL: ralphkit-0.1.1rc2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e447e9844bb28a47d7bbcade52e90fa39b9b0355b921a50b83c5a00902c491ba
|
|
| MD5 |
f4da184472d5ed97d7e62bdb01297f25
|
|
| BLAKE2b-256 |
49690075339f9080250fec8a4514fd58bdf454e9bf9cf329bf332cf54a9bda57
|