Run coding agents in parallel with Git worktrees
Give Claude Code, Codex or any other coding agent a worktree of its own, run several at once on the same repository, and watch them from one board: who is still working, whose branch is ready to review, and what can be removed. Nothing here needs a plugin or an integration; the agents run in their terminals as usual. If you would rather the agent made its own worktrees and told the board when the work is ready, see Let your coding agent make its own worktrees.
Why a worktree per agent
An agent edits files in a folder. Two agents in the same folder edit the same files, and the second one to save wins; worse, each sees the other's half-finished change and reasons about it. Stashing does not help because a stash is per folder too.
A worktree gives each agent a folder and a branch of its own, in the same repository. They share history, so you can merge, cherry-pick or diff between them at any moment, but they cannot step on each other's files. When an agent finishes, you review its branch, merge it or throw it away, and delete the folder. The post How to run several coding agents on one repo without collisions explains the reasoning at more length; this guide is the practice.
Set up once
- Open the repository in Mergepond and press ⌘3 for the Worktrees view.
- Click the gear, "Worktree settings: folder pattern and setup recipe". Keep the default pattern
../<repo>.worktrees/<branch>, so agent folders sit next to the repository and never inside it. - Fill in the recipe so an agent can run the project straight away: copy
.env, linknode_modules, run your install command. Worktrees that set themselves up walks through it. - Save.
Start an agent
- Press ⌘N. The new-worktree sheet opens on "New branch"; the name field's placeholder,
agent/claude-3, hints at the convention. Name it for the task, sayagent/search-index. - Check "Starts from" is the branch you want the agent to build on, usually your default branch.
- Click "Create worktree" and wait for "Worktree ready", or close the sheet; the card on the board reads "Setting up" until the recipe is done.
- On the card, click Terminal. Terminal opens in the worktree's folder.
- Start the agent in that terminal, with its task. For Claude Code that is
claudeand your prompt; for Codex,codex. The agent sees only this folder and this branch. - Repeat for the next task. Each ⌘N is another agent, on another branch, in another folder.
Watch the board
Mergepond watches each worktree's folder, so the board updates as agents save and commit, without you refreshing. Each card is one agent, and the column tells you what it needs.
- Working holds cards with uncommitted changes, shown as "5 changed files", and cards that are "Up to date" or "2 behind" with nothing committed yet. An agent that is typing shows here.
- Ready for review holds cards whose branch has commits that are not pushed, "3 commits to push", or that have no upstream yet, "Ready for review". An agent that has committed and stopped lands here.
- Merged or gone holds branches you have merged, branches whose remote has been deleted, and folders that are missing. These are safe to remove and the card says so, with the disk they free.
Switch between Board, Grid and List layouts with the control in the header. Grid gives each worktree equal room; List packs more onto a laptop screen.
Click a card's "Open" to see the worktree in a new window, or "Open here" to switch this window to it; the card for the worktree you are in says "View changes" instead. The sidebar lists the same worktrees under the repository, and ⌘-click there opens one in a new window too.
Review and merge
- When a card is in Ready for review, open it and press ⌘2. The agent's commits sit above your default branch in History; click each to read the diff in the inspector.
- If the branch needs changes, start the agent again in the same folder with your notes. If it needs a tidy, right-click the first agent commit and pick "Interactive rebase from here…" to squash the work into a commit you would sign. See Rebase by dragging.
- Switch back to your main worktree. Right-click the agent's branch in the sidebar and choose "Merge into" your branch, or press ⌘K and type the branch name for the same command.
- If two agents touched the same lines, the conflict banner appears and Resolve merge conflicts takes it from there.
- Push from the toolbar, or ⌘⇧↑. The agent's card moves to Merged or gone.
If you would rather open a pull request from the agent's branch, open the worktree and push with ⌘⇧↑; once the branch has an upstream its card gains a Push button for the next time. The review then happens on your Git host, and the card moves to Merged or gone when the branch is deleted there.
Clean up
Click "Clean up" in the board header. The sheet lists every worktree in Merged or gone, says how much disk removing them frees, and removes them in one go; the branches stay. Worktrees with uncommitted changes are unticked by default, so an agent that is still mid-task is never removed by accident.
To remove a single worktree, right-click its card, or use the card's More button, and choose "Remove worktree…"; cards in Merged or gone have a "Remove worktree" button in plain sight. If the agent left uncommitted changes, Mergepond asks whether to "Commit first" or "Remove and lose changes"; if it has unpushed commits, it offers "Push, then remove".
Get more from it
- Name the branch after the task, not the agent:
agent/search-index,agent/flaky-tests. In a week you will remember what it did; you will not remember which one was "claude-3". - One agent per worktree does not mean one at a time. Six cards on the board is a normal afternoon.
- Skip steps 1 to 4 of "Start an agent": with the Mergepond plugin for Claude Code, or
pondwired into Codex, the agent makes the worktree itself and the card reads "Claude Code working" and then "Claude Code: ready for review" with the agent's note. See Let your coding agent make its own worktrees and Coding agents. - Multi-select cards with ⌘-click or the ticks, then "Remove N" from the bar that appears, to clear several worktrees that Clean up would not pick on its own.
- With Pro, do all of this on a dev box over SSH: the worktrees and the agents live there, and the board is on your Mac.