3.3 — Path-Specific Rules for Conditional Convention Loading
CCAR-F Domain 3 · Task 3.3
What You Need to Know
Path-specific rules load conventions only when you edit files matching their glob patterns. They solve what neither root CLAUDE.md nor directory-level CLAUDE.md handles well: one file type scattered across many directories.
How Path-Specific Rules Work
Rule files live in .claude/rules/. Each starts with YAML frontmatter:
---
paths: ["terraform/**/*"]
---
# Terraform Conventions
- Use snake_case for all resource names
- Tag every resource with environment and team labels
Why Not Directory-Level CLAUDE.md?
Test files across 50+ directories would need a CLAUDE.md in each → massive duplication and drift.
Why Not Root CLAUDE.md?
Root CLAUDE.md loads in every session. Terraform conventions would consume tokens while editing React components.
Key Concept: Path-scoped rules are more token-efficient because they load only when you edit matching files.
When to Use Each Approach
| Scenario | Best approach |
|---|---|
| Universal team standards | Root CLAUDE.md |
| Conventions for one package directory | Directory-level CLAUDE.md |
| Conventions for a file type across many directories | Path-specific rules with globs |
| Task-specific workflows on demand | Skills |
Exam Traps
- Choosing directory-level CLAUDE.md for cross-directory conventions
- Placing file-type-specific conventions in root CLAUDE.md
- Confusing skills with path-specific rules for automatic convention application
Check your understanding
Practice Scenario
🔒 This practice scenario is part of Skillmarked Pro
The lessons stay free. Pro unlocks the other 23 CCAR-F practice scenarios and the 60-question timed mock exam, plus everything for every other exam.
Cancel anytime. Or €199 a year, which saves 17%.
Not sure yet? Try 10 free mock exam questions.
Already Pro? Log in.
Sources
- How Claude remembers your project, Claude Code Docs
- Settings files and precedence, Claude Code Docs
- Best practices for Claude Code, Claude Code Docs