blog

Git worktrees are the right primitive for parallel coding agents

Oct 29, 2026 1 min read agentsgitagentdeck

The moment you run two coding agents on the same repo you hit the obvious problem: they edit the same files. One rewrites a function while the other is reading it, and now neither result means anything.

You could clone the repo twice. It works, but you pay for a full copy, lose the shared object database, and have to reconcile branches by hand. A git worktree is the same idea done properly: another working directory, on its own branch, backed by the same repository.

What a task looks like

git worktree add ../task-login -b agent/login
# start the agent in ../task-login
# review, then either:
git merge agent/login
git worktree remove ../task-login   # or just discard it

Each agent gets an isolated directory and branch. Nothing it does touches your working copy until you decide to merge.

Races

The same trick gives you comparisons for free. Start 2 to 4 agents, or the same agent with different models, from one base commit and give them the same prompt. Because they all branch from the same point, the diffs are directly comparable and you merge the winner.

That is the idea behind the Task and Race features in Agentdeck. The worktree is the boring part, and the boring part is what makes the rest safe.