CCAR-F · Claude Code
Rules that load depending on the file
Terraform conventions are useless to someone editing a React component, and testing conventions aren’t needed when touching the build configuration. If everything lives in the root CLAUDE.md, everything loads every session and spends context. Path-scoped rules solve that.
How it’s written
A path-scoped rule is a file in .claude/rules/ with a paths field in its YAML frontmatter:
---
paths:
- "terraform/**/*"
- "**/*.tf"
---
# Terraform conventions
- Resources are named with the environment prefix.
The rule loads only when Claude reads or edits a file that matches one of the globs. That’s conditional loading: less irrelevant context and fewer tokens on every other task. There’s nothing to invoke and nothing to restart.
Without paths, the rule loads every session, just like CLAUDE.md. And if the YAML is broken, the frontmatter is ignored and the rule behaves as if it had no paths.
How to read a glob
A glob pattern describes paths:
| Pattern | Matches |
|---|---|
**/*.test.tsx |
Every .tsx test, in any folder |
src/api/**/* |
Everything under src/api/, subfolders included |
src/*.ts |
Only .ts files directly in src/, no subfolders |
src/components/*.tsx |
Only direct children of that folder: src/components/forms/Input.tsx is left out |
* doesn’t cross folders; ** does. The pattern is read from the project root, so tests/src/x.ts doesn’t match src/*.ts. And paths accepts several globs: to extend an API rule to lib/api/, add "lib/api/**/*" to the list, without duplicating the rule.
Path rules or subfolder CLAUDE.md
A CLAUDE.md inside a folder only covers that folder. It works when the convention belongs to one place (a monorepo package). But if tests sit next to the code they test, spread across more than 50 folders, you’d need 50 copies that drift apart. A single rule with paths: ["**/*.test.tsx", "**/*.test.ts"] covers them all, wherever they are. Same for a repo mixing Python and Go: python.md with **/*.py and go.md with **/*.go.
What goes where
- Applies to every task (build, commits, general review standards): root CLAUDE.md or a rule without
paths. - Depends on the file being edited (migrations, Terraform, tests): a rule with
paths. - Used occasionally and on request: a skill.
A subtle trap: moving general standards into rules with specific globs leaves out files that match none of them, such as a src/utils/format.ts. Universal standards stay at the root or use **/*.
The usual traps
- Consolidating everything in the root CLAUDE.md “with a heading per area” and trusting Claude to infer which section applies.
- One skill per code type: it depends on someone invoking it.
- One CLAUDE.md per folder for files spread across the repo.
- A glob that doesn’t match:
tests/**/*.tsdoesn’t load the rule foruser.spec.js. - Using
/memoryto “activate” a rule: it only shows what’s there.
In the exam
If the scenario says “files spread throughout the codebase”, “regardless of folder” or “only when editing those files”, the answer is .claude/rules/ with paths. Check the globs carefully: * versus ** and the extension are the detail that decides.
Quick question
A practice exam question on this domain. It counts towards your progress.
A data-platform team of nine engineers wants to standardise how pull requests are reviewed with Claude Code. They want a /review command that is available to everyone who clones the repository, with the same steps for all reviewers, and that is updated through normal pull requests.
Separately, one senior developer wants a personal /brainstorm skill. It explores the codebase broadly and produces a long, verbose analysis: file lists, dependency notes, half-formed ideas. When he tried it as a plain prompt, the output filled his main conversation and he lost track of what he was working on.
He does not want teammates to see or use /brainstorm, because it reflects his own way of working and is not polished.
The team already has a .claude/ folder in the repository with a settings file and a couple of rules files.
Where should each be created, and what configuration does the skill need?