Summary: Worktrees and parallel agents
The one-sentence definition
Section titled “The one-sentence definition”A worktree is a separate working directory attached to the same git repository: multiple folders sharing one .git/, each with its own branch checked out.
The essential commands
Section titled “The essential commands”git worktree add <path> <branch> # attach existing branch as new worktreegit worktree add -b <newbranch> <path> <baseref> # create new branch in new worktreegit worktree list # see all attached worktreesgit worktree remove <path> # detach and delete (use --force for unsaved changes)git worktree prune # clean up records for manually-deleted foldersgit worktree lock <path> --reason "..." # prevent accidental pruninggit worktree unlock <path> # release the lockWorktree vs clone vs checkout-switching
Section titled “Worktree vs clone vs checkout-switching”| Tool | When to use |
|---|---|
| Worktree | Parallel branches on one machine; frequent context-switching; multi-agent workflows; save disk space |
| Clone | Truly independent copies; across machines; want isolation from teammates’ pushes |
| Checkout-switching | Sequential work, done with one branch before starting another, occasional swaps |
The constraint
Section titled “The constraint”One branch per worktree: cannot check out the same branch in two worktrees simultaneously. Workaround: different branches or detached HEAD if you need to inspect the same commit.
The four canonical use cases
Section titled “The four canonical use cases”- Review a teammate’s PR without disturbing your current work
- Hotfix during a feature: spin up a worktree off main, fix, ship, remove
- Side-by-side version comparison: inspect v1.4 and main simultaneously
- Multi-agent fleet: one worktree per agent, parallel work, shared history
Why worktrees are the Phase 4 substrate
Section titled “Why worktrees are the Phase 4 substrate”L14-L16 assume you can spin up multiple parallel working directories cheaply. Worktrees deliver this: one command to create, one to remove, near-zero overhead. Multi-agent AI workflows go from “annoying” with multiple clones to “trivial” with worktrees.
Voice anchor
Section titled “Voice anchor”Git stores snapshots. Every other command is just navigating those snapshots.
Worktrees don’t change the snapshots. They just give you more windows looking at the snapshot database simultaneously. Each window shows one branch; together, they show many.
What you carry into L14
Section titled “What you carry into L14”L14 covers the three multi-agent integration patterns built on top of worktrees: shared origin, per-agent fork, shared worktrees. Lead orchestration. Semantic-conflict catching at integration. All assume L13’s worktree foundation.