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).

Advertisement
📖 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.

🏛️ 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.
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.
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.

📏 .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.

Advertisement

🧪 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.