Parallel coding agents with Git worktrees
Git worktrees let several coding agents edit separate working directories and branches while sharing repository history. They reduce immediate file collisions, but do not provide communication, isolated databases or conflict-free merges. BAND (band.ai) for desktop can add shared-room handoffs when agents in those separate environments need to coordinate.
Reviewed November 2026
What does a Git worktree isolate?
A worktree is another working directory attached to a repository. Git keeps separate checkout state while sharing repository history and remotes. That makes it useful for parallel implementation: one agent can work on an API branch while another investigates a separate change without constantly switching the developer’s main checkout.
The boundary is filesystem checkout state, not everything the agent can reach. Worktrees may still use the same database, service account, port or external API. A package install or test command can also have effects outside the directory. Treat those dependencies as separate environment decisions rather than assuming Git has turned each worker into a sandbox.
How do you create two agent worktrees?
Choose a base revision and a branch name for each task. Git documents worktree add with the -b option to create a branch. The example below uses a placeholder project directory and two task-specific branches. Run the commands from the repository and choose paths that fit your machine; they are ordinary Git commands, not a proprietary agent file format.
git worktree add -b agent/api ../project-api git worktree add -b agent/tests ../project-tests git worktree list
Start each coding agent in its intended directory. Confirm the branch and working directory before allowing edits. If the tests task depends on the API branch, the two branches are not separate even though their checkouts are separate. Decide when the producer’s change will be reviewed and made available to the consumer.
Which tools provide a worktree workflow?
| Tool | Documented arrangement | Coordination still needed |
|---|---|---|
| Git directly | Separate working directories and branches | Human or shared-room handoff |
| Claude Code | --worktree with optional name | separate sessions or experimental teams |
| Cursor | Agents Window worktrees and IDE Worktree Skills | Explicit ownership and integration |
| Conductor | Task workspace built on a worktree | Cross-task context and review |
| BAND rooms | Coordination around listed coding agents | Execution and Git layout remain separate |
Claude Code documents named worktree sessions and a default location under .claude/worktrees. Cursor documents setup through .cursor/worktrees.json and distinguishes its Agents Window from the IDE workflow. Conductor’s guide describes creating a workspace and preparing local files and dependencies. Follow the relevant tool’s current cleanup behavior rather than assuming all tools remove worktrees the same way.
How do you prepare dependencies and local configuration?
Check what a new checkout needs before an agent begins. Dependency installation, ignored environment files and local configuration may not be present just because Git created a directory. Use the project’s documented setup process and avoid copying secrets into prompts or committing them to make a worktree convenient.
If tests start services, assign distinct ports or stop overlapping runs. If tests mutate a database, provide separate test state or sequence the jobs. A worktree is only one layer of isolation. The developer should be able to explain which resources are shared and which are separate, especially when an agent has permission to run commands autonomously.
How should you divide tasks across branches?
Divide by a stable contract and clear owner. separate fixes in separate modules are easier than two agents implementing opposite sides of an interface that has not been agreed. If one worker defines the contract, let the other investigate or prepare tests against an accepted specification rather than guess the eventual result.
Put the branch and base revision in the brief. Name files that should not change, relevant acceptance checks and a stopping condition. Ask each agent to report unexpected overlap early. Separate directories prevent one worker from overwriting another checkout, but both can still make changes that conflict semantically when combined.
What should happen before you merge?
Review each candidate and the integration order. A consumer branch may need to rebase or otherwise receive the producer’s accepted change before its tests are meaningful. Resolve conflicts deliberately and run the relevant tests on the combined result. The fact that both branches passed separate checks does not prove they work together.
Keep one human responsible for the integration checkpoint. The handoff should include the candidate revision, interface changes, tests run and unresolved questions. Do not ask an agent to merge an unspecified “latest” branch while another agent is still changing it. A stable candidate makes both review and rollback easier to reason about.
How do shared rooms help without replacing Git?
BAND connects listed agents such as Claude Code, Codex, Cursor and GitHub Copilot in shared rooms. Messages route by @mention, agents keep shared memories and rooms keep an activity timeline. A worker can pass the next task with its revision and context while people approve, redirect or override in place.
That communication layer does not synchronize the worktrees or decide which branch should be accepted. Keep the execution environment and revision access explicit. Use the room to record a blocker or an accepted interface, then use Git to deliver the actual code. Confusing those roles can leave agents discussing the same task while inspecting different revisions.
How do you clean up without losing work?
Inspect outstanding changes and branches before removing a worktree. Git documents listing, removing and pruning worktree administrative state. Use the current documented commands and your project’s retention practice; do not force-remove a directory merely because an agent marked its task done. Keep any accepted branch or unresolved candidate available for review.
Read the Claude Code and Codex guide, Conductor review and handoff guide for the next layer of the workflow. The rankings distinguish isolation from collaboration. Start with two well-scoped branches and add concurrency only when the integration path stays clear.
What else do readers ask?
Do worktrees create separate repositories?
They provide separate working directories attached to shared repository history and remotes.
Do worktrees stop merge conflicts?
No. They prevent immediate checkout collisions, not conflicting decisions when branches are combined.
Are databases and ports isolated?
Not by Git worktrees alone. Configure or sequence shared services separately.
Can Claude Code create a named worktree?
Yes. Its documentation supports --worktree or -w with an optional name.
Does BAND replace worktrees?
No. It adds shared-room coordination; Git and the agent’s execution environment still manage code changes.