Skip to content

fix(source-control): /worktree creates in-repo .claude/worktrees/ -> hits CC double-load bug; create out-of-tree #400

Description

@kyle-sexton

Summary

The /worktree skill creates worktrees at Claude Code's native in-repo location (.claude/worktrees/<name>). Working inside such a nested worktree triggers a confirmed, unfixed Claude Code bug that double-loads CLAUDE.md + .claude/rules/ (~26K wasted input tokens per message). The skill should create worktrees out-of-tree to avoid it.

Component

plugins/source-control/skills/worktree/context/create.md (currently calls EnterWorktree, which lands in .claude/worktrees/).

Evidence

  • Upstream, confirmed & unfixed: anthropics/claude-code #29599 ("Worktree rules loaded twice", closed as duplicate) and #23565 ("Memory files loaded twice in worktree", closed not-planned). Mechanism: a worktree at .claude/worktrees/<n> is physically inside the parent repo; CC's upward walk from the worktree discovers both the worktree root and the parent repo root (shared .git), loading rules/memory twice. Reported waste ~12–26K tokens/message.
  • Related: .claude/worktrees/ is not auto-excluded and adding it to .gitignore breaks git worktree add in future clones (#57512 — use .git/info/exclude); worktree .claude/ is missing skills/agents/rules/ (#28041).
  • A sibling/external worktree (not nested under the parent repo) is not an ancestor of the parent, so the upward walk does not hit the parent → the double-load does not occur. Out-of-tree placement sidesteps the bug entirely.

Expected

/worktree create places worktrees out-of-tree (via the shared helper / external root), not under .claude/worktrees/, so the double-load bug never triggers.

Acceptance criteria

  • /worktree create no longer produces in-repo .claude/worktrees/ worktrees for ghq/normal repos.
  • Placement flows through the shared helper (unify issue) / external root (epic).
  • Note the upstream bugs in the skill's context docs as the rationale; add .git/info/exclude guidance if any in-repo path remains for a fallback.

Part of / depends on

Epic #398; implemented via the shared helper in the unify issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: highSignificant impact, or blocks an imminent release; staff this cycle.status: needs-decisionAwaiting a human or maintainer judgment call.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions