Path-specific rules: CCAR-F task statement 3.3
CCAR-F · Claude Code Configuration & Workflows (20% of the exam)
Task statement 3.3 sits in Claude Code Configuration & Workflows, 20% of the CCAR-F exam. It tests how you make a convention load only when Claude works on the files it applies to, and when a glob-scoped rule is a better choice than a CLAUDE.md file in a subdirectory.
What the official guide covers
The Claude Certified Architect Foundations exam guide (version 1.0, effective July 2026) lists this under task statement 3.3, "Apply path-specific rules for conditional convention loading":
| Knowledge of | Skills in |
|---|---|
Files in .claude/rules/ with YAML frontmatter paths fields that hold glob patterns | Writing rule files with paths frontmatter, such as paths: ["terraform/**/*"], so they load only for matching files |
| Path-scoped rules load only when Claude edits matching files, which cuts irrelevant context and token use | Using globs such as **/*.test.tsx to apply conventions by file type, wherever the files sit |
| Glob rules beat directory-level CLAUDE.md files for conventions that span many directories, such as test files | Choosing path-specific rules over subdirectory CLAUDE.md files when the files are spread across the codebase |
This page covers the paths field. For the CLAUDE.md layers and for splitting a large CLAUDE.md into unscoped rule files, see 3.1 CLAUDE.md hierarchy.
How a path-scoped rule loads
- Put Markdown files in
.claude/rules/, one topic per file. Claude Code finds them recursively, so subfolders such asfrontend/andbackend/work. The subfolder only organises the files: a rule in.claude/rules/database/withoutpathsstill loads in every session. Scope comes from the frontmatter, never from where the file sits. - A rule without
pathsloads when the session starts, at the same priority level as.claude/CLAUDE.md. - A rule with
pathsloads when Claude uses the Read, Write or Edit tool on a file that matches one of its patterns. It does not load because your prompt mentions the topic, and it is not checked on every tool call. pathsis the only frontmatter field Claude Code reads from a rule. Any other field is ignored without an error.- If the YAML between the
---markers does not parse, Claude Code ignores the frontmatter and loads the rule as if it had nopaths, so it loads every session.claude --debugshows the parse error. - After
/compact, path-scoped rules load again as Claude reads matching files.
Personal rules in ~/.claude/rules/ work the same way and apply to every project on your machine. Claude Code loads them before project rules. Neither set overrides the other, so keep them consistent.
Example: test conventions for files in any folder
---
paths:
- "**/*.test.ts"
- "**/*.test.tsx"
---
# Test conventions
- Use Vitest. Import test helpers from "vitest", never from "jest".
- One describe block per exported function.
- Build test data with the factories in tests/factories/. Do not inline large objects.
- Never call the real payment API. Use the mock in tests/mocks/payments.ts.
Save it as .claude/rules/testing.md. The test files can sit next to their components in fifty folders; one rule covers all of them. paths also accepts a comma-separated string, and braces expand to several patterns:
---
paths: "infra/**/*.tf, src/**/*.{ts,tsx}"
---
| Pattern | Matches |
|---|---|
**/*.test.tsx | Test files in any directory |
terraform/**/* | Every file under terraform/ |
src/**/*.{ts,tsx} | TypeScript and TSX files under src/ |
*.md | Markdown files in the project root only |
Why scoping also improves adherence
Scoped rules save tokens, but the bigger gain is that Claude follows the rules it does see. CLAUDE.md is context, not enforced configuration, and every line competes with every other line. Anthropic's guidance is to keep each CLAUDE.md under about 200 lines and to move instructions that matter for only part of the codebase into path-scoped rules.
A worked case: a team's CLAUDE.md has grown to 800 lines, including a history log and archived notes. Line 340 says "do not modify legacy/tokens/". During an auth refactor, Claude edits a file in that folder. The rule was loaded; it was buried. The fix has three parts:
- Move area-specific conventions, such as database or Terraform rules, into
.claude/rules/files withpaths. - Move history and archived notes out of the always-loaded files into a document Claude reads on request.
- Turn the "must never touch" line into a permission deny rule or a PreToolUse hook, because that is the one rule that cannot be left to attention.
Check which rules loaded
- Run
/contextto see which CLAUDE.md and rule files are in the current session. - For an audit trail, add an
InstructionsLoadedhook. It runs each time a CLAUDE.md or rule file is loaded, and its input carries the file path and aload_reason. A path-scoped rule reportspath_glob_match, together with the patterns and the file that triggered the load.
Rule file or subdirectory CLAUDE.md?
A CLAUDE.md in a subdirectory loads when Claude reads files in that directory. It is tied to one folder tree. That works for conventions that belong to one package. It fails for a file type that appears everywhere: test files beside their source in 40 folders would need 40 copies of the same CLAUDE.md, and the copies drift apart.
A rule with a glob is tied to a file pattern, not a folder. One **/*.test.tsx rule covers every test file, wherever it is, and stays out of context while Claude works on anything else.
| Situation | Choose | Why |
|---|---|---|
| One file type spread across the codebase (tests, stories, migrations) | Rule in .claude/rules/ with a paths glob | One file covers every location |
| Conventions for everything inside one package | Subdirectory CLAUDE.md, or a rule with paths: ["packages/billing/**/*"] | Both load only for that package; rules keep all conventions in one folder |
| A standard that applies to all code | Project CLAUDE.md or a rule without paths | It should load every session |
| A long procedure used only now and then | Skill | Loads only when invoked |
Something that must never happen, such as edits to migrations/ | Hook or permission deny rule | Rules are context Claude reads, not enforcement |
Rules that decide exam answers
- Spread across folders means a glob, not a folder. When matching files sit in many directories, a
pathsrule beats one CLAUDE.md per directory. - Scoped rules save context. A Terraform rule with
paths: ["terraform/**/*"]stays out of context while Claude edits React components. - The trigger is a matching file, not the prompt. The rule loads when Claude reads, writes or edits a file that matches. Asking about tests does not load it until a test file is touched.
- The field is
paths. A misnamed field such asglobsis ignored without an error, so the rule has no scope and loads every session. - Rules guide; hooks and permissions enforce. If the requirement is "must never", a rule file is not enough.
- Folders inside
.claude/rules/do not scope anything. Only thepathsfield limits when a rule loads.
Where it appears in the exam
Claude Code Configuration & Workflows is a primary domain in three of the six exam scenarios: Code Generation with Claude Code, Developer Productivity with Claude, and Claude Code for Continuous Integration. Conventions that differ by area of the codebase fit the Code Generation scenario most closely.
Two sample questions
These are original Timo practice questions. They are not official exam questions.
Build exercise
- In a test repository, create
.claude/rules/testing.mdwithpaths: ["**/*.test.ts"]and one easy-to-spot convention, such as "every test name starts with 'should'". - Start a session and run
/context. Confirm the rule is not loaded. Ask Claude to edit a test file, run/contextagain and confirm the rule now appears. - Put test files in three different folders and ask Claude to add a test to each. Check that the naming convention is followed in all three.
- Rename
pathstoglobs, start a new session and use/contextto confirm the rule now loads at launch. Change it back.
Practise this topic
- Claude Certified Architect practice exam: free, 20 questions, no sign-up
- Claude Certified Architect hub
- CCAR-F study guide: all topics
- Worked example: CLAUDE.md hierarchy
- Previous topic: 3.2 Slash commands and skills
- Next topic: 3.4 Plan mode vs direct execution
Sources
- Claude Certified Architect Foundations Exam Guide, version 1.0, effective July 2026 (Anthropic), task statement 3.3
- Claude Code documentation: How Claude remembers your project
- Claude Code documentation: Extend Claude with skills
- Claude Code documentation: Hooks reference
By Amotion AI