Path-scoped rules and subdirectory CLAUDE.md not loaded when creating new files matching the pattern

Resolved 💬 2 comments Opened May 28, 2026 by bogdan Closed Jul 6, 2026

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

  1. Create .claude/rules/typescript.md with paths: ["**/*.ts"] and an instruction like "Always report after reading this file"
  2. Ask Claude to create a new .ts file (one that doesn't exist yet)
  3. 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗