MXterm Pro

Claude Code Worktrees: Give Each Agent Its Own Branch

Henry AGI
4 min read
Cover: Claude Code worktrees, one repository with a separate branch and worktree for each agent.

A Git worktree gives a coding agent its own folder and branch inside the same repository. In MXterm Pro, each agent can work on its own branch in its own worktree. That can reduce collisions, but it does not stop conflicting edits to the same file.

Who actually needs a worktree per agent

A single agent alone in a repository has nothing to collide with. The main working directory is enough, and turning on isolation buys you nothing.

Isolation matters once you run several agents against the same repository at the same time. Without it, one agent's git checkout or git stash can change the files another agent is editing.

Open a new tab, choose the agents, and turn on "Isolate features in git worktrees" in the new-tab window. The app describes it as "Each agent pane starts in its own worktree and branch."

Related guideDocker Build Terminal on Mac: Builds Alongside SSH Deploys

What the switch does

MXterm Pro
One repository with a separate branch and worktree for Claude Code and for Codex; merging stays manual.
One repository, one worktree per agent.

Each agent can work on its own branch in its own worktree. The agents and Control Room docs describe the same setting.

Claude Code's own --worktree flag

MXterm Pro
Claude Code worktrees: one command creates a worktree folder and a new branch, drawn as three connected boxes
Claude Code worktrees: one command creates a worktree folder and a new branch, drawn as three connected boxes

Claude Code can create a worktree itself. Its docs say that claude --worktree feature-auth creates the worktree under .claude/worktrees/feature-auth/ at the repository root, on a new branch named worktree-feature-auth, and starts Claude Code in it. You can run the command again with a different name in another terminal to start a second isolated session. When a session ends, a clean worktree from an unnamed session is removed together with its branch; a clean named session asks whether to keep it, and a worktree with changes asks whether to keep or remove it (Claude Code docs, code.claude.com/docs/en/worktrees, read 28 October 2026).

In MXterm, each agent can work on its own branch in its own worktree. If you start Claude Code by hand in a plain pane you can still use the flag. Pick one approach for a given task; we have not tested using both on the same pane.

What isolation prevents, and what it does not

MXterm Pro
Git worktrees for AI agents: a two list card of what isolation reduces and what it does not do
Git worktrees for AI agents: a two list card of what isolation reduces and what it does not do

Take the concrete case: Claude Code lands on its own branch and worktree, Codex on another.

Without isolation, both agents share one working directory. If Codex runs git checkout or git stash mid-task, the files Claude Code has open on disk change under it. Neither agent's next tool call knows why the file it just wrote does not match what it reads back.

With separate worktrees, each agent has its own copy of every file, checked out to its own branch. This reduces the chance that one agent's checkout rewrites the files another agent has open.

Isolation does not remove every kind of conflict. Agents editing the same feature from different angles can still produce branches that need a real, human-reviewed merge later, and MXterm does not automate that part. What isolation removes is narrower and purely mechanical: the filesystem-level fight over one shared working directory.

A worktree is not a sandbox. The pane is still a normal shell, so an agent can leave its folder and run any command your user can. Every worktree also shares the one .git behind the repository. Isolation keeps the agents' files apart; it does not limit what they can do.

Merging and removing worktrees

Merging stays manual on purpose. Once an agent's branch is ready, merge it the normal way: git merge <branch-name> from your main checkout, or push it and open a pull request, whichever your team already does. MXterm does not merge for you.

When you are done with a worktree, remove it from Settings > Agents, or clean up from the Git panel. To keep several agents in one room while they work, see the Control Room.

Doing it by hand

The manual route is a git worktree per AI agent set up by hand, with plain git worktree add and git worktree remove in whatever terminal you already use. That works if you do not mind typing the commands.

In MXterm, each agent can work on its own branch in its own worktree. To try it, use the download page, and see running Claude Code in MXterm for a full walkthrough.

For how another app describes worktrees, see MXterm vs Orca. For Mac terminals compared for Claude Code, see the best terminal for Claude Code on Mac.

See it running for yourself

Multi-pane SSH, Command Recipes (Cmd+J), and a multi-agent Control Room.

Download MXterm Pro

Frequently Asked Questions

What is the difference between a Git branch and a Git worktree?

A branch is a pointer to a commit in your repository history. In normal use you check out one branch at a time in your folder. A worktree is a separate folder linked to the same repository, so you can have a different branch checked out in each.

Does isolating agents in worktrees use a lot of extra disk space?

Some, but far less than a full second clone. A git worktree shares the repository's commit history and objects through the same underlying .git. Only the checked-out files and a small amount of per-worktree metadata are duplicated, so the overhead scales with your working tree's size, not your repo's whole history.

How does MXterm isolate agent workspaces?

In MXterm each agent can work on its own branch in its own worktree. Turn on "Isolate features in git worktrees" in the new-tab window. A worktree keeps checkouts apart; it is not a sandbox.

Does Claude Code have its own worktree option?

Yes. Claude Code's --worktree flag, for example claude --worktree feature-auth, creates a worktree under .claude/worktrees/ on a branch named worktree-<name>. When a session ends, a clean worktree from an unnamed session is removed with its branch; a clean named session asks whether to keep it, and a worktree with changes asks whether to keep or remove it (Claude Code docs, read 28 October 2026). In MXterm, each agent can work on its own branch in its own worktree, and you can run claude --worktree <name> in a plain pane. We have not tested using both on the same pane.

Ask AI about MXterm Pro

Open a live answer in ChatGPT, Claude or Perplexity, based on this page. The assistant writes it, not us, so check the sources it cites.

Question sentHow does MXterm Pro use git worktrees to keep several coding agents from overwriting each other's files?