|
| 1 | +--- |
| 2 | +hide: |
| 3 | + - toc |
| 4 | +--- |
| 5 | + |
1 | 6 | # Ralphify |
2 | 7 |
|
3 | | -Put your AI coding agent in a `while True` loop and let it ship. |
| 8 | +**Put your AI coding agent in a `while True` loop and let it ship.** |
| 9 | + |
| 10 | +Ralphify is a minimal CLI harness for autonomous AI coding loops, inspired by the [Ralph Wiggum technique](https://ghuntley.com/ralph/). It pipes a prompt to an AI coding agent, validates the work with checks, and repeats — each iteration starts with a fresh context window. |
4 | 11 |
|
5 | | -Ralphify is a minimal harness for running autonomous AI coding loops, inspired by the [Ralph Wiggum technique](https://ghuntley.com/ralph/). It pipes a prompt to an AI coding agent, lets it do one thing, commits, and repeats — each iteration starts with a fresh context window. |
| 12 | +[Get Started](getting-started.md){ .md-button .md-button--primary } |
| 13 | +[View Cookbook](cookbook.md){ .md-button } |
| 14 | + |
| 15 | +--- |
6 | 16 |
|
7 | 17 | ## Install |
8 | 18 |
|
9 | 19 | ```bash |
10 | 20 | uv tool install ralphify |
11 | 21 | ``` |
12 | 22 |
|
13 | | -This gives you the `ralph` command. |
14 | | - |
15 | | -## Quickstart |
| 23 | +## Two commands to start |
16 | 24 |
|
17 | 25 | ```bash |
18 | 26 | ralph init # Creates ralph.toml + PROMPT.md |
19 | 27 | ralph run # Starts the loop (Ctrl+C to stop) |
20 | 28 | ``` |
21 | 29 |
|
22 | | -### What `ralph init` creates |
| 30 | +`ralph init` creates a config file and a starter prompt. `ralph run` reads the prompt, pipes it to the agent, waits for it to finish, and does it again. Edit `PROMPT.md` while the loop is running — changes take effect on the next iteration. |
23 | 31 |
|
24 | | -**`ralph.toml`** — tells ralphify which agent to call: |
| 32 | +--- |
25 | 33 |
|
26 | | -```toml |
27 | | -[agent] |
28 | | -command = "claude" |
29 | | -args = ["-p", "--dangerously-skip-permissions"] |
30 | | -prompt = "PROMPT.md" |
31 | | -``` |
| 34 | +## Why it works |
32 | 35 |
|
33 | | -**`PROMPT.md`** — a starter prompt template. This file is the prompt. It gets piped directly to your agent each iteration. Edit it to fit your project. |
| 36 | +<div class="grid cards" markdown> |
34 | 37 |
|
35 | | -### What `ralph run` does |
| 38 | +- :material-repeat:{ .lg .middle } **One thing per loop** |
36 | 39 |
|
37 | | -Each iteration: |
| 40 | + --- |
38 | 41 |
|
39 | | -1. Reads `PROMPT.md` |
40 | | -2. Resolves any [contexts and instructions](primitives.md) into the prompt |
41 | | -3. Pipes the assembled prompt to your agent command |
42 | | -4. Waits for the agent to finish |
43 | | -5. Runs any configured [checks](primitives.md#checks) and feeds failures into the next iteration |
44 | | -6. Repeats |
| 42 | + The agent picks a task, implements it, tests it, and commits. Then the next iteration starts fresh — no accumulated state, no context window bloat. |
| 43 | + |
| 44 | +- :material-refresh:{ .lg .middle } **Fresh context every time** |
| 45 | + |
| 46 | + --- |
| 47 | + |
| 48 | + Each iteration re-reads `PROMPT.md` and the codebase from scratch. The agent always works from the current state, not stale assumptions. |
| 49 | + |
| 50 | +- :material-source-branch:{ .lg .middle } **Progress lives in git** |
| 51 | + |
| 52 | + --- |
| 53 | + |
| 54 | + Code and commits are the only state that persists. If something goes wrong, `git reset --hard` and run more loops. No hidden state to debug. |
| 55 | + |
| 56 | +- :material-sign-direction:{ .lg .middle } **The prompt is a tuning knob** |
| 57 | + |
| 58 | + --- |
| 59 | + |
| 60 | + When the agent does something dumb, add a sign to the prompt. "SLIDE DOWN, DON'T JUMP." The next iteration follows the new rules. |
| 61 | + |
| 62 | +</div> |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Three primitives |
| 67 | + |
| 68 | +Ralphify extends the basic loop with three building blocks that live in the `.ralph/` directory: |
| 69 | + |
| 70 | +<div class="grid cards" markdown> |
| 71 | + |
| 72 | +- :material-check-circle-outline:{ .lg .middle } **Checks** |
| 73 | + |
| 74 | + --- |
| 75 | + |
| 76 | + Run after each iteration to validate the agent's work — tests, linters, type checks. Failed check output feeds into the next iteration so the agent can fix its own mistakes. |
| 77 | + |
| 78 | + [:octicons-arrow-right-24: Learn more](primitives.md#checks) |
| 79 | + |
| 80 | +- :material-database-outline:{ .lg .middle } **Contexts** |
| 81 | + |
| 82 | + --- |
| 83 | + |
| 84 | + Inject dynamic data into the prompt before each iteration — recent git history, current test status, API responses. The agent always sees fresh information. |
| 85 | + |
| 86 | + [:octicons-arrow-right-24: Learn more](primitives.md#contexts) |
| 87 | + |
| 88 | +- :material-file-document-edit-outline:{ .lg .middle } **Instructions** |
| 89 | + |
| 90 | + --- |
| 91 | + |
| 92 | + Reusable rules and coding standards injected into the prompt. Toggle them on and off without editing `PROMPT.md` — useful for style guides, commit conventions, or safety constraints. |
| 93 | + |
| 94 | + [:octicons-arrow-right-24: Learn more](primitives.md#instructions) |
| 95 | + |
| 96 | +</div> |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## The self-healing loop |
| 101 | + |
| 102 | +Checks create a feedback loop that makes the agent self-correcting: |
45 | 103 |
|
46 | | -```bash |
47 | | -ralph run # Run forever |
48 | | -ralph run -n 10 # Run 10 iterations then stop |
49 | 104 | ``` |
| 105 | +Iteration N Agent makes a change |
| 106 | + Check runs → test fails |
50 | 107 |
|
51 | | -## The technique |
| 108 | +Iteration N+1 Agent sees failure output in prompt |
| 109 | + Fixes the broken test → checks pass |
52 | 110 |
|
53 | | -The Ralph Wiggum technique works because: |
| 111 | +Iteration N+2 No failures from previous iteration |
| 112 | + Agent moves on to the next task |
| 113 | +``` |
54 | 114 |
|
55 | | -- **One thing per loop.** The agent picks the most important task, implements it, tests it, and commits. Then the next iteration starts fresh. |
56 | | -- **Fresh context every time.** No context window bloat. Each loop starts clean and reads the current state of the codebase. |
57 | | -- **Progress lives in git.** Code and commits are the only state that persists between iterations. If something goes wrong, `git reset --hard` and run more loops. |
58 | | -- **The prompt is a tuning knob.** When the agent does something dumb, you add a sign. Like telling Ralph not to jump off the slide — add "SLIDE DOWN, DON'T JUMP" to the prompt. |
| 115 | +You define what "valid" means. Ralphify feeds failures back into the prompt automatically. The agent doesn't need to remember anything — check output tells it exactly what went wrong. |
59 | 116 |
|
60 | | -Read the full writeup: [Ralph Wiggum as a "software engineer"](https://ghuntley.com/ralph/) |
| 117 | +--- |
61 | 118 |
|
62 | 119 | ## Requirements |
63 | 120 |
|
64 | 121 | - Python 3.11+ |
65 | 122 | - [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) (or any agent CLI that accepts piped input) |
66 | 123 |
|
| 124 | +--- |
| 125 | + |
67 | 126 | ## Next steps |
68 | 127 |
|
69 | | -- [Getting Started](getting-started.md) — step-by-step tutorial from install to a running loop with checks and contexts |
70 | | -- [How It Works](how-it-works.md) — the iteration lifecycle, prompt assembly, and feedback loop explained |
71 | | -- [Writing Your Prompt](prompts.md) — how to write prompts that produce useful work |
72 | | -- [Cookbook](cookbook.md) — complete, copy-pasteable setups for Python, TypeScript, bug fixing, and docs |
73 | | -- [Primitives](primitives.md) — add checks, contexts, and instructions to your loop |
74 | | -- [Configuration & CLI](cli.md) — `ralph.toml` format, all commands, and options |
75 | | -- [Troubleshooting](troubleshooting.md) — common issues and how to fix them |
| 128 | +<div class="grid cards" markdown> |
| 129 | + |
| 130 | +- **[Getting Started](getting-started.md)** |
| 131 | + |
| 132 | + --- |
| 133 | + |
| 134 | + Step-by-step tutorial from install to a running loop with checks and contexts. |
| 135 | + |
| 136 | +- **[Writing Your Prompt](prompts.md)** |
| 137 | + |
| 138 | + --- |
| 139 | + |
| 140 | + How to write prompts that produce useful work — anatomy, patterns, and tips. |
| 141 | + |
| 142 | +- **[Cookbook](cookbook.md)** |
| 143 | + |
| 144 | + --- |
| 145 | + |
| 146 | + Complete, copy-pasteable setups for Python, TypeScript, bug fixing, and docs. |
| 147 | + |
| 148 | +- **[How It Works](how-it-works.md)** |
| 149 | + |
| 150 | + --- |
| 151 | + |
| 152 | + The iteration lifecycle, prompt assembly, and feedback loop explained. |
| 153 | + |
| 154 | +</div> |
0 commit comments