Two teams adopt Claude Code. Six months later, one has an agent that knows the build commands, respects the repo's conventions, and never touches the legacy directory. The other re-explains the same three things in every session and wonders why the agent keeps running the wrong test command. The difference is rarely the model. It is whether anyone wrote a good CLAUDE.md.
CLAUDE.md is Claude Code's persistent memory: a Markdown file the harness loads into context at session start, automatically, every time. It anchors the Context Management & Reliability domain (15% of the CCA-F exam) and leaks into the Configuration domain (20%) too. This guide covers the hierarchy, what belongs in the file, and the context-window principles behind all of it.
Find out where you stand first
Take the free CCA-F sample questions cold (no signup, real exam style), then read on with your gaps in mind. When you are ready for full rehearsal, Preporato's CCA-F practice tests include 6 full-length exams (390 questions in total, domain-proportional, every answer explained) for a one-time $19.99 with lifetime access.
The Memory Hierarchy
Claude Code assembles persistent context from several locations, and the exam expects you to know what lives where:
| Location | Scope | Typical content |
|---|---|---|
| Enterprise managed CLAUDE.md | Organization-wide | Policies every project inherits |
~/.claude/CLAUDE.md | You, across all projects | Personal preferences, tone, universal habits |
<repo>/CLAUDE.md | The project, shared via git | Build commands, architecture, conventions, boundaries |
<repo>/subdir/CLAUDE.md | A subtree | Module-specific rules, loaded when working there |
More specific scopes layer on top of broader ones, and project files are the ones your teammates inherit when they clone the repo. The file supports imports: an @path/to/file reference pulls another file into memory, so a large project can split conventions into composable pieces instead of one monolith.
Try 15 CCA-F practice questions free
They come from the CCA-F practice tests, and each option shows its explanation once you answer.
- 6 timed practice exams
- Every answer explained
- A score for each domain
- $19.99 one-time
What Belongs in CLAUDE.md (and What Does Not)
The file is loaded into every session, which makes it precious and expensive at the same time: everything in it consumes context before the first user message. The discipline the exam rewards:
Belongs in CLAUDE.md:
- Commands the agent cannot guess: build, test, lint, deploy invocations with their flags
- Architecture facts that are true for months: where things live, what talks to what
- Hard conventions: "database migrations are applied manually," "never edit
generated/" - Repository-specific gotchas that would otherwise burn a session to rediscover
Does not belong:
- Long procedures used occasionally: that is a skill, loaded on demand instead of every session
- Anything enforceable: "always run the formatter" belongs in a hook, because prose compliance is probabilistic
- Prompt-of-the-day experiments and session-specific context
- Documentation that already exists elsewhere: link it, don't duplicate it
The heuristic that resolves most exam questions: CLAUDE.md is for what the agent must know every session; skills are for what it must know some sessions; hooks are for what must happen regardless of what it knows.
Writing style matters more than people expect. The file is instructions, not an essay. Short declarative bullets outperform paragraphs; specific beats general ("run npm run test:unit, the bare npm test runs the slow e2e suite" beats "run appropriate tests"). Review it periodically: a CLAUDE.md that has drifted from reality is worse than none, because the agent trusts it.
The Context Window: Why All of This Matters
Every Claude Code session runs inside a finite context window shared by the system prompt, CLAUDE.md, the conversation, file contents, and tool results. Three consequences drive both real-world practice and exam questions:
Context is a budget. Every token of memory-file boilerplate is a token unavailable for actual work. Bloated CLAUDE.md files degrade the very sessions they are meant to help. Lean memory plus on-demand skills is the architecture that scales.
Signal degrades as the window fills. Long sessions accumulate file dumps and tool output. Claude Code compacts the conversation when it approaches limits (summarizing older turns), and the PreCompact hook exists precisely so critical state can be preserved before summarization. Durable state should live in files, commits, and logs rather than conversation history: conversation is lossy, the filesystem is not.
Isolation beats accumulation. When a job requires reading fifty files, the answer is not a bigger window but a subagent whose context absorbs the noise and returns a conclusion. Context management and orchestration are the same discipline at two scales.
Reliability Patterns Built on These Foundations
The Context Management & Reliability domain pairs the window mechanics with operational judgment:
- Checkpoint long work. Commits, files, and structured logs survive compaction and crashes; the transcript does not.
- Re-anchor after compaction. Critical invariants ("we are migrating to v2 API, never write v1 calls") belong in CLAUDE.md, which is reloaded fresh, rather than only in early conversation turns that compaction may summarize away.
- Design for resumability. A task that can resume from artifacts (a progress file, a TODO list on disk) tolerates interruption; one whose state lives only in the conversation cannot.
Worked Example: A CLAUDE.md That Earns Its Tokens
# Project: acme-billing
Three questions from the CCA-F practice tests
Your support agent, built on the Claude Agent SDK, issues refunds through a process_refund tool owned by another team, and you cannot change that tool. Policy says refunds above $500 must go to a human reviewer. The system prompt states this in capital letters, yet audits find a few refunds between $600 and $800 every month. Where should you enforce the limit?
[object Object]
Correct. A PreToolUse hook runs before the tool executes and can deny the call, so a refund above $500 never reaches the payments system. The denial reason goes back to the agent, which can then escalate to a human. This enforces the rule without changing the other team's tool.
A. Placement and examples can make escalation more likely, but prompt instructions keep a non-zero failure rate. The audits already show the rule being missed in its current form.
B. A description guides how Claude uses the tool, but nothing enforces it, and the tool itself would still accept the amount. This is prompt-based guidance in a different place.
C. PostToolUse runs after the tool has succeeded, so the refund has already been issued by the time the hook sees it. Flagging it afterward turns a prevention rule into cleanup.
Your team shares two MCP servers through the repository's .mcp.json: a GitHub server that needs each developer's personal token, and a database tool whose launch command needs a socket path. Most developers use /var/run/pg.sock, but a few have it elsewhere. You want one committed file that works for everyone without anyone editing it locally. What should .mcp.json contain?
[object Object]
Correct. ${VAR} keeps each developer's token out of the file, and ${VAR:-default} falls back to /var/run/pg.sock when PG_SOCKET is not set. Most developers need nothing extra, and the few with another path set one variable.
A. Ignoring the file stops it from being shared, so new developers get no servers at all, and committing real tokens was never an option. The team loses the single shared configuration it wanted.
B. Local edits to a committed file drift and show up in everyone's diffs, and the requirement was that no one edits it. Expansion with a default handles the exceptions without that.
C. This works only for developers who set PG_SOCKET. Anyone who does not gets the literal ${PG_SOCKET} text in the launch command, which breaks the tool for the majority who need no override.
Your monorepo has packages/billing (Python), packages/web (React) and packages/shared-ui (React). The platform team maintains company-wide standards files: python-style.md, react-style.md and security.md. Each package's maintainers want Claude Code to apply the standards relevant to their package, plus a few notes of their own, without loading unrelated standards. What setup fits best?
[object Object]
Correct. A package's CLAUDE.md loads when Claude works with files in that package, and its @imports bring in exactly the standards its maintainers chose. billing imports python-style.md and security.md, web imports react-style.md and security.md, and each adds its own notes. Unrelated standards stay out of context.
A. Imported files load at launch with the root CLAUDE.md, so every standard is in context for every task. Headings cannot keep the Python standards away from React work.
B. Rules without a paths field load at launch for every task, the same as the root CLAUDE.md. Without path scoping, nothing limits them to the packages they belong to.
D. Skills load on demand, when invoked by name or when Claude decides the description fits. Standards that should always apply in a package should load automatically, without depending on that judgment.
Full CCA-F set: 6 timed exams, every answer explained, $19.99 one-time.
See the practice testsCommands
- Build:
pnpm build(tsc + vite) - Unit tests:
pnpm test:unit(barepnpm testruns slow e2e, avoid) - Lint:
pnpm lint --fix
Architecture
src/core/pure domain logic, no IOsrc/adapters/all external services live here- Invoices are IMMUTABLE after issue; corrections are new credit notes
Boundaries
- Never edit
src/generated/(regenerated bypnpm codegen) - DB migrations are applied manually in production, never auto-run
@docs/conventions/typescript.md
Thirty lines, every one of which prevents a real failure or a wasted exploration. That density is the standard to aim for, in production and in exam answers alike.
Author a CLAUDE.md hierarchy that actually steers a monorepo
A graded project: write the enterprise, user, project, and subtree files for a real monorepo, wire imports, and prove the agent follows them, which is the memory-hierarchy judgment this domain tests.
- Author a CLAUDE.md Hierarchy That Actually Steers a Monorepo ~1hintermediateRubric-graded ProOpen project
- Manage Long-Running Claude Context with Compaction ~3hintermediateRubric-graded ProOpen project
How This Shows Up on the Exam
- Where does a convention every teammate should inherit belong? (Project CLAUDE.md, committed to the repo.)
- A 400-line CLAUDE.md full of deploy runbooks slows every session. What is the fix? (Move runbooks to skills; keep memory lean.)
- A critical instruction from early in a long session stops being followed. Why, and what prevents it? (Compaction summarized it away; persistent invariants belong in CLAUDE.md.)
- What survives a session crash? (Artifacts on disk; nothing conversational.)
The Claude Code course drills this in Level 3 (Context & Memory) with graded exercises, and Preporato's CCA-F practice tests cover the domain across 390 explained questions, with the flashcard deck carrying the hierarchy tables for spaced review.
Frequently asked questions
Sources:
- Claude Code Documentation: Memory
- Anthropic Academy
- Anthropic: Effective Context Engineering for AI Agents
Last updated: September 4, 2026
