How to run several Claude Code sessions at once: worktrees, tmux and apps
We make AI Bridge, a Mac app that runs these command-line agents side by side. We do not sell any of them, are not affiliated with their makers, and none of them paid for or reviewed this guide. We use them every day.
Why parallel sessions collide
Two agents in one folder share one set of files and one checked-out branch, so each sees, and can overwrite, the other’s half-finished work. A folder has one branch checked out at a time: if one agent switches branch, the files change under the other. If both edit the same file, one overwrites the other; Anthropic’s own guide to agent teams warns that two agents editing the same file “leads to overwrites”. And a test run in one session picks up the other’s unfinished edits, so a failure no longer tells you whose change broke it.
The fix is not fewer agents but separate checkouts. A git worktree gives each session its own folder and its own branch while sharing one repository’s history, so the agents work side by side and you merge their branches as you would anyone else’s.
Give each session its own git worktree
A worktree is a second working folder for the same repository, on its own branch. Commits made in any worktree land in the one shared repository, so there is nothing to push between them. Four commands cover daily use:
# a new folder beside the repo, on a new branch called auth
git worktree add ../myapp-auth -b auth
# every worktree, with the commit and branch it has checked out
git worktree list
# delete the folder once its branch is merged
git worktree remove ../myapp-auth
# forget worktrees whose folders you deleted by hand
git worktree pruneThen start an agent in each folder, in its own terminal tab or window:
cd ../myapp-auth && claudeThree rules from git’s documentation are worth knowing before you rely on this:
- Without
-b,git worktree add ../myapp-authcreates a branch named after the folder,myapp-auth. - Git refuses to check out a branch that another worktree already has checked out. That is the protection you want: two agents can never be on the same branch by accident.
git worktree removeonly removes a clean worktree. One with untracked or modified files needs--force, which deletes that work, so commit or copy out anything you want first.
Seen first-hand
Claude Code files each conversation under the folder it started in, and claude -c continues the most recent session recorded under the folder you launch it from. Start a session inside its worktree and resume it from there; run from the main checkout, claude -c will not find it. Codex behaves differently: codex resume <id> finds a session from any folder.
The gotcha: .env and other untracked files stay behind
A new worktree is a fresh checkout of tracked files only, so your .env, local config and installed dependencies are not there. Claude Code’s documentation says so directly: untracked files like .env or .env.local from your main repository are not present. It is one of the complaints that come up most about worktree-based tools, and the cause of many “it works in the other session” failures.
Three ways round it:
- Copy by hand when you create the worktree, for example
cp .env ../myapp-auth/, then install dependencies there withnpm installor your project’s equivalent. - Let Claude Code copy them. A
.worktreeincludefile at the project root, in.gitignoresyntax, lists files to copy into every worktree Claude Code creates. Only files that match a pattern and are gitignored are copied, so tracked files are never duplicated. The Codex app reads a.worktreeincludefile too. - Use the app’s setting if you run agents through one: Conductor, for example, has a “Files to copy” setting for the same job.
# .worktreeinclude, at the repository root
.env
.env.local
config/secrets.jsonOne more that surprises people: if you set up Git LFS with git lfs install --local, a worktree Claude Code creates holds LFS pointer files rather than the real files, because it skips filter drivers defined in the repository’s own config. Run git lfs pull inside the worktree to fetch them.
Claude Code’s own ways to run in parallel
Claude Code has four built-in options, from you driving every session to Claude coordinating a team: --worktree, agent view, subagents and agent teams. All of them run Claude sessions only; none of them starts Codex or another CLI.
| Option | Start it with | Where edits go | Status |
|---|---|---|---|
| Worktree session | claude --worktree auth (or -w) | .claude/worktrees/auth, on a new branch worktree-auth | Standard feature |
| Agent view | claude agents, or claude --bg "task" from your shell | Each session moves into its own worktree under .claude/worktrees/ before it edits | Research preview |
| Subagents | Ask Claude, or add isolation: worktree to a subagent’s definition | Optionally a temporary worktree each | Standard feature |
| Agent teams | CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1, then ask for teammates | No worktree isolation: give each teammate its own files | Experimental, off by default |
Worktree sessions
claude --worktree <name> creates the worktree under .claude/worktrees/<name>/ at the repository root, on a new branch called worktree-<name>, and starts Claude in it; leave out the name and Claude invents one. New worktrees branch from the repository’s default branch; set worktree.baseRef to "head" in settings to start from your current work instead, or pass a pull request (claude --worktree "#1234") to start from that. Add .claude/worktrees/ to .gitignore, and run claude once in the repository first: an interactive worktree session needs the folder trusted.
When you exit, a clean, unnamed worktree is removed with its branch. One with work in it prompts you to keep or remove it, and Claude Code prints the claude --worktree <name> --resume command to come back to it.
Agent view
claude agents opens one screen for sessions running in the background: what each is doing, which need your input, and which are done. It is a research preview, so the interface may change. Anthropic is unusually direct about the cost: background sessions use your subscription “the same as interactive sessions, so running ten agents in parallel uses quota roughly ten times as fast as running one.”
Agent teams
Agent teams let a lead session spawn teammates that message each other and share a task list. They are experimental and off by default, and teammates are not isolated in worktrees, so the work has to be split so each owns different files. Teammates can run inside your main terminal, or each in its own split pane; split panes need tmux, or iTerm2 with its it2 command-line tool, and are not supported in VS Code’s integrated terminal, Windows Terminal or Ghostty. Anthropic estimates teams use about seven times the tokens of a standard session when teammates run in plan mode, and suggests starting with three to five teammates.
Anthropic’s overview also lists dynamic workflows and cloud projects as ways to run work in parallel. This guide sticks to sessions on your own machine.
Keep sessions alive with tmux
tmux keeps each agent running after you close the terminal window, and lets you come back to it later, including over SSH. tmux keeps its state in a server process, so a session you detach from carries on, and you reattach when you want to look. The default prefix key is Ctrl-b.
tmux new -s auth # a new session called auth; start claude inside it
# Ctrl-b d detach: the agent keeps running
tmux ls # list your sessions
tmux attach -t auth # go back to it
# Ctrl-b % split the window left and right
# Ctrl-b " split it top and bottom
# Ctrl-b c a new window; Ctrl-b n and Ctrl-b p move between them
tmux kill-session -t auth # end it when the work is mergedA layout that scales: one tmux session per worktree, named after its branch, so tmux ls doubles as a list of what your agents are working on.
Claude Code needs three lines in ~/.tmux.conf to behave inside tmux. Without them, Shift+Enter sends your message instead of adding a new line, and Claude Code’s desktop notifications never reach your terminal:
set -g allow-passthrough on
set -s extended-keys on
set -as terminal-features 'xterm*:extkeys'Apply them to a running server with tmux source-file ~/.tmux.conf. If you use iTerm2, Anthropic suggests starting tmux with tmux -CC.
Which terminal is best for Claude Code?
Any terminal runs Claude Code. With several sessions open, the differences that matter are notifications and keys. By default Claude Code sends a desktop notification only in Ghostty, Kitty and iTerm2. Anywhere else, set preferredNotifChannel to "terminal_bell" in ~/.claude/settings.json, or add a Notification hook (below).
| Terminal | Desktop notification by default | Shift+Enter for a new line |
|---|---|---|
| Ghostty, Kitty, iTerm2 | Yes | Yes |
| WezTerm, Warp, Apple Terminal | No: use the terminal bell or a hook | Yes |
| VS Code, Cursor, Zed | No: use the terminal bell or a hook | After running /terminal-setup once |
| Any of these, inside tmux | Needs allow-passthrough on | Needs the extended-keys lines above |
Two more differences show up with parallel work. Agent-team split panes need tmux or iTerm2, as above. And since version 2.1.295, Claude Code reports each session’s state (working, waiting on you, or done) to terminals that implement the OSC 7501 Program Status Protocol; inside tmux it asks tmux rather than your terminal, so start the session outside tmux if you want to see it, and background sessions report their state in agent view instead. Whether your terminal implements the protocol is in its own documentation.
Knowing which session is waiting on you
Add a Notification hook: Claude Code runs it when a session needs your approval or has finished and gone quiet, so you can leave sessions working and come back when one asks. This example, in ~/.claude/settings.json, shows a macOS notification:
{
"hooks": {
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
}
]
}
]
}
}The hook can match on the kind of notification. permission_prompt fires when an approval prompt has waited about six seconds; idle_prompt when Claude finished about 60 seconds ago and you have not typed since. Put "matcher": "permission_prompt" beside the inner "hooks" list to be told only when something needs approving. On macOS, osascript notifications come from Script Editor, which needs notification permission in System Settings; without it the command fails silently. The full walkthrough is in Claude Code hooks, explained.
Seen first-hand
Building AI Bridge meant reading these signals from every CLI to show whether a session is working or waiting. They have gaps worth knowing. In Claude Code, a turn you interrupt with Ctrl-C reports nothing, and one that ends on an API error fires StopFailure instead of Stop, so a status that listens only for Stop can say “working” about a session that has stopped. In our testing, Codex fired no Stop event for a failed turn either, and OpenCode reported nothing for the first 8 to 10 seconds after it started. If a session has said “working” for longer than the task deserves, go and look at it.
What running several sessions costs
Every session draws on the same plan, so parallel work spends your limits faster; it does not make them go further. Anthropic says ten agents in parallel use quota roughly ten times as fast as one, and that agent teams use about seven times the tokens of a single session when teammates plan.
Claude’s Pro, Max and Team plans meter Claude Code in a rolling five-hour window plus weekly limits, shared with your Claude chats, and Anthropic publishes no hour or prompt numbers for either. On ChatGPT Plus, Codex has a five-hour window and weekly limits may apply; OpenAI says ChatGPT Pro “currently has no five-hour limit”.
Ways to make a plan last with several sessions open, all from Anthropic’s own cost guidance:
- give routine sessions and teammates a cheaper model, such as Sonnet, and keep Opus for the hard ones;
- run
/clearbetween unrelated tasks, because every request carries the whole conversation; - close sessions you are done with: scheduled tasks and goal check-ins send their context even while a session sits idle.
Current plans and limits are on each vendor’s own page, which we link rather than copy because they change often: Claude pricing and Codex pricing.
Mixing Claude Code, Codex and other CLIs
Worktrees are plain git, so any CLI works in one: Claude Code in one worktree and Codex or OpenCode in the next. A pattern developers describe often is one agent writing on its branch while another, from a different vendor, reviews it.
Codex has worktrees built in too, in the ChatGPT desktop app: each Codex chat there runs in Local, Worktree or Cloud mode. Its worktrees live in $CODEX_HOME/worktrees, start in a detached HEAD state rather than on a branch, and Codex keeps the 15 most recent by default. It copies the gitignored files listed in .worktreeinclude, the same file Claude Code reads. The Codex CLI, like OpenCode, simply runs in whichever worktree you start it in.
The difference that bites when you mix them is resuming, which works by folder in Claude Code and by session id from anywhere in Codex (above). How the CLIs compare more widely: Codex vs Claude Code and OpenCode vs Claude Code.
Apps built for running agents in parallel
If you would rather not wire worktrees, tmux and hooks together yourself, several apps do it; they differ mostly in platform, licence, and whether they are built around worktrees or around terminals. In alphabetical order, as listed on 12 October 2026:
| App | Platform | Licence | Approach |
|---|---|---|---|
| Claude Squad | macOS, Linux | AGPL-3.0, free | A terminal UI on top of tmux, with a worktree per agent; runs Claude Code, Codex, Gemini, Aider, OpenCode and Amp |
| cmux | macOS | GPL-3.0 or later, free | A native terminal built on Ghostty, with workspaces and notifications for agent CLIs |
| Conductor | macOS, iOS, cloud | Closed source, with a free plan | A worktree per workspace; runs Claude Code, Codex, Cursor and OpenCode, locally or in cloud sandboxes |
| Emdash | macOS, Windows, Linux | Apache-2.0, free | Worktrees, plus remote machines over SSH; takes tasks from issue trackers; 25+ CLIs |
| Superset | macOS, Linux (experimental), iOS | Elastic License 2.0, with a free plan | Worktrees with terminals, a diff view and a browser; runs any CLI |
| Warp | macOS, Linux, Windows | Free, with paid plans | A terminal with its own agent that also hosts other CLI agents, plus cloud agents |
We make one of these apps, AI Bridge, so we have left it out of the table; it is described once, in the box below. Projects in this space change quickly, so check that one is still maintained before you build your day around it.
Questions
Can you run multiple Claude Code sessions at once?
Yes. Every terminal running claude is an independent session. To stop them editing the same files, give each its own git worktree, for example with claude --worktree <name>, and remember that every session counts against the same plan limits.
Do git worktrees copy my .env file?
No. A new worktree holds only tracked files, so gitignored files such as .env are missing. Copy them by hand, or list them in a .worktreeinclude file, which Claude Code and the Codex app read when they create a worktree.
Where does claude --worktree put the worktree?
Under .claude/worktrees/<name>/ at the repository root, on a new branch called worktree-<name>. Add .claude/worktrees/ to your .gitignore so the folders do not show up as untracked files.
Do I need tmux to run Claude Code agents in parallel?
No. Terminal tabs work, and claude agents runs sessions in the background. tmux helps when sessions should survive a closed window or an SSH disconnect, and it is one of two ways to get split panes for the experimental agent teams.
What is the best terminal for Claude Code?
Any terminal works. Ghostty, Kitty and iTerm2 show Claude Code’s desktop notifications without setup; elsewhere, turn on the terminal bell or add a Notification hook. For agent-team split panes you need tmux or iTerm2.
Does running several Claude Code agents use more of my plan?
Yes, roughly in proportion. Anthropic says ten agents in parallel use quota about ten times as fast as one, and agent teams use around seven times the tokens of a single session when teammates plan.
Sources
Checked on 12 October 2026. These tools change often; where a source and this page disagree, the source is right, and we would like to hear about it at hello@aibridge.sh.
- git worktree reference · git-scm.com · checked 12 Oct 2026
- tmux: Getting Started · github.com · checked 12 Oct 2026
- Claude Code: run parallel sessions with worktrees · code.claude.com · checked 12 Oct 2026
- Claude Code: run agents in parallel · code.claude.com · checked 12 Oct 2026
- Claude Code: agent view · code.claude.com · checked 12 Oct 2026
- Claude Code: agent teams · code.claude.com · checked 12 Oct 2026
- Claude Code: configure your terminal · code.claude.com · checked 12 Oct 2026
- Claude Code: hooks guide · code.claude.com · checked 12 Oct 2026
- Claude Code: manage costs · code.claude.com · checked 12 Oct 2026
- Claude usage limits · support.claude.com · updated Oct 2026
- Codex pricing · learn.chatgpt.com · checked 12 Oct 2026
- Codex: local, worktree and cloud modes · learn.chatgpt.com · checked 12 Oct 2026
- Codex: worktrees · learn.chatgpt.com · checked 12 Oct 2026
- Claude Squad · github.com · v1.0.20, 20 Aug 2026
- cmux · github.com · v0.65.0, 5 Oct 2026
- Conductor pricing · conductor.build · checked 12 Oct 2026
- Emdash · github.com · v1.2.8, 10 Oct 2026
- Superset · github.com · desktop v1.37.0, 8 Oct 2026
- Superset pricing · superset.sh · checked 12 Oct 2026
- Warp pricing · warp.dev · checked 12 Oct 2026
Change log
- : First published.
Keep reading
- How-toClaude Code permissions, explained: modes, sandbox and --dangerously-skip-permissionsHow Claude Code’s six permission modes, allow/ask/deny rules, /sandbox and --dangerously-skip-permissions work in October 2026, with a safe starting policy.
- ComparisonsCodex vs Claude CodeCodex vs Claude Code as they ship in October 2026: price and limits, default models, sandboxing, instruction files, sessions and CI, and when to use both.
- ConceptsClaude Code hooks, explained (with examples)Claude Code hooks in October 2026: the 33 events, settings JSON, stdin payload, matchers and exit codes, with notification and command-blocking examples.
- ComparisonsCursor vs Claude CodeCursor is an AI editor, Claude Code a terminal agent, and they work together. Price, models, approvals, privacy and the SpaceX deal, checked October 2026.