In this article
A worktree gives a session its own file checkout, while dependencies, external resources and final integration still need explicit coordination.
Independent coding sessions can collide when they edit the same working directory. Claude Code documents starting sessions in Git worktrees so each can operate in a separate checkout. The mechanism provides a clear file boundary, while the surrounding environment and the eventual combination of results remain part of the developer’s workflow.
Start from an existing repository state
The documented claude --worktree workflow creates a checkout from an existing commit, so a repository needs a commit to provide the base. For a hypothetical search fix, name the worktree according to the task and identify its starting state. This makes the resulting diff meaningful. Without a known base, a reviewer cannot tell which changes belong to the independent session.
Prepare the checkout that will run commands
A fresh working copy may lack ignored dependencies or local configuration. Check the project’s supported setup before running tests. A command in the main checkout does not validate a patch that exists only in the worktree. Record the actual working directory for the relevant check. In the search example, the test must read the changed query handler and its matching fixture from the intended copy.
Coordinate resources outside Git
Separate files do not automatically allocate separate ports, databases or service accounts. Two development servers can still compete for the same address. Choose resource assignments that make the independent checks possible, or serialize the operation that requires a shared resource. This is a concrete environment decision, not a reason to assume that all parallel work is unsafe or that worktree isolation has failed.
Review the isolated result before combining it
Inspect the worktree diff against its base and connect each file to the requested search behavior. Generated outputs may legitimately accompany a source change, but their relationship should be visible. Keep validation evidence with that candidate. A second session’s successful check does not prove this patch works, even if both tasks concern the same application and use the same test command name.
Verify the combined state when needed
Independent patches can interact through shared interfaces even when they edited different files. After combining a search change with a new serializer, run the focused integration check that exercises their relationship. Preserve which worktree produced each patch and what was verified before combination. This completes the lifecycle: a separate checkout helped develop the candidate, while the final application state receives its own relevant validation.
Documentation and further study
Related engineering guides: Reproducible inference stacks: preserving a GPU pilot’s result; Choose a local AI stack: desktop chat, shared UI or coding agent.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.