[FEATURE] Path-scoped rules should trigger on Write and Edit, not only on Read

Resolved 💬 7 comments Opened Jun 2, 2026 by gmbalaa14 Closed Jul 6, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Summary

Path-scoped rules (.claude/rules/ with paths frontmatter) should trigger whenever Claude reads, writes, or edits a file matching the glob — not only on reads.

Problem

Currently, paths-scoped rules fire when Claude calls the Read tool on a matching file. This works for editing existing files since Claude reads before editing. But for brand new files, Claude calls Write directly with no prior Read — so the rule is never injected into context.

Example: a coding standard rule scoped to **/*.cs is silently skipped when Claude creates a new .cs file from scratch, which is precisely when the standard is most needed.

Proposed Fix

Extend the paths trigger to cover Write and Edit tool calls on matching paths, in addition to Read:

| Tool call | Current behaviour | Expected behaviour |
|---|---|---|
| Read on matching path | ✅ Rule injected | ✅ Rule injected |
| Edit on matching path | ✅ Rule injected (read first) | ✅ Rule injected |
| Write on new matching path | ❌ Rule skipped | ✅ Rule injected |

No frontmatter changes required — paths semantics become complete by covering all file-touching tool calls, not just reads.

Why This Matters

Rules are the right place for coding standards and conventions. But a standard that applies to existing files but silently skips new ones creates inconsistency that is hard to notice and debug. Completing the paths trigger closes that gap without any additional configuration burden on the user.

Alternatives Considered

  • allowed-tools frontmatter on rules — proposed in this issue originally, but correctly challenged as unnecessary complexity. The simpler fix is completing the paths trigger semantics instead.
  • Global @ import in CLAUDE.md — works but loads the rule unconditionally every session, wasting tokens even when not writing code.
  • Subdirectory CLAUDE.md — scopes to a directory but doesn't solve the tool-call trigger gap.

Priority

Medium - Would be very helpful

Feature Category

CLI commands and flags

Additional Context

The linked duplicate #63142 is itself a consolidation of multiple reports describing the same gap, which indicates this is a recurring pain point across different workflows — not an edge case.

Key distinction: #63142 documents the problem across those reports but does not include a proposed solution. This issue (#64708) provides a concrete design proposal with the allowed-tools frontmatter trigger mechanism, use cases, and alternatives considered.

Requesting this issue remain open as the design proposal to complement #63142, or that the proposal be incorporated into #63142 before this is closed.

View original on GitHub ↗

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