# Claude Code Worktrees, tmux and Parallel Agents: A Practical Guide

Claude Code worktrees let you run several Claude sessions on one repository at once without them overwriting each other's files: each session gets its own checkout and branch. Since the `--worktree` flag shipped, one command creates the worktree under `.claude/worktrees/<name>/` on a branch named `worktree-<name>` and starts Claude in it. Add tmux and you can watch three or four agents side by side, but every parallel session also multiplies your token use.

This guide covers worktrees by hand, the built-in flag, tmux layouts, subagents, desktop workbenches, and running parallel agents in the cloud.

## Why parallel Claude Code agents need worktrees

Two Claude sessions in the same directory share one working tree. If both edit `package.json`, or one runs `git checkout` while the other is mid-edit, you get lost changes and confusing test failures. A git worktree is a second checkout of the same repository in another folder, on its own branch, sharing the same `.git` history. Each agent gets its own files, and merging happens later through ordinary branches and pull requests.

Anthropic's [parallel agents page](https://code.claude.com/docs/en/agents) puts it plainly: worktrees give each session a separate git checkout, so parallel sessions each edit their own copy of the files.

## Git worktrees by hand

You don't need any Claude feature to do this. Plain git works:

```bash
# From your main checkout
git worktree add ../myapp-auth -b feature/auth
git worktree add ../myapp-billing -b feature/billing

# Start a Claude session in each
cd ../myapp-auth && claude
cd ../myapp-billing && claude

# When done
git worktree list
git worktree remove ../myapp-auth
```

The catch: a worktree is a fresh checkout. Gitignored files like `.env` are not there, and `node_modules` or a Python virtualenv has to be installed again in each one.

## Claude Code worktrees with the --worktree flag

Claude Code automates the same thing. Per the [worktrees docs](https://code.claude.com/docs/en/worktrees):

```bash
# Creates .claude/worktrees/feature-auth on branch worktree-feature-auth
claude --worktree feature-auth

# Short form
claude -w bugfix-123

# Branch a worktree from a pull request
claude --worktree "#1234"
```

Useful details:

- **Ignore the folder.** Add `.claude/worktrees/` to `.gitignore` so worktrees don't show up as untracked files in your main checkout.
- **Copy secrets in.** A `.worktreeinclude` file at the project root, in `.gitignore` syntax, copies matching gitignored files such as `.env` into each new worktree.
- **Base branch.** New worktrees branch from the default branch. Set `worktree.baseRef` to `"head"` to branch from your current work instead.
- **Cleanup.** On exit, a clean unnamed worktree is removed automatically. If there are changes or commits, Claude asks whether to keep or remove it.
- **Resume.** Return to a kept worktree with `claude --worktree <name> --resume <session-id>`.

## Claude Code and tmux

tmux gives you one terminal with many panes, which is the natural way to watch parallel sessions. Claude Code has a flag for it:

```bash
# Create a worktree and open it in its own tmux session
claude -w feature-auth --tmux

# Force classic tmux instead of iTerm2 native panes
claude -w feature-auth --tmux=classic
```

If you prefer to build the layout yourself, a common setup is one window per task with Claude in the top pane and a shell for tests below:

```bash
tmux new -s agents -n auth -c ~/code/myapp-auth
tmux split-window -v -c ~/code/myapp-auth
tmux new-window -n billing -c ~/code/myapp-billing
tmux split-window -v -c ~/code/myapp-billing
```

Switch windows with `Ctrl-b n`, detach with `Ctrl-b d`, and reattach later with `tmux attach -t agents`. tmux also keeps sessions alive over SSH, which is covered in [how to run Claude Code remotely](/blog/run-claude-code-remotely).

## Subagents, agent view and agent teams

Not all parallel work needs separate terminals. Anthropic lists five ways to work on several tasks at once, including dynamic workflows, where Claude coordinates many workers on one job. The other four:

| Approach | What it is | Isolation |
|---|---|---|
| Subagents | Helpers Claude spawns inside one session | Optional worktree per subagent |
| Agent view | `claude agents` dashboard for background sessions, research preview | A dispatched session moves into its own worktree before editing |
| Agent teams | A lead session coordinating teammates, experimental | Split panes need tmux or iTerm2; avoid shared files |
| Projects | One ongoing conversation at claude.ai/code that starts parallel threads, public beta on Pro, Max and Ultra | Cloud or your machine |

To give a custom subagent its own worktree every time, add `isolation: worktree` to its frontmatter, as the [subagents docs](https://code.claude.com/docs/en/sub-agents) describe. The `/batch` skill goes further and splits one large change across 5 to 30 worktree-isolated subagents.

Agent teams need an environment variable to enable:

```bash
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
```

With teammates in split panes inside tmux, you can watch each one and click into a pane to steer it. The [agent teams docs](https://code.claude.com/docs/en/agent-teams) warn that two teammates editing the same file leads to overwrites, so give each teammate its own set of files.

## Workbenches: Conductor and Superset

If you'd rather not manage worktrees and tmux yourself, desktop workbenches do it for you:

- **Conductor** is a Mac app that runs coding agents such as Claude Code and Codex in parallel, with each workspace in its own git worktree. See [OpenComputer vs Conductor](/compare/opencomputer-vs-conductor).
- **Superset**, now renamed Paradev, is an [MIT-licensed open source](https://docs.superset.sh/overview) platform where every task gets its own workspace, a separate git worktree on its own branch. It runs Claude Code, Codex, Amp and other CLI agents. See [OpenComputer vs Superset](/compare/opencomputer-vs-superset).

Both give you a diff viewer and a list of running agents, which beats juggling terminal panes once you have more than three or four tasks going. More options are on the [compare hub](/compare).

## Running parallel agents in the cloud

Local parallelism hits two walls: your laptop's CPU and memory, and the fact that closing the lid stops everything. Cloud options move the worktrees somewhere else. Claude Code's own cloud sessions run each session in an Anthropic-managed VM, and the [cloud coding agents comparison](/blog/cloud-coding-agents-compared) covers Cursor and Codex equivalents.

## One worktree per Slack thread with OpenComputer

OpenComputer applies the worktree pattern to a team. Each Slack workspace gets one cloud Linux machine, sized to its plan, and every Slack thread where someone mentions @Computer gets its own git worktree and branch on that machine. Ten threads means ten branches working side by side, with no tmux layout to manage and nothing running on a laptop.

Within a thread, Claude Code (or Codex on the hosted version) can still use subagents for its own fan-out. Everyone in the thread sees what it does and can steer it, and the result lands as a GitHub pull request saying what changed, why and how it was checked. The machine resumes warm, so installed dependencies survive between threads instead of being reinstalled per worktree.

As of November 2026, hosted plans are Pro at $20 a month for 2,000 work minutes and Max at $200 a month for 25,000, per workspace, and it is [open source](https://github.com/diggerhq/opencomputer). See [OpenComputer vs Claude Code](/compare/opencomputer-vs-claude-code).

## Tips for running agents in parallel

1. **Split by file, not by feature name.** Two agents touching the same module will still conflict at merge time.
2. **Keep tasks small.** A focused task finishes faster and is easier to review than a sprawling one.
3. **Watch usage.** Every parallel session draws on the same plan limits. See [Claude Code usage limits](/blog/claude-code-usage-limits).
4. **Script setup.** Put dependency installs in a setup script so each new worktree is ready in one step.
5. **Clean up.** Run `git worktree list` weekly and remove what you've merged.

## FAQ

### What does claude --worktree do?

It creates a new git worktree under the .claude/worktrees folder at your repository root, on a new branch named after the worktree, and starts Claude in it. On exit, Claude removes a clean worktree or asks whether to keep one that has changes.

### How many Claude Code agents can I run in parallel?

There is no fixed cap on local sessions, but each one uses your plan's shared usage allowance and your machine's CPU and memory. Most people find three to five parallel sessions is the practical limit before review becomes the bottleneck.

### Do I need tmux to run parallel Claude Code sessions?

No. Separate terminal tabs work fine. tmux helps when you want several sessions visible in one window, when you work over SSH, or when you use agent teams in split-pane mode, which requires tmux or iTerm2.

### Do subagents use worktrees automatically?

Not by default. You can ask Claude to use worktrees for its agents, or add the worktree isolation setting to a custom subagent's frontmatter so it always gets its own checkout. The batch skill always uses worktree-isolated subagents.

### Why are my environment files missing in a new worktree?

A worktree is a fresh checkout, so gitignored files are not copied. Add a worktreeinclude file at the project root listing patterns such as the env file, and Claude Code copies matching gitignored files into each new worktree.

## Sources

- [Claude Code worktrees](https://code.claude.com/docs/en/worktrees)
- [Run agents in parallel](https://code.claude.com/docs/en/agents)
- [Agent teams](https://code.claude.com/docs/en/agent-teams)
- [Subagents](https://code.claude.com/docs/en/sub-agents)
- [CLI reference](https://code.claude.com/docs/en/cli-reference)
- [Paradev (formerly Superset) overview](https://docs.superset.sh/overview)
- [Conductor](https://conductor.build)
- [git worktree documentation](https://git-scm.com/docs/git-worktree)
