Why worktrees
A git worktree is a second working folder for the same repository, checked out on its own branch. Every worktree shares one history and one object store, so it costs little disk and no clone. An agent in its own worktree works on its own files, runs its own tests and commits to its own branch; another agent’s half-done edits never show up there.
This works the same for every agent with a CLI: Claude Code, Codex, OpenCode, Cursor Agent, Gemini CLI, Aider or your own.
By hand
- Make a worktree per task, on a new branch from main.Terminal
cd ~/code/payments-api git worktree add -b refund-retries ../payments-api-refund-retries main git worktree add -b ledger-export ../payments-api-ledger-export main
- Prepare each one.A new worktree has no
node_modulesand no untracked files such as.env.Terminalcd ~/code/payments-api-refund-retries pnpm install cp ../payments-api/.env .env cd ~/code/payments-api-ledger-export pnpm install cp ../payments-api/.env .env
- Start one agent per worktree, each in its own tmux session.Ctrl-b, then a lowercase d, leaves the session and brings you back to your shell;Terminal
tmux new-session -d -s refund-retries -c ~/code/payments-api-refund-retries claude tmux new-session -d -s ledger-export -c ~/code/payments-api-ledger-export codex tmux attach -t refund-retries
tmux attach -t ledger-exportvisits the other agent. - See what you have.Terminal
git worktree list tmux ls
Cleaning up
When a branch is on main and its agent has stopped, remove its worktree and the branch. git worktree remove refuses a worktree with uncommitted changes, which protects work you have not looked at yet. A squash merge leaves the branch looking unmerged to git, so delete it with -D.
cd ~/code/payments-api git worktree remove ../payments-api-refund-retries git branch -D refund-retries
How many agents
As many as you can follow. Each agent asks questions, waits for answers and produces a diff someone has to read. Three agents you follow well get more merged than ten you check on now and then. The limits that bite first are usually your attention, your usage limits and your laptop’s memory.
With Dockazor
New Worktree… ⇧⌘N does the first three steps in one sheet. It makes the worktree at <project>/.dockazor/worktrees/<name> on a new branch from main, runs your setup command, and opens a chat on the default chat preset. Type a brief and it becomes the chat’s first message.
- Each chat is the agent’s own CLI in a terminal. Dockazor sends nothing to a model you did not ask for.
- The New Chat menu adds a chat on another agent to the same worktree, for a reviewer or a different model; ⌘N starts the default preset.
- Every worktree of every project sits in one sidebar, each chat marked Working, Needs you or Idle.
- Archive removes the worktree’s folder and its branch, on your Mac and on origin.
The worktrees and branches Dockazor makes are ordinary git. git worktree list shows them, and your work stays usable with git alone.