[BUG] Path-scoped .claude/rules inject on Read but not on Write of a new file

Open 💬 0 comments Opened Jul 1, 2026 by BenjaminG

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 (.claude/rules/*.md with paths: frontmatter) inject when Claude reads a matching file, but not when Claude creates a new matching file with the Write tool.

The docs (memory.md, "Path-specific rules") say:

"Path-scoped rules trigger when Claude reads files matching the pattern, not on every tool use."

The wording only covers reads. A file that is written but never read never loads its own path-scoped rules. Feature work creates a lot of new files, so much of the freshly-written code lands without its conventions in context, which is exactly when the rules would help.

What Should Happen?

Writing a new file whose path matches a rule's paths: glob should inject that rule, the same way reading a matching file does. The rule is equally relevant whether the file is read or created.

If the Read-only behavior is intentional, the docs should say so explicitly: state that Write of a new file does not trigger injection, so users don't assume "working with a matching file" covers creation.

Steps to Reproduce

Verified with headless claude -p (deterministic, no interactive state):

  1. Add a path-scoped rule at .claude/rules/react.md:

```markdown
---
paths:

  • "**/*.tsx"

---
# React rule
Treat useEffect as a last resort.
```

  1. Read case, works:

``bash
claude -p "Read an existing .tsx file, then list any project rules you received automatically" --allowedTools Read
`
The React rule is injected as a
<system-reminder>` after the Read.

  1. Write case, fails:

``bash
claude -p "Create a NEW .tsx file with the Write tool (do not Read it first), then list any project rules you received automatically" --allowedTools Write
``
The React rule is not injected. Only PostToolUse hooks fire.

Is this a regression?

Not that I can tell. It looks like the behavior since path-scoped rules shipped.

Claude Code version

2.1.197

Additional context

Different from #16853 (rules never load, including on Read), #65257 (subdirectory launch CWD), and #66027 (@import eager loading). Here Read injection works: only Write of a new file is uncovered. Whether the answer is code (inject on Write) or docs (state the limit), the Read/Write split is worth clarifying.

View original on GitHub ↗