CLAUDE.md Configuration Guide: Hierarchy, @import and Path-Specific Rules

📚 Exam guide v1.0 (July 2026)🔄 Checked against official sources: 11 Nov 2026✏️ Updated: 12 Nov 2026⏱️ 8 min read🎯 Official objectives 3.1 and 3.3

👋 In plain words: CLAUDE.md is a plain text file where you write instructions Claude Code reads every time, such as 'use pytest' or 'never edit generated files'. Where you put that file decides who gets the rules. This lesson shows how to set it up so the whole team gets the same behaviour.

Advertisement

CLAUDE.md is how you give Claude Code persistent project knowledge. The exam tests where instructions live, who receives them, and how to keep them modular so the right conventions load at the right time (Task Statements 3.1 and 3.3).

📖 What You’ll Learn: You will be able to set up CLAUDE.md files so the right conventions reach every teammate and load only when they are relevant.

🔑 Key terms

  • CLAUDE.md: A Markdown file of standing instructions that Claude Code loads automatically.
  • User level: ~/.claude/CLAUDE.md on your own machine. Only you get these rules.
  • Project level: CLAUDE.md in the repository. Everyone who clones it gets these rules.
  • @import: A line in CLAUDE.md that pulls in another file's contents.
  • Path-specific rule: A rule file in .claude/rules/ that loads only when Claude edits matching files.

📖 The story in this lesson

A new tester joins Ravi's team and Claude Code ignores the team's test conventions on their laptop. The reason: Ravi had put the rules in his personal CLAUDE.md.

💡 Think of it like this

CLAUDE.md levels are like notices in a company. A sticky note on your own monitor (user level) is for you alone. A notice on the office board (project level) reaches everyone. A sign on the lab door (directory or path rules) applies only to people working in that room.

🏛️ The three-level hierarchy

LevelLocationShared with team?
User~/.claude/CLAUDE.mdNo — only you
Project./CLAUDE.md or ./.claude/CLAUDE.mdYes, via git
Directorypackages/api/CLAUDE.mdYes; applies when working there
⚠️ Watch out: “New team members don’t get our conventions” → the conventions are in a user-level file. Move them to the project CLAUDE.md.

🌍 Real-world example: The rules the new hire never got

Ravi moves 'Use Playwright fixtures, never hard-coded waits' from ~/.claude/CLAUDE.md into the repository's CLAUDE.md and commits it. The next morning the new tester pulls the repository and Claude follows the rule on their laptop too.

CLAUDE.md configuration hierarchyUser level~/.claude/CLAUDE.md · ~/.claude/skills · ~/.claude/commandsonly you — not sharedProject level./CLAUDE.md (+ @imports) · .claude/commands · .claude/skills · .mcp.jsonwhole team via gitDirectory levelpackages/payments/CLAUDE.mdwhen working in that folderPath-scoped rules.claude/rules/testing.md → paths: [“**/*.test.tsx”]only for matching filesAll applicable files load together into the session — run /memory to see exactly which onesTeam conventions belong at project level; a new teammate never receives your user-level file
Figure: where each CLAUDE.md and rule file lives, and who receives it. Swipe sideways to see the whole diagram.
Advertisement

📎 Keep it modular with @import

# packages/payments/CLAUDE.md
Payments service conventions.
@docs/standards/pci.md
@docs/standards/error-handling.md

Each package imports only the standards relevant to it, instead of loading everything everywhere.

🌍 Real-world example: Payment rules only where they matter

The payments package needs PCI security rules, but the storefront doesn't. The payments CLAUDE.md imports only the files it needs, so storefront work never loads irrelevant rules.

# packages/payments/CLAUDE.md
@docs/standards/pci.md
@docs/standards/error-handling.md

📏 .claude/rules/ and path-specific rules

Split a huge CLAUDE.md into topic files such as testing.md, api-conventions.md and deployment.md in .claude/rules/. Add YAML frontmatter with paths globs so a rule loads only when Claude edits matching files:

---
paths: ["**/*.test.tsx", "**/*.test.ts"]
---
Use React Testing Library. One behaviour per test. No snapshot tests.

Path-scoped rules beat directory CLAUDE.md files when matching files are scattered (tests next to components, Terraform in many service folders), and they save context because irrelevant rules never load.

🌍 Real-world example: Test rules that follow the test files

ShopNest's test files sit next to the code they test, in dozens of folders. One rule file with a paths pattern applies the testing conventions wherever a test file lives, and only when Claude edits a test.

---
paths: ["**/*.spec.ts"]
---
Use page objects. One behaviour per test.
Advertisement

🧠 Debug with /memory

When two developers see different behaviour, run /memory in each session to see exactly which memory files are loaded. It is the first diagnostic for hierarchy problems.

🌍 Real-world example: Why do our laptops behave differently?

Two testers get different results from the same request. Each runs /memory and compares the list of loaded files. One laptop still has an old personal rule file that overrides the team setup.

🚫 Common beginner mistake: Putting team rules in your personal ~/.claude/CLAUDE.md. Only you get them. Team rules belong in the repository.

🛠️ Try it yourself (about 8 minutes)

  1. In a test repository, run /init in Claude Code to create a CLAUDE.md.
  2. Add one rule, such as 'Write tests with pytest'.
  3. Run /memory and find your file in the list.
  4. Ask Claude to write a small test and check it follows the rule.

✅ You are done when: /memory shows the project CLAUDE.md and the generated test follows your rule.

🧪 Exam-Style Practice Questions

Try these before opening the answers. They use the same scenario style as the real exam.

Question 1. Your packages/payments/CLAUDE.md should include the PCI standards file but not the frontend style guide. What's the cleanest method?

  • A. @import the PCI standards file in that package's CLAUDE.md
  • B. Copy-paste the PCI text into it
  • C. Create a skill
  • D. Put everything in the root
Show answer

Answer: A. Selective, modular imports. B duplicates text that will drift. D loads irrelevant rules everywhere. C isn't always-on.

Question 2. Test files sit next to their sources throughout the repo. What's the best way to apply testing conventions automatically?

  • A. Root CLAUDE.md
  • B. A CLAUDE.md in each folder
  • C. A /test command
  • D. A .claude/rules/testing.md with paths: ["**/*.test.*"]
Show answer

Answer: D. Glob-scoped rules follow file types wherever they are. B is impractical for scattered files. C needs manual invocation. A loads the rules always and relies on inference.

Question 3. What's the key difference between a skill and CLAUDE.md?

  • A. CLAUDE.md can't be shared
  • B. Skills are invoked on demand for specific tasks; CLAUDE.md holds always-loaded standards
  • C. Skills can't restrict tools
  • D. Skills are always loaded
Show answer

Answer: B. D is reversed. A: project CLAUDE.md is shared. C: allowed-tools restricts them.

Advertisement

📝 Assignment

Do these tasks in order. Each one has a Done when check, so you know when it is complete. The stretch task is optional but close to what the exam expects from an architect. Keep your answers in one notes file or Git repository, and revisit them in your final week of revision together with the cheat sheet in the last lesson of this course.

  1. Task 1: Run /init in a repository, then move one team convention from your user-level file into the project CLAUDE.md.
    ✅ Done when: A teammate who pulls the repository gets the convention without changing their own machine, and /memory shows the project file.
  2. Task 2: Create .claude/rules/testing.md with a paths glob for test files and confirm it loads only when you edit a test.
    ✅ Done when: The testing rule appears when you edit a test file and does not appear when you edit an unrelated source file.
  3. Stretch: split a long CLAUDE.md into three rule files and use @import for one shared standards document.
    ✅ Done when: The original CLAUDE.md is shorter, the three rule files each cover one topic, and the imported file loads where you expect.
Advertisement

❓ Frequently Asked Questions

🤔 Why doesn't my teammate get my CLAUDE.md rules?

They are probably in ~/.claude/CLAUDE.md, which is personal. Put team rules in the project CLAUDE.md.

🤔 What does @import do in CLAUDE.md?

It pulls another file's contents into CLAUDE.md, so each package can include only the standards it needs.

🤔 When should I use .claude/rules with paths?

When conventions apply to files spread across many folders, such as all test files.

🤔 How do I see which memory files are loaded?

Run /memory in the Claude Code session.

🏁 Summary

  • User-level = personal; project-level = team.
  • @import for modular standards; .claude/rules/ for topic files.
  • paths globs load conventions only for matching files, wherever they live.
  • /memory shows what’s loaded.
📝 Test yourself: Mock Test 1 · Mock Test 4 (30 scenario-based questions in 60 minutes, with explanations).

Next, continue with Claude Code Slash Commands and Skills (SKILL.md Frontmatter).

🎬 Prefer video? Watch QA, automation and AI testing tutorials on the SQA Tools YouTube channel.

Independent study material by SQA Tools. Not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic. Mock questions are original practice items, not real exam content. Exam facts checked against Anthropic's official exam guides and certification FAQ on 11 November 2026.