Guide
Claude Code worktrees: run parallel sessions without collisions
Run claude --worktree feature-auth and Claude Code creates a separate checkout for that session under .claude/worktrees/feature-auth/, on a new branch named worktree-feature-auth, then starts in it. Run the same command with another name in a second terminal and the two sessions cannot overwrite each other's files. This guide follows Anthropic's worktrees documentation (checked 24 October 2026); versions differ, so check yours.
Start one
claude --worktree feature-auth
claude -w bugfix-123 # short form, in another terminal
The repository needs at least one commit. If you leave out the name, Claude generates one such as bright-running-fox. By default a new worktree branches from the repository's default branch on the remote, so it starts clean; set worktree.baseRef to "head" in settings to branch from your current work instead. To start from a pull request, quote the reference: claude --worktree "#1234".
Add .claude/worktrees/ to your .gitignore so the folders do not show up as untracked files in your main checkout.
Set up the environment
A worktree is a fresh checkout: dependencies are not installed and gitignored files such as .env are missing. Ask Claude to install dependencies, and list files to carry over in a .worktreeinclude file at the project root:
.env
.env.local
config/secrets.json
It uses .gitignore syntax, and only files that match and are also gitignored are copied. Each worktree also needs its own dev server port if you run servers.
What happens when you exit
- Clean worktree: an unnamed session removes it and its branch. A named session asks first.
- Changes or new commits: Claude asks whether to keep or remove it. Keeping preserves the folder and branch; resume later with the
claude --worktree <name> --resumecommand it prints. Removing deletes the work.
To remove one yourself: git worktree remove <path> (add --force if it has changes; run git worktree unlock first if git says it is locked). Subagents can have their own worktrees too: add isolation: worktree to a custom subagent's frontmatter.
What worktrees do not isolate
They separate file edits. All worktrees still share one repository .git directory and your plan's usage limits: each extra session spends the same allowance (details). You also still have to watch each session separately.
Seeing all of them at once
Paneherd opens one terminal per session in a grid in VS Code or Cursor, so you can run a worktree session in each pane and see which is working, waiting or finished from one sidebar. It works with --worktree rather than replacing it. See how to run multiple Claude Code sessions at once.
Frequently asked questions
Do I need worktrees for two sessions?
Only if both change code in the same repository. Read-only sessions or sessions in separate projects do not collide.
Can two sessions use the same worktree name?
Passing a name whose folder already exists opens that existing worktree rather than creating a new one.