D2.4 resolved MCP servers and settings across a strict precedence where the highest scope wins. The instruction layer looks like the same machinery — files at managed, user, project, and local scopes — but it behaves in the opposite way: the files do not compete, they concatenate. This chapter is the exam angle on that distinction and on the @import mechanism that stitches files together. The design rationale for treating the file as a context budget lives in the Further reading.

Four scopes that load broadest-first

Claude Code assembles its persistent instructions from up to four CLAUDE.md scopes, loaded broadest to most specific: Managed policy, then User (~/.claude/CLAUDE.md), then Project (./CLAUDE.md or ./.claude/CLAUDE.md), then Local (./CLAUDE.local.md, which you add to .gitignore). [Official] How Claude remembers your project · AnthropicT1-official original Discovery walks up the directory tree from your working directory; a CLAUDE.md nested below cwd is not loaded at launch but on demand, when Claude first reads a file in that subdirectory. [Official] How Claude remembers your project · AnthropicT1-official original The managed-policy file is the one scope that cannot be excluded by any individual setting — which is exactly what makes it the instrument for org-enforced instructions. [Official] How Claude remembers your project · AnthropicT1-official original

Concatenation, not precedence

Here is the property that separates the instruction layer from every settings file: the discovered CLAUDE.md files do not override one another. “All discovered files are concatenated into context rather than overriding each other. Across the directory tree, content is ordered from the filesystem root down to your working directory.” [Official] How Claude remembers your project · AnthropicT1-official original Within a single directory, CLAUDE.local.md is appended after CLAUDE.md. [Official] How Claude remembers your project · AnthropicT1-official original

Contrast settings, which resolve by a strict five-level precedence where the highest scope wins. Named in full, highest to lowest: [Official] Claude Code Settings · AnthropicT1-official original

So CLAUDE.md and settings sit at opposite ends: one accumulates, the other overrides — and the override ladder is five rungs, not three, with CLI and Local the two most often forgotten.

@import: stitching files together

A CLAUDE.md can pull in other files with @path/to/import. The imported files expand and load at launch alongside the referencing file; relative paths resolve relative to the file containing the import; and the import chain has a maximum recursion depth of 5. [Official] How Claude remembers your project · AnthropicT1-official original The first time a session encounters an import, Claude shows an approval dialog — and declining it disables imports permanently (the dialog does not reappear). [Official] How Claude remembers your project · AnthropicT1-official original

AGENTS.md, managed policy, and the budget you don’t develop here

Three controls round out the layer. First, the cross-tool bridge: Claude Code reads CLAUDE.md, not AGENTS.md — to share one instruction set with other agents, create a CLAUDE.md that imports @AGENTS.md. [Official] How Claude remembers your project · AnthropicT1-official original Second, managed settings can deploy instructions with no file at all: the claudeMd key carries inline CLAUDE.md content, honored only in managed/policy settings, and it loads before the user and project files. [Official] How Claude remembers your project · AnthropicT1-official original Claude Code Settings · AnthropicT1-official original Third, claudeMdExcludes — glob patterns matched against absolute paths, merged across layers — skips ancestor CLAUDE.md files, with the single exception that the managed-policy file can never be excluded. [Official] How Claude remembers your project · AnthropicT1-official original

Practice

Exercise solutions

Solution ↑ Exercise

C. CLAUDE.md files do not compete: “All discovered files are concatenated into context rather than overriding each other,” ordered “from the filesystem root down to your working directory.” So both “use tabs” and “use 2-space indent” are in context simultaneously — which is itself a smell, because contradictory ancestor instructions are not resolved by proximity. A and B both assume a precedence the instruction layer does not have. D is the high-value trap: it imports the settings model (where settings.local.json overrides user settings) onto memory, where files merge instead. To actually suppress the root file you would use claudeMdExcludes, not a closer CLAUDE.md.

Solution ↑ Exercise

haiku runs. The five-level settings precedence, highest to lowest, is Managed → CLI arguments → Local → Project → User; the --model haiku CLI argument (level 2) beats both the project opus (level 4) and the user sonnet (level 5). The same two-scope setup behaves differently for CLAUDE.md because the instruction layer concatenates instead of overriding — two CLAUDE.md files setting contradictory guidance would both load into context at once, with no “winner,” whereas settings resolve to exactly one value down the ladder.

Solution ↑ Exercise

(a) The maximum @import recursion depth is 5. (b) On first encountering an import, Claude Code shows an approval dialog; declining it disables imports permanently — the dialog does not reappear, so a future import in that environment silently will not expand until the choice is reset. Design import chains shallow (≤5) and approve deliberately.

Exam essentials

Further reading

The discipline behind what belongs in these files — treating the always-loaded CLAUDE.md as a permanent slice of the context budget rather than documentation, and the controlled study measuring the cost of overstuffing it — is developed in the Agentic Systems Design book, Chapter 4, The Instruction Layer: CLAUDE.md & AGENTS.md. Optional depth; this chapter stands on its own.