Source-first reader · whitepaper edition

The Swarm: Parallel Coding Agents in Git Worktrees

Read the full paperAll rights reserved · quotes onlyRead panel by panel

The paper is the spine. Underlined passages carry a numbered comic note — click one and the panel pops up alongside the text it explains. Between sections, the full comic page is inserted as a break.

the paper at a glanceIsolation, not more agents, makes parallel coding safe · 19 sections
01 · In our words
/p/1full text

Isolation, not more agents, makes parallel coding safe

A single coding agent handles a repo's tasks one at a time even when those tasks are independent. The session's promise is to run many agents on one repository without collisions by giving each its own isolated space via git worktrees. The plan is to deliberately fan work out to a fleet and then reassemble it on purpose rather than hope git sorts it out.

in short — one repo: shared object store; N agents: each isolated in a worktree.

From the paper · shown for commentary

 1

One agent is a queue. Your repo has ten independent things to do and it does them one at a time. Tonight we  2.

the comic take · 01the full page
This page introduces the premise that isolated worktrees let N agents share one repo safely.

This page introduces the premise that isolated worktrees let N agents share one repo safely.

↑ back to the passage
02 · The problem · in our words
/p/2full text

One agent is slow because it's a single-server queue

A lone coding agent processes a backlog one task at a time, which feels slow — but the delay isn't the model's speed. It's that a single agent is a queue with exactly one server. When four independent tasks wait behind one, none of them actually depend on the others; they're stuck only because of an accidental scheduling choice: one agent, one working tree, one thing at a time.

in short — slow model: not the real cause; single-server queue: the real bottleneck.

From the paper · shown for commentary

A single coding agent grinds your repo one task at a time.  1

Not one of those four waiting tasks needs the one above it to finish first.  2: one agent, one working tree, one thing at a time.

the comic take · 02the full page
This page reframes agent slowness as a queueing problem caused by having one server for independent tasks.

This page reframes agent slowness as a queueing problem caused by having one server for independent tasks.

↑ back to the passage
03 · The problem · in our words
/p/3full text

One shared folder means parallel edits race and corrupt

The obvious first attempt — many agents in the same directory — works briefly and then breaks. The danger is that it fails as damaged work, not as a clean error: overwritten files, mixed-up staging, shifting HEADs, and lockfile collisions. A single working tree is one shared mutable surface, and parallel edits on shared state are a race you can't win by adding more runners. What's missing is isolation, a primitive git already provides.

in short — shared folder: races silently; isolation: git already ships it.

From the paper · shown for commentary

This is everyone's first idea, and it half-works for about four minutes. That is what makes it dangerous:  1.

 2. Parallelism on shared mutable state is a race, and you do not get to win a race by adding more runners.  3.

the comic take · 03the full page
This page shows why pointing many agents at one folder half-works then silently corrupts work.

This page shows why pointing many agents at one folder half-works then silently corrupts work.

↑ back to the passage
04 · The concept · in our words
/p/4full text

The conductor splits, dispatches, and merges — never codes

One orchestrator owns the split and never writes code. It has exactly three jobs — split the backlog into non-overlapping slices, dispatch one agent per isolated slice, and merge the finished branches. Each is a judgement only the conductor can make because a worker can't see the other workers. The conductor's only products are the plan and the merge; the moment it starts editing code, it becomes a fourth worker with a global view — the one role that can't be isolated.

in short — split: the only creative step; dispatch: mechanical; merge: mechanical until it isn't.

From the paper · shown for commentary

One orchestrator owns the split. It does not write code.  1, because a worker cannot see the other workers.

 2. If you find yourself editing code as the conductor,  3 with a global view, which is the one role that cannot be isolated.

the comic take · 04the full page
This page defines the conductor pattern and its three exclusive jobs.

This page defines the conductor pattern and its three exclusive jobs.

↑ back to the passage
05 · The concept · in our words
/p/5full text

Worktrees give N desks; branches only give N histories

Branching isn't the primitive you need — it gives many histories but only one working tree, so agents still serialize on switching files in place. Two agents can't be on two branches at once. Git worktrees instead give many branches with many working trees: each agent gets its own directory, index, and HEAD, all backed by the same shared object store. The result is N desks on one clone's worth of objects, a trick git has shipped since version 2.5.

in short — git switch: one tree, agents serialize; git worktree: N trees, one object store.

From the paper · shown for commentary

 1

Same history, N desks.  2 That is the whole trick, and it has shipped in git since 2.5.

the comic take · 05the full page
This page contrasts in-place branch switching with worktrees as the real isolation primitive.

This page contrasts in-place branch switching with worktrees as the real isolation primitive.

↑ back to the passage
06 · The concept · in our words
/p/6full text

A worktree isn't a sandbox — shared config corrupts authors

A worktree isolates four things — working tree, index, HEAD, and checked-out branch — but silently shares everything else, including .git/config, refs, and hooks. When three agents each set their identity the obvious way, they race on the shared config file: two commands fail to lock it, yet all three commit anyway. Commit messages look right, but the author field is wrong on every commit — the one field you'd use to audit who did what. A worker may write its own tree but must never write the shared config.

in short — isolated: tree, index, HEAD, branch; shared: config, refs, hooks.

From the paper · shown for commentary

 1

The commit messages are right, so the log looks fine at a glance.  2 - it is whichever agent won the race - which is the one field you would use to audit who did what. A worker may write its tree.  3

the comic take · 06the full page
This page shows a worktree isolates only four things and that shared config silently corrupts authorship.

This page shows a worktree isolates only four things and that shared config silently corrupts authorship.

↑ back to the passage
07 · The concept · in our words
/p/7full text

Four commands stand up N isolated arenas cheaply

The entire setup half of the pattern is four commands: three `git worktree add` calls creating a branch each, plus `git worktree list` to verify. Every `../sw/NN` is a full checkout an agent can build in without touching the others. Crucially, there's no re-clone and no second copy of history — the object store is shared, so the marginal cost of another agent is just its working files. Fan-out is genuinely cheap.

in short — worktree add: one arena per task; shared objects: no re-clone cost.

From the paper · shown for commentary

 1, and every one of them ran on this laptop tonight.

Each ../sw/NN is a full checkout an agent can build in without touching the others. Note what you did not pay: no re-clone, no second copy of history. The object store is shared, so  2.

the comic take · 07the full page
This page shows the four setup commands that stand up one isolated worktree per task cheaply.

This page shows the four setup commands that stand up one isolated worktree per task cheaply.

↑ back to the passage
08 · The replay · in our words
/p/8full text

Fan-out is cheap; fan-in is where the real work lives

A real run on a scratch repo split into three independent tasks, ran three agents concurrently in three worktrees, and merged them back. The before-and-after git graphs show three features advanced in the wall-clock time one agent needs for one. The fan-out cost only four commands — the real work was the fan-in, the serial merges and conflict triage that the later slides cover in depth.

in short — fan-out: four commands, cheap; fan-in: where real work lives.

From the paper · shown for commentary

A real run on a scratch repo: split into three independent tasks, three worktrees, three agents fired concurrently, then merged back. Before, and after.

 1 The fan-out cost four commands.  2, and slides 14 to 16 are entirely about that half.

the comic take · 08the full page
This page replays a real three-agent run showing fan-out is cheap and fan-in is where effort lives.

This page replays a real three-agent run showing fan-out is cheap and fan-in is where effort lives.

↑ back to the passage
09 · The replay · in our words
/p/9full text

Teardown can follow a link outward and delete real data

To keep the swarm cheap, people link a shared `.venv` or `node_modules` into each worktree. That same trick arms a data-loss trap: if a worktree carries a junction pointing outside itself, removing the worktree follows the link outward and deletes the target's contents — then exits 0 with no output at all. `rm -rf` and `shutil.rmtree` behave identically. This actually fired in the team's own fleet nine hours before doors.

in short — linked deps: makes swarm cheap; teardown: follows link, deletes data.

From the paper · shown for commentary

N cheap worktrees usually means linking a shared .venv or node_modules into each one.  1

 2 rm -rf and shutil.rmtree do the same thing. This fired for real in our own agent fleet nine hours before doors, and there it at least printed an error afterwards. Here it said nothing at all.

the comic take · 09the full page
This page shows how linking shared deps can make worktree teardown silently delete real data.

This page shows how linking shared deps can make worktree teardown silently delete real data.

↑ back to the passage
10 · The replay · in our words
/p/10full text

Rehearsing a plan catches failures that pass silently

The deck was planned in June but the lab was run today, before it was written. The plan mostly survived; where it didn't, the slides changed rather than the run. Three edits resulted — a whole slide added, an agent-identity fix, and a teardown unlink step. Every VCN lab gets run before it's taught because it's the cheapest quality gate available: tonight it cost about twenty minutes and caught two silently-passing failures that would otherwise have reached fifty laptops.

in short — dry run: twenty minutes; two silent bugs: caught before fifty laptops.

From the paper · shown for commentary

This deck was planned in June and the lab was run today, before it was written. The plan survived mostly intact.  1

Every VCN lab gets run before it gets taught.  2: tonight it cost about twenty minutes and it caught  3 and would have reached fifty laptops.

the comic take · 10the full page
This page argues that running the lab before teaching it is a cheap gate that catches silent failures.

This page argues that running the lab before teaching it is a cheap gate that catches silent failures.

↑ back to the passage
11 · Step 0 · in our words
/p/11full text

Pick disjoint tasks; overlapping ones are really one task

The first lab step is to open your own repo and name three tasks that touch disjoint sets of files. Independence is the whole game, and this is the only step where you actively choose it. The setup is three `git worktree add` commands plus a list, with cross-platform variants shown. The hard gate: you want four rows and three distinct branch names, and if two tasks want the same file they are really one task — merge them now, before any agent touches anything.

in short — disjoint files: parallelizable; shared file: really one task.

From the paper · shown for commentary

Open your own repo.  1, and this is the only step where you get to choose it.

Checkpoint · hard gate Four rows from git worktree list, three distinct branch names.  2 Merge them now, before an agent touches anything.

the comic take · 11the full page
This page defines step 0: pick three tasks touching disjoint files, since independence is everything.

This page defines step 0: pick three tasks touching disjoint files, since independence is everything.

↑ back to the passage
12 · Step 1 · in our words
/p/12full text

Set identity via env vars, one agent per tree

Each worktree gets one terminal and one agent, driven by z.ai plus Claude Code and fueled by Nebius credits. The identity is set through `GIT_AUTHOR`/`GIT_COMMITTER` environment variables per process — never `git config`, which writes the shared file and races (the slide 6 bug). The brief follows three rules: tight named scope, stay in your own tree with no cross-task reads, and commit only when tests are green. Isolation is enforced by the filesystem, not by trusting the agent to behave.

in short — env vars: per-process identity, safe; git config: shared, races.

From the paper · shown for commentary

One terminal per worktree. z.ai + Claude Code drives each worker; Nebius credits fuel the fleet.  1

The brief, in three rules Tight scope (one task, named). Stay in your tree (no cross-task reads - agents must not coordinate). Commit on green (a branch is the handoff, not a diff you paste).  2

the comic take · 12the full page
This page assigns one agent per tree with identity set via per-process env vars.

This page assigns one agent per tree with identity set via per-process env vars.

↑ back to the passage
13 · Step 2 · in our words
/p/13full text

Poll the fleet's status but never help by editing

While the workers run, the conductor acts as a scheduler — checking who's alive, who has committed, and who is stuck — using `git worktree list` and a loop over each tree's last commit as a status board. The temptation to open an editor must be resisted: the moment you edit, you become a fourth worker with a global view. The checkpoint verifies each tree's commit is authored by its own agent; if two rows share an author, the slide 6 bug is present and must be fixed before merging, since attribution becomes permanent afterward.

in short — poll: who's alive, stuck, done; edit: becomes a fourth worker.

From the paper · shown for commentary

While the workers run, you are a scheduler: who is alive, who has landed a commit, who is stuck.  1

Checkpoint Each tree shows a commit authored by its own agent. If two rows share an author name, your identity scoping is broken and you have the slide 6 bug - fix it before you merge, because  2.

the comic take · 13the full page
This page tells the conductor to poll the fleet's status without editing any code.

This page tells the conductor to poll the fleet's status without editing any code.

↑ back to the passage
14 · Step 3 · in our words
/p/14full text

Merge serially with --no-ff so each conflict is traceable

Fan-out is parallel but fan-in must be serial. The temptation is to merge everything at once and let git sort it out — don't. Merging one branch at a time means any conflict is traceable to exactly which branch introduced it. Using `--no-ff` keeps a merge commit per agent so the graph still shows who did what after the fan-in, which a fast-forward would erase. Two clean merges and one conflict is a normal, healthy result; a swarm that never conflicts probably had tasks too small to be worth splitting.

in short — parallel fan-out: agents run at once; serial fan-in: one merge at a time.

From the paper · shown for commentary

The temptation is to merge everything at once and let git sort it out. Do not.  1

 2 after the fan-in. a fast-forward erases that.

the comic take · 14the full page
This page mandates serial --no-ff merges so conflicts stay traceable to one branch.

This page mandates serial --no-ff merges so conflicts stay traceable to one branch.

↑ back to the passage
15 · Step 4 · in our words
/p/15full text

Keep both intents; tests catch clean-merging semantic conflicts

When two agents edited a file nobody expected to be shared, neither is wrong — the merge isn't a contest, both features should survive, so keep both. When it's harder, hand the conflict to a fresh agent with both intents. But the truly dangerous case is the semantic conflict: both branches merge cleanly with no markers, yet the result is broken — one agent renamed a field, another wrote a caller for the old name elsewhere. Measured at 5–10% of parallel-agent runs, git will never flag it, so run the tests after the last merge.

in short — textual conflict: keep both intents; semantic conflict: tests only, after last merge.

From the paper · shown for commentary

The merge is not a contest to pick a winner -  1.

 2 - agent 01 renamed a field, agent 02 wrote a caller for the old name in a different file. Measured at 5 to 10 percent of parallel-agent runs (CodeCRDT, arXiv 2510.18893). Git will never flag it.  3 - that is the only place it surfaces.

the comic take · 15the full page
This page teaches resolving conflicts by intent and catching semantic conflicts with tests.

This page teaches resolving conflicts by intent and catching semantic conflicts with tests.

↑ back to the passage
16 · Step 5 · in our words
/p/16full text

Unlink internal links first, then remove, and keep -d

Teardown order is safety-critical. If you linked anything into a worktree to make it cheap, you must drop that link first — `rmdir` removes only the link, while `rm -rf` follows it and deletes the target. Only then remove the worktree, prune stale metadata, and delete the branch. Skipping the unlink reproduces the slide 9 data-loss that exits 0 silently. Keep `-d` rather than `-D`, because its refusal to delete unmerged branches is the only thing protecting an agent's unfinished work.

in short — 1. unlink: drop internal links first; 2. remove: then worktree and branch.

From the paper · shown for commentary

Stale trees pile up and stale branches pile up faster. But if you linked anything into a worktree to make it cheap,  1.

Checkpoint git worktree list is back to one row. If you skipped step 1 and something outside the repo is now empty, that is slide 9, and it exited 0 while doing it.  2

the comic take · 16the full page
This page gives the teardown order: unlink internal links first, then remove, and keep -d.

This page gives the teardown order: unlink internal links first, then remove, and keep -d.

↑ back to the passage
17 · Gotchas · trust gates · in our words
/p/17full text

Fan out only work that shares no write surface

Fanning out isn't always a win: CodeCRDT's 600 trials measured up to 21% speedup on some task shapes and up to 39% slowdown on others. The one-sentence test is to parallelize only work that shares no write surface — if two tasks edit the same file they are one task, and splitting them turns a five-minute edit into a merge you reason about twice. Two human trust gates bracket the run: Gate 1 reviews the conductor's split before fan-out, and Gate 2 reviews the merged result before it ships. Agents commit; humans integrate.

in short — +21% faster: disjoint write surfaces; -39% slower: shared write surface.

From the paper · shown for commentary

Those last two numbers are measured, not ours: CodeCRDT (arXiv 2510.18893) ran 600 trials of parallel LLM code generation and found  1. Fanning out is not free and it is not always a win. The test is one sentence:  2. If two tasks edit the same file, they are one task, and splitting them converts a five-minute edit into a merge you reason about twice.

Gate 1 · before fan-out  3 This is the step that decides whether the night is cheap or expensive, and no worker can check it.

the comic take · 17the full page
This page gives the when-to-fan-out rule with measured numbers and the two human trust gates.

This page gives the when-to-fan-out rule with measured numbers and the two human trust gates.

↑ back to the passage
18 · Leave-with · in our words
/p/18full text

You leave with a conductor, isolation map, playbook, and test

The session's four deliverables: a conductor that fans N agents across N worktrees on one repo; per-worktree isolation plus a clear map of the four things worktrees do not isolate; a fan-in playbook covering serial merges, conflict-by-intent resolution, and a teardown that unlinks before removing; and the one-sentence test for whether work should be fanned out at all. Together they turn a single-agent workflow into a disciplined fleet.

in short — conductor: fans N agents; isolation map: what's not isolated; fan-in playbook: merge, resolve, teardown.

From the paper · shown for commentary

01  1

02 Isolation per worktree - and  2. 03  3 04 The one-sentence test for whether work should be fanned out at all.

the comic take · 18the full page
This page enumerates the four concrete things the reader leaves with.

This page enumerates the four concrete things the reader leaves with.

↑ back to the passage
19 · Paths forward · in summary
/p/19full text

Split where nothing overlaps, then let the fleet run

You arrived with one agent and leave with a fleet — but the swarm only works when isolation is real, splits are truly disjoint, and humans gate both the plan and the merge. Take a repo with more than one thing to do, split it where nothing overlaps, and let the agents run in isolated worktrees, then integrate serially by intent.

Next steps: grab the cheatsheet, conductor prompt template, and lab transcript from Telegram; join Wednesdays at F10 or Saturdays at F9; and bring the swarm to session #50, Own the Stack, where the same pattern gets pointed at infrastructure.

the comic take · 19the full page
Comic page 19
↑ back to the passage

source materials

everything this reading draws on — add your own below

staying on the right side of copyright

how this reading mode is built
1 · quote less, explain more

Each snapshot is a short excerpt paired with substantial original commentary — the comic. The comic is the point of the page; the quote is evidence for it.

2 · always point home

Every excerpt links to the full paper and never substitutes for it — trimmed passages say so, out loud, with a link to continue at the source.

3 · prefer open licenses

Openly licensed papers get fuller snapshots with attribution. All-rights-reserved papers fall back to minimal quotation.