Task Statement 3.3·Domain 3 — 20% of exam
Path-Specific Rules for Conditional Convention Loading
Apply path-specific rules for conditional convention loading
Official Exam Guide Objectives
Knowledge of
- .claude/rules/ files with YAML frontmatter paths fields containing glob patterns for conditional rule activation
- How path-scoped rules load only when editing matching files, reducing irrelevant context and token usage
- The advantage of glob-pattern rules over directory-level CLAUDE.md files for conventions that span multiple directories (e.g., test files spread throughout a codebase)
Skills in
- Creating .claude/rules/ files with YAML frontmatter path scoping (e.g., paths: ["terraform/**/*"]) so rules load only when editing matching files
- Using glob patterns in path-specific rules to apply conventions to files by type regardless of directory location (e.g., **/*.test.tsx for all test files)
- Choosing path-specific rules over subdirectory CLAUDE.md files when conventions must apply to files spread across the codebase
What You Need to Know
Path-specific rules make a convention conditional on what you are editing rather than on where you launched Claude. That closes a gap neither root CLAUDE.md nor a directory-level file covers well: a rule that belongs to a file type which happens to be scattered across the whole tree.
How Path-Specific Rules Work
The files live in .claude/rules/, and each one opens with YAML frontmatter carrying a paths field of glob patterns. Whatever the file says applies only while you are working on files those globs match.
---
paths: ["terraform/**/*"]
---
# Terraform Conventions
- Resource names in snake_case, no exceptions
- Every resource carries environment and owning-team tags
- AMI IDs come from data sources; a hardcoded one is a review blocker
- A module is incomplete without variables.tf, outputs.tf and a README.mdOpen a file matching terraform/**/*, and the rules arrive with it. Open a React component or a request handler, and they do not — they stay out of context entirely until the moment they describe the work in front of you.
Glob Patterns Match Across the Entire Codebase
This is the property that makes them worth using. **/*.test.tsx reaches every test file in the repository, no matter how deep or how scattered. A typical layout makes the point:
src/
components/
Button.tsx
Button.test.tsx
api/
auth.ts
auth.test.ts
utils/
format.ts
format.test.ts
pages/
dashboard/
Dashboard.tsx
Dashboard.test.tsxEvery test sits beside the thing it tests, which puts them in four directories here and rather more in a real project. One rule file declaring paths: ["**/*.test.tsx", "**/*.test.ts"] reaches all of them without knowing where any of them are.
Why Not Directory-Level CLAUDE.md?
Because it reaches one directory. Covering tests spread across 50-odd directories would mean a CLAUDE.md in each of them, which buys you:
- 50-odd copies of one set of conventions
- a new copy to write every time someone adds a directory containing tests
- 50-odd edits every time a convention changes
- copies that fall out of step, because eventually one of those edits gets missed
A single glob replaces all of that, and there is nothing to keep in sync because there is only ever one file.
Why Not Root CLAUDE.md?
Because it loads regardless. Terraform conventions in the root file are in context while you edit React components; test conventions are in context while you write request handlers. Neither is doing anything except consuming budget that the current work needs — and on a project with several convention sets, the ones that are irrelevant will usually outnumber the ones that are not.
Practical Rule File Examples
Test conventions across the entire codebase:
---
paths: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"]
---
# Test Conventions
- describe/it names should read as sentences describing behaviour
- Every file covers at least one success path and one failure path
- Build test data through factory functions rather than inline literals
- Mock at the module boundary; mocking individual functions couples tests to internals
- Assert on what the code does, never on how it does itAPI conventions for any route handler:
---
paths: ["src/api/**/*", "**/routes/**/*", "**/*.controller.ts"]
---
# API Conventions
- Every response takes the shape { data, error, metadata }
- Validate with Zod at the handler boundary, before anything else runs
- Error responses carry the request ID
- State rate limits explicitly; inheriting a default is not a decisionInfrastructure-as-code conventions:
---
paths: ["terraform/**/*", "**/*.tf", "infrastructure/**/*"]
---
# Infrastructure Conventions
- State lives in a remote backend; local state is never committed
- Environments are separated by workspace
- Modules are versioned and carry a CHANGELOGWhen to Use Each Approach
| Scenario | Best approach |
|---|---|
| Standards every line of code should follow | Root CLAUDE.md |
| Conventions belonging to one package directory | Directory-level CLAUDE.md |
| Conventions belonging to a file type wherever it appears | Path-specific rules with glob patterns |
| A procedure someone runs deliberately, now and then | Skills in .claude/skills/ |
The scenario to watch for is tests co-located with the code they cover, across a large tree. It appears repeatedly, and glob-scoped rules are the answer every time — the giveaway is that the files share a naming pattern but no common location.
Deep Dive
The paths frontmatter mechanism, precisely
Rules can be scoped to specific files using YAML frontmatter with a paths field: "these conditional rules only apply when Claude is working with files matching the specified patterns." Rules in .claude/rules/ are discovered recursively, so .md files can be organised into subdirectories as a project grows — .claude/rules/frontend/components.md is discovered the same as a flat file.
Sourcecode.claude.com › memoryfetched 2026-07-30
Glob syntax and brace expansion
paths accepts standard glob patterns (**/*.ts for any TypeScript file at any depth) and brace expansion to match multiple extensions in a single pattern, plus multiple patterns in the same array:
---
paths:
- "src/**/*.{ts,tsx}"
---Sourcecode.claude.com › memoryfetched 2026-07-30
Rules without paths frontmatter
A rule file that omits paths entirely isn't conditional — it "is loaded at launch with the same priority as .claude/CLAUDE.md." That's the default for a rules file with no frontmatter at all: always-on, just like the earlier project CLAUDE.md.
Sourcecode.claude.com › memoryfetched 2026-07-30
User-level rules and their priority
Personal rules in ~/.claude/rules/ apply to every project on your machine, exactly the way ~/.claude/CLAUDE.md does. Crucially, "user-level rules are loaded before project rules, giving project rules higher priority" — so when a user-level rule and a project-level rule genuinely conflict, the load order favours the project rule appearing later in context.
Sourcecode.claude.com › memoryfetched 2026-07-30
Quick Reference
| Item | Value / behaviour |
|---|---|
| Rule file location | .claude/rules/*.md, discovered recursively (subdirectories included) |
paths frontmatter | YAML array of glob patterns; rule loads only for matching files |
| Glob syntax | standard globs (**/*.ts) plus brace expansion (src/**/*.{ts,tsx}) |
Rule with no paths | loads at launch — same priority as .claude/CLAUDE.md |
| User-level rules | ~/.claude/rules/ — every project on the machine |
| User vs project rule priority | user rules load first; project rules load later, so project wins on conflict |
| Directory-level CLAUDE.md vs path rules | directory CLAUDE.md = one directory; path rules = one file type, any directory |
| Root CLAUDE.md vs path rules | root CLAUDE.md always loads; path rules load only for matching files (token savings) |
Exam Traps
Practice Scenario
A codebase has test files co-located with source files throughout 50+ directories (e.g., Button.test.tsx next to Button.tsx). The team wants all tests to follow the same conventions regardless of location. What is the most maintainable approach?
Build Exercise
Configure Path-Specific Rules with Glob Patterns
Difficulty: Intermediate (2/4)
30 minutes
- Create .claude/rules/testing.md with YAML frontmatter paths: ["/*.test.ts", "/.test.tsx", "**/.spec.ts"] and test conventions (naming, assertions, mocking patterns)
Why: Path-specific rules with glob patterns are the correct solution for conventions that apply to a file type spread across many directories. The exam favourite scenario is test files co-located with source files across 50+ directories.
You should see: A file at .claude/rules/testing.md with YAML frontmatter containing a paths array with glob patterns. The body contains at least three test conventions covering naming, assertions, and mocking.
- Create .claude/rules/api-conventions.md with paths: ["src/api//*", "/routes/**/*"] and API conventions (response shape, validation, error handling)
Why: Separating API conventions into their own path-scoped rule means they only load when editing API files. This avoids consuming tokens with irrelevant context when working on frontend or infrastructure code.
You should see: A file at .claude/rules/api-conventions.md with YAML frontmatter paths targeting API directories. The body contains at least three API conventions.
- Create .claude/rules/terraform.md with paths: ["terraform//*", "/*.tf"] and infrastructure conventions
Why: Infrastructure conventions are completely irrelevant when editing application code. Path-scoped rules ensure Terraform rules never consume tokens during React or API development sessions.
You should see: A file at .claude/rules/terraform.md with YAML frontmatter paths matching Terraform files. The body contains infrastructure-specific conventions.
- Edit a test file and use /memory to verify that testing rules are loaded but API and Terraform rules are not
Why: This proves the conditional loading mechanism works. The exam tests whether you understand that path-specific rules load only for matching files, and /memory is the diagnostic tool to verify this.
You should see: When editing a .test.ts file, /memory output lists .claude/rules/testing.md as loaded. The .claude/rules/api-conventions.md and .claude/rules/terraform.md files do NOT appear in the /memory output.
- Edit an API handler and verify that API rules load while testing and Terraform rules do not
Why: This is the complementary verification. Switching contexts should swap which rules are loaded, confirming that the glob patterns correctly scope each rule file.
You should see: When editing a file in src/api/, /memory output lists .claude/rules/api-conventions.md as loaded. The testing and Terraform rule files do NOT appear.
- Compare the token footprint when all conventions are in root CLAUDE.md versus split into path-specific rules
Why: Token efficiency is a key exam concept. Root CLAUDE.md loads all conventions for every session regardless of relevance. Path-specific rules load only matching conventions, reducing irrelevant context and preserving token budget for actual work.
You should see: With all conventions in root CLAUDE.md, /memory shows the full set of conventions loaded even when editing a simple utility file. With path-specific rules, /memory shows only the relevant subset. The token count for loaded configuration is measurably smaller when using path-specific rules for targeted editing sessions.
Sources
- Claude Code Memory and Rules Documentation — Anthropic
- Claude Certified Architect Foundations Exam Guide — Task Statement 3.3 — Anthropic
- Claude Certified Architect Foundations Exam Guide — Sample Question 6 — Anthropic
Appendix A — Build Exercise Step Hints
Progressive hints revealed by the "Stuck? Get a nudge" control on each step.
Step 1. Create .claude/rules/testing.md with YAML frontmatter paths: ["/*.test.ts", "/.test.tsx", "**/.spec.ts"] and test conventions (naming, assertions, mocking patterns)
Why: Path-specific rules with glob patterns are the correct solution for conventions that apply to a file type spread across many directories. The exam favourite scenario is test files co-located with source files across 50+ directories.
You should see: A file at .claude/rules/testing.md with YAML frontmatter containing a paths array with glob patterns. The body contains at least three test conventions covering naming, assertions, and mocking.
Stuck? Get a nudge
Step 2. Create .claude/rules/api-conventions.md with paths: ["src/api//*", "/routes/**/*"] and API conventions (response shape, validation, error handling)
Why: Separating API conventions into their own path-scoped rule means they only load when editing API files. This avoids consuming tokens with irrelevant context when working on frontend or infrastructure code.
You should see: A file at .claude/rules/api-conventions.md with YAML frontmatter paths targeting API directories. The body contains at least three API conventions.
Stuck? Get a nudge
Step 3. Create .claude/rules/terraform.md with paths: ["terraform//*", "/*.tf"] and infrastructure conventions
Why: Infrastructure conventions are completely irrelevant when editing application code. Path-scoped rules ensure Terraform rules never consume tokens during React or API development sessions.
You should see: A file at .claude/rules/terraform.md with YAML frontmatter paths matching Terraform files. The body contains infrastructure-specific conventions.
Stuck? Get a nudge
Step 4. Edit a test file and use /memory to verify that testing rules are loaded but API and Terraform rules are not
Why: This proves the conditional loading mechanism works. The exam tests whether you understand that path-specific rules load only for matching files, and /memory is the diagnostic tool to verify this.
You should see: When editing a .test.ts file, /memory output lists .claude/rules/testing.md as loaded. The .claude/rules/api-conventions.md and .claude/rules/terraform.md files do NOT appear in the /memory output.
Stuck? Get a nudge
Step 5. Edit an API handler and verify that API rules load while testing and Terraform rules do not
Why: This is the complementary verification. Switching contexts should swap which rules are loaded, confirming that the glob patterns correctly scope each rule file.
You should see: When editing a file in src/api/, /memory output lists .claude/rules/api-conventions.md as loaded. The testing and Terraform rule files do NOT appear.
Stuck? Get a nudge
Step 6. Compare the token footprint when all conventions are in root CLAUDE.md versus split into path-specific rules
Why: Token efficiency is a key exam concept. Root CLAUDE.md loads all conventions for every session regardless of relevance. Path-specific rules load only matching conventions, reducing irrelevant context and preserving token budget for actual work.
You should see: With all conventions in root CLAUDE.md, /memory shows the full set of conventions loaded even when editing a simple utility file. With path-specific rules, /memory shows only the relevant subset. The token count for loaded configuration is measurably smaller when using path-specific rules for targeted editing sessions.
Stuck? Get a nudge
Appendix B — Interactive Study Prompts
Two prompts to paste into Claude. B1 drills the judgement the exam actually measures; B3 reviews the configuration you wrote for the Build Exercise above. The exam simulator between them is the interactive quiz on this page.
B1. Concept Check — Discrimination Drill
You are examining me for the Claude Certified Architect – Foundations (CCAR-F) exam, Domain 3: Claude Code Configuration & Workflows (20% of the exam), Task Statement 3.3: Path-Specific Rules for Conditional Convention Loading. Use British English throughout.
What this exam actually measures. Not one item on the official exam asks what something is. Every item drops you into a production system that is already misbehaving, offers four defensible engineering responses, and asks which is best. The skill being tested is proportionality: fix the root cause with the cheapest instrument that gives the guarantee the situation demands. So do not quiz me on definitions. Make me choose between options that are both defensible, then attack whatever I chose.
How to run this session.
- One question at a time. Stop and wait. Never answer your own question, and never move on until I have committed.
- Never reveal which option is right before I commit to one.
- Do not praise me. A correct answer earns "Yes" and the next question. If I am right for the wrong reason, say so — that is the failure that costs marks on exam day.
- When I am wrong, quote the exact phrase in my answer that gave it away, correct it in one sentence, and move on. One correction at a time.
- If I write something fluent but empty, name it: "That is a restatement, not a reason."
- Set every scenario inside one of the exam's production contexts: Code Generation with Claude Code (a team leaning on custom slash commands, CLAUDE.md configuration, and plan mode versus direct execution), Claude Code for Continuous Integration (automated review, test generation and PR feedback in a pipeline that has to keep false positives down), or Developer Productivity with Claude (an agent over an unfamiliar codebase using the built-in
Read,Write,Bash,Grep,Globtools).
Session plan — about twelve questions.
Round 1 — Anchor (1 question). One concrete question to check I have actually read the material. If I cannot answer it, stop the session and tell me to read the lesson before continuing.
Round 2 — Discrimination (5 questions). Each one: describe a symptom in one of the contexts above, with a number or a concrete observation in it — how many directories hold the affected files, which rule files a session reports as loaded, how much of the configuration is irrelevant to the file being edited. Offer exactly two responses, both defensible. Ask me to pick one and justify it in a single sentence. Then argue the case for the option I rejected as strongly as you can, and ask whether I am holding or changing my answer. Only after I answer that, tell me which is right and why the other one is the more tempting trap.
Round 3 — Proportionality (2 questions). Take one symptom and run it twice with different stakes: once where the cost of the wrong call is a few hundred tokens of irrelevant convention riding along in every session, once where it is a security convention failing to load on the very files it was written for. The right answer must change between the two. If I answer the same way both times without noticing the stakes moved, that is the finding — tell me.
Round 4 — Code review (3 questions). Present a colleague's confident proposal containing one of the trap errors listed below, written the way a teammate would write it in a pull request. Ask me what is wrong with it. Do not signal that anything is wrong.
Round 5 — Verdict. Rate me green, amber or red on each concept below. Name the single weakness most likely to cost me marks, and give me one specific next action: a section of this lesson to re-read, or a step of the Build Exercise to redo. If I am not ready for this task statement, say so plainly.
Concepts in scope
- The
pathsfrontmatter — a file under.claude/rules/carrying a YAMLpathsarray of glob patterns loads only while Claude is working with files that match. Rule files are discovered recursively, so they can be organised into subdirectories as the project grows. - Globs cross directory boundaries — a pattern anchored to a file type catches every instance of it wherever it sits, and brace expansion folds several extensions into a single pattern. This is the property that directory-scoped configuration cannot reproduce.
- Cheaper than root CLAUDE.md — root CLAUDE.md loads on every session whatever is being edited, so infrastructure conventions burn context during frontend work; a path-scoped rule stays invisible until it is relevant.
- Cheaper than a directory-level CLAUDE.md — one directory file covers one directory, so a convention spread across dozens of directories means dozens of copies, a new copy for every new directory, and drift as some fall behind. One pattern replaces all of it.
- Rules with no
paths, and user-level rules — a rule file that omitspathsis not conditional at all: it loads at launch with the same priority as.claude/CLAUDE.md. Personal rules in~/.claude/rules/apply to every project and load before project rules, so project rules land later in context. - Rules versus skills — a rule is background guidance that loads when Claude reads a matching file and shapes every edit to it; a skill is an on-demand workflow triggered by invocation or an intent match. Automatic, always-on convention loading for a file type is a rule.
Trap errors to plant in Round 4
- Choosing a directory-level
CLAUDE.mdfor conventions that span many directories, which means one copy per directory and inevitable drift between them. - Parking conventions for a single file type in root
CLAUDE.md, where they load and consume context during work that has nothing to do with them. - Reaching for a skill when the requirement is automatic, always-on convention loading every time a matching file is touched.
Stay inside the material above. If I raise something outside it, tell me it is out of scope for this task statement and return to the drill. Begin with Round 1.
B2. Exam Simulator
Exam simulator
Question 1 of 10
Scenario · Code Generation with Claude Code
Your repository keeps test files beside the code they test — Button.test.tsx sits next to Button.tsx — across more than fifty directories. Claude follows your test conventions only when someone remembers to paste them into the prompt. What's the most maintainable way to fix this?
B3. Build Coach — Config Review
The Build Exercise and its hint ladder are already on this page. This prompt is for the one thing the page cannot do: review the configuration you actually wrote.
You are a staff engineer reviewing my implementation of a build exercise for the Claude Certified Architect – Foundations exam, Domain 3, Task Statement 3.3: Path-Specific Rules for Conditional Convention Loading. Use British English throughout.
I am building three conditionally loaded rule files under .claude/rules/ — one for test conventions, one for API conventions, one for infrastructure conventions — each fronted by a YAML paths array of globs, together with the evidence that switching which file I am editing swaps which of the three is loaded, and a comparison against the same conventions parked in root CLAUDE.md.
It has to satisfy all of the following:
- The test rule carries glob patterns that catch test files by extension wherever they live, plus at least three conventions covering naming, assertions and mocking.
- The API rule is scoped to the API paths and the infrastructure rule to the Terraform tree and infrastructure file extensions, each with its own conventions in the body.
- Editing a test file loads the test rule and neither of the other two.
- Editing an API handler swaps the loaded set: API conventions come in, test and infrastructure conventions drop out.
- A recorded comparison against the everything-in-root-CLAUDE.md arrangement, showing the whole set loading regardless of which file is open.
How to review.
- Ask me to paste the three rule files with their frontmatter exactly as written, and the loaded-file listings I got in each editing context. If I have not pasted them, ask for that and nothing else. Do not write the configuration for me, do not offer a reference version, and do not fill in a step I have skipped.
- Work through the criteria above in order. For each one, quote the line of my configuration or my listing that satisfies it, or say plainly that nothing does.
- Then hunt for the failure modes below. Each is a real misconfiguration, not a style preference.
- Rank everything you find: (1) the rule would not load when it is needed, (2) would lose marks on the exam, (3) style. Give me the first item under (1) and then stop — wait for my fix before giving me the next one.
- If my configuration satisfies everything, do not congratulate me. Change the requirements — one convention now has to apply to every test file and every API handler, and a second must apply on every session regardless of what is open — and make me work out which files change.
- If I ask you to just write it for me, refuse once and give me the smallest nudge that would unblock me instead.
Failure modes to probe
- Frontmatter that is not a
pathsarray at the very top of the file, so the rule quietly becomes an always-on rule and the conditional behaviour the exercise is proving never happens. - A pattern anchored to a directory when the convention actually follows a file type, so the co-located files outside that directory are missed entirely.
- A pattern that matches one directory level where arbitrary depth was needed, which looks right on the sample tree and fails on the real one.
- The same conventions also copied into per-directory files, reintroducing exactly the duplication and drift the glob was chosen to remove.
- The token-efficiency claim asserted rather than demonstrated — no before-and-after comparison of what actually loads in each editing context.
Start by asking me for my rule files and the loaded-file listings.