Path-scoped rules and subdirectory CLAUDE.md not loaded when creating new files matching the pattern
Summary
Path-scoped rules (.claude/rules/*.md with paths frontmatter) and subdirectory CLAUDE.md files are only loaded when Claude reads a matching file. When Claude creates a new file matching the pattern, the rules are never loaded — because there is no read before a write on a file that doesn't exist yet.
Note: this is not an issue for editing existing files, since Claude always reads a file before modifying it, which triggers rule loading correctly.
Steps to reproduce
- Create
.claude/rules/typescript.mdwithpaths: ["**/*.ts"]and an instruction like "Always report after reading this file" - Ask Claude to create a new
.tsfile (one that doesn't exist yet) - Observe: the rule is not loaded, the instruction is not followed
Same behavior with subdirectory CLAUDE.md: create src/components/CLAUDE.md, ask Claude to create a new file in src/components/ — rule is not loaded.
Expected behavior
Rules should also load when Claude creates a new file whose path matches the pattern.
Actual behavior
Rules only load on file reads. Since a new file has no prior content to read, rules are never loaded when creating it.
Why this matters
Creating new files is the most important case for path-scoped conventions — that's when there's no existing code to follow as a reference and Claude needs the rules most.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗