Herdr fleet
HARD RULE, STEP 1: load the herdr skill (Skill tool) before anything else. Do it before you read the config, write files, or run any script. The fleet scripts do not replace it: it holds the CLI rules this skill assumes. No exceptions, even if you plan no direct herdr calls.
Run order
Copy into your todo list. Each step names the section that holds its rules.
- Load the
herdrskill and checkHERDR_ENV(above). - Pick a persistent run dir
$R, scaffold it, and pin the session (Files, not chat; Session pin). - Read
.herdr-fleet.config.jsonand pick agents (Agents). For each kind you launch, read its entry in kinds.md. - Write
$R/00-context.mdwith the hard rules, then one brief per agent (Files, not chat). - Create panes with
grid.py, launch, send the standard prompt (Layout; Launch). - Start one background watcher per agent (Watch).
- Re-check results and build the index (Verify).
- Stop processes and close the panes you created (Clean up).
Before any herdr command: test "${HERDR_ENV:-}" = 1. Never run bare herdr (it opens the TUI).
Session pin. Several herdr sessions can run at once, and the inherited HERDR_* can point to the wrong one (for example, a background job started from a pane in another session). Before the first launch, run R=$R $S/session.py from the project dir. It finds this agent's own pane (the agent pane whose cwd is $PWD or its nearest parent, in any running session) and pins it in $R/herdr.env. Every fleet script loads that file and stops if no single pane matches. Check that the printed pane is yours. If it fails with a tie, write $R/herdr.env by hand from the candidates it lists. For your own direct herdr calls, prefix source $R/herdr.env;.
Scripts: S is the scripts/ directory of this skill, as an absolute path. Installed with npx skills add -g it is ~/.agents/skills/herdr-fleet/scripts; from a repo checkout it is skills/herdr-fleet/scripts. Check it exists before you use it. Every $S/... below uses it.
Agents
The agent list lives in .herdr-fleet.config.json in the project root (git top level), not in this skill. Each project has its own. Run $S/launch.sh from inside the project repo: on first use it creates the file from herdr-fleet.config.example.json. Outside a git repo it stops, so the config is never written to the wrong place.
| field | meaning |
|---|---|
| key | agent name the user says: "run it on codex-sol and cursor-grok" |
kind |
herdr agent start --kind value, or command-code (see below) |
model |
optional. Passed as --model <model>. Omit it to use the CLI's own default |
model_flag |
optional. Flag used for the model, if the CLI does not take --model (-m is already used for command-code, opencode, gemini) |
args |
extra CLI args, one array item per argv item |
notes |
what it is good at, what to watch, how long it takes; pick by it |
Read the file before you pick agents. To add or change an agent, edit the file. Every kind is optional: keep only the CLIs the user has installed and logged in to. The shipped example is a starting point, not a recommendation.
Models: one per entry, checked against the CLI
The example has one entry per model, and every entry sets model. Ids go stale: if a launch fails on an unknown model, run $S/models.sh and fix the config. Two more ways to pick a model:
- Choose at launch. Run
$S/models.sh [kind...](no argument: every installed CLI). It asks each CLI for its live list. Filter withgrep -i. Then launch withMODEL=<id> $S/launch.sh ..., which overrides the config for this launch only. When the user names a model ("run it on the newest codex"), resolve it this way yourself. - Use a bare kind.
launch.sh <name> $PANE codexworks with no config entry at all: the CLI starts with its own defaults. AddMODEL=or extra args as needed.
models.sh covers cursor, codex, devin, command-code, opencode, pi and grok through their listing commands. claude has none (its --model takes aliases or full ids, see claude --help); for other kinds it points you to <cli> --help. herdr agent start --help lists every supported --kind.
Kinds and permissions
kinds.md holds per-kind flags and quirks (cursor, codex, claude, devin, grok) and the headless command-code flow, which herdr cannot see and which watch.sh and prompt.sh handle differently. Read the entry for every kind you launch before you set its args.
Auto-approve (cursor --force, devin bypass, grok --always-approve, command-code --yolo) means no approval gate sits between the agent and rm -rf. The no-destruction rule in 00-context.md (see Files, not chat) is required. Do not launch without it. If the harness you run in blocks auto-approve agents, tell the user and ask before you launch.
Layout
- One tab per run, never the caller's tab. Max 10 agents per tab; more → a second tab label.
grid.pyrefuses an 11th pane. - A run gets its own tab. This overrides the sibling-pane default in the
herdrskill, which fits single-pane work. grid.pyuses the workspace from$R/herdr.env(see Session pin), so the tab lands in this agent's own session.- Get each agent's pane from
$S/grid.py, never from a bareherdr pane split. Chained splits leave the oldest panes a few rows high.PANE=$(R=$R $S/grid.py <tab-label> --new)adds an empty pane to that tab and creates the tab if it is missing. It then re-tiles the tab into an even grid (max 3 per row, oldest first) and prints the pane id.- After
herdr pane close, run$S/grid.py <tab-label>so the rest fill the gap.
- Do not keep an empty "anchor" shell pane in the tab: it takes a grid cell. The tab closes with its last pane and
--newrecreates it. - Always
--no-focus. Parse pane ids from the JSON. - Names:
[a-z][a-z0-9_-]{0,31}.
Launch
PANE=$(R=<run dir> $S/grid.py <tab-label> --new)
[MODEL=<id>] R=<run dir> $S/launch.sh <name> $PANE <agent|kind> [extra agent args...]
R=<run dir> $S/prompt.sh <name> [--slug <topic>] [--replaces <agent>:<n>] "<task>" # prints: task #<n> sent; report: ...launch.sh cd's the pane to $R (stray relative writes land there, not in the code repo), looks up <agent> in the config (or accepts a bare kind) and starts it. It does not send a task. For a research run, send the standard prompt:
You are agent '<name>'. Read fully: $R/00-context.md, then $R/briefs/<name>.md. Do the brief. Scratch files go to $R/work/<name>/.Do not name a report path or a status line in the task. prompt.sh gives every task a number n and appends a block with its report path ($R/reports/<name>-<n>[-<topic>].md) and the exact finish.sh line the agent runs when the report is complete. Keep the printed number: the watcher waits for it.
If agents use a browser tool, give each its own named session and forbid commands that close every session.
Gotchas
- Follow-ups: use
$S/prompt.sh. It sends the text and flushes the agent's message queue: it presses the key of that CLI until the queue marker leaves the screen, up to 4 times. If its last line saysQUEUED <name>, the message is still not delivered: read the agent's screen before you continue. Do not send the text again, it would be queued twice. Each follow-up is a new task with its own number and report. A new task never closes an older one:collect.shwaits for every task. To drop or take over an older task, send the new one with--replaces <agent>:<n>. To nudge the current task (continue, an answer to its question), useprompt.sh <name> --raw "<text>": no new number, the watcher keeps waiting. agent_statusalone lies (idle/done while still writing, or done with a half-written report). Completion =$R/work/<name>/done-<n>, whichfinish.shwrites ($S/watch.sh). Report lines and file times do not count.- Agent CLIs may self-update on start (for example codex:
Update ran successfully! Please restart Codex.) and exit.launch.shrestarts once if the agent is gone 8 s after start. Always wait withwatch.sh, not a file-only loop: it reports GONE. - Shared state. Agents share the machine: browser sessions, ports, lock files. Give each its own session name and profile, and never run a "close all" command.
- Agents may leave background processes running. At the end:
pkill -f "$R/work/<name>/"per agent, and check for relative-path children (ps -axo pid,command | grep <script>).cleanup.shdoes the first part. A leftover process that holds a shared lock (a GPU or CPU slot) blocks every other agent; after stopping an agent, check the lock files and kill the holder. - Context overflow. A Devin footer shows
Context: N / 262k; at 100 % it stops withResponse truncatedand cannot continue. Commits survive. Start a fresh agent (new name, same worktree and branch) with a short resume brief: its commits so far, what is left, "overwrite the WIP report". Check long runners at ~80 %. - Stale branch names. A branch left from an earlier run with the same name makes worktree creation fail while launch and prompt still succeed, so the agent starts without a tree. Prefix branches per run and check the worktree exists before sending the prompt. If a remote has a branch of the same name, pass
refs/heads/<branch>as the base. - Stopping a code agent early: if its tree is clean and it has commits, merge what is committed (each commit was green); write its log line from the commit subjects. Testing-only agents can simply be stopped.
Files, not chat
$R/00-context.md goal, known facts, hard rules, report format, agent list
$R/briefs/<name>.md one brief per agent
$R/reports/<name>-<n>[-<topic>].md report of task n (prompt.sh names it)
$R/work/<name>/ agent scratch; prompt.sh and finish.sh keep task state here:
run (latest n), prompt-<n>.txt, report-<n>, done-<n>, replaced-<n>
$R/work/orchestrator/ your own checks (notes.md)Scaffold it once before the first launch: mkdir -p "$R"/briefs "$R"/reports "$R"/work/orchestrator && R=$R $S/session.py. launch.sh creates $R/work/<name> itself.
Do not put $R in /tmp or a scratch dir that a reboot wipes. Use a persistent dir, one per task (for example <project>/runs/<task-slug>), and reuse it for every agent in that task.
Hard rules to put in 00-context.md (adapt to the task):
- you may run with auto-approve, so no permission prompt will stop you. Never delete, overwrite, or destroy anything you did not create this run: no
rm, nomvonto existing files, nogit clean/reset --hard/checkout --, nokill/pkilloutside your ownwork/<name>/processes, no dropping/truncating files, dirs, rows, tables, or branches. If something is in the way, write beside it or stop and report; - read-only on code repos; write only to
work/<name>/and the report; the user may edit the repo during the run (readgit show HEAD:<path>if a file looks half-written); - no access to production systems; no tests, training or long jobs unless the brief allows;
- no accounts, no purchases, no signups;
- keep work files to a size the brief names (aggregate or sample large data);
- every claim with
file:line/ URL + date / command + numbers; markverified/likely/speculative; - run the
finish.shline from your task only when its report is complete, and only for that task number.
Watch
One background watcher per agent. Start it with the shell tool in background mode (run_in_background), never as a foreground loop:
R=... $S/watch.sh <name> [task#] [timeout_s]
It waits for one task: the number prompt.sh printed, by default the agent's latest task when the watcher starts. A later task or a late finish.sh of an older task never closes it; only a task sent with --replaces <name>:<n> does.
It exits on DONE (done-<n> exists; checked first, so a watcher started late, restarted, or started after the pane closed still sees it; it blocks on herdr agent wait with a 10 s timeout, so it wakes within ~10 s),
IDLE (agent not working, no busy marker on screen, report unchanged 10 min, no finish: read the report, then nudge with --raw), BLOCKED, GONE, TIMEOUT (default 90 min), EXITED (command-code only), or REPLACED (a later task took it over with --replaces).
Each exit also raises a herdr notification (fleet <name> #<n>), so the user sees it without watching the tab.
That wakes you. No polling in between.
Recovery is your job. If a watcher dies, start it again with the same task number. If the agent dies before it finishes, start a fresh agent and send it prompt.sh <new> --replaces <old>:<n> "<task>". The task holds "Continue task #n of <old>", the text from $R/work/<old>/prompt-<n>.txt, and the path of its partial report. --replaces writes replaced-<n> in the old agent's work dir, so the index keeps its row (replaced by <new>#<m>) and the gate waits for the new task. Without it the old task stays open and collect.sh fails.
In Cursor: start all watchers in one backgrounded tool shell with an output notification on ^(DONE|BLOCKED|GONE|TIMEOUT|EXITED|REPLACED); ( watch.sh ... & ) inside a normal call dies when the call ends. IDLE also fires on an agent that is only thinking for a long time, so re-run on IDLE: while true; do o=$(watch.sh $a $n); echo "$o"; case $o in DONE*|GONE*|BLOCKED*|TIMEOUT*|EXITED*|REPLACED*) break;; esac; sleep 30; done.
Clean up
When a run is over, R=$R $S/cleanup.sh lists the processes and panes of this run. Add --close to stop the processes and close the panes. It resolves each pane by agent name, so panes moved by grid.py are still found. It never closes the orchestrator's own pane. Then re-tile the tab with grid.py if you keep it.
Verify
- Give the most suspicious topic to 2 agents of different models. Overlap finds more, and disagreement shows what needs a re-check.
R=$R $S/collect.shbuilds$R/index.md: one row per task of every agent, with the statewatch.shuses. FINAL (finished), WIP (report, no finish), missing, send failed, EXITED (command-code), replaced by<agent>#<m>, no task. Reports no task owns show as untracked. It exits 0 only when every task is FINAL or replaced.- Re-check every key number yourself with a small script before it goes in the final report. Keep a "refuted" list.
- Close only panes and tabs you created, and only when the user no longer needs them.