Run two Claude Code sessions in the same folder and they share one set of files: while one builds a feature, the other’s bug fix lands in the same working tree, and the edits tangle. A git worktree fixes that. It’s a second working directory with its own files and its own branch, sharing the repository’s history and remote with your main checkout. Give each session its own worktree and their edits can’t collide.
Worktrees don’t run anything in parallel themselves. They’re the isolation underneath the things that do: sessions you start yourself, subagents, and the background sessions you dispatch.
Start a session in one
claude --worktree feature-auth--worktree (or -w) creates the worktree at .claude/worktrees/feature-auth/ on a new branch, worktree-feature-auth, and starts Claude there. Run it again with another name in a second terminal for a second isolated session; leave the name out and Claude picks one. Mid-session, you can also just ask Claude to “work in a worktree”.
By default a new worktree branches from your repository’s default branch on the remote, so it starts clean. Set worktree.baseRef to "head" in settings to branch from your current local work instead.
Subagents can have their own
A subagent can run in a temporary worktree so parallel edits don’t conflict: ask Claude to “use worktrees for your agents”, or add isolation: worktree to a custom subagent’s frontmatter. If the subagent finishes without changes, its worktree is removed for you.
Cleaning up
When you exit, Claude checks the worktree. A clean one from an unnamed session is removed along with its branch; one with changes or new commits prompts you to keep it or remove it. Kept worktrees can be resumed with claude --worktree <name> --resume.
The catch
A worktree is a fresh checkout. Your dependencies aren’t installed there, and gitignored files like .env are missing. Run your setup in it, and list files to copy in a .worktreeinclude file at the project root (it uses .gitignore syntax). Add .claude/worktrees/ to your .gitignore too.
Worktrees need git; other version control systems can supply their own logic through WorktreeCreate and WorktreeRemove hooks. And several sessions at once means several times the tokens. Worktrees isolate files on disk; to undo within a single session, that’s checkpoints.