claude-code - 💡(How to fix) Fix Allow configuring worktree root directory outside the project folder [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#57738Fetched 2026-05-11 03:26:43
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
labeled ×2commented ×1

Fix Action

Fix / Workaround

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.

Code Example

{
  "worktree": {
    "root": "~/worktrees/my-project"
  }
}
RAW_BUFFERClick to expand / collapse

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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING