Certopolis

Claude Certified Architect – Foundations

CLAUDE.md hierarchy: managed, user, project, local

Claude Code reads four kinds of CLAUDE.md file: managed policy, user (~/.claude/CLAUDE.md), project (./CLAUDE.md or ./.claude/CLAUDE.md) and local (./CLAUDE.local.md). All of them are concatenated into context, not overridden, with files closer to your working directory read last.

The four scopes

Managed policy CLAUDE.md is deployed by IT to a fixed path, such as /Library/Application Support/ClaudeCode/CLAUDE.md on macOS or /etc/claude-code/CLAUDE.md on Linux. It applies to every user on the machine and cannot be excluded by individual settings.

The user file at ~/.claude/CLAUDE.md holds your personal preferences for all projects. The project file at ./CLAUDE.md or ./.claude/CLAUDE.md is committed and shared with the team through source control: build commands, conventions, layout. The local file ./CLAUDE.local.md holds personal notes for one project, such as your sandbox URL, and you add it to .gitignore.

Use /init to generate a starting project file, and run /context to see which files actually loaded under Memory files.

How files load and in what order

Claude Code loads CLAUDE.md and CLAUDE.local.md from your working directory and every directory above it, at launch. Start in foo/bar/ and it loads foo/CLAUDE.md and foo/bar/CLAUDE.md. Content is ordered from the filesystem root down, so foo/bar/CLAUDE.md is read after foo/CLAUDE.md. Within one directory, CLAUDE.local.md is appended after CLAUDE.md.

Files in subdirectories below your working directory do not load at launch. Each one loads when Claude reads, writes or edits a file in that subdirectory.

Because nothing is overridden, two contradicting instructions both reach Claude and it may pick either one. Keep files consistent instead of relying on one to cancel another.

Imports, exclusions and compaction

A CLAUDE.md can pull in other files with @path/to/file. Imported files load at launch, so they help you organise a long file but do not reduce its context cost. Imports can nest up to four hops.

In a large monorepo, claudeMdExcludes in .claude/settings.local.json skips other teams' files by path or glob. Managed policy files cannot be excluded.

After /compact, Claude re-reads the project-root CLAUDE.md from disk. Nested CLAUDE.md files return only when Claude next works with a file in their directory. An instruction given only in chat is gone.

Where the exam catches people

  • A subdirectory CLAUDE.md does not replace the root one; both are concatenated, and the closer file is simply read later.
  • CLAUDE.local.md is per project; for a preference that applies in every project, use ~/.claude/CLAUDE.md.
  • An @ import does not save context, because imported files load at launch with the file that imports them.
  • CLAUDE.md shapes behaviour but does not enforce it; to block an action regardless of what Claude decides, use a PreToolUse hook or a permissions.deny rule.

Written from Anthropic's documentation

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. Every session you re-explain the same three things about your service: the build command, the test command, and where the request handlers live. A teammate joining next month would need the same context, and everyone who clones the project should get it without asking you. What's the most effective way to give Claude that context in every session?

    Right. In the game that’s Renown for your Claude Code Configuration and Workflows building.

    Not that one: C is right. In the game your Claude Code Configuration and Workflows building would lose a little Renown, and this question would come back later.

  2. You run Claude Code from services/billing/ in a monorepo whose root CLAUDE.md sets a repository-wide four-space indentation rule. The billing team needs its own two-space rule to win in sessions started there, and each developer needs a personal override that wins over both and never reaches a commit. Where should you create the two overriding files?

    Right. In the game that’s Renown for your Claude Code Configuration and Workflows building.

    Not that one: B is right. In the game your Claude Code Configuration and Workflows building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Across the tree the content is ordered from the filesystem root down to the working directory, so services/billing/CLAUDE.md appears after the root file and is read last. Within a single directory CLAUDE.local.md is appended after CLAUDE.md, which puts a developer's personal notes last of all. CLAUDE.local.md is the file the documentation designates for private per-project preferences and tells you to add to .gitignore, so it is the half that never reaches a commit.

    Written from code.claude.com/docs/en/memory.md

  3. You run long sessions from your monorepo's root. The root CLAUDE.md's conventions hold all the way through, but after each /compact the naming rules from packages/api/CLAUDE.md stop being applied, then start being applied again some turns later without you doing anything. What is the most likely root cause?

    Right. In the game that’s Renown for your Claude Code Configuration and Workflows building.

    Not that one: B is right. In the game your Claude Code Configuration and Workflows building would lose a little Renown, and this question would come back later.