CCAR-F - Claude Code Configuration & Workflows - Section 3.3

Apply path-specific rules for conditional convention loading.

Rule files carry YAML frontmatter with a paths field of glob patterns, so a rule loads only when a matching file is being edited, cutting irrelevant context and token usage. Glob-pattern rules beat directory-level configuration wherever a convention spans directories, which is the normal case for test files sitting beside the code they test. Candidates should pick path scoping over a per-directory file when files of one type are spread across the tree.

YAML frontmatter paths fieldglob-pattern rule activationconditional convention loadingtoken usage reductionrules spanning directories

Practice question for this objective

Free sampleClaude Code Configuration & Workflowsmedium

In the Beacon Platform monorepo the file apps/web/api/routes.ts is matched by two rule files at once: one scoped to apps/web/** carrying front-end component conventions, and one scoped to a pattern spanning any api directory carrying request-validation conventions. An engineer expects the narrower of the two to win. What happens when Claude edits that file?

  • AThe rule with the longer literal prefix takes effect on its own, because path scoping resolves overlaps by specificity in the way a routing table picks a single winning route.
  • BBoth patterns match the path, so both sets of conventions are loaded together and Claude works from their union unless the text of a rule narrows its own applicability. Correct
  • CNeither rule takes effect, because two overlapping patterns make activation ambiguous and Claude falls back to the conventions held in the root CLAUDE.md for that edit.
  • DThe rule file declared later replaces the earlier one for any path they share, so the request-validation conventions are the only guidance in context for that edit.
Overlapping path patterns compose: every rule file whose glob matches a file contributes its conventions to that session's context. Each rule file's pattern is tested on its own against the path being worked on, so overlap produces addition rather than a contest. A file in the intersection of two globs loads both sets of conventions, which is why patterns should be drawn so that any guidance they combine is compatible, and why genuinely narrow guidance belongs in a narrow pattern rather than being relied on to displace something broader.

Why A is wrong: Tempting because specificity ordering is the norm in routers and in stylesheets, but rule files are not competing candidates for one slot and are not narrowed to a single winner.

Why B is correct: Correct: activation is evaluated independently per rule file, so a file sitting in the intersection of two globs picks up both bodies of guidance.

Why C is wrong: Plausible if you assume overlap is treated as a configuration error, but an overlap is a normal outcome of independent globs and does not disable either file.

Why D is wrong: Tempting because later-wins is a common override rule in layered configuration, but declaration order does not evict a rule whose pattern still matches the path.

See more CCAR-F practice questions, answers explained.

More in this domain

Back to all Claude Code Configuration & Workflows objectives, or the CCAR-F cert hub.

Examworthy is not affiliated with or endorsed by Anthropic. Original, blueprint-aligned practice material only.