[BUG] Path-conditional rules (paths: frontmatter) ignored when loaded via git worktree resolution
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When running Claude Code inside a git worktree, .claude/rules/ files are loaded from both the parent repository path and the worktree-relative path (see #16600). The paths: frontmatter filtering works correctly for files resolved via the parent repository path, but is completely ignored for the same files resolved via the worktree-relative path.
This means path-conditional rules are always loaded from the worktree side, even when working on files that don't match the glob patterns.
Environment
- Claude Code v2.1.32
- macOS (Darwin 25.0.0)
Steps to Reproduce
- Create a rule file with
paths:frontmatter:
.claude/rules/coordinates.md:
```yaml
---
paths:
- "src/components/glyph-editor/**"
- "src/store/viewport/**"
---
# Coordinate system rules
...
```
- Create a git worktree:
``bash``
git worktree add .worktrees/wt-feature feature-branch
- Launch Claude Code inside the worktree and run
/context
Expected Behavior
coordinates.md should not be loaded unless working on files matching the paths: patterns, regardless of which resolution path loaded it.
Actual Behavior
The parent repo resolution correctly filters the rule — coordinates.md does not appear under ~/project/.claude/rules/. However, the worktree resolution ignores the paths: frontmatter and loads it unconditionally under .claude/rules/:
Memory files · /memory
└ ~/project/.claude/rules/coordinates.md ← NOT loaded (paths: filter works)
...
└ .claude/rules/coordinates.md: 1.9k tokens ← LOADED (paths: filter ignored)
What Should Happen?
The paths: frontmatter should be evaluated consistently regardless of which resolution path loads the file.
Additional Context
- This is distinct from #16600 (duplicate loading itself) and #16853 (paths: not working at all). Here,
paths:works for one resolution path but not the other. - Confirmed with multiple rule files (
storybook.md,coordinates.md,storage.md) — all show the same behavior.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗