Worktrees for Parallel Agents
Why every agent session gets its own worktree instead of fighting over one checkout.
Running three coding agents on one git checkout is how you lose an afternoon to stash conflicts. The too.foo monorepo instead keeps a bare too.foo repo plus one worktree per active task (analytics-page, ds-wt, and so on).
The pattern
Each worktree tracks agent/<topic> rebased onto origin/main. Agents never commit to main directly; they merge through PRs once fleet-score --regress is clean.
What breaks without it
- Agent A edits
pnpm-lock.yamlwhile Agent B runspnpm install. - Two agents touch the same
app.jsonand the second push wins silently. - A long-running build holds
dist/while another agent tries to deploy.
Worktrees isolate all of that. The cost is disk — acceptable on a machine that already hosts the whole fleet.
Practical rule
One slug per worktree per session. When the queue says “drain fleet-next”, pick the next slug in this tree, not every slug in the fleet.