How to run multiple Claude Code sessions in parallel with git worktrees
Updated 17 November 2026
Give each session its own git worktree. Run claude --worktree feature-auth in one terminal and claude --worktree bugfix-123 in another, and each gets a separate checkout under .claude/worktrees/ on its own branch, so their edits cannot collide.
Two Claude Code sessions in the same folder will edit the same files and undo each other’s work. A git worktree fixes that. It is a second working directory with its own files and branch that shares the repository’s history, and Claude Code can create one for you with a single flag.
The commands below are from the worktrees page and the sessions page of the Claude Code docs.
How do I start Claude Code in a worktree?
-
In your repository, run:
claude --worktree feature-auth-wis the short form. Claude Code creates the worktree at.claude/worktrees/feature-auth/on a new branch namedworktree-feature-authand starts the session inside it. -
Open a second terminal tab and run it again with another name:
claude --worktree bugfix-123 -
Add the worktree folder to
.gitignoreso the checkouts do not show up as untracked files:.claude/worktrees/
If you leave the name off, Claude Code makes one up, such as bright-running-fox. The folder has to be one you have already trusted; if you have never run claude there, do that once first.
By default a new worktree branches from the repository’s default branch on the remote, usually main. To branch from your current local work instead, set this in settings:
{
"worktree": {
"baseRef": "head"
}
}
To start from a pull request, pass its number in quotes: claude --worktree "#1234".
Why are my .env file and node_modules missing?
A worktree is a fresh checkout, so anything gitignored is absent. There are two fixes.
For small files such as .env, add a .worktreeinclude file to the project root. It uses .gitignore syntax, and only files that match and are also gitignored get copied:
.env
.env.local
config/secrets.json
For dependencies, install them in the worktree. Ask Claude to do it as its first step, or run your setup command yourself in the folder under .claude/worktrees/.
How do I create the worktree myself with git?
Use git directly when you want an existing branch or a folder outside the repository.
# new branch
git worktree add ../project-feature-a -b feature-a
# existing branch
git worktree add ../project-bugfix fix-issue-456
# start Claude in it
cd ../project-feature-a
claude
# see them all
git worktree list
# remove one when done
git worktree remove ../project-feature-a
What happens to the worktree when I exit?
Claude Code checks whether removing it would lose anything.
- Clean, unnamed session: the worktree and its branch are removed automatically.
- Has changes, untracked files or new commits: you are asked whether to keep or remove it. Keeping preserves the folder and the branch. Removing deletes both, with the work in them.
Runs with claude -p have no exit prompt, so those worktrees are left in place. Remove them with git worktree remove.
How do I get back to a session later?
Name sessions so you can find them. This matters most with several running.
| When | How |
|---|---|
| At startup | claude -n auth-refactor |
| During a session | /rename auth-refactor |
| To return | claude --resume auth-refactor or /resume auth-refactor |
claude --continue reopens the most recent session in the current directory. claude --resume with no argument opens a picker; press Ctrl+W there to show sessions from all worktrees of the repository. When you resume a session that ended inside a worktree, Claude Code puts you back in that worktree.
What do worktrees share with the main checkout?
- The
.gitdirectory. Commits made in a worktree land in the same repository. - Permission approvals. Choosing “Yes, and don’t ask again” for a Bash command in a worktree saves the rule to the main checkout’s
.claude/settings.local.json, so it applies in every worktree. - Project-scope plugins.
Worktrees isolate file edits and nothing else. Two sessions that both run migrations against one local database, or both bind port 3000, will still get in each other’s way.
While a session is in a worktree, Claude Code also blocks edits that target the main checkout and git commands redirected into it.
Can subagents use worktrees too?
Yes. Ask Claude to “use worktrees for your agents”, or add isolation: worktree to a custom subagent’s frontmatter:
---
name: refactorer
description: Applies mechanical refactors across many files
isolation: worktree
---
Apply the requested refactor across every affected file, then run the tests
and report the results.
Each subagent gets a temporary worktree, which is removed when it finishes without changes.
How do I keep track of them all?
Worktrees solve the file problem. They do not help you notice that the session in tab two stopped five minutes ago to ask about a git push. A few free habits help:
- Name every session and every terminal tab after its task.
- Add a
Notificationhook so you get a ping when any session is waiting. The setup is in getting notified when Claude Code is waiting. - Put
session_nameandworktree.branchin your status line so each terminal says what it is. - Stop at two or three sessions. Past that, reviewing the changes becomes the queue.
If you run parallel sessions most days, NotchDaddy lists every session in the MacBook notch with what it is doing, shows the request a waiting one is stuck on with Allow and Deny buttons, and keeps the Mac awake while they work. An approval you leave unanswered falls back to that session’s terminal prompt.
You do not need it if you run parallel sessions only now and then; names plus a notification hook are enough. The habits side of this is covered in running several coding agents at once.
Start a 3-day trial for $0, then $19 once.