TimoBy Amotion AI

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 ofSkills in
Files in .claude/rules/ with YAML frontmatter paths fields that hold glob patternsWriting 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 useUsing 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 filesChoosing 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

  1. Put Markdown files in .claude/rules/, one topic per file. Claude Code finds them recursively, so subfolders such as frontend/ and backend/ work. The subfolder only organises the files: a rule in .claude/rules/database/ without paths still loads in every session. Scope comes from the frontmatter, never from where the file sits.
  2. A rule without paths loads when the session starts, at the same priority level as .claude/CLAUDE.md.
  3. A rule with paths loads 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.
  4. paths is the only frontmatter field Claude Code reads from a rule. Any other field is ignored without an error.
  5. If the YAML between the --- markers does not parse, Claude Code ignores the frontmatter and loads the rule as if it had no paths, so it loads every session. claude --debug shows the parse error.
  6. 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}"
---
PatternMatches
**/*.test.tsxTest files in any directory
terraform/**/*Every file under terraform/
src/**/*.{ts,tsx}TypeScript and TSX files under src/
*.mdMarkdown 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 with paths.
  • 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 /context to see which CLAUDE.md and rule files are in the current session.
  • For an audit trail, add an InstructionsLoaded hook. It runs each time a CLAUDE.md or rule file is loaded, and its input carries the file path and a load_reason. A path-scoped rule reports path_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.

SituationChooseWhy
One file type spread across the codebase (tests, stories, migrations)Rule in .claude/rules/ with a paths globOne file covers every location
Conventions for everything inside one packageSubdirectory 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 codeProject CLAUDE.md or a rule without pathsIt should load every session
A long procedure used only now and thenSkillLoads only when invoked
Something that must never happen, such as edits to migrations/Hook or permission deny ruleRules 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 paths rule 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 as globs is 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 the paths field 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.

Question 1

A monorepo has Storybook story files (*.stories.tsx) in about 60 component folders across four packages. The team wrote story conventions in a CLAUDE.md inside packages/ui/, but Claude ignores them when it edits stories in the other three packages. What is the most maintainable fix?

Answer: D. One glob covers every story file wherever it lives, and the rule loads only when Claude works on a story. A creates 60 copies to keep in step. B works but loads story conventions into every session, including backend work. C depends on developers remembering to run it.

Question 2

A developer adds .claude/rules/terraform.md with the frontmatter globs: ["infra/**/*.tf"]. Developers who only work on the frontend now see the Terraform conventions in their context from the start of every session. What is the cause?

Answer: B. paths is the only field Claude Code reads from a rule; globs is ignored without an error, so the rule counts as unscoped and loads at launch. Renaming the field to paths fixes it. A is wrong because paths rules load on demand. C is wrong because **/*.tf is valid. D is wrong because project rules support paths.

Build exercise

  1. In a test repository, create .claude/rules/testing.md with paths: ["**/*.test.ts"] and one easy-to-spot convention, such as "every test name starts with 'should'".
  2. Start a session and run /context. Confirm the rule is not loaded. Ask Claude to edit a test file, run /context again and confirm the rule now appears.
  3. 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.
  4. Rename paths to globs, start a new session and use /context to confirm the rule now loads at launch. Change it back.

Practise this topic

Sources