Lv.1 0 XP

Path-Specific Rules — Conditional Convention Loading

⚡ Exam Tested 8 min +35 XP
💡
THE ANALOGY

A context-aware employee handbook. Instead of reading 400 pages every day, the system shows you only the sections relevant to what you're currently working on. Working on an API endpoint? The API conventions section activates. Writing a test? The testing standards section activates.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Using directory-level CLAUDE.md when path-specific rules with glob patterns are the better choice. Directory CLAUDE.md always loads for everything in that directory. Path-specific rules load only when editing files matching the glob pattern — more precise and lower noise.

KEY POINTS
1 Path-specific rules live in .claude/rules/ directory as individual YAML files with glob pattern frontmatter.
2 Rules load ONLY when Claude is editing files matching the glob pattern — targeted, not always-on.
3 This is better than directory CLAUDE.md when the convention applies to specific file types across multiple directories.
4 Example: test conventions apply to *.test.tsx files anywhere in the project — a path-specific rule beats a CLAUDE.md in every directory.
5 YAML frontmatter specifies: which paths this rule applies to, when it loads, and the rule content.