Lesson 3.3Lesson 15 of 30
Path-specific rules
Apply path-specific rules for conditional convention loading
Key points
- 1A Markdown file in .claude/rules/ with YAML frontmatter paths: ["terraform/**/*"] is a conditional rule: it loads only when Claude reads or edits a file that matches the glob.
- 2Conditional loading keeps unrelated conventions out of context: a session in React code does not carry Terraform or migration rules. A rule without paths, like an @import, loads at launch.
- 3Match by file type anywhere with **: "**/*.test.tsx" covers every test file in every folder; "*.test.tsx" only matches the project root.
- 4Conventions for files spread across many directories (tests, stories, migrations) belong in one glob rule, not in a
CLAUDE.mdcopied into each directory. - 5A subdirectory
CLAUDE.mdstill fits conventions tied to one directory, such as a legacy module that lives only in services/payments/.
What the exam guide checks here
Objective wording from the exam guide (English).
- 3.3.K1.claude/rules/ files with YAML frontmatter paths globs activate conditionally
- 3.3.K2Path-scoped rules load only when editing matching files, saving context
- 3.3.K3Glob rules beat directory CLAUDE.md for conventions spanning directories
- 3.3.S1Write rules with paths: ["terraform/**/*"] frontmatter
- 3.3.S2Apply conventions by file type anywhere (**/*.test.tsx)
- 3.3.S3Choose path rules over subdirectory CLAUDE.md for files spread across the codebase
Lock it in
Answer scenario questions on this topic. Every option comes with an explanation.
Practise 3.3 · 16 questions