Skip to content

Example

tonialmagro-tomtom edited this page Nov 28, 2026 · 5 revisions

See it work

This page follows one real Herd run from the request to the finished code. Every output block is copied from that run.

The run asked for a small Python function, slugify, that turns text like "Hello, World!" into "hello-world". It ran on 2026-11-26 in a new local repository that held only a README. It took 2 min 42 s and cost $0.30. It used Herd 0.14.9 and Claude Code 2.1.332: Sonnet (claude-sonnet-5-5) ran the main session, and a Haiku herd-builder subagent wrote the code. The output formats shown here are unchanged in Herd 0.14.13.

In plain words, this is what happened:

  1. You ask for a change and say what "done" means.
  2. Herd writes that down as criteria. Each criterion gets a check: a command that passes or fails.
  3. Herd runs every check before writing any code. They all fail, which shows they really test something.
  4. Herd plans six ways to break the result (the attacks), then builds.
  5. Herd runs the checks again. When all pass, it writes the evidence and a short report.

Words used on this page:

Word Meaning
criterion One thing that must be true when the work is done.
check The command that tests a criterion. Exit code 0 means it passed.
human A criterion in your own words. Herd copies it exactly and never changes it.
agent-proposed A criterion Herd added to cover what yours leave open.
attack A planned attempt to break the result, such as bad input. n/a means it does not apply to this task, with the reason.
evidence The saved output of the checks, with the commit and the time they ran.

Herd's script paths are shortened to herd. Anything else that was cut is marked [trimmed: ...].

1. The request

/herd:run Add a slugify(text) function in a new module textutil.py at the repository root, with unit tests in test_textutil.py (standard library unittest only). slugify lowercases ASCII text, turns each run of non-alphanumeric characters into one hyphen and strips leading and trailing hyphens, so slugify("Hello, World!") returns "hello-world". `python3 -m textutil TEXT` prints the slug. Criteria: Given 'Hello, World!', when slugify runs, then it returns 'hello-world'. ASCII text only. This repository has no remote: commit locally on the task branch, do not push and do not open a PR. Use a private folder from `mktemp -d` for any temporary file, never a fixed /tmp path.

2. Who does what

Before the task starts, herd status says which model does each step:

$ herd status
Models: design sonnet, build haiku (herd.toml [models]); this session: claude-sonnet-5-5
Design: here, in this session (its model matches sonnet)
Build: spawn herd:herd-builder with model haiku
no active task: run herd init <slug> "<goal>"

The session already ran on Sonnet, the design model, so it did the design itself. With another model, Herd would ask for a herd-designer subagent on Sonnet instead.

3. The task Herd wrote

The design step wrote this file, .herd/tasks/slugify/task.toml. C1 and C2 are the two criteria from the request, copied word for word. C3 to C5 are criteria Herd added. Each [[inputs]] entry lists two ways a person could read the request (readings), so the build cannot quietly pick the easier one.

goal = "Add slugify(text) in textutil.py with unittest tests and a python3 -m textutil CLI"
test_budget = "Unit tests of slugify on the example, all 128 ASCII code points and seeded random strings against a separate reference; CLI run as a subprocess. No performance test: the request names no size."
known_limits = "ASCII only: any non-ASCII character is refused, not transliterated. The shell limits CLI argument length and cannot pass NUL."

[[inputs]]
human = "python3 -m textutil TEXT"
program = "command line arguments after the module name; several are joined with one space"
readings = ["python3 -m textutil TEXT", "TEXT typed unquoted as several words"]

[[inputs]]
human = "slugify lowercases ASCII text"
program = "a Python str passed to slugify(text)"
readings = ["slugify lowercases ASCII text", "any of the 128 ASCII code points, control characters and newlines included"]

[[criteria]]
id = "C1"
text = "Given 'Hello, World!', when slugify runs, then it returns 'hello-world'."
source = "human"
coverage = "Proves the exact example returns exactly hello-world; says nothing about other texts (see C3)."
check = "python3 -m unittest test_textutil.HumanExample"

[[criteria]]
id = "C2"
text = "ASCII text only."
source = "human"
coverage = "Proves every one of 128 ASCII code points is accepted and sampled non-ASCII characters raise ValueError; not every Unicode code point."
check = "python3 -m unittest test_textutil.AsciiOnly"

[[criteria]]
id = "C3"
text = "Given random ASCII strings, when slugify runs, then results match a separately written character-by-character reference."
source = "agent-proposed"
check = "python3 -m unittest test_textutil.Random"

[[criteria]]
id = "C4"
text = "Given TEXT on the command line, when python3 -m textutil runs, then it prints the slug and exits 0."
source = "agent-proposed"
check = "python3 -m unittest test_textutil.Cli"

[[criteria]]
id = "C5"
text = "Given no argument or non-ASCII text, when the CLI runs, then stderr has one message, exit is non-zero, no traceback."
source = "agent-proposed"
check = "python3 -m unittest test_textutil.BadInput"

4. Every check fails first

Herd ran the checks before writing any code. All of them failed, as they should: a check that passes before the work exists proves nothing. This run came right after Herd logged its six attacks (the six noted (tried) lines are cut):

$ herd verify
0 passing, 5 failing, 0 unchecked (checks took 0.7 s)
  C1 failing: Given 'Hello, World!', when slugify runs, then it returns 'hello-world'.
  C2 failing: ASCII text only.
  C3 failing: Given random ASCII strings, when slugify runs, then results match a separately written character-by-character reference.
  C4 failing: Given TEXT on the command line, when python3 -m textutil runs, then it prints the slug and exits 0.
  C5 failing: Given no argument or non-ASCII text, when the CLI runs, then stderr has one message, exit is non-zero, no traceback.
  attack bad-input failing: python3 -m unittest test_textutil.BadInput --refuses python3 -m textutil
  attack collision n/a: n/a: the tool takes one text value; no entries or identities can collide or contradict
  attack one-bad-part failing: python3 -m unittest test_textutil.OneBadPart --refuses python3 -m textutil good words café
  attack recount n/a: n/a: the output is a slug; no totals, counts or times are reported
  attack refusal failing: python3 -m unittest test_textutil.Refusals
  attack other-reading failing: --example python3 -m textutil '  A--b_2! ': exit 1, needs 0

5. After the build, everything passes

These are the last two commands of the session. The report that herd done printed is shown in section 7.

$ herd verify --fresh && herd done
5 passing, 0 failing, 0 unchecked (checks took 2.0 s)
  attack collision n/a: n/a: the tool takes one text value; no entries or identities can collide or contradict
  attack recount n/a: n/a: the output is a slug; no totals, counts or times are reported
done: evidence is fresh and passing (5 of 5 criteria proven)
report: .herd/tasks/slugify/evidence.md
final report (paste it as written):
[trimmed: the final report, shown below]

herd verify keeps its output short. It lists a criterion only when it needs attention: failing, unchecked, or a check that ran zero tests. It always lists attacks marked n/a, and it names any check that took over 60 s. Add --verbose to list everything. On an unchanged tree it runs no check and keeps the evidence it has; --fresh runs every check anyway.

6. The evidence

This is the full report in evidence.md. herd status and herd done --verbose print it too.

# Evidence: slugify

Goal: Add slugify(text) in textutil.py with unittest tests and a python3 -m textutil CLI
Run at 2026-11-26T19:50:08Z on commit a5321d1d6994
Result: 5 passing, 0 failing, 0 unchecked
Design: claude-sonnet-5-5, in the main session (sonnet asked)
First verify: 5 of 5 checks failed before the work
Elapsed: 2m 30s from herd init to this verify; first verify at 40s (wall clock, includes any waiting on the human)
Test budget: Unit tests of slugify on the example, all 128 ASCII code points and seeded random strings against a separate reference; CLI run as a subprocess. No performance test: the request names no size.
Known limits: ASCII only: any non-ASCII character is refused, not transliterated. The shell limits CLI argument length and cannot pass NUL.
Inputs (as you described them -> as the program receives them): python3 -m textutil TEXT -> command line arguments after the module name; several are joined with one space (readings: python3 -m textutil TEXT; TEXT typed unquoted as several words); slugify lowercases ASCII text -> a Python str passed to slugify(text) (readings: slugify lowercases ASCII text; any of the 128 ASCII code points, control characters and newlines included)
Adversarial pass: 7 attempts recorded; bad-input passing (`python3 -m unittest test_textutil.BadInput --refuses python3 -m textutil`); collision n/a: the tool takes one text value; no entries or identities can collide or contradict; one-bad-part passing (`python3 -m unittest test_textutil.OneBadPart --refuses python3 -m textutil good words café`); recount n/a: the output is a slug; no totals, counts or times are reported; refusal passing (`python3 -m unittest test_textutil.Refusals`); other-reading passing (`python3 -m unittest test_textutil.Readings --example python3 -m textutil '  A--b_2! '`)
Risk: medium

| id | status | source | check |
| --- | --- | --- | --- |
| C1 | passing (0.1 s) | human | `python3 -m unittest test_textutil.HumanExample` |
| C2 | passing (0.1 s) | human | `python3 -m unittest test_textutil.AsciiOnly` |
| C3 | passing (0.1 s) | agent-proposed | `python3 -m unittest test_textutil.Random` |
| C4 | passing (0.8 s) | agent-proposed | `python3 -m unittest test_textutil.Cli` |
| C5 | passing (0.3 s) | agent-proposed | `python3 -m unittest test_textutil.BadInput` |

Coverage of human criteria (what each check proves and does not):
- C1: Proves the exact example returns exactly hello-world; says nothing about other texts (see C3).
- C2: Proves every one of 128 ASCII code points is accepted and sampled non-ASCII characters raise ValueError; not every Unicode code point.

Caveats during the run: 1 found, 1 fixed, 0 open
- 0s decision: request.md holds the /herd:run message from the session log, not --request; the human's words win; --request was: [trimmed: the same request, word for word]
- 38s tried: no argument and non-ASCII or undecodable argument: one message, non-zero exit, no traceback
- 38s tried: n/a: the tool takes one text value; no entries or identities can collide or contradict
- 39s tried: one non-ASCII character among good words refuses the whole text, never skipped
- 39s tried: n/a: the output is a slug; no totals, counts or times are reported
- 39s tried: random strings: refused exactly when some ord > 127 (separate test); everything ASCII is served
- 39s tried: readings: one quoted argument vs several unquoted words; printable ASCII vs all 128 code points
- 43s decision: Refuse non-ASCII text (ValueError; CLI exit 1) instead of treating it as a separator; 'ASCII text only' and silent loss of letters; override by asking for separator behaviour
- 43s decision: CLI joins several arguments with one space, no argument is a usage error (exit 2); unquoted text then works; override by asking for exactly one argument
- 1m 38s decision: Build: tests written first in test_textutil.py; red run fails on the missing textutil module as expected; the 128-code-point expectation was corrected to the reference-derived slug before running (A-Z and a-z are separated by 91-96)
- 1m 59s found: BadInput bytes helper returned bytes stdout, so the empty-stdout check compared b"" to "" and failed; the program output was correct
- 2m 00s fixed: run_cli_bytes in test_textutil.py now decodes stdout and stderr before comparing; no assertion was weakened
- 2m 27s tried: own review, not a fresh-context subagent: 20000 random ASCII strings against a regex reference, 3M-character input (0.41 s), empty, '--', 100000-character argument, non-ASCII under LC_ALL=C, Kelvin sign; no failure

Example: `python3 -m textutil '  A--b_2! '`; expected "a-b-2"; output tail:
```
a-b-2
```

The example at the end is a case Herd worked out by hand before writing any code: for the input ' A--b_2! ' it expected a-b-2. It is the --example and --expect of the other-reading attack.

7. The final report

The agent ends with the short report that herd done printed. It is filled from the evidence and links to it:

Done: Add slugify(text) in textutil.py with unittest tests and a python3 -m textutil CLI; committed on herd/slugify at a5321d1.
Proven: 5 of 5 criteria; evidence in .herd/tasks/slugify/evidence.md.
Not proven: nothing open.
Caveats: found at 1m 59s: BadInput bytes helper returned bytes stdout, so the empty-stdout check compared b"" to "" and failed; the program output was correct; fixed at 2m 00s: run_cli_bytes in test_textutil.py now decodes stdout and stderr before comparing; no assertion was weakened.
Decisions: request.md holds the /herd:run message from the session log, not --request; the human's words win; --request was: [trimmed: the same request, word for word] | Refuse non-ASCII text (ValueError; CLI exit 1) instead of treating it as a separator; 'ASCII text only' and silent loss of letters; override by asking for separator behaviour | CLI joins several arguments with one space, no argument is a usage error (exit 2); unquoted text then works; override by asking for exactly one argument | Build: tests written first in test_textutil.py; red run fails on the missing textutil module as expected; the 128-code-point expectation was corrected to the reference-derived slug before running (A-Z and a-z are separated by 91-96).
Limits: ASCII only: any non-ASCII character is refused, not transliterated. The shell limits CLI argument length and cannot pass NUL.
Example: `python3 -m textutil '  A--b_2! '`; expected "a-b-2"; output tail: a-b-2

8. As a pull request

With herd pr, the same evidence becomes the pull request description. This repository had no remote, so nothing was pushed. The text below comes from herd.py's own pr_body function, run on the same task:

# Evidence: slugify

**Goal:** Add slugify(text) in textutil.py with unittest tests and a python3 -m textutil CLI

Design: claude-sonnet-5-5, in the main session (sonnet asked)

**Result:** 5 of 5 criteria proven by a passing check (0 failing, 0 unchecked).

The evidence is fresh: the checks ran at 2026-11-26T19:50:08Z on commit `a5321d1d6994`.

## What is proven

| id | source | criterion | proof: the check that passed |
| --- | --- | --- | --- |
| C1 | human | Given 'Hello, World!', when slugify runs, then it returns 'hello-world'. | `python3 -m unittest test_textutil.HumanExample` exit 0 |
| C2 | human | ASCII text only. | `python3 -m unittest test_textutil.AsciiOnly` exit 0 |
| C3 | agent-proposed | Given random ASCII strings, when slugify runs, then results match a separately written character-by-character reference. | `python3 -m unittest test_textutil.Random` exit 0 |
| C4 | agent-proposed | Given TEXT on the command line, when python3 -m textutil runs, then it prints the slug and exits 0. | `python3 -m unittest test_textutil.Cli` exit 0 |
| C5 | agent-proposed | Given no argument or non-ASCII text, when the CLI runs, then stderr has one message, exit is non-zero, no traceback. | `python3 -m unittest test_textutil.BadInput` exit 0 |

## What is not proven

- C1, what its check proves and does not: Proves the exact example returns exactly hello-world; says nothing about other texts (see C3).
- C2, what its check proves and does not: Proves every one of 128 ASCII code points is accepted and sampled non-ASCII characters raise ValueError; not every Unicode code point.
- Known limits: ASCII only: any non-ASCII character is refused, not transliterated. The shell limits CLI argument length and cannot pass NUL.
- Attack collision marked n/a: the tool takes one text value; no entries or identities can collide or contradict
- Attack recount marked n/a: the output is a slug; no totals, counts or times are reported

<details><summary>Run details and caveat log (7 tried, 1 found, 1 fixed)</summary>

- Route: standard
- First verify: 5 of 5 checks failed before the work
- Elapsed: 2m 30s from `herd init` to the last verify
- Test budget: Unit tests of slugify on the example, all 128 ASCII code points and seeded random strings against a separate reference; CLI run as a subprocess. No performance test: the request names no size.
- Inputs (as you described them -> as the program receives them): python3 -m textutil TEXT -> command line arguments after the module name; several are joined with one space (readings: python3 -m textutil TEXT; TEXT typed unquoted as several words); slugify lowercases ASCII text -> a Python str passed to slugify(text) (readings: slugify lowercases ASCII text; any of the 128 ASCII code points, control characters and newlines included)
- Adversarial pass: 7 attempts recorded; bad-input passing (`python3 -m unittest test_textutil.BadInput --refuses python3 -m textutil`); collision n/a: the tool takes one text value; no entries or identities can collide or contradict; one-bad-part passing (`python3 -m unittest test_textutil.OneBadPart --refuses python3 -m textutil good words café`); recount n/a: the output is a slug; no totals, counts or times are reported; refusal passing (`python3 -m unittest test_textutil.Refusals`); other-reading passing (`python3 -m unittest test_textutil.Readings --example python3 -m textutil '  A--b_2! '`)

Caveats logged during the run:

- 0s decision: request.md holds the /herd:run message from the session log, not --request; the human's words win; --request was: [trimmed: the same request, word for word]
- 38s tried: no argument and non-ASCII or undecodable argument: one message, non-zero exit, no traceback
- 38s tried: n/a: the tool takes one text value; no entries or identities can collide or contradict
- 39s tried: one non-ASCII character among good words refuses the whole text, never skipped
- 39s tried: n/a: the output is a slug; no totals, counts or times are reported
- 39s tried: random strings: refused exactly when some ord > 127 (separate test); everything ASCII is served
- 39s tried: readings: one quoted argument vs several unquoted words; printable ASCII vs all 128 code points
- 43s decision: Refuse non-ASCII text (ValueError; CLI exit 1) instead of treating it as a separator; 'ASCII text only' and silent loss of letters; override by asking for separator behaviour
- 43s decision: CLI joins several arguments with one space, no argument is a usage error (exit 2); unquoted text then works; override by asking for exactly one argument
- 1m 38s decision: Build: tests written first in test_textutil.py; red run fails on the missing textutil module as expected; the 128-code-point expectation was corrected to the reference-derived slug before running (A-Z and a-z are separated by 91-96)
- 1m 59s found: BadInput bytes helper returned bytes stdout, so the empty-stdout check compared b"" to "" and failed; the program output was correct
- 2m 00s fixed: run_cli_bytes in test_textutil.py now decodes stdout and stderr before comparing; no assertion was weakened
- 2m 27s tried: own review, not a fresh-context subagent: 20000 random ASCII strings against a regex reference, 3M-character input (0.41 s), empty, '--', 100000-character argument, non-ASCII under LC_ALL=C, Kelvin sign; no failure

</details>

<details><summary>Reproduce: run from the repository root</summary>

```bash
python3 -m unittest test_textutil.HumanExample
python3 -m unittest test_textutil.AsciiOnly
python3 -m unittest test_textutil.Random
python3 -m unittest test_textutil.Cli
python3 -m unittest test_textutil.BadInput
```

</details>

---
Opened by Herd with `herd pr`. Herd never merges: review the evidence above, then merge.

In the table, long check commands are cut short. The Reproduce section shows them in full.

9. If the agent tries to stop early

While a check fails, the Stop hook refuses to let the agent finish and says what to fix. After 3 refused stops it lets the agent stop, so a stuck agent can ask you instead of looping. This session never tried to stop early, so the message below is not from the run. It shows the format herd gate uses:

{"decision": "block", "reason": "Herd task `slugify` is not done (1/3 stop attempts blocked).
 C1 is failing: Given 'Hello, World!', ... Run `python3 .../scripts/herd.py verify` after fixing. ..."}

Clone this wiki locally