CLAUDE.md Configuration Guide: Hierarchy, @import and Path-Specific Rules
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).
🏛️ The three-level hierarchy
| Level | Location | Shared with team? |
|---|---|---|
| User | ~/.claude/CLAUDE.md | No — only you |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | Yes, via git |
| Directory | packages/api/CLAUDE.md | Yes; applies when working there |
📎 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.
📏 .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.
🧠 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.
🧪 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.
📝 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.
- 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. - 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. - 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.
❓ 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.
pathsglobs load conventions only for matching files, wherever they live./memoryshows what’s loaded.
Next, continue with Claude Code Slash Commands and Skills (SKILL.md Frontmatter).
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.