Splitting Coding Agents by Role and Repository with herdr
If one coding agent handles every repository and every role, at some point a human can no longer follow what was changed and how far. This post covers three setups that split agents by repository boundary and by role, and the problems found along the way.
- One Claude Code session per repository in internal platform work, with sessions exchanging requests
- Separate builder and reviewer sessions in a personal project (a shopping mall refactoring)
- A local Mac agent (OmO) and a cloud VM agent (Poppy) handing work to each other
The common tools are Claude Code and herdr. The herdr versions are 0.9.5 locally and 0.9.0 on the remote. That gap causes one of the problems later on. herdr command descriptions are limited to what I confirmed from --help output on each machine and from the official herdr docs (agent-guide.md on herdr.dev and the pages linked from llms.txt).
herdr basics
Section titled āherdr basicsāWhat herdr does
Section titled āWhat herdr doesāherdr is a terminal workspace manager for AI coding agents. Like tmux, a background server owns the real terminal processes and clients only attach and detach, so agents inside panes keep running when the terminal closes or SSH drops.
It has four levels.
- session: a background server namespace. Most people use only the default session.
- workspace: a container for one repository or task. The sidebar rolls agent states up per workspace.
- tab: a layout inside a workspace.
- pane: a real terminal, addressed by an ID such as
w1:p2.
What sets it apart from tmux is that it recognizes coding agents running inside panes. For supported agents such as Claude Code, Codex, OpenCode, Pi, and Hermes Agent, herdr decides the state either by reading the bottom of the pane against rules or from reports sent by the agent itself. There are five states: idle, working, blocked, done, and unknown. The official docs say blocked is deliberately strict. herdr only marks blocked when the screen matches a known approval, question, or permission UI, so an unfamiliar prompt can show up as idle. An idle label is therefore not permission to type into the pane.
I use herdr for that state information and for its CLI. A person looks at the sidebar to see which agent is waiting. An agent uses the CLI to ask another agentās state, submit a prompt, and read its screen.
Agent commands I used most
Section titled āAgent commands I used mostāThese are the herdr agent subcommands that became routine. Each target accepts a pane ID or an agent name.
herdr agent list # all agents on this server and their statesherdr agent get w1:p1 # one agent: agent, agent_status, and moreherdr agent read w1:p1 --lines 80 # read the pane's screen textherdr agent prompt w1:p1 "..." --waitherdr agent wait w1:p1 --until idle --timeout 600000herdr agent rename w1:p1 reviewerherdr agent send-keys w1:p1 escherdr agent explain w1:p1 # why the state was judged that wayHere is where each one came in.
agent listandagent get: check the other agentās state before sending a request. Runningagent geton the remote VM shows something likeagentashermesandagent_statusasidle. If it saysworking, the agent is busy with something else, so I reconsider sending.agent read: confirm on screen whether a prompt arrived and what the agent is doing. I used it most in the timeout case described below.--sourcepicks one ofvisible,recent,recent-unwrapped, ordetection, and the default isrecent.agent rename: give role names such as builder and reviewer. According to the official docs, names must match[a-z][a-z0-9_-]{0,31}and be unique among live agents. The name is an alias for the agent currently in that pane and is cleared when that agent exits. It does not permanently rename the pane.agent send-keys: send keys such asescorenterwhen the agentās screen is stuck on a question or approval. When the target isblocked,agent promptrefuses without sending input, so this is the command for a deliberate response after reading that screen.agent explain: look at the reasoning when the state display looks wrong.
What agent prompt --wait waits for
Section titled āWhat agent prompt --wait waits forāThe command most easily misunderstood is agent prompt --wait. At first I assumed it waited until my request was finished. The help text says something different.
--wait: Wait for the first matching state observed after submission--until <STATUS>: State to match after --wait; possible values: idle, working, blocked, done, unknown
If the agent is already blocked, submission is rejected with agent_blocked beforeany input is sent. When an accepted submission starts from another non-workingstate, --wait requires an observed working or blocked state within 5000ms;otherwise it returns agent_prompt_stalled. A caller timeout that expires firstreturns timeout. It then matches idle, done, or blocked by default, or any exact--until state. It does not track turns: if the agent is already working, thatactive turn's completion may match.This text was identical in the local 0.9.5 and remote 0.9.0 help. Laid out as a flow:
Two things matter here.
First, it does not track turns. If the target is already working when the prompt goes in, the end of the previous turn can be the āmatching stateā. A successful return does not necessarily mean my request is done. So I got into the habit of checking agent_status with agent get and sending only when it is idle.
Second, timeout is not a delivery failure. The input was written before the wait began; the caller simply did not see the desired state within its own time limit. A request I sent to the remote Poppy did end with a timeout while Poppy was already working on it. Sending the same request again would run the job twice. On a timeout I do not resend; I look at the screen with agent read first.
agent wait should be read the same way. Its help says āWithout āuntil, matches idle, done, or blocked. Without ātimeout, waits indefinitely.ā Without --timeout it waits forever, so scripts always pass one.
One session per repository
Section titled āOne session per repositoryāDeployment for the work cluster is split across Git repositories with different roles: an app deployment manifest repository, a cluster base configuration repository, another appās manifest repository and so on. We ran one Claude Code session per repository, and each session changed only its own repository.
When a session decides another repository also needs a change, it does not edit it. It sends a request to the session that owns that repository through Claude Codeās inter-session messaging (the ListAgents and SendMessage tools). The receiving session makes the change and replies, and the requesting session then opens the other repositoryās diff itself to confirm the change matches the request. Not trusting the reply text alone is the key.
Two real examples:
- Changing the routing host meant the docs and comments in the cluster base configuration repository had to follow. The app manifest session sent a request, and the configuration repository session made the change and replied.
- Responding to a security review required action in another appās repository as well. The session for that repository was not open, so there was no one to receive the request. The human opened that session and then the request was sent. This approach assumes the receiving session is running.
Fixed rules
Section titled āFixed rulesāEvery session got the same rules.
- A human does commit, push and Argo CD sync.
- Agents check only up to
kustomize buildandkubectl apply --dry-run=server, and state ānot committedā in every report. - Secret files are blocked from agents by permission settings. Agents do not work around this; they write out the command for a human to run instead.
The reason for ānot committedā in every report is simple. With several sessions moving at once, it is easy for a human to lose track of what landed in which repository. Fixing the status in the report format makes it explicit that nothing reaches the cluster until a human commits.
Separating builder and reviewer
Section titled āSeparating builder and reviewerāFor the shopping mall refactoring, a personal project, the split was by role. Two herdr panes each ran a Claude Code session, and each got a name.
herdr agent rename <pane-1> poppy-builderherdr agent rename <pane-2> poppy-reviewerWhen the builder needs a review, it puts a prompt straight into the reviewer pane.
herdr agent prompt poppy-reviewer "Please do the first review of docs/spec.md. Write results to docs/review/phase-1.md" --waitThe exact meaning of --wait is explained earlier in What agent prompt --wait waits for.
Work starts from documents, with a review at each stage.
- Once the intent document is Ready, the builder writes spec, plan, tasks and ADR drafts.
- The reviewer reviews, the builder applies the findings, and the reviewer reviews again.
- Implementation starts only after a human approves the tasks. T1 through T13 are committed one task at a time.
Review record format
Section titled āReview record formatāThe reviewer writes findings to docs/review/phase-N.md. Each finding has a number such as P1-01 and a grade of Major, Minor or Info. The first spec review found 3 Major, 6 Minor and 5 Info. The re-review confirmed earlier fixes and added 2 new Major findings.
Numbering kept conversations short (āP1-03 fixedā) and made it easy to track which findings were closed in a re-review.
One rule matters. If the builder only reports āfixedā, the reviewer does not close the item and records it as āfix reported, not verified by reviewerā. Actual verification happens at the next review by reading the diff. It is the same principle as the requesting session opening the diff in the per-repository setup.
Interim review in parallel
Section titled āInterim review in parallelāWhile the builder worked on T8, the reviewer did an interim review of the already committed T1 through T7 in parallel. The reviewer does not only read code; it runs the build and tests itself. The tests use Testcontainers, so the reviewer side also needed Docker.
One catch from review: test code violated the project rule against Thread.sleep in tests. The part waiting for an asynchronous result was changed to a condition wait with Awaitility. Had the same session both written and reviewed the code, it would have been hard for it to see the sleep it had just written as a rule violation.
Handing herdr to the agents with the herdr skill
Section titled āHanding herdr to the agents with the herdr skillāThe builder and reviewer setup above started with a human relaying results between the two panes. To hand that job to the agents, the agents have to use herdr properly too. herdr ships a skill for exactly that.
What the skill contains
Section titled āWhat the skill containsāThe herdr skill is a single SKILL.md that agents such as Claude Code read. You can install it from the herdr repository (herdrdev/herdr) with a skill installer, and herdr --skill prints the version that matches the installed binary. It reads less like a command list and more like a set of rules, and much of it overlaps with the tips I worked out by hand in this post.
- Before any control command, check that
HERDR_ENV=1. If not, say that you are outside herdr and stop. - The installed binary is the authority for command syntax. Read
herdr --helpand the group help first. Plainherdrwithout arguments opens the TUI, so do not use it for discovery. - Read IDs and states from JSON responses. Do not guess them from sidebar order or examples.
- Create background panes with
--no-focusso the humanās screen is not taken over. --waitwaits for a state, not a turn. A timeout oragent_prompt_stalleddoes not prove the prompt was not delivered, so do not resend it as is; checkagent getandagent readfirst.idleanddonedo not guarantee that an unfamiliar approval screen was recognized.
Having the agent read the skill first makes these tips available before work begins. Its commands and results still need to be checked for compliance.
Install location and version
Section titled āInstall location and versionāThe herdr skill was installed under .agents/skills/herdr in the home directory, a location several agents share. That Claude Code session did not discover the skill at its installed location, so I linked it under ~/.claude/skills. That story is in herdr skill not showing up.
The version matters too. The SKILL.md installed in September (202 lines) differed from the herdr --skill output of the 0.9.5 binary (214 lines). The installed copy had no section on controlling remote machines with --machine, and lacked the caution that idle does not guarantee an approval screen was recognized. Update the skill when you upgrade herdr, or have the agent read the current version with herdr --skill.
Letting an agent name itself
Section titled āLetting an agent name itselfāWhen I said ārename yourself in herdrā, the builder session read the skill and renamed its own pane.
herdr pane rename "$HERDR_PANE_ID" builder-aherdr agent rename "$HERDR_PANE_ID" builder-aherdr agent listherdr injects HERDR_PANE_ID into every pane it manages, so an agent can point at itself without knowing its pane ID. It left the neighboring reviewer pane alone, judging that each agent should name itself.
There are two separate names. Claude Codeās /rename only changes the terminal title and the session name used for cross-session messages. The name used by herdr agent prompt has to be set separately with herdr agent rename. That name disappears when the agent exits. After restarting sessions the next day the names are empty, so at session start I check names with herdr agent list and fix them first. Pane IDs are stable handles, but moving a pane to another workspace changes its workspace-qualified ID. After a move, use the new ID returned by the command or the live agent name. I record roles in notes and rediscover the current targets with herdr agent list before acting.
Handing the review loop to the agents
Section titled āHanding the review loop to the agentsāOnce the names were in place, the builder requested reviews from the reviewer directly.
herdr agent prompt reviewer "Review request for phase-3 cart. Write the result to docs/review/phase-3-cart.md" \ --wait --until done --until idle --timeout 2400000- The reviewer runs builds and tests, so I set a 40-minute timeout. The command above records what I used at the time. For ordinary work, use
--wait --timeout 2400000; the default matching states areidle,done, andblocked. The--until done --until idleflags above excludeblocked. Removing them also lets the wait return at an approval or question, so check the returned state and review file separately. - After writing the review file, the reviewer replies to the builderās session name with Claude Codeās cross-session message. The builder reads the file, applies the fixes and asks again. No human relays in between.
- Approving tasks and merging the implementation still belong to the human.
Once, after the reviewer was restarted, its name was gone and agent prompt failed with agent_not_found. An output filter hid the original exit status, making the command look successful. Automation should preserve both herdrās exit status and its full output. Searching for error strings is useful for diagnosis, not as a substitute for checking success.
if output=$(herdr agent prompt reviewer "..." --wait --timeout 2400000 2>&1); then rc=0else rc=$?fiprintf '%s\n' "$output"if [ "$rc" -ne 0 ]; then exit "$rc"fiSeveral builders and worktrees
Section titled āSeveral builders and worktreesāFor the stage that builds services in parallel, I added three builders. Each builder owns one service (payment, cart, account) and works in its own worktree. The worktrees were also created with herdr.
herdr worktree create --cwd <repo> --base main --branch feat/cart \ --path ../shop-cart --label cart --no-focusThe skill says not to create a workspace or worktree the human did not ask for. Here the layout came from the humanās parallel development plan, so it meets that condition. The rules that came out of running it:
- Give each builder its own worktree. When Gradle builds ran at the same time in one working tree, the build broke with
NoSuchFileException. - Give every file that several builders touch a single owner:
settings.gradle.kts,AGENTS.md, the service template document,asyncapi.yamland the shared platform modules. - Commit documents (intent, spec, review) to the main checkout so the human can read them right away, and commit implementation to the worktreeās
feat/<svc>branch. The human merges into main.
Where the rules live
Section titled āWhere the rules liveāThe skill only covers general herdr rules. Project rules, such as who uses which name, how the reviewer replies, and the worktree and file ownership rules, went into the repositoryās CLAUDE.md (the āparallel developmentā section) and Claude Code project memory. This gives freshly started sessions, and sessions whose conversations were compacted, a place to look up the same rules again.
The memory also got the line āload the herdr skill before any herdr workā. One session had been calling the CLI from memory without reading the skill. Having the skill installed does not guarantee that the agent reads it.
Local agent and remote VM agent
Section titled āLocal agent and remote VM agentāThe third setup spans machines. OmO on a local Mac (an OpenCode-based agent) hands work to Poppy (a Hermes agent) on a cloud VM. This post itself was requested that way.
Connecting a remote machine
Section titled āConnecting a remote machineāherdr offers three ways to work with a remote machine. Following the official docs:
- SSH in and run
herdron the remote, the same way as tmux. - Attach the local UI to one remote session with
herdr --remote <ssh-target>. - Save the remote with
herdr machine add <ssh-target> --label <label>and see Local plus several remote machines together in the local sidebar.
I used the third. The help describes machine add as āPrepare the remote Herdr server and save an SSH machineā. It checks for a compatible herdr server on the remote and, if one is missing or incompatible, installs or replaces it after asking for approval before saving.
When local herdr attaches to a remote machine, it opens an OpenSSH ControlMaster connection. The options I saw were ControlPersist 600, BatchMode, and StrictHostKeyChecking yes, and the remote side runs herdr remote-client-bridge. The temporary SSH config file for this connection lives under the macOS temp folder as herdr-ssh-<pid>-<N>/config. Because the path contains the herdr process ID, it changes whenever the herdr process changes.
Local 0.9.5 against remote 0.9.0
Section titled āLocal 0.9.5 against remote 0.9.0āThe 0.9.5 docs recommend a --machine prefix for remote automation, as in herdr --machine <label-or-id> agent list. Running that locally ended like this.
$ herdr --machine my-agent-vm agent listremote Herdr does not support machine API forwarding; update Herdr on this machineAt the same moment herdr machine status showed the machine as reachable. The connection is alive, but remote 0.9.0 does not support --machine API forwarding. The remote 0.9.0 help shows more of the gap.
| Command | Local 0.9.5 | Remote 0.9.0 |
|---|---|---|
machine subcommands | list, status, reconnect, add, rename, remove, enable, disable | list, add, rename, remove, enable, disable |
worktree subcommands | list, create, open, remove | list, create, open, remove |
agent prompt help | same as the text above | same as the text above |
Remote 0.9.0 has no machine status or machine reconnect. The worktree command, which creates Git worktree-backed workspaces, exists in both versions.
Upgrading the remote herdr was an option, but replacing that VMās herdr server means restarting the panes and agents on it. For now I reuse the SSH connection herdr already opened instead. I find herdrās ssh command in the local process list, pull out the -F config file and the -S ControlMaster socket path, and use the two to run herdr agent prompt directly on the remote.
ssh -F "$F" -S "$S" -o BatchMode=yes my-agent-vm \ 'herdr agent prompt w1:p1 "request body" --wait --timeout 60000'Because it reuses an already authenticated connection, no new authentication is needed. It does depend on herdrās internal paths, so once the remote is on 0.9.5 or later, moving to --machine is the right call.
A channel in the other direction
Section titled āA channel in the other directionāThat opened the path from local to remote. The other direction was the problem. The remote Poppy had no way to report results or ask the local OmO for something. I compared three options.
| Option | What the remote gets | Decision |
|---|---|---|
| pull: the remote writes files to an outbox folder and the local side reads them periodically | nothing, it only writes files | adopted |
ssh -R reverse tunnel so the remote can reach local herdr | control over local panes | rejected |
| turn on Mac Remote Login (sshd) and upgrade remote herdr for a two-way machine setup | a login path into the local machine | rejected |
A reverse tunnel is the same as handing the remote agent the ability to type anything into local panes. Mac Remote Login was off at the time, and with VPN and NAT in the way it was unclear whether the remote could reach the Mac at all. It was also the most complex to set up.
The pull option gives the remote no permissions. The local side only reads the remote folder over the SSH connection it already has. When the local side needs to reply to Poppy, it puts the reply into the remote pane with herdr agent prompt again.
The outbox reader script
Section titled āThe outbox reader scriptāThe local OmO runs this script as an always-on monitor at a 60-second interval. The remote host name has been replaced with a generic value.
#!/usr/bin/env bashset -euo pipefailHOST=my-agent-vmSTATE="${XDG_STATE_HOME:-$HOME/.local/state}/agent-outbox/seen"mkdir -p "$(dirname "$STATE")"; touch "$STATE"line=$(ps -ax -o command= | grep -E "^ssh .* -S [^ ]+ .*$HOST" | grep -v grep | head -1 || true)[ -z "$line" ] && { echo "herdr SSH connection to $HOST not found" >&2; exit 2; }F=$(sed -E 's/.* -F ([^ ]+) .*/\1/' <<<"$line")S=$(sed -E 's/.* -S ([^ ]+) .*/\1/' <<<"$line")ssh_r() { ssh -F "$F" -S "$S" -o BatchMode=yes -o ConnectTimeout=10 "$HOST" "$@"; }files=$(ssh_r 'cd $HOME/omo-outbox 2>/dev/null && ls -1 -- *.md 2>/dev/null' | grep -E '^[A-Za-z0-9._-]+\.md$' || true)new=$(comm -23 <(printf '%s\n' "$files" | sed '/^$/d' | sort) <(sort "$STATE"))[ -z "$new" ] && exit 0for f in $new; do echo "=== REQUEST $f"; ssh_r "cat \$HOME/omo-outbox/$f"; echo "$f" >>"$STATE"; donePiece by piece:
- Finding the connection:
pslists local processes, and the script picks the ssh command that has a-Ssocket option and the remote host name. That is the ControlMaster connection herdr opened. If none exists, the script exits with code 2 so the monitor can tell āno connectionā apart. As noted above, the config path changes with each herdr process, so the script looks it up every time instead of hardcoding it. FandS: the-Fconfig file and-Ssocket path from that line.ssh_rconnects with those two. WithBatchMode=yesit never stalls waiting for a password.- Filtering file names: the remote
lsoutput is filtered to.mdnames made only of letters, digits, dots, underscores, and hyphens. These names go inside a remote shell command on the next line, so the filter keeps an oddly named file from being interpreted as another command by the remote shell. - Choosing new files: the remote list and the local
seenfile are sorted, andcomm -23keeps names that exist only on the remote. - Read and record: each new file is printed with
catand its name is appended to the localseenfile.
The design keeps three rules. The remote is only read, and the record of what has been read lives only on the local side. A remote file is never edited after it is written; additions go into a new file named YYYYMMDD-HHMMSS-slug.md. That way the file name alone tells whether content is new, with no need to compare modification times or contents. Finally, the remote agent gets no permission that reaches into the local machine.
Problems we hit
Section titled āProblems we hitāherdr skill not showing up
Section titled āherdr skill not showing upāIn the reviewer session, the herdr skill did not appear in Claude Codeās skill list. The cause was that the skill was installed in a different path from where Claude Code looks. A symbolic link under .claude/skills in the home directory pointing to that path fixed it.
To the receiver it is keyboard input
Section titled āTo the receiver it is keyboard inputāA prompt sent by herdr is not an agent protocol message like ACP. As the official docs describe, it writes text and Enter into the terminal, and from the receiving agentās point of view it is the same as a person typing. Because it is not a structured message, the receiver is responsible for checking the content.
When I sent a long body over SSH, the tilde dropped out, and a time range written as 09:00 tilde 16:30 arrived as 09:16:30. I believe it was lost somewhere along the input path, but I did not confirm the exact cause. Since then I avoid the tilde in request text, and the receiver rechecks the original intent when a time or path value looks wrong.
The sidebar display name follows the session name
Section titled āThe sidebar display name follows the session nameāThe local OmO runs in a setup called OmO Native, and its actual engine is senpi. herdr recognizes that pane as the pi kind, and agent prompt --wait and agent read both work. The problem is that the sidebar shows the session name instead of the agent name.
pane report-metadata reports what its help calls ādisplay-only pane metadataā, with options such as --title, --display-agent, --clear-display-agent, --state-label STATUS=TEXT, and --token. Setting --display-agent by hand changes the name briefly, but it does not stick. Tracing the cause, I found that the herdr extension built into senpi reports both title and display_agent as the session name in reportTitle. So the display name follows every session rename, and a hand-set value is overwritten on the next report.
As of 2026-10-29, I have opened OmO issue #11397 and senpi fix PR #4582; the PR has not been merged. The one-line change, tests, change fragment, and CLI QA are recorded in the senpi contribution article. There was an earlier, separate issue about herdr being unable to put prompts into an OmO Native pane, but that was a prompt delivery problem and it is already closed. It is a different problem from this one.
Connection and network
Section titled āConnection and networkāWith the VPN on, remote connections and uploads were restricted. On a day the connection dropped, herdrās temporary SSH config file was gone, so the outbox script could not find the connection either. Having a separate exit code 2 in the script helped here. I check the connection state before sending a request.
Lessons
Section titled āLessonsāCollaboration principles
Section titled āCollaboration principlesā- Give agents names and repository boundaries. A name lets you address a request, and a boundary lets you answer āwho changed this fileā.
- Let a session with a different context review. A session finds it hard to doubt its own decisions. The reviewer runs the build and tests itself.
- Put human approval at every document stage. No implementation before tasks are approved, and a human does commit, push and sync.
- Confirm delivery from the screen or a file. Reply text, a commandās exit code and a āfixedā report are things to verify, not evidence. Check with something you can see directly: the diff,
herdr agent read, the outbox file.
Using herdr
Section titled āUsing herdrā- Check the targetās
agent_statuswithagent getbefore sending. If it isworking, the--waitresult may be the end of the previous turn. --waitandagent waitwait for states, not turns.- If local and remote herdr versions differ, commands in the docs may not work on the remote. Read the remote
--helpfirst. - For the reverse channel, a pull model that gives the remote no permissions was the simplest.
- A prompt is keyboard input. Avoid fragile characters, and have the receiver recheck values.
- Most of the tips above are already in the herdr skill. When handing herdr work to an agent, have it read the skill first, and since the installed copy may be older than the binary, check the current version with
herdr --skill. - At session start, check names with
herdr agent list. A name disappears when its agent exits. - Preserve herdrās exit status and full output even when filtering the display. Searching for error strings helps diagnosis but does not replace checking success.
- With several builders, give each its own worktree and decide who owns each shared file.