|
| 1 | +--- |
| 2 | +date: 2026-04-04 |
| 3 | +categories: |
| 4 | + - Standards |
| 5 | +authors: |
| 6 | + - kasper |
| 7 | +description: A short manifest defining the ralph format — a single-file, skill-like spec for autonomous agent loops. |
| 8 | +keywords: ralph format, ralph spec, RALPH.md, autonomous agent loop format, agent harness spec, ralph standard |
| 9 | +--- |
| 10 | + |
| 11 | +# The Ralph Format |
| 12 | + |
| 13 | +A **ralph** is a directory with a `RALPH.md` file in it. `RALPH.md` defines an autonomous agent loop: the agent to run, the commands to run between iterations, and the prompt to pipe in. |
| 14 | + |
| 15 | +That's the whole format. |
| 16 | + |
| 17 | +<!-- more --> |
| 18 | + |
| 19 | +## Minimal example |
| 20 | + |
| 21 | +```markdown |
| 22 | +--- |
| 23 | +agent: claude -p |
| 24 | +commands: |
| 25 | + - name: tests |
| 26 | + run: uv run pytest -x |
| 27 | +--- |
| 28 | + |
| 29 | +Fix the failing tests. |
| 30 | + |
| 31 | +{{ commands.tests }} |
| 32 | +``` |
| 33 | + |
| 34 | +Each iteration: run the commands, fill the `{{ commands.<name> }}` placeholders with their output, pipe the assembled prompt to the agent, repeat. |
| 35 | + |
| 36 | +## The spec |
| 37 | + |
| 38 | +`RALPH.md` is a markdown file with YAML frontmatter and a prompt body. |
| 39 | + |
| 40 | +**Frontmatter fields:** |
| 41 | + |
| 42 | +| Field | Required | Description | |
| 43 | +|---|---|---| |
| 44 | +| `agent` | yes | Command to run. Anything that reads a prompt on stdin. | |
| 45 | +| `commands` | no | List of `{name, run}` (plus optional `timeout`). Output fills `{{ commands.<name> }}` placeholders. | |
| 46 | +| `args` | no | List of argument names. Values fill `{{ args.<name> }}` placeholders and become CLI flags. | |
| 47 | + |
| 48 | +**Body:** markdown with `{{ placeholders }}`. Unmatched placeholders resolve to empty strings. |
| 49 | + |
| 50 | +**Placeholders:** |
| 51 | + |
| 52 | +- `{{ commands.<name> }}` — output of a command (stdout + stderr, regardless of exit code) |
| 53 | +- `{{ args.<name> }}` — value of a CLI argument |
| 54 | +- `{{ ralph.name }}`, `{{ ralph.iteration }}`, `{{ ralph.max_iterations }}` — runtime metadata |
| 55 | + |
| 56 | +## Directory form |
| 57 | + |
| 58 | +`RALPH.md` on its own is enough. But a ralph is a directory so it can bundle anything the loop needs: |
| 59 | + |
| 60 | +``` |
| 61 | +bug-hunter/ |
| 62 | +├── RALPH.md # required |
| 63 | +├── check-coverage.sh # command script (optional) |
| 64 | +├── coding-guidelines.md # context for the agent (optional) |
| 65 | +└── test-data.json # supporting file (optional) |
| 66 | +``` |
| 67 | + |
| 68 | +Commands whose `run` starts with `./` resolve relative to the ralph directory, so bundled scripts just work. The directory is the unit of sharing. |
| 69 | + |
| 70 | +## A realistic example |
| 71 | + |
| 72 | +```markdown |
| 73 | +--- |
| 74 | +agent: claude -p --dangerously-skip-permissions |
| 75 | +commands: |
| 76 | + - name: tests |
| 77 | + run: uv run pytest -x |
| 78 | + - name: lint |
| 79 | + run: uv run ruff check . |
| 80 | + - name: git-log |
| 81 | + run: git log --oneline -10 |
| 82 | +args: |
| 83 | + - focus |
| 84 | +--- |
| 85 | + |
| 86 | +You are an autonomous bug-hunting agent running in a loop. |
| 87 | +Each iteration starts with fresh context. |
| 88 | + |
| 89 | +## Tests |
| 90 | +{{ commands.tests }} |
| 91 | + |
| 92 | +## Lint |
| 93 | +{{ commands.lint }} |
| 94 | + |
| 95 | +## Recent commits |
| 96 | +{{ commands.git-log }} |
| 97 | + |
| 98 | +## Task |
| 99 | + |
| 100 | +Find and fix one real bug in this codebase. {{ args.focus }} |
| 101 | + |
| 102 | +Rules: |
| 103 | +- One bug per iteration |
| 104 | +- Write a failing regression test before fixing |
| 105 | +- Do not change unrelated code |
| 106 | +- Commit with `fix: resolve <description>` |
| 107 | +``` |
| 108 | + |
| 109 | +## The runtime |
| 110 | + |
| 111 | +The format is the spec. A runtime executes it. [Ralphify](https://github.com/computerlovetech/ralphify) is the reference runtime: |
| 112 | + |
| 113 | +```bash |
| 114 | +uv tool install ralphify |
| 115 | +ralph run ./bug-hunter --focus "authentication" |
| 116 | +``` |
| 117 | + |
| 118 | +Anything that implements the loop — read `RALPH.md`, resolve placeholders, pipe to the agent, repeat — is a conforming runtime. |
| 119 | + |
| 120 | +## Why a format |
| 121 | + |
| 122 | +Everyone writing ralph loops ends up with the same scaffolding: a markdown prompt, a few shell commands that surface state between iterations, a while-loop that ties them together. A format turns that scaffolding into something you can share, version, and install. |
| 123 | + |
| 124 | +Ralphs are to the outer loop what [skills](https://agentskills.io/) are to the inner loop. A skill guides an agent inside a session. A ralph defines what runs *between* sessions. |
| 125 | + |
| 126 | +See also: [RALPH.md — a markdown format for autonomous agent loops](the-ralph-standard.md) — the longer thinking piece behind the format. |
0 commit comments