Repository navigation
How Herd works
Most agent workflows ask people to write long requirement lists, then trust the agent when it says "done". Herd flips that:
| You provide | The agent provides |
|---|---|
| A goal, and optionally criteria with a check for each | Plan, code, tests, attacks planned before the build, and evidence |
You review evidence (command output, commit SHA, timestamps), not process. The short version, with when to use Herd and when to think twice: Why Herd. What happens to everything a request leaves out: How Herd fills the gaps.
Why use it
- Done means proven. A Stop hook blocks the agent from finishing until every check passes, with evidence newer than the last edit. It blocks only the session that owns the task, so a parent session that started a headless Herd session can stop.
-
Your words stay yours. Criteria you write are quoted verbatim and never weakened:
herd donerefuses one that is not a quote of your request. Gaps are filled by the agent and markedagent-proposed. - Caveats surface early. The agent must say what each check does not prove, try to break its own work, and log what it finds, so problems appear during the run, not after it.
- Checks that test nothing are caught. A check that exits 0 but ran zero tests is flagged instead of counted as proof.
-
The pull request is the evidence (opt-in).
herd propens a PR whose description shows what is proven and by which check, what is not, and how to reproduce it. It never merges. - Short by default. Commands print a line or two, the agent ends with a six-line report, and the pull request collapses its details. The full detail is one flag or one file away.
-
Several tasks at once (opt-in).
herd init --worktreegives each task its own branch and git worktree, so several agents can work in one repository without touching each other. - Light. A small Python CLI on the standard library, no dependencies, plain-text task files. It uses Superpowers when it is installed.
flowchart LR
A[Goal] --> B[Intake and risk floor<br/>branch herd/slug<br/>opt-in: own worktree]
B -->|standard| C[Criteria with checks]
B -->|trivial: quick route| Q[One criterion, one check]
C --> K[Second look and 6 attacks<br/>on the design model]
K --> R[Red first<br/>checks fail before the work]
Q --> R
R --> D[Build on the build model:<br/>plan, tests first, code]
D --> X[Break it<br/>generated cases, scale<br/>6 attacks, each with a command]
D -->|quick route| F
X --> F[herd verify<br/>criteria and attack commands]
F -->|failing| D
F -->|passing| G[herd done<br/>evidence report]
S[Stop hook] -.->|blocks finishing until the conditions hold| G
G -->|opt-in| P[herd pr<br/>PR with the evidence]
-
Intake. The task gets a folder,
.herd/tasks/<slug>/task.toml, and a risk floor computed from path rules inherd.toml(migrations, auth, billing, and so on). The agent can raise the risk, never lower it. A trivial change takes the quick route: one criterion and one check, no criteria interview, no approval question. It is refused at ahighrisk floor and still ends in fresh passing evidence. With--worktree(opt-in) the task starts on its own branch in its own git worktree: see Several tasks at once. -
Criteria. Every criterion has a
check: a shell command where exit 0 means pass. Criteria you write are authoritative: the agent quotes your words, adds acoveragenote saying what the check proves and what it does not.herd doneand the Stop gate refuse ahumancriterion that is not a verbatim quote of the request Herd recorded atherd init: your latest/herd:runmessage, read from the session log (--requestcounts only when there is none). Case, spacing, line wraps, quote marks, dashes, sentence punctuation and Markdown are ignored; words, numbers and operators are not. Your own rewording, recorded withherd note --human-change "C1: <your words>", counts as a source. With no recorded request it is only a warning. At medium and high risk on the standard route they also refuse whiletest_budget,known_limitsor a human criterion'scoverageis empty, or whileinputsis missing, incomplete or written inside a[[criteria]]table instead of as top-level[[inputs]]tables (each input as you described it,human, and as the program receives it,program;inputs = []for none), and say what to write: only absence and structure are checked, the words are the agent's. Thetask.tomlthatherd initwrites shows the[[inputs]]table. A criterion with no check isuncheckedand is never counted as met.herd detectproposes the project's real test command. Before any work,herd verifyruns the checks once: they should fail (red first), and the report shows how many did.Design on a stronger model. On the standard route the criteria, the
inputs, a "be specific" second look and the six attacks are the design, made on thedesignmodel (default Sonnet); the code is built on thebuildmodel (default Haiku).herd statussays which step runs in your session and which in theherd-designerorherd-buildersubagent. The second look is the fixed messageherd design-brief, answered in the task'sANSWERS.mdbefore the attacks: the firstherd verifyrefuses without it, andherd donerefuses without a design on thedesignmodel. A hook records the designer's model indesign.json, and the report and the PR name it. Settings:[models]in Settings. -
Build. Tests first, small steps, on a branch. Superpowers is used for planning, TDD and subagents when installed.
herd initrecords the starting commit, the stash list and any files already uncommitted (those are yours, not the agent's, until the agent changes them; in Claude Code a hook moves the ones this session already edited back to the agent), so the firstherd verifyknows whether code was written before the checks, including code moved aside or stashed for that run (a check by file times and the stash list, not proof): if it was, the report says "red first not proven" andherd donewaits for the agent's reason (herd note --late-red). The guard hook runs while the task is active. -
Break it. The six standard attacks are planned before the build: on the standard route all of them are logged, each with a command or an
n/a:reason, before the firstherd verify, so they shape the design. After the build the agent tries to break the result. See Attacks. There is no review step: it was removed in 0.13.0 (Review). -
Verify.
herd verifyruns every check and stores evidence: status, exit code, output tail, commit SHA, a content id of the work done since the task started and a fingerprint of the workspace, a timestamp, how many checks failed on the first run (a check that was green before any work is visible), and the wall-clock time sinceherd init. A check that exits 0 but whose output says it ran zero tests (Ran 0 tests,no tests ran,[no test files]and the like) is marked in the evidence and the report warns about it. The warning is advisory: the Stop gate does not change. It also runs theherd checkwarnings every time, freezes the human criteria at the first run (changing or removing one later blocksherd doneuntil the human's own words are recorded withherd note --human-change "C1: ...", quoting the new text or saying it was dropped; the same holds for a changed check on a human criterion, and a changed check on an agent's criterion is shown; a change that only moves the human criteria toward your request needs no note: when every human criterion now quotes the request and every earlier human quote is still inside one of them, the changed ones are re-frozen with their checks, and the report and the PR list them for you to confirm), and counts failures in a row: after 3 on one criterion it says to escalate. The command prints one summary line plus only what needs attention. Each check records how long it took; the summary line ends with(checks took N s)and names each check over 60 s, as evidence only. When the work,task.tomland the attack notes are unchanged since the last full run,herd verifyruns no check and keeps that evidence;--freshruns every check. -
Stop gate. See Hooks and guard.
-
Pull request (opt-in). When the request asks for a PR, or
herd.tomlhas[pr] open = true,herd prpushes the task'sherd/<slug>branch and opens a pull request whose description is the evidence: the result, what is proven and by which check, what is not proven (failing or unchecked criteria, coverage gaps, known limits, open caveats), then, collapsed, the run details, the caveat log and the commands to reproduce. Ask for a draft or a milestone and the agent adds--draftor--milestone NAME. Once the PR exists, everyherd verifyrewrites its description from the latest evidence, andherd donereplaces it with the final evidence (runherd pragain any time; it shows stale evidence as stale). Lines after Herd's footer line, such asCloses #N, are kept; text above it is replaced. It needs a clean working tree, so the PR holds exactly the verified code. It leaves check output out of the description (it can hold secrets) but publishes the check commands, the criteria and the notes as written, so never put a secret in them. It pushes no other branch and never merges: you review the evidence and merge.
Herd keeps a task's state in the checkout it runs in, so a plain herd init refuses while another task there is still active. To run several tasks in one repository, start each in its own worktree:
$ herd init export-json "Add a --json flag to the export command" --worktree
created worktree <repo>/.claude/worktrees/herd-export-json on branch herd/export-json, cut from feature/reports. Work from there: in Claude Code, EnterWorktree with that path; otherwise cd into it. Run every herd command from it.
-
Its own branch, cut from where you are.
herd/<slug>starts at the current local branch, which is recorded as the task's base;herd propens the pull request against it. A plainherd initdoes the same in the current checkout, without a new folder. - Its own state. The task's files and Stop gate live in the worktree. Other agents can start other tasks from the same branch at the same time; each gate sees only its own task, and a duplicate task name fails without touching the first.
-
A forgotten move fails loudly.
herdcommands run from the starting checkout for a task that lives in a worktree refuse and name the worktree. -
Clean main checkout. Herd adds
/.claude/worktrees/and.herd/to the repository's own.git/info/exclude(never committed), so other tasks never show up ingit statusor agit add -A. -
Make it the rule. With
[worktree] required = trueinherd.toml, a plainherd initrefuses outside a matching worktree. -
Clean up after the merge with
git worktree remove .claude/worktrees/herd-<slug>. Uncommitted changes in the starting checkout are not carried over; Herd warns when there are some.
flowchart LR
subgraph Plugin
S["Skills<br/>run, criteria, evidence"]
H["Hooks<br/>Stop gate, pre-init, guard,<br/>design hook, lint"]
A["Subagents<br/>herd-designer, herd-builder"]
end
CLI["herd CLI<br/>plugin/scripts/herd.py"]
T["herd_triage<br/>risk floor"]
D["herd_detect<br/>test command"]
G["git and gh<br/>task branch, worktrees, herd pr"]
subgraph State[".herd/tasks/<slug>/"]
TT["task.toml and request.md<br/>goal, criteria, checks;<br/>the human's message"]
NO["notes.jsonl<br/>caveats, attacks with commands"]
EV["evidence.json<br/>criteria and attack results,<br/>SHA, content id, fingerprint"]
RP["evidence.md<br/>the report"]
RR["start, red, frozen, green, fails .json<br/>run-rule state"]
DS["design.json<br/>the designer's model"]
SR["stopped.json<br/>why it stopped, what next"]
end
S -->|instruct the agent to run| CLI
H -->|gate, preinit, guard, design-hook, lint| CLI
A -->|run| CLI
CLI --> T
CLI --> D
CLI --> G
CLI -->|reads| TT
CLI -->|appends| NO
CLI -->|runs checks and attack commands, writes| EV
CLI -->|herd done writes| RP
CLI -->|init and verify write| RR
CLI -->|gate and cancel write| SR
CLI -->|design hook writes| DS
-
Short skills, details on demand, quality first. The run skill holds the steps; the quick route, the worktree start, the adversarial pass and the PR step are separate files the agent must read in full when that step applies. Where skipping a step would cost quality, the CLI enforces it itself at
herd doneand the Stop gate: the adversarial attacks, red first, the frozen human criteria, the design model and the commit. Budget tests keep the skills and the command output from growing back. -
The skills are the method; the CLI is the referee. The skills tell the agent what to do in each step. The CLI only records and checks: it runs the commands in
task.tomland decides from their exit codes, never from what the agent says. -
The Stop hook enforces it. It asks the CLI whether the stored evidence is passing, meets the run rules and still matches the workspace: a content id (a SHA-1 over every file that differs from the task's start commit, with its content, the same before and after a commit) plus a hash of
task.toml. Any edit afterherd verifymakes the evidence stale; a commit alone does not, soherd doneafter a commit needs no second verify.herd doneandherd prthen record the final commit ashead(the verified one stays asverified_head). Outside git, and for evidence without a content id, the older fingerprint overHEADand the diff decides. The hook finds the task from any subdirectory: the root is the nearest folder with.herd/orherd.toml, so a project in a subfolder of a repository keeps its own tasks. - State is plain files in the project, one folder per task (in the task's own worktree when it has one), so a human can read, diff or delete it.
-
GitHub only when you opt in.
herd pruses theghCLI to push the task's branch and open its pull request. Nothing else talks to a service. -
Two modules are not wired in yet.
herd_arbiter.py(rules on findings) andherd_escalation.py(one GitHub issue to pause and ask a human) are tested building blocks for the GitHub automation on the roadmap.
-
Gaps never block. Missing criteria or checks are filled in by the agent, marked
agent-proposed, and listed for you. -
Evidence over claims.
passingandfailingcome from commands.uncheckedis listed and never counted as met. - Ask rarely, ask once. The agent stops for an irreversible action, a real trade-off, or when stuck after 3 failed attempts on a criterion. It asks one question with numbered options.
- Decisions are reported in at most three lines: decision, reason, how to override.
-
Checks run as shell commands from
task.toml, in your repository, with your permissions. Treat a task file like code: read it, especially in a repository you do not trust. -
Push only its own branch, never merge.
herd prpushes only the task'sherd/<slug>branch from a clean working tree and opens or updates its pull request. The merge is yours. During a task the guard hook deniesgit push,gh pr mergeand the other irreversible commands the agent might type.