Claude Code runs parallel sessions and subagents in git worktrees: separate checkouts on separate branches, sharing one repository. What a worktree shares and doesn't, the one-branch rule, where Claude Code puts them and when it cleans them up, and the things that still collide: dependencies, ports, local databases and .env files.
A git worktree is a second working directory for the same repository: its own files, its own branch, its own staging area, the same history. Coding agents use them so two sessions, or a session and its subagents, can edit at the same time without overwriting each other. If you run Claude Code with --worktree, or ask it to use worktrees for its agents, this is what is happening underneath.
Two consequences follow. A commit made in one worktree is visible from all of them at once, with no push or fetch. And git refuses to check out a branch that another worktree already has checked out, so each worktree works on its own branch, and merging is how their work comes together.
Book a free 30-minute call. You'll leave knowing what we'd do first and roughly what it costs, whether or not you hire us.
`claude --worktree feature-auth` (or `-w`) creates `.claude/worktrees/feature-auth/` on a new branch, `worktree-feature-auth`, and starts the session there. Run it again with another name in another terminal for a second, isolated session.
New worktrees branch from the repository's default branch on the remote. Set `worktree.baseRef` to `"head"` to branch from your current local work instead, which is what subagents working on an in-progress change usually need.
Subagents get their own worktrees when you ask for it, or always, with `isolation: worktree` in a custom agent's frontmatter.
On exit, a clean worktree from an unnamed session is removed with its branch; one with changes, untracked files or new commits prompts you to keep or remove it. Subagent worktrees with work in them stay until a periodic sweep can remove them without losing anything.
While a session is isolated, Claude Code refuses edits and git commands aimed at the main checkout.
`git worktree list` shows every worktree and its branch.
`git worktree remove <path>` deletes one cleanly (it must be clean, or use --force). Deleting the directory by hand leaves metadata behind; `git worktree prune` clears it.
`git worktree lock` protects one from pruning; Claude Code locks the worktrees of running agents, so unlock before removing one by hand.
`git worktree repair` reconnects worktrees after you move the repository.
Once a month: what changed in tech that month and what it means for you, from cloud and AI to security and the tools you build with. Every item links to its source. No sales pitch, unsubscribe in one click.
Book a free 30-minute call about it. Bring your setup and your bill; you'll leave knowing what we'd do first and roughly what it costs, whether or not you hire us.
Or keep reading
Using AI to Upgrade Legacy Code in 2026: AWS Transform Custom vs General Coding Agents
Java 8 to 17, Python and Node.js runtime bumps, AWS SDK v1 to v2, framework upgrades: the same change repeated across hundreds of repositories. AWS Transform custom (December 2025) runs these as defined transformations from one CLI command; coding agents such as Claude Code and Codex handle one-off and judgment-heavy changes. When to use which, and how to keep both safe.
Read
Transitioning From Team Foundation Server to GitHub or Azure DevOps: TFVC to Git, Builds and Work Items
Team Foundation Server 2017 reaches end of support on January 11, 2027, and Azure DevOps Server 2020 left mainstream support in October 2025. How to move source control from TFVC to Git, pipelines from XAML or classic builds to YAML or GitHub Actions, and work items to a supported system.
Read
As of November 2, 2026. Provided as is, for general information, and accurate to the best of our knowledge on the date shown. Not legal, compliance, tax, financial or other professional advice. Prices, limits and vendor services change; check current vendor documentation before relying on anything here. Terms of use.