[BUG]

Status Open
Reported on v2.1.216
Maintainer reply None cached
Activity 1 comment · opened Jul 22, 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?

A .claude/rules/*.md file with paths: frontmatter (a path-scoped rule) is injected into context only when a matching file is opened with the Read tool. It is not injected when the agent touches a matching file any other way:

  • Write of a matching file — no injection.
  • Bash-mediated read of a matching file — git show <ref>:file, grep, cat, etc. — no injection.

There is no diagnostic that a matching rule exists but was not loaded, so the guidance is silently absent exactly in the situations it was scoped to cover.

The high-consequence case is subagents and review agents, which routinely gather file contents through Bash rather than the Read tool — git show, git diff, grep, forge-CLI diff commands. Because Bash-mediated reads don't trigger injection, a reviewer never receives the path-scoped rules for the files it is reviewing — the guidance a maintainer scoped to those files (conventions, invariants, "don't do X in this module") is absent precisely when it would be applied. Any workflow that relies on path-scoped rules to steer agents on specific files has to work around this by hand (e.g. re-injecting the contract into the agent's prompt), and there is no way to detect a silent miss.

What Should Happen?

A path-scoped rule whose paths: glob matches a file the agent is working with should load into context regardless of how the agent touches the file — or, at minimum, there should be a signal when a matching rule exists but was not loaded, so the rule's author can tell "no rule matched" from "rule matched but wasn't applied."

Error Messages/Logs

Steps to Reproduce

  1. In a project, create .claude/rules/py-rule.md:
---
paths: ["**/*.py"]
---
SENTINEL-9F3A: If you can read this, the path-scoped rule loaded.
  1. Ensure at least one committed .py file exists (for the git show step).
  2. Start a fresh Claude Code session.
  3. Bash-read: ask the agent to run git show HEAD:<that_file>.py (or grep -n . <that_file>.py). → The agent has no knowledge of SENTINEL-9F3A; the rule did not load.
  4. Read tool: ask the agent to open the same .py file with the Read tool. → SENTINEL-9F3A is now in context; the rule loaded.
  5. Write: ask the agent to create a new .py file with the Write tool. → The rule does not load for the write.

The asymmetry between steps 4 and 5 (same file, different access path) is the bug.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.216

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

I'm using Claude Desktop

View original on GitHub ↗

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