The question
Say it happens anyway — two subagents both need to write to the same file. Then what?The answer
Avoid the collision by design first. Isolate with worktrees when it can’t be avoided.1 — Partition by design
Split work so no two subagents own the same mutable file. Exactly what the previous question’s “non-conflicting” check catches before delegation happens.2 — If unavoidable
Each subagent gets its own git worktree — a separate working directory, own branch, same repo history. Edits in one worktree never touch files in the other while both run.3 — Merge time
Reconciled through a normal git merge — if the changes genuinely overlap, that surfaces as an ordinary merge conflict, resolved the standard way. Not something the agents negotiate live.Source
code.claude.com/docs/en/worktrees — Worktree isolation (isolation: worktree) is a documented, native Claude Code feature for subagents and parallel sessions — not a third-party workaround.
Continue the walkthrough
When to delegate
Continue to topic 12 of 14.