[MODEL] Claude ignore Path-scoped rules during file creation
Preflight Checklist
- [x] I have searched existing issues for similar behavior reports
- [x] This report does NOT contain sensitive information (API keys, passwords, etc.)
Type of Behavior Issue
Claude created files without relevant rules applied.
What You Asked Claude to Do
File-scoped rules load on editing an existing file, not on creating a new one
_Summary_
A rule scoped to a file pattern (a glob tied to a file extension or path) loads into context once Claude opens or edits a file that already exists at a matching path. That half works. It does not load when Claude is about to create a brand new file at a path that would match the same pattern — there is no existing file yet for the pattern to match against, so the rule never enters context before the first draft is generated.
_What happened_
A rule meant to govern every file of a given type was followed reliably whenever an existing file of that type was opened and edited — the rule loaded first, the edit followed it. The same rule was not followed when a brand-new file of that same type was created from scratch. Nothing was wrong with the rule's content or the edit-time behavior; the gap was specifically at file-creation time, before any file existed for the pattern-matching to key off of.
_Why this matters_
Editing is a non-issue: the mechanism already works there. Creation is the actual problem: a rule intended to apply to "every file of type X" silently does not apply the first time a file of type X is written, because the load trigger depends on a file already being present at that path. This means brand-new files are the one case where a file-scoped rule is guaranteed to be missing from context at the moment it matters most — while the content is being generated, not after.
_Current workaround_
Writing a separate, always-on rule (one with no path pattern, so it loads every session regardless of any file existing) whose only job is to tell Claude, before creating a new file of a given type, to explicitly pull in and apply the relevant file-scoped rule. This works, but it is a manual patch for a gap in the trigger itself — every project that wants new files covered has to author the same workaround by hand, for every file-scoped rule it cares about.
_Suggested improvement_
When Claude is about to create a new file at a path, match that intended path against file-scoped rule patterns the same way an open/edit on an existing file already does, and load the matching rules before generation starts — not only after the file exists and something later opens it.
What Claude Actually Did
Created files without contextual rules applied.
Expected Behavior
Claude should apply all applicable rule for any extension before even it generates the first token of the new file it is planning to add to the project.
Files Affected
Any code file or document file that rules were made against.
Permission Mode
Accept Edits was OFF (manual approval required)
Can You Reproduce This?
Yes, every time with the same prompt
Steps to Reproduce
- Create a conditional rule that applies to .md file.
2.Ask model to create a new file with .md extension.
3.Observe the model does not load/apply in the rule crated in step 1.
Claude Model
Opus
Relevant Conversation
Impact
Medium - Extra work to undo changes
Claude Code Version
2.0.1 (Claude Code)
Platform
Anthropic API
Additional Context
Unity Project cs.
Documentation using md files.
Using terminal to send prompts.
Setup rules under .claude/rules/
Added about information about rule lin CLAUDE.md (Always apply)
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗