Run multiple AI coding agents in parallel on one repo

ai agents & parallel sessions

// what it does

The core recipe for parallel agent work: one worktree and one branch per agent. Two agents sharing a single checkout trample each other — conflicting edits, one agent staging the other's half-finished files, .git/index.lock contention, dev servers rebuilding on foreign changes. With a worktree each, every agent gets its own directory, index, and HEAD while sharing the repository's history, so results land as sibling branches you can diff, test, and merge.

// shell

$ git worktree add -b agent/auth ../myapp-agent-auth main
$ git worktree add -b agent/search ../myapp-agent-search main
$ git worktree list

// gotcha

Give every agent its own branch, never the same one — Git enforces this by refusing to check out a branch twice. And launch each agent with its working directory inside its worktree: an agent started in the main checkout will happily edit the main checkout.

// resources