Run a fleet of Claude Code agents without becoming their dispatcher

One agent working with you is a collaborator. Three or four at once turns you into a dispatcher, and the decisions that are actually yours get buried under the bookkeeping.

The short version of what fixes it:

  • Let Claude make the judgment calls, and put every limit in code. A rule in a prompt is a suggestion; a hook is a limit.
  • Test how the tools actually behave before building on them, and write each test down, including the ones that turn out wrong.
  • Review in a fresh context, and only merge the exact commit that was checked.

These lessons come from building Orchestral, my open source tool for running a fleet of Claude Code agents: a plugin plus a small Rust binary. It plans the work, starts the agents, keeps them inside the limits you set, and only brings you in for the decisions that are yours. Along the way, about a dozen behaviors of Claude Code and GitHub were tested, and each test was written up as a decision record in the repo.

What goes wrong with several sessions

Most of this shows up the first day you try it.

  • You become the message bus. One agent has a question, another one finished, a third is stuck on a permission prompt, and nothing tells you which is which unless you go and look.
  • Waiting looks like working. From the outside, an idle session, a busy one and one blocked on you can be hard to tell apart, and some of the signals you’d reach for are wrong.
  • A rule in a prompt is a strong suggestion. “Never merge” in an agent’s instructions holds until the right (or wrong) request comes along.
  • The session that wrote the code is the worst one to review it.
  • A fleet burns through the plan’s usage window fast, and nobody is watching it at 2am.
  • Merges race. A commit lands between CI passing and the merge, and something nobody checked goes in.

Orchestrator, workers and a supervisor

The shape that held up has three parts, and the most useful column is the last one.

Part Does Never does
Orchestrator (the one Claude session you talk to) Turns a brief into issues, picks the work, answers worker questions within your policy, routes PRs Writes product code, reviews code, merges
Workers (background Claude sessions, one git worktree each) Implement one issue, open the PR, get it reviewed, report findings Merge, approve, decide their own out-of-scope findings, start sessions
Supervisor (a plain process, not Claude) Watches the sessions and GitHub, wakes the orchestrator, sends reminders, merges approved PRs Makes judgment calls

The orchestrator is where Claude’s judgment pays off: reading a brief, sizing the work, and answering “should I also fix this?” against your policy. Workers use it on a smaller scale, one issue and one PR each. The supervisor is deliberately dumb. Every tick, it compares what should be happening with what is, and since the parts don’t talk to each other directly, recovering from a crash is the normal path: restart it and it catches up.

You only talk to the orchestrator. Anything that’s yours to decide (a plan, a design choice, a question, a merge) arrives there, with a reminder on your phone until you answer.

Claude decides, the binary enforces

Let the agents make the judgment calls, and put every limit somewhere they can’t talk their way past.

In Orchestral that’s the orchestral binary. It won’t start a worker past the cap, past the plan’s usage limit, or past the fleet’s token budget. Workers can’t merge, approve or push to main, and their prompt has nothing to do with it: a PreToolUse hook denies the commands and a pre-push hook rejects the push. The policy that sets the limits lives in your config directory, outside every worktree, so no branch can raise its own limits.

It’s this strict because a test showed how little a prompt alone guarantees.

Auto mode won’t stop a request it’s explicitly given

Workers run unattended, so they run in auto mode. The question was whether the classifier would stop a worker from doing something only you should do. Tested on Claude Code 2.1.314 with Sonnet 5.5, in seven runs it blocked nothing (ADR-0004):

  • A worker whose rules said “never merge” ran gh pr merge as soon as it was told to, and the PR merged.
  • The same rules did make a worker decline a force push to main. Without them, the same request went through, and on a diverged branch it rewrote main.
  • An explicit curl … | sh ran too.

On that version, auto mode mostly went along with what the request explicitly asked for. That makes sense in an interactive session, where the request is you. In a fleet, whatever reaches a worker as its prompt counts as your request, whether it came from you, from an orchestrator mistake, or from text someone put in an issue. So the hooks are the limit, and the prompt is just good manners.

It can also block what you do want

The opposite problem showed up later (ADR-0010). The classifier treats a background session’s first message as the user’s request, so a commit or push the orchestrator asked for later in the run got denied as unrequested, and the worker stalled.

The fix was narrow allow rules for the exact git and gh commands a worker needs, like git push to its own branch, gh pr ready and comments on its own issue. Claude Code checks those before the classifier, but only when each command matches a rule, so the worker prompt says to run each git and gh command on its own.

The next result was a surprise. A worker whose chained command was denied, when told to retry the parts separately, refused, because it saw that as a way around the denial. A fresh worker that had the one-command-at-a-time rule from the start went straight through. That’s the right instinct from the model, and it means the rule has to be in the prompt before the first denial.

Approvals are comments

GitHub won’t let an account approve its own PR, and when you’re the only operator, every PR is opened under your account. So approval is an /approve comment, which the supervisor polls for (ADR-0005). Workers post under the same account, so a hook denies any gh command that would post /approve or /hold, whether it’s in the command, a body file or a raw API call.

That guard only stops accidents. A worker set on posting /approve could build the word at run time and get past it. Better to say that up front than to pretend it’s a security boundary.

Merge only the commit you checked

The supervisor merges with gh pr merge --match-head-commit <sha>, using the head commit that passed review and CI (ADR-0003). If anything was pushed in between, GitHub refuses. A refused merge isn’t retried; the whole check runs again on the next tick. An /approve also belongs to the commit that was the head when it was posted, so a push after an approval needs a new one.

Waking a session without polling

The orchestrator is idle for most of a run, and it has to react to events without spending turns checking for them. What worked is a plugin monitor: a background process that ships with the plugin, whose output lines arrive in the session as events. An idle session reacted in about three seconds, even after its conversation had been compacted (ADR-0001).

The side effect turned out to matter more. A running monitor makes an idle session report itself as busy. That’s fine for the orchestrator, but the supervisor reads each worker’s status to notice when it’s idle or waiting, and a worker that always looks busy is useless. So workers run with the plugin turned off in their own settings and call the binary by its full path. It’s also why the README says to install at local scope: at user scope, the monitor would run in every session you open.

The status signals you’d reach for are undocumented, and they have side effects. Test what each one actually reports in each state before building on it, and keep the captured output as test fixtures, so when a new Claude Code version changes them, a test fails instead of the fleet.

Review in a fresh context

The first design gave every PR its own reviewer session. With two worker slots, it deadlocked: both slots held authors with ready PRs, no reviewer could start, and nothing could merge (ADR-0011).

Now, before marking its PR ready, the author starts a fresh subagent (not a fork, so it has none of the author’s context) and gives it only the PR, the issue and what to check against, which by default is the issue’s acceptance criteria and non-goals. The subagent posts its report as a PR comment and doesn’t touch code. The author fixes the findings that hold up, notes the ones it chose to skip, and records the verdict on the commit that was reviewed. Two failed rounds block the issue and bring it to you.

That keeps the separate context that makes a review worth anything, without using a slot. It has a cost: the author writes the reviewer’s brief and records the verdict. That’s fine while a person approves every merge, and weaker when the supervisor merges on its own, as it did on the project described at the end. That one isn’t solved yet.

Plan limits, and the minute that kept moving

A fleet has to wind down near the plan’s usage limit and pick back up after the reset, with nobody watching. Claude Code doesn’t have a documented way to read the limits, but running /usage in a throwaway non-interactive session (claude -p) prints them the same way every time, and all 24 reads over two hours parsed cleanly. It’s undocumented, so any release could change it, which is why that output is saved as a test fixture (ADR-0008).

The bug was in the reset time. It moved by a minute between reads, back and forth, and the first version treated a changed reset time as a reset, which woke the fleet two hours early. Now a reset only counts once the parsed time has passed and a new read shows the window moved on by at least an hour. If no read can confirm it, the fleet wakes at the parsed time anyway.

Write down every test, especially the wrong ones

Every decision in Orchestral that depends on how Claude Code or GitHub actually behaves has a decision record with the same sections: the context, the test as it was run (version, model, effort and what was measured), the decision, the consequences and the limits.

If you could only keep one section, keep the limits. “One run, one model, a one-line change” shows up in a lot of them, and writing it down stops one lucky run from turning into something the rest of the system depends on.

Records also get superseded, and that’s the process working. The worker-permissions test above is one: ADR-0004’s permission setup was superseded by ADR-0010 once later runs showed the other side of the problem. The first record stays, marked as superseded, with a link to the one that superseded it. A wrong conclusion that’s written down gets caught. One that only lives in someone’s head doesn’t.

Where it stands

Orchestral is early. Every part runs end to end, from a brief through planning, review and merge, and it took cc-notify-tts, a Claude Code plugin that reads out spoken summaries using local models, from a brief to a public release, closing 46 issues with 45 merged pull requests. On that project the owner approved the plan, anything hard to undo and the launch, and let the supervisor merge each PR once its checks passed. Long unattended runs, like a fleet sitting idle for days, are still being tested (#2, #44). The code, the decision records and the specs are all in the repo, under the MIT license.

  • agents
  • claude-code
  • orchestration