Where Can Claude Code Worktrees Still Collide?

Use Claude Code worktrees for checkout isolation, then check file ownership and shared resource claims before launching parallel sessions.

Compare integration surfaces before assigning tasks

Write a launch manifest with one row per session. Record its checkout path, branch, planned write paths, and the resources it will touch outside the checkout. Use the Claude Code worktree flag to open separate checkouts, then inspect the actual manifest against your plan. Two bug fixes can occupy different branches and still both edit the same generated manifest or lockfile. Treat that overlap as an integration handoff. For example, assign dependency changes to one session and ask the other to consume the reviewed dependency commit before regenerating its fixtures. At review time, compare the paths in the resulting patches with the planned write sets. An unexpected shared generated file counts as a missed boundary even if Git can merge it cleanly.

Common workflows - Claude Code Docs

Check the shared resource with both sessions alive

Git gives a linked worktree its own checkout metadata within the repository. Your test server, database, and cache still follow the addresses configured by the project. Before opening both sessions, assign distinct ports and separate disposable database names. Start both test servers in their respective checkouts and request a local health response containing the branch and a run identifier. Each address should return its own pair. A bind error exposes a duplicate port. A successful response carrying the other branch exposes a more dangerous case where tests can pass against the wrong server. For a database check, write a distinct marker to each disposable database and verify that the other session cannot read it through its own test configuration. Record the resolved addresses in the manifest so the check covers the effective settings.

Git - git-worktree Documentation

Give fresh tasks a common starting commit

Claude Code documents that its worktree workflow creates a separate checkout on its own branch from an existing commit. Before launching sessions, record the approved starting commit, then start each native worktree from the intended checkout and confirm the resulting base in each session. Assign one deliverable, a set of owned files, and a test to each branch.

In an illustrative repository, one session updates CSV export fixtures and another revises search help text. Run claude --worktree export-fixtures and claude --worktree search-help in separate terminals, following the documented named-worktree pattern. Before allowing edits, confirm the sessions report different directories and branches. At review, check that each branch contains the expected diff and that both sets of tests pass on the combined result.

Common workflows - Claude Code Docs

Attach a session to work already in progress

Git documents adding a worktree for an existing branch by passing a path and branch name. Suppose an illustrative task is already on fix/export-header. From the authoritative SSD repository, use git worktree add ../export-header fix/export-header, then start Claude Code from the new directory. Confirm the branch and compare its tip with the commit you expected to continue.

If Git reports that the branch is checked out elsewhere, locate its owner before doing anything to that checkout. Reuse the existing directory when it is available or assign a separate branch to the new session. Save this manual path for tasks whose starting branch matters, such as a review follow-up. It gives the operator a chance to verify the checkout before Claude begins editing.

Git - git-worktree Documentation

Check what approvals the sessions share

Claude Code’s settings documentation says worktree sessions use the local settings file at the main checkout’s root, subject to the documented settings rules. Inspect that file before launching parallel sessions, especially if an operator has saved approvals for shell commands. Give each session scoped development inputs and verify the effective settings using a harmless action that should ask for approval.

If one session seems to have inherited another task’s approval, compare the effective rule with the main checkout’s local settings. Coordinate any edit with the people using those worktrees, since one change can affect multiple sessions. If the tasks require separate permission policies or credentials, run them in separate environments and repeat the approval check before granting access to real resources.

Settings files and precedence - Claude Code Docs

Sources