Repository navigation
Hooks and guard
The hooks are the Stop gate (herd gate), the pre-init hook (herd preinit, before herd init and herd status), the guard (herd guard), the design hook (herd design-hook, when the herd-designer subagent stops) and the optional lint hook (herd lint). Commands lists each one and Settings the lint hook.
While the task is active, a guard hook denies, with a reason, edits to secrets (.env in any folder, keys, .git; .env.example stays editable) and to Herd's own state files, and irreversible commands in any part of a chain, inside if or for blocks and behind sudo or env: git push (publish with herd pr), git reset --hard, git clean -f, git branch -D, git checkout -- . (or ., or -f), git restore ., git stash drop or clear, git switch -f, git commit --no-verify, gh pr merge, gh repo delete, rm -rf of /, ~ or the current folder. Quoted text, heredoc bodies and # comments are not read as commands. [guard] in herd.toml adds paths and commands; it cannot remove any. Running Herd's hook commands by hand (herd gate, herd preinit, herd guard, herd design-hook) is denied too. The guard also sees the Agent tool: with or without a task, it denies herd:herd-designer and herd:herd-builder unless run_in_background is false, because a main session that waits for a background subagent tries to stop and uses up the Stop gate. Each denial during a task is logged and listed in the report and the PR. It reads command text, so a script, an alias or bash -c can get past it: Claude Code's sandbox and permissions are the boundary for that; the guard catches the honest mistakes and makes them visible.
While a task is active, a Stop hook refuses the session that owns it to let the agent finish unless the evidence is fresh and passing, every standard attack has a passing command, red first is proven or explained, the human criteria are quoted and unchanged, test_budget, known_limits, human coverage and inputs are filled in where the risk needs them. The owner is the session that ran herd init and the last session to run a herd command in that checkout, such as one that resumes the task; any other session, such as a parent that spawned a headless Herd session into the same worktree, stops freely and uses up none of the owner's stop budget (0.14.8). With no recorded session the gate blocks as before. Edit a file after verifying and the evidence is stale; a commit alone does not make it stale, because freshness is decided by content (0.12.6). Once all of that holds, it still blocks up to 3 times until herd done runs, which checks the commit and prints the final report. If Herd's own state files are corrupt, it blocks and says which; with no start.json (a task started before 0.4.0, or the file deleted), red first needs a herd note --late-red reason. After 3 blocked attempts on a problem the gate lets the agent stop so it can ask you one question instead of looping. To drop a task, herd cancel closes it and keeps its files as a record. Whenever a task stops without herd done (the gate lets it go after 3 blocks, it is cancelled, or a criterion failed 3 times in a row), Herd writes stopped.json: why it stopped, the problems left, the evidence state, and whether the task can be resumed and with what next step. Herd computes resumable and next from the same problems the gate checks, never from what the agent says. herd status prints that line first, so a new session knows where to start (it says when the task went on after the stop), and herd status --json prints the record for a reporting agent. A later herd done keeps the record and adds resolved_at.