
Every AI coding agent I run — Claude Code, Cursor, Codex CLI, Aider, Continue — shares one annoying bottleneck: you cannot run two of them on the same checkout at the same time without the second stomping on the first. They share .git, they share the working tree, they share the index. One agent runs git checkout, the other is mid-edit, and you get phantom diffs in both panes.
The fix is two Unix tools you have probably already installed: git worktrees and tmux. Twenty minutes of setup, hours saved per week.
A git worktree is a second working directory attached to the same repository, on a different branch. Each worktree has its own checkout, its own index, and its own ignored files — but they all share the same .git metadata. So commits, branches, and refs are visible across every worktree, but filesystem writes are isolated.
bash cd ~/code/my-saas-app git worktree add ../my-saas-app.refactor -b ai/refactor-pricing git worktree add ../my-saas-app.tests -b ai/add-integration-tests git worktree add ../my-saas-app.bugfix -b ai/fix-webhook-race
Three directories, three branches, three agents working in parallel. None of them can see the others' filesystem changes, so they cannot stomp each other. When an agent is done, you cd into its worktree, review, push the branch, open the PR.
Worktrees alone solve the file-conflict problem. tmux solves the "I cannot keep three terminals and three agent CLIs straight in my head" problem. One tmux session per worktree, each with its own panes for the agent CLI and a build watcher.
```bash
new-session -A -s coding new-window -n refactor -c ~/code/my-saas-app.refactor new-window -n tests -c ~/code/my-saas-app.tests new-window -n bugfix -c ~/code/my-saas-app.bugfix ```
Then a single alias:
bash alias coding='tmux attach -t coding || tmux new-session -s coding "$HOME/.tmux/coding.sh"'
Run coding and you land in a four-pane dashboard: an overview at the top, three windows below — one per agent. Each window is cd-ed into its own worktree. Each window runs its own AI CLI independently.
1. Kick off all three agents in parallel. Each one reads its own branch context, makes its own commits, runs its own tests. 2. Monitor from the overview pane. A small loop works nicely: ``bash while true; do clear for d in ~/code/my-saas-app.*/; do branch=$(git -C "$d" branch --show-current) last=$(git -C "$d" log -1 --format='%h %s (%ar)' 2>/dev/null) echo "$d [$branch] $last" done sleep 10 done ` 3. **Review and ship.** When an agent finishes, tmux select-window -t tests, read the diff, push the branch, open the PR. The other two keep running. 4. **Clean up.** Once merged, drop the worktree: `bash git worktree remove ../my-saas-app.refactor git branch -d ai/refactor-pricing
Services listening on fixed ports. If your dev server runs on :3000, three worktrees mean three servers, three ports. Bind by worktree (PORT=3001 npm run dev) or use tmuxinator profiles that auto-set env vars per window. The first time I ran this setup I had three Postgres instances competing for :5432 and lost twenty minutes to it.
Background processes that write to the parent directory. Test runners, linters, and watch tools sometimes write coverage or cache files to the repo root. Those write into whichever worktree they run from, which is what you want — but if a tool writes into an absolute path like /var/tmp/agent-cache, every worktree will collide there. Audit your tooling.
The point of an AI coding agent is throughput. A single agent on a single branch is half the throughput. Three agents on three branches in three worktrees is the same wall-clock cost as one — because they are not waiting on each other — and you get the review-and-merge flow for free because every change is already on its own branch. The whole setup is git worktree add, a tmux session, and a habit of opening one window per task. Once you run two agents at once, you will not go back.
— Mr. Technology