[BUG] Rules with glob patterns not applied when creating new files

Resolved 💬 3 comments Opened Feb 8, 2026 by gherrink Closed Feb 8, 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?

Rules defined in .claude/rules/ with glob patterns are only surfaced as system-reminders when reading or
editing
existing files, but not when creating new files with the Write tool. This means rules are
silently ignored during file creation.

Actual Behavior

Rules are only triggered on file reads/edits. New file creation bypasses the rules entirely, leading to
inconsistent and hard-to-catch issues.

What Should Happen?

Rules with matching glob patterns should be surfaced when creating new files via the Write tool, not only
on reads/edits. This would ensure rules are applied consistently from the start.

Error Messages/Logs

Steps to Reproduce

.claude/rules/javascript.md:

---
paths:
  - "**/*.js"                                                                                                   
---                                                                                                             
                                                                                                                 
In each function you create add a `console.log("Called {function-name}.")` at the end of the function.

Scenario 1: Create file, then read and apply rule

  1. Ask Claude to create a new JS file with a helloWorld function
  2. Claude creates the file without applying the rule — no console.log is added
  3. Ask Claude to read the file — the rule now appears as a system-reminder
  4. Only after reading does Claude become aware of the rule and can retroactively apply it

Result: The rule is missed on creation and only discovered on a subsequent read, requiring a manual
follow-up to fix the file.

Scenario 2: Create file, then add a second function

  1. Ask Claude to create a new JS file with a helloWorld function
  2. Claude creates the file without applying the rule — no console.log is added to helloWorld
  3. Ask Claude to add a second function (e.g. sayHallo) to the same file
  4. Claude reads the file to edit it — the rule now appears as a system-reminder
  5. Claude applies the rule to the new sayHallo function but the original helloWorld function remains

non-compliant

Result: The same file ends up with inconsistent behavior — new functions follow the rule, but the
original function created before the rule was surfaced does not.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.37

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

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