|
2 | 2 |
|
3 | 3 |  |
4 | 4 |
|
5 | | -Ralph is an autonomous AI agent loop that runs AI coding tools ([Amp](https://ampcode.com) or [Claude Code](https://docs.anthropic.com/en/docs/claude-code)) repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context. Memory persists via git history, `progress.txt`, and `prd.json`. |
| 5 | +[](https://github.com/promptexecution/b00t-wiggums/actions/workflows/python-ci.yml) |
| 6 | + |
| 7 | +Ralph is an autonomous AI agent loop that runs AI coding tools ([Amp](https://ampcode.com), [Claude Code](https://docs.anthropic.com/en/docs/claude-code), or [Codex](https://codex.anthropic.com)) repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context. Memory persists via git history, `progress.txt`, and `prd.json`. |
| 8 | + |
| 9 | +**Python Rewrite**: Ralph has been rewritten in Python for improved maintainability, testability, and type safety. See [ralph/README.md](ralph/README.md) for Python-specific documentation. |
6 | 10 |
|
7 | 11 | Based on [Geoffrey Huntley's Ralph pattern](https://ghuntley.com/ralph/). |
8 | 12 |
|
9 | 13 | [Read my in-depth article on how I use Ralph](https://x.com/ryancarson/status/2008548371712135632) |
10 | 14 |
|
11 | 15 | ## Prerequisites |
12 | 16 |
|
| 17 | +- Python 3.11+ with [uv](https://github.com/astral-sh/uv) package manager installed |
13 | 18 | - One of the following AI coding tools installed and authenticated: |
14 | 19 | - [Amp CLI](https://ampcode.com) |
15 | 20 | - [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (`npm install -g @anthropic-ai/claude-code`) |
16 | | -- `jq` installed (`brew install jq` on macOS) |
| 21 | + - [Codex](https://codex.anthropic.com) |
17 | 22 | - A git repository for your project |
18 | 23 |
|
19 | 24 | ## Setup |
@@ -109,15 +114,35 @@ This creates `prd.json` with user stories structured for autonomous execution. |
109 | 114 |
|
110 | 115 | ### 3. Run Ralph |
111 | 116 |
|
| 117 | +**Python Version (Recommended)**: |
| 118 | + |
| 119 | +```bash |
| 120 | +# Using Amp (default) |
| 121 | +uv run ralph [max_iterations] |
| 122 | + |
| 123 | +# Using Claude Code |
| 124 | +uv run ralph --tool claude [max_iterations] |
| 125 | + |
| 126 | +# Using Codex |
| 127 | +uv run ralph --tool codex [max_iterations] |
| 128 | + |
| 129 | +# Or use justfile commands |
| 130 | +just ralph # Run with amp (default) |
| 131 | +just ralph-claude # Run with claude |
| 132 | +just ralph-codex # Run with codex |
| 133 | +``` |
| 134 | + |
| 135 | +**Bash Version (Deprecated)**: |
| 136 | + |
112 | 137 | ```bash |
113 | | -# Using Amp |
114 | | -./scripts/ralph/ralph.sh [max_iterations] |
| 138 | +# Using Amp (default) |
| 139 | +./ralph.sh [max_iterations] |
115 | 140 |
|
116 | 141 | # Using Claude Code |
117 | | -./scripts/ralph/ralph.sh --agent claude [max_iterations] |
| 142 | +./ralph.sh --tool claude [max_iterations] |
118 | 143 | ``` |
119 | 144 |
|
120 | | -Default is 10 iterations. Use `--agent amp`, `--agent claude`, or `--agent codex` to select your AI coding tool. |
| 145 | +Default is 10 iterations. Use `--tool amp`, `--tool claude`, or `--tool codex` to select your AI coding tool. |
121 | 146 |
|
122 | 147 | Ralph will: |
123 | 148 | 1. Create a feature branch (from PRD `branchName`) |
@@ -151,12 +176,15 @@ or Codex so you can validate behavior locally before handing off to agents. |
151 | 176 |
|
152 | 177 | | File | Purpose | |
153 | 178 | |------|---------| |
154 | | -| `ralph.sh` | The bash loop that spawns fresh AI instances (supports `--agent amp`, `--agent claude`, or `--agent codex`) | |
| 179 | +| `ralph/` | Python implementation of Ralph (recommended) | |
| 180 | +| `ralph/README.md` | Detailed Python documentation | |
| 181 | +| `ralph.sh` | Bash wrapper (delegates to Python version) | |
155 | 182 | | `prompt.md` | Prompt template for Amp | |
156 | | -| `CLAUDE.md` | Prompt template for Claude Code | |
| 183 | +| `CLAUDE.md` | Prompt template for Claude Code and Codex | |
157 | 184 | | `prd.json` | User stories with `passes` status (the task list) | |
158 | 185 | | `prd.json.example` | Example PRD format for reference | |
159 | 186 | | `progress.txt` | Append-only learnings for future iterations | |
| 187 | +| `justfile` | Just commands for Ralph (ralph, ralph-test, ralph-check, etc.) | |
160 | 188 | | `skills/prd/` | Skill for generating PRDs (works with Amp and Claude Code) | |
161 | 189 | | `skills/ralph/` | Skill for converting PRDs to JSON (works with Amp and Claude Code) | |
162 | 190 | | `.claude-plugin/` | Plugin manifest for Claude Code marketplace discovery | |
@@ -250,6 +278,52 @@ After copying `prompt.md` (for Amp) or `CLAUDE.md` (for Claude Code) to your pro |
250 | 278 |
|
251 | 279 | Ralph automatically archives previous runs when you start a new feature (different `branchName`). Archives are saved to `archive/YYYY-MM-DD-feature-name/`. |
252 | 280 |
|
| 281 | +## Migration from Bash to Python |
| 282 | + |
| 283 | +The Python version of Ralph maintains the same behavior as the bash version while adding benefits: |
| 284 | + |
| 285 | +### What's the Same |
| 286 | +- Same command-line interface (just `--agent` → `--tool`) |
| 287 | +- Same file structure (`prd.json`, `progress.txt`) |
| 288 | +- Same workflow (iterations, completion signal, archival) |
| 289 | +- Same tool support (amp, claude, codex) |
| 290 | + |
| 291 | +### What's Better |
| 292 | +- **Type Safety**: Full mypy strict mode type checking |
| 293 | +- **Testing**: 92% code coverage with unit and integration tests |
| 294 | +- **Error Handling**: Proper exception handling with returns Result types |
| 295 | +- **Maintainability**: Modular architecture with clear separation of concerns |
| 296 | +- **Development Tools**: justfile commands, ruff linting, comprehensive documentation |
| 297 | + |
| 298 | +### Migration Steps |
| 299 | + |
| 300 | +1. **Install uv** (if not already installed): |
| 301 | + ```bash |
| 302 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
| 303 | + ``` |
| 304 | + |
| 305 | +2. **Test the Python version**: |
| 306 | + ```bash |
| 307 | + uv run ralph --help |
| 308 | + ``` |
| 309 | + |
| 310 | +3. **Update your workflow**: |
| 311 | + - Replace `./ralph.sh` with `uv run ralph` or `just ralph` |
| 312 | + - Update CI/CD scripts if needed |
| 313 | + - Note: `ralph.sh` still works (delegates to Python version) |
| 314 | + |
| 315 | +4. **Customize configuration** (optional): |
| 316 | + - Set environment variables for codex (see [ralph/README.md](ralph/README.md)) |
| 317 | + - Update `CLAUDE.md` or `prompt.md` for your project |
| 318 | + |
| 319 | +### Breaking Changes |
| 320 | + |
| 321 | +- CLI flag: `--agent` → `--tool` |
| 322 | +- Python 3.11+ required (was: bash) |
| 323 | +- `uv` package manager required (was: none) |
| 324 | + |
| 325 | +See [ralph/README.md](ralph/README.md) for complete Python documentation. |
| 326 | + |
253 | 327 | ## References |
254 | 328 |
|
255 | 329 | - [Geoffrey Huntley's Ralph article](https://ghuntley.com/ralph/) |
|
0 commit comments