Parallel Agents via Git Worktrees
Sequential agents are the bottleneck. Git worktrees give each agent an isolated filesystem, separate branch, and zero blast radius. Spawn three agents in parallel and cut your implementation time by 3x.
Sequential is slow. If you are running one Claude Code session at a time, waiting for it to finish before starting the next task, you are operating at a fraction of the potential. When tasks are independent — a refactor that does not touch the same files as a new feature, a test suite that does not depend on an API change in progress — there is no reason to serialize them.
Git worktrees are the mechanism. Parallel Claude Code sessions are the payoff. This lesson is about the setup that makes it safe, repeatable, and fast.
Why Sequential Agents Are the Bottleneck
A single Claude Code session handles one task thread at a time. Even with high-quality prompts and efficient tool use, a complex feature — build the thing, write the tests, fix the edge cases — takes real wall-clock time. If you have three such features queued, sequential execution means you wait for all three in series.
The alternative is obvious in every other domain. A software team with three engineers works three tasks in parallel and converges at review time. The AI equivalent is three Claude Code sessions, each on its own branch, each isolated from the others.
The problem with naive parallelism is collisions. If two sessions both have the project directory in their working set, they can overwrite each other's changes. Session A edits lib/auth.ts. Session B, working on something else, reads lib/auth.ts in its original state. Session A commits. Session B overwrites. The work is lost or corrupted.
Git worktrees eliminate the collision by giving each session a physically separate directory.
How Git Worktrees Work
A git repository normally has one working tree — the directory where you check out files. git worktree add checks out a branch into a new directory, creating an independent working tree that shares the same git history and object store but has its own file state, staging area, and checked-out branch.
The key: each worktree directory is isolated. What Claude Code Agent A writes to /project-auth/lib/auth.ts does not touch /project-api/lib/auth.ts or /project-tests/lib/auth.ts. They are literally different files on disk.
Setting Up Parallel Sessions
Step 1: Start from a clean main
cd ~/Documents/Dev/myproject
git checkout main
git pull
Always pull before cutting worktrees. You want agents starting from current state, not diverged from it.
Step 2: Create the branches and worktrees
# Agent A: auth refactor
git branch feature/auth-refactor
git worktree add ../myproject-auth feature/auth-refactor
# Agent B: new API client
git branch feature/api-client
git worktree add ../myproject-api feature/api-client
# Agent C: test coverage
git branch feature/test-coverage
git worktree add ../myproject-tests feature/test-coverage
Each command creates a new directory (../myproject-auth, etc.) with the specified branch checked out. The directory is a full, usable copy of the repo's working tree.
Step 3: Spawn Claude Code in each
Open three terminal tabs. In each tab, navigate to the worktree directory and launch Claude:
# Tab 1
cd ~/Documents/Dev/myproject-auth
claude
# Tab 2
cd ~/Documents/Dev/myproject-api
claude
# Tab 3
cd ~/Documents/Dev/myproject-tests
claude
Give each agent its task. They run in parallel. They cannot collide.
Coordination Patterns
Independent tasks — no coordination needed. The ideal case. Three tasks with completely non-overlapping file sets. Agents work simultaneously. You merge the PRs when each is done. No conflicts because the file sets never touched.
Sequential dependencies — ordered merges. Agent A builds a new utility function. Agent B's task depends on that utility. Start Agent A. When A's PR is merged and main is updated, Agent B's worktree pulls main and continues. The dependency is temporal, not spatial.
Shared interface contracts. Two agents need to agree on a function signature or data structure. Define the contract before spawning agents. Write it down in a shared file (a types file, a schema file) and commit it to main before cutting the worktrees. Agents implement against the contract independently.
Managing Blast Radius
The blast radius of an agent is the scope of damage if it makes a mistake. In a shared working tree, that radius is the entire codebase. In a worktree, the radius is the branch — maximum damage is the work on that branch, which has not been merged yet.
This is structural safety, not procedural. You do not need to trust the agent to stay in bounds. The filesystem enforces the bounds.
When to discard a worktree: If an agent goes sideways — wrong approach, bad state, a decision you do not want to untangle — delete the worktree and branch, cut fresh, restart with a better-scoped prompt.
git worktree remove ../myproject-auth
git branch -D feature/auth-refactor
Two commands. The bad work is gone. Main is untouched. This disposability is part of the value.
Give each agent a clear what. The worktree isolates the how.
Convergence — Merging Parallel Work
When all agents finish:
# Review each agent's work
cd ~/Documents/Dev/myproject-auth
git log main..HEAD --oneline # See what the agent committed
git diff main # See the full diff
# If satisfied, push and open PR
git push origin feature/auth-refactor
gh pr create --title "feat: auth refactor" --base main
Repeat for each agent's worktree. Code review — from you or an automated reviewer — happens at the PR stage. Merge the PRs in dependency order if any exist. Clean up worktrees after merge.
Lesson 59 Drill
Take your next medium-sized task and consciously decompose it into two independent sub-tasks. Set up two worktrees, spawn two Claude Code sessions, and run them in parallel. Observe the wall-clock time compared to sequential. Observe that the isolation held — neither session touched the other's files.
After you merge both PRs, document the decomposition pattern. What made the task safely parallelizable? That pattern is the one to repeat.
Bottom Line
Sequential agents are the bottleneck when tasks are independent. Git worktrees give each agent its own directory, its own branch, and zero blast radius on parallel work. The setup is four commands: pull main, git branch, git worktree add, claude. Scope tasks to non-overlapping file sets to eliminate coordination overhead. Converge via PRs. Discard bad worktrees in two commands and restart clean. The compounding effect: every hour you would have waited sequentially becomes an hour of parallel output.