Allow configuring worktree root directory outside the project folder

Resolved 💬 3 comments Opened May 10, 2026 by bigmonkiki Closed May 13, 2026

Problem

When Claude Code creates worktrees inside .claude/worktrees/ (the default), they live as subdirectories of the main project. This causes Yarn 4 to traverse up the directory tree and treat the main project as the workspace root — inheriting its node_modules instead of resolving a fresh install.

Impact

This breaks projects that run multiple package versions concurrently. For example, a design system repo with a V2 stable branch and a V3 experimental branch checked out simultaneously: the V3 branch updates @optiaxiom/react to 3.0.0-next.0 in the main project's node_modules, and any V2 worktree nested inside the same directory silently inherits V3 — causing incorrect styles and token values at runtime.

The workaround (copy yarn.lock into the worktree + run npx @yarnpkg/cli-dist install) works but requires manual setup every time a new worktree is created.

Proposed solution

Add a worktreeRoot setting to settings.json that lets users specify a directory outside the project folder where Claude Code creates worktrees:

{
  "worktree": {
    "root": "~/worktrees/my-project"
  }
}

This would prevent any package manager from traversing up from the worktree into the main project, making multi-version setups work out of the box.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗