Path-specific rules in .claude/rules
How a paths glob in a .claude/rules/ file makes conventions load only when Claude reads, writes or edits a matching file, how the patterns resolve, what silently breaks scoping, and when a path-scoped rule beats a subdirectory CLAUDE.md. Also covers compaction, symlinked rules and logging loads with the InstructionsLoaded hook.
Apply path-specific rules for conditional convention loading
~8 min read · 9 practice questions ·
What the exam expects
- Create a
.claude/rules/file with YAMLpathsfrontmatter (for examplepaths: ["terraform/**/*"]) so its conventions load only when Claude works with matching files. - Write glob patterns that match files by type in any directory, such as
**/*.test.tsx, and spot patterns that match too little. - Choose a path-scoped rule over a subdirectory CLAUDE.md when conventions apply to files spread across the codebase, and the reverse when one team owns one directory.
- Diagnose rules that load everywhere or never, including after compaction and through symlinks.
Key terms: path-scoped rule (a rule file whose paths frontmatter limits when it loads); glob (a pattern such as src/**/*.ts, where ** spans any depth); base directory (the folder a rule's patterns are relative to); unconditional rule (a rule without paths, loaded at launch); lazy load (loading triggered by a file access during the session).
Key facts
- Detail
pathsonly; other keys ignored without error
paths formats- Detail
- YAML list or comma-separated string
- Detail
- Read, Write or Edit of a matching file, or a single-file Bash read
paths- Detail
- Loads at launch, every session
- Detail
- Rule loads unconditionally;
claude --debugshows the error
- Detail
- The directory containing the rule's
.claudefolder
*.md- Detail
- Root-level Markdown files only
- Detail
- 1,000 expanded patterns per rule's
pathslist
/compact- Detail
- Scoped rules reload on demand, not re-injected
- Detail
- After approval, only rules without
pathsload
InstructionsLoaded- Detail
- Logs loads with
load_reason,globs,trigger_file_path; no blocking
- Why does a rule with
globs:frontmatter load in every session? - When does a rule with
paths: ["db/migrations/**/*.sql"]enter context? - Why choose a path-scoped rule over subdirectory CLAUDE.md files for test conventions?
- What happens to a loaded scoped rule after
/compact? - Which hook logs each rule load with the glob and trigger file?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Claude Certified Architect - Foundations pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 30 lessons of the Claude Certified Architect - Foundations guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (9 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams
Practice for the Claude Certified Architect - Foundations exam
Certifyforce is an independent study resource and is not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic.