[BUG] Path-scoped `.claude/rules/` not injected when Claude is launched from a subdirectory (glob matched against launch CWD, not project root)

Resolved 💬 1 comment Opened Jun 4, 2026 by keithschacht Closed Jul 8, 2026

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?

Path-scoped rules in .claude/rules/*.md (with paths: frontmatter) are injected correctly when Claude Code is launched from the project root, but the same rule fails to inject when Claude Code is launched from a subdirectory — even though the project-root CLAUDE.md still loads fine from that subdirectory.

This appears to be a separate bug from #16853 (where path-scoped rules never load at all). Here they do load — but only depending on the launch directory. The glob match seems to be anchored to the launch CWD rather than the project root (where .claude/ lives).

Reproduction

Project layout:

the-project/
├── .claude/
│   └── rules/
│       └── livekit_menubar.md
├── livekit-menubar/
│   └── src/
│       └── agent.py
└── rails/            # sibling subdirectory

.claude/rules/livekit_menubar.md frontmatter:

---
paths:
  - "livekit-menubar/**"
---
# (rule body)

Case A — launch from project root:

cd the-project
claude
> read this file: livekit-menubar/src/agent.py

Result: ✅ The rule is injected as a <system-reminder> immediately after the Read returns.

Case B — launch from a sibling subdirectory:

cd the-project/rails
claude
> read this file: livekit-menubar/src/agent.py

Result: ❌ The file is read successfully, but the rule is NOT injected. (The project-root CLAUDE.md does still load in this session, confirming the project root is discovered correctly.)

The only variable changed between A and B is the directory Claude was launched from. The file read and its path are identical.

What Should Happen?

paths: glob matching for .claude/rules/ should be evaluated relative to the project root (where .claude/ is discovered), not the launch CWD — so the same file read triggers the same rule regardless of which directory Claude was launched from. Launching from a subdirectory should narrow nothing about which root-level rules can fire for files outside that subdirectory.

Notes

  • Related but distinct: #16853 (path-scoped rules not loading at all), #23478 (path rules only firing on Read, not Write).
  • The docs ("Path-specific rules" in the Memory guide) don't specify what the glob is anchored to.

Environment

  • Claude Code: 2.1.162
  • Platform: macOS 26.4

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗