[BUG] paths: frontmatter with multiple patterns only matches first pattern; globs: has no scoping at all
Summary
Two related issues with rules frontmatter scoping:
paths:with multiple patterns: Only the first pattern is evaluated. Second and subsequent patterns are silently ignored.globs:field: Provides no scoping at all — rules are loaded unconditionally at session start regardless of glob patterns.
Environment
- Windows 11 Pro
- Claude Code latest (tested across multiple recent versions)
- Tested at both user-level (
~/.claude/rules/) and project-level (.claude/rules/)
Bug 1: paths: multiple patterns — only first matches
Reproduction
- Create
.claude/rules/test.md:
---
paths:
- "**/*.ts"
- "**/*.js"
---
# MULTI_PATTERN_TEST
This rule should load for both .ts and .js files.
- Start a new interactive session (not resume)
- Read a
.tsfile → rule loads ✅ - Start another new session
- Read a
.jsfile → rule does NOT load ❌
Pattern swap test
Swapping list order (.js first, .ts second):
.jsnow matches ✅.tsno longer matches ❌
→ Always only the first pattern is evaluated.
All tested formats (same behavior)
| Format | 1st pattern | 2nd pattern |
|--------|-------------|-------------|
| YAML list: - "**/*.ts" + - "**/*.js" | ✅ | ❌ |
| CSV: paths: **/*.ts,**/*.js | ✅ | ❌ |
| Brace expansion: paths: **/*.{ts,js} | 1st expansion only ✅ | ❌ |
| Space-separated: paths: **/*.ts **/*.js | ❌ | ❌ |
Tested at both project-level and user-level — same result.
Expected behavior
All patterns in the list should be evaluated with OR logic. The v2.1.84 CHANGELOG states "Rules and skills paths: frontmatter now accepts a YAML list of globs", implying full support.
Bug 2: globs: field has no scoping
Reproduction
- Create
.claude/rules/test-globs.md:
---
globs: **/*.ts, **/*.js
---
# GLOBS_TEST
This rule should only load for .ts and .js files.
- Start a new interactive session
- Without reading any file, ask if the rule is visible → rule IS loaded ❌
The rule is loaded unconditionally at session start, regardless of glob patterns. Tested with:
- Quoted:
globs: "**/*.ts, **/*.js"— same behavior (always loaded) - Unquoted:
globs: **/*.ts, **/*.js— same behavior (always loaded) - Project-level and user-level — same behavior (always loaded)
Expected behavior
globs: should scope rules to matching files only, similar to paths:.
Test methodology
- Each test performed in a fresh interactive session (not resume, not
-pbatch mode) - One file read per session to avoid cross-contamination
- Unique keywords embedded in test rules (e.g.,
MULTI_PATTERN_TEST) to detect loading via Claude's response - Confirmed that single
paths:pattern works correctly (control test)
What works correctly (control tests)
| Condition | Behavior |
|-----------|----------|
| paths: single pattern + project-level | ✅ Lazy-loads on matching file Read |
| paths: single pattern + user-level | ✅ Lazy-loads on matching file Read |
| No frontmatter (no scoping) | ✅ Loads at session start |
Related issues
- #13905 — YAML syntax issues (partially addressed in v2.1.84)
- #17204 — Documentation vs implementation mismatch
- #21858 — User-level rules paths ignored (single pattern now works, but multiple still broken)
- #23478 — Write operation doesn't trigger paths rules (NOT_PLANNED)
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗