CCA Prep

Lesson 3.3Lesson 15 of 30

Path-specific rules

Apply path-specific rules for conditional convention loading

Path-specific rulesWhere does this convention apply?everywhere in the projectRoot CLAUDE.mdloads at launchone directory onlySubdirectory CLAUDE.mde.g. services/payments/a file type across manyfolders.claude/rules/*.md withpathspaths: ["**/*.test.tsx"]Path rules load only when Claude works with matching files, so they save context

Key points

  1. 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.
  2. 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.
  3. 3Match by file type anywhere with **: "**/*.test.tsx" covers every test file in every folder; "*.test.tsx" only matches the project root.
  4. 4Conventions for files spread across many directories (tests, stories, migrations) belong in one glob rule, not in a CLAUDE.md copied into each directory.
  5. 5A subdirectory CLAUDE.md still 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