Guide
Git worktrees for Claude Code: run parallel sessions without collisions
One checkout per session prevents file overwrites, though ports and services stay shared.
Claude Code behavior from Anthropic’s docs, checked 26 October 2026.
The short answer
A git worktree gives each Claude Code session its own folder and branch while sharing one repo history, preventing edit collisions. Use claude --worktree <name> or git worktree add. Worktrees isolate files only: ports, local databases and merge conflicts remain shared.
Three ways to get a worktree
Let Claude Code create it
Creates
.claude/worktrees/<name>/on branchworktree-<name>(needs at least one commit).claude --worktree feature-authCreate it with git
Add a sibling folder on a new branch, then launch Claude Code inside it.
git worktree add -b feature-auth ../myapp-auth origin/main cd ../myapp-auth && claudeUse agent view
In a git repo,
claude agentsautomatically places each background session in its own worktree.Clean up after merging
Remove the checkout folder and delete the branch.
git worktree list git worktree remove ../myapp-auth git branch -d feature-auth
What a worktree does not isolate
- Ports
Two dev servers still compete for the same port.
- Databases and services
Local databases, caches and queues remain shared across checkouts.
- Untracked files
Fresh worktrees lack
.envand installed dependencies. Use.worktreeincludeto have Claude Code copy gitignored files.- Merge conflicts
Overlapping branch edits still conflict at merge time.
Worktrees on a myth/acc canvas
myth/acc does not auto-create worktrees. Create them with git or Claude Code, then open each worktree folder as its own project. Both the jail and per-turn undo follow each checkout independently.
Running agents in parallelQuestions, answered
How many worktrees can I run?
No hard cap. Your review bandwidth, machine resources and plan limits set the practical ceiling.
Do I need worktrees for every agent?
Only when multiple agents edit the same repository at the same time.
Does myth/acc make a worktree for each agent?
No. Create worktrees with git or Claude Code and open each folder as a project.
Does undo work in a worktree?
Yes. Each worktree is a normal git checkout with independent snapshots and undo.
Keep reading
- Tools for running several agentsTerminal panes, native views, desktop apps and browser canvases compared.
- Parallel coding agentsHow to run several AI coding agents at the same time: one prompt to many, shared notes, checklists and delegation.
- Claude Code without permission promptsSkipping prompts is only as safe as the boundary around the process.
Sources
- Claude Code: run parallel sessions with worktrees
- Claude Code: common workflows
- git-worktree documentation
- Claude Code: agent view
Facts on this page were checked on . Products change: check the vendor’s own page before you decide.