Deployed Lab

Module 4 · Claude Code configuration and workflows · Chapter 13

CLAUDE.md hierarchy and path-specific rules: where team rules belong

18 min1 clickable picture1 hands-on lab (12 items)1 predict, 2 quick quizzes, 5-question final quiz5-min video review
In 30 seconds

The picture: a house has house rules on the fridge, room rules on the room door, and your own habits in your head. Each rule sits where it applies.

Exam objective: Task statements 3.1 and 3.3

Domain 3, Claude Code Configuration and Workflows (20 percent of the exam). Organise project configuration and path-specific rules. You should be able to:

The cold open Harbor & Pine Outfitters is a made-up gear shop. Kavish and Owen Brandt's team share the harbor-web monorepo, and their rules are in the wrong homes: Nobody wrote a bad rule. Every rule is in the wrong file.
The plan for this chapter
  1. The three CLAUDE.md levels, and what belongs at each.
  2. @import and conflicts: the nearer file wins.
  3. Path-scoped rules in .claude/rules/.
  4. A worked example: what always-on rules cost a team.
  5. A lab: sort a messy pile of rules into the right homes.

Next: the three levels.

Step 1: Three levels, three audiences

Why this step: most exam questions here ask one thing: which file should hold this rule?

The house picture again: fridge rules bind everyone, room rules bind the room, habits bind only you.

Where the picture breaks down:

The test for any rule: who needs it? Only you: user file. The team: project file. One folder: nested file or path rule (Step 3).

Quick check: where does a team rule belong?

Next: sharing files with @import, and what happens when rules disagree.

Step 2: Import shared files, and nearer wins

Why this step: teams outgrow one file, and files disagree.

A CLAUDE.md can pull in another file with an @import line:

# harbor-web project rules (illustrative)
@import ../shared/team-standards.md

## This repo
- API handlers use the repository pattern.
- Test files sit next to the code they test.

Conflicts: when two loaded files disagree, the nearer file wins. A rule in src/payments/CLAUDE.md beats the root file for work in src/payments, because it is closer to the work.

So fix a conflict at the level that is wrong. If the root rule should hold everywhere, remove the nested exception. If the exception is right, narrow the root rule.

Do this: pick your answer, then press the button.

The nearer file wins for its subtree. The root rule still governs the rest of the repo. If that split is an accident, delete one of the two rules instead of adding a third.

Next: the picture, then rules that load only on matching paths.

Where CLAUDE.md rules live User, project and nested CLAUDE.md files, path rules in .claude/rules, and a shared file pulled in by @import all feed the session context. Nearer and path-matched rules apply to their own area. User CLAUDE.md~/.claude, only you Project CLAUDE.mdrepo root, the team Nested CLAUDE.mdone subtree only Path rules.claude/rules, paths set Shared filepulled in by @import Session context @import
  1. Personal defaults from ~/.claude/CLAUDE.md. Only your machine has it, so nothing in it can be a team rule.
  2. The root CLAUDE.md is committed with the code. Clone the repo and you have the rules. Change them in a pull request.
  3. An @import line pulls shared standards into the project file, so several repos follow one source.
  4. A CLAUDE.md inside src/payments speaks for that folder. On conflict with the root file, the nearer file wins.
  5. Files in .claude/rules/ with paths frontmatter join only when work touches matching paths.
  6. The session context is the sum of what loaded. A rule in the wrong home is missing for its audience or noise for everyone else.
YoursTeam filesScoped and sharedResult

Next: path rules in detail.

Step 3: Path rules load only where they match

Why this step: some rules are too narrow for a folder file, too noisy for the root file.

Files in .claude/rules/ can carry paths frontmatter. The rule loads only when the work touches a matching path:

---
paths:
  - "src/**"
---
# Test conventions (illustrative)
- Name each test after the behaviour it checks.
- One assertion focus per test.
- Test files sit next to the code: Button.test.tsx beside Button.tsx.

Exact load timing and glob behaviour are version-dependent: check the current docs.

Quick check: the unscoped rule.

Next: what the always-on pile costs.

Step 4: Worked example, the price of loading everything

Why this step: scoping buys back context on every session.

Made-up token counts for the harbor-web rule set:

Worked example (all numbers made-up):

1. Everything in the root file: 600 + 500 + 450 + 400 = 1,950 tokens, plus the 150 user tokens, so 2,100 tokens load at every session start.

2. Scoped: every session loads 600 + 150 = 750. A src session adds the test rules: 1,250. A db session: 1,200. A payments session: 1,150.

3. Team week, made-up mix: 240 sessions. 96 in src, 48 in db, 36 in payments, 60 at root level only.

4. Always-on total: 240 × 2,100 = 504,000 tokens a week.

5. Scoped total: 96 × 1,250 = 120,000; 48 × 1,200 = 57,600; 36 × 1,150 = 41,400; 60 × 750 = 45,000. Sum: 264,000 tokens.

6. Saving: 504,000 - 264,000 = 240,000 tokens a week, about 48 percent. At a made-up price of $3 per million input tokens, that is about $0.72 a week.

The money is trivial, and saying so matters. The real win is 850 to 1,350 tokens of context room per session, plus fewer irrelevant rules competing for Claude's attention. New to context budgets? See Tokens and context windows in the AI engineering course.

Next: sort the rule pile yourself.

Step 5: Hands-on lab, sort the rule pile

Why this exercise: the exam gives you a rule and four candidate homes. This is that question, eight times, on harbor-web.

Lab: Harbor and Pine's harbor-web rules started in the wrong files: a team rule sat in Kavish's personal file where nobody else loaded it, and a payments rule sat in the root file where it fired on marketing work. This lab runs in your browser and needs JavaScript enabled.

Field note, November 2026

Teams that treat the project CLAUDE.md like code, short, reviewed, pruned when a rule stops earning its tokens, tend to keep it trusted. A root file that grows unchecked gets ignored, like an ignored linter. This is common practice, not a measured statistic.

The Deployed Lab jobs page (snapshot 15 Nov 2026) lists 367 open roles at 10 companies, median posted base about $243K (base pay only).

Mix-ups to avoid

Chapter quiz

Five questions. Score 70% or more to mark this chapter complete.

Review this chapter in 5 minutes

Watch the whole chapter recapped: the three CLAUDE.md levels, nearer file wins on conflict, @import for shared standards, and path-scoped rules.

Decision rule: for every rule, ask who needs it and where it applies. The answers pick the file. If you cannot answer both, the rule is not ready to write.

Independent exam preparation. Not affiliated with or endorsed by Anthropic.

Review

Glossary

User-level CLAUDE.md
Your personal configuration file at ~/.claude/CLAUDE.md. Example: "keep my summaries short".
Project CLAUDE.md
The team file at the repo root, committed with the code. Example: "run the full test suite before a pull request".
Nested CLAUDE.md
A CLAUDE.md inside a folder, holding rules for that subtree. Example: payments rules in src/payments/CLAUDE.md.
@import
A line in a CLAUDE.md that pulls in another file's contents. Example: importing shared team standards.
Precedence
Which rule wins on a conflict: the nearer file. Example: the payments indent rule beats the root indent rule inside payments.
.claude/rules/
A folder of rule files that can be scoped to paths. Example: a migrations rule file for db/**.
paths frontmatter
Metadata at the top of a rule file listing the paths it applies to. Example: paths: ["src/**"].
Path-scoped rule
A rule that loads only when work touches matching paths. Example: test conventions under src/**.
Always-on context
Content loaded into every session whether or not it is relevant. Example: migration rules during front-end work.
Subtree
A folder and everything under it. Example: src/payments and all its files.

Next: "Slash commands and skills: share workflows with the whole team".