[BUG] Memory files loaded twice when working in git worktree — parent repo and worktree paths both resolved
When running Claude Code inside a git worktree, .claude/CLAUDE.md and .claude/rules/ are loaded from both the parent repository path and the worktree path, resulting in duplicate memory file consumption.
Environment
- Claude Code v2.1.32
- macOS (Darwin 25.0.0)
- Model: claude-opus-4-6
Steps to Reproduce
- Create a project with
.claude/CLAUDE.mdand.claude/rules/*.md - Create a git worktree:
``bash``
git worktree add .worktrees/wt-feature feature-branch
- Launch Claude Code inside the worktree:
``bash``
cd /path/to/project/.worktrees/wt-feature
claude
- Run
/contextto inspect memory file loading
Expected Behavior
Each .claude/ file should be loaded once. Claude Code should recognize that the worktree's .claude/ directory contains the same files as the parent repository and deduplicate them.
Actual Behavior
Every file in .claude/ is loaded twice — once resolved via the parent repository path and once via the worktree-relative path:
Memory files · /memory
└ ~/project/.claude/CLAUDE.md: 2.6k tokens
└ ~/project/.claude/rules/styles.md: 3.5k tokens
...
└ .claude/CLAUDE.md: 2.6k tokens ← duplicate
└ .claude/rules/styles.md: 3.5k tokens ← duplicate
...
In my case, this results in ~12k extra tokens of duplicated memory files (25.5k total, where ~12.5k is duplication).
Additional Context
- Path-conditional rules (with
paths:frontmatter) are correctly filtered on the parent repo side but still loaded unconditionally from the worktree side, suggesting the two resolution paths apply filtering independently. - Related: #19516 (duplicate memory files on Windows), #17927 (worktree path resolution bug)
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗