Worktrees - Claude Code
Isolated git worktrees for parallel Claude Code sessions.
Git worktrees let you run multiple Claude Code sessions against the same repo on different branches without stomping on each other.
What it does
A worktree is a second checkout of the same repo, pointing at a different branch. Claude Code's EnterWorktree tool creates one, runs tasks in it, and exits back to the main checkout when done. Each session has its own working directory, its own branch, and its own in-flight changes - but shares the git object store.
When to use it
- Running two or three agents in parallel on different features.
- Keeping a clean main checkout while Claude experiments in a branch.
- Reviewing a PR in isolation without stashing.
- Dogfooding branch-heavy workflows like stacked PRs.
Gotchas
- Some tools (node_modules, build artifacts) need a separate install in each worktree.
- Hooks that assume a single working directory may misfire. Check your SessionStart scripts.
- Cleaning up abandoned worktrees takes an explicit prune - they're not garbage-collected.
Official docs: https://code.claude.com/docs/en/common-workflows.md#run-parallel-claude-code-sessions-with-git-worktrees
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
Was this helpful?





