[BUG] Memory files loaded twice when working in git worktree — parent repo and worktree paths both resolved

Resolved 💬 4 comments Opened Feb 6, 2026 by ln-north Closed Feb 6, 2026

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

  1. Create a project with .claude/CLAUDE.md and .claude/rules/*.md
  2. Create a git worktree:

``bash
git worktree add .worktrees/wt-feature feature-branch
``

  1. Launch Claude Code inside the worktree:

``bash
cd /path/to/project/.worktrees/wt-feature
claude
``

  1. Run /context to 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)

View original on GitHub ↗

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