CertSafari
    Anthropic Claude Certified Architect – Foundations (CCAR-F)· Lessons

    Domain 3 · Lesson 13/30

    CLAUDE.md hierarchy, scope, imports and rules files

    Configure CLAUDE.md files with appropriate hierarchy, scoping, and modular organization

    19 min read
    3.33% of exam
    8 sources
    Published 20 Oct 2026
    Docs as of 14 Oct 2026

    What you will be able to do

    • Place an instruction at the right scope (managed, user, project, local, or subdirectory) by deciding who should receive it
    • Name the three levels of the CLAUDE.md configuration hierarchy (user-level, project-level and directory-level) and where each file lives
    • Predict which CLAUDE.md files load when a session starts and which load only on demand, then check with /memory
    • Work out why a teammate is missing instructions that live in someone's user-level configuration
    • Use @path imports so each package's CLAUDE.md pulls in only the standards files that apply to it
    • Break a large CLAUDE.md into topic files under .claude/rules/ that still load in every session

    Key concept

    Instruction scope — Where a CLAUDE.md or rules file lives decides who receives it and when it loads. Files committed to the project reach the whole team. Files under ~/.claude reach only the person whose machine they are on. All loaded levels add their content to the context together.

    1.Project scope vs user scope: who receives an instruction

    CLAUDE.md is a plain markdown file of standing instructions that Claude reads at the start of every session, so you don't have to repeat build commands, conventions or warnings in each prompt. It can live in several places, and the location decides who gets it. Before you write an instruction, ask who should receive it: you alone, the team, or the whole organization.

    CLAUDE.md scopes and who each one reaches
    ScopeLocationShared withTypical content
    Managed policy/Library/Application Support/ClaudeCode/CLAUDE.md (macOS), /etc/claude-code/CLAUDE.md (Linux and WSL), C:\Program Files\ClaudeCode\CLAUDE.md (Windows)All users in organizationCompany coding standards, security policies, compliance requirements
    User instructions~/.claude/CLAUDE.mdOnly you (all projects)Code styling preferences, personal tooling shortcuts
    Project instructions./CLAUDE.md or ./.claude/CLAUDE.mdTeam members via source controlProject architecture, coding standards, common workflows
    Local instructions./CLAUDE.local.md (add to .gitignore)Only you (current project)Your sandbox URLs, preferred test data

    Project instructions are the ones a team depends on. A project-root CLAUDE.md is committed to git, so everyone who clones the repository gets the same file. User-level files sit under ~/.claude on one person's machine and are never part of the repository. The same split applies to rules: .claude/rules/ in the project is shared, while ~/.claude/rules/ holds one person's preferences and workflows.

    A new team member who doesn't receive the team's instructions is the classic configuration hierarchy issue, and the cause is almost always level, not wording. Long-standing teammates find that Claude always follows the commit-message format and runs the tests. For the new team member who has just cloned the repo, Claude ignores both. The conventions were never in project-level configuration. Each veteran keeps them in user-level configuration, their own ~/.claude/CLAUDE.md, or Claude picked them up in auto memory, the notes it writes for itself under ~/.claude/projects/<project>/memory/. Neither location is committed, so a fresh clone gets nothing.

    Diagnosing it takes two sessions and one commit:

    1. In the new team member's session, run /memory and read the list of memory files across user and project scopes. The project CLAUDE.md is there, but the missing conventions aren't in it.
    2. Run /memory in a veteran's session and open the files it lists until you find the conventions, usually in the user-level ~/.claude/CLAUDE.md.
    3. Move them into the project-level ./CLAUDE.md or ./.claude/CLAUDE.md (or a project rules file), commit, and have the new team member pull.

    The new team member is also the test for anything else you are unsure about: if a newcomer would need the context to be productive, it belongs at project level.

    Checkpoint 1 of 9· Match them up

    Each CLAUDE.md location reaches a different set of people. Match each location to who receives its instructions.

    Tap a term, then the definition that fits it.

    Sources1234

    2.Which files load at launch, which load on demand, and how /memory shows them

    The CLAUDE.md configuration hierarchy has three levels a developer deals with every day: user-level, project-level and directory-level. User-level instructions live in ~/.claude/CLAUDE.md and follow you into every project on your machine. Project-level instructions live in the root CLAUDE.md of the repository or in .claude/CLAUDE.md, and for most teams this is the main file. Directory-level instructions live in subdirectory CLAUDE.md files and carry the conventions of one module, such as a frontend/ package that works differently from api/. Claude merges what it finds from broad to specific, and an organization can deploy a managed policy file above all three.

    The three everyday levels of the CLAUDE.md hierarchy
    LevelLocationLoadsGood for
    User-level~/.claude/CLAUDE.mdEvery session, in every project on your machinePersonal preferences, such as "I use pnpm, not npm"
    Project-level<repo-root>/CLAUDE.md or ./.claude/CLAUDE.mdEvery session in this projectArchitecture, conventions and commands the team shares
    Directory-level<subdir>/CLAUDE.mdOn demand, when Claude reads files in that subdirectoryModule-specific rules, such as different conventions in frontend/ vs api/

    Every level adds content; none of them replaces another. Managed, user and project files all go into the context together. When two instructions conflict, Claude uses judgment to reconcile them, which means it may pick either one. So remove contradictions instead of counting on one level to override another.

    The working directory sets the dividing line. CLAUDE.md files in that directory and in every directory above it are read at session start. CLAUDE.md files below it load only when Claude reads files in that subdirectory. This is what makes per-package files cheap in a monorepo: work in packages/web never loads the API package's conventions.

    How the starting directory changes what loads at launch in a monorepo
    Start fromCLAUDE.md loaded at launchUse when
    Repository rootRoot only; subdirectory files load on demandTasks span multiple packages or subsystems
    A subdirectoryThat directory's plus every ancestor'sWork is scoped to one package or subsystem

    Use /memory to see what is actually loaded. It lists the CLAUDE.md files in scope for the current session and lets you open any of them to edit. When Claude behaves differently from one session to the next, check this list first. A missing file, or an extra one such as a stale CLAUDE.local.md, usually explains the difference faster than rewriting the instructions.

    Timing also matters when you edit a file mid-session. Claude doesn't re-read the file from disk on every turn. Compaction is Claude Code summarizing the conversation so far to free up context space, and /compact runs it on demand. The edit takes effect after the next /compact, when you open the file through /memory, or in your next session. After compaction, the project-root CLAUDE.md is re-injected from disk, while nested subdirectory files reload on demand again.

    Checkpoint 2 of 9· Check yourself

    A developer notices that in Monday's session Claude followed the package's error-handling convention, but in Tuesday's session on the same repo it ignored it. Nobody edited any instruction file in between. What should they do first?

    Sources2156

    3.Organization-wide instructions developers cannot switch off

    A committed CLAUDE.md reaches the team, but the team controls it. Any developer can edit or delete it, and it covers only one repository. For instructions that have to reach every developer in every repository, use the managed scope, which IT or DevOps deploy to a system location with a configuration management system.

    Claude Code reads two different kinds of file. Instruction files such as CLAUDE.md hold text that is loaded into Claude's context each session, and when two instructions conflict Claude uses judgment to reconcile them. Settings files such as settings.json configure Claude Code itself: permissions, hooks, environment variables and model defaults. A settings rule is applied by Claude Code, while instruction text is guidance Claude weighs, which is why anything that must hold belongs in settings.

    There are two managed mechanisms. A managed CLAUDE.md at the OS policy path holds behavioral guidance: code style and quality guidelines, data-handling and compliance reminders. Managed settings, in managed-settings.json, are enforced settings that your own settings files and --settings values can't override, apart from a few narrow exceptions. Managed settings can carry instruction text in a claudeMd field, and they also handle concerns that need enforcement instead of persuasion, such as blocking tools with permissions.deny or turning on sandbox isolation.

    Instruction text delivered through managed settingsjson
    {
      "claudeMd": "Always run `make lint` before committing.\nNever push directly to main."
    }

    For security and compliance, the other scopes all fall short in the same way: someone below the organization controls them. A per-repository CLAUDE.md misses repositories nobody updated, and a developer can edit it. Seeding each person's ~/.claude/CLAUDE.md with an onboarding script leaves the file in their hands. A gitignored CLAUDE.local.md is personal by design. Only the managed location sits above developer and project control.

    Checkpoint 3 of 9· Check yourself

    Your compliance team wants a data-handling instruction to reach every developer in every repository, and no developer should be able to remove it. Which approach meets both requirements?

    Checkpoint 4 of 9· Exam question

    An architect is designing a configuration strategy for a company rolling out Claude Code to all engineering teams. They need security and compliance instructions that every developer receives on every machine, in every repository, and that individual developers or teams cannot disable through their own settings. Which approach satisfies this requirement?

    Sources135

    4.Keeping CLAUDE.md modular with @path imports

    An @path reference inside a CLAUDE.md imports another file. Claude Code loads the referenced file's contents at launch as part of the instructions. You can reference project files, docs, and even a file in your home directory. A home-directory file is a way to keep personal notes about a shared project out of the repository.

    Imports of project files, a docs file, and a personal file in the home directorymarkdown
    See @README for project overview and @package.json for available npm commands for this project.
    
    # Additional Instructions
    - git workflow @docs/git-instructions.md
    
    # Individual Preferences
    - @~/.claude/my-project-instructions.md

    Imports work well in a monorepo where each package keeps its own CLAUDE.md. The people who maintain a package know which shared standards apply to it. The API package's file can import the API conventions and the database standards, and the frontend package's file can import the component guidelines. Each package then loads only what is relevant to it, and the standards text still lives in one place. Per-directory files suit this because directory owners maintain their own conventions, and those conventions are versioned with the code.

    Imports organize a file, but they don't shrink it. An imported file loads at launch together with the file that imports it, so a 300-line CLAUDE.md split into three imported files costs the same context. To actually load less, move area-specific guidance into a subdirectory CLAUDE.md or into a path-scoped rule. Importing a file from outside the working directory also needs approval: Claude Code asks you to approve external imports for the project.

    The same mechanism lets you share AGENTS.md with other coding tools without keeping two copies. A CLAUDE.md that imports @AGENTS.md and then adds Claude-only notes loads both. A CLAUDE.md that only tells Claude in words to read AGENTS.md is weaker, because Claude sees the file only if it decides to open it.

    A CLAUDE.md that imports shared AGENTS.md conventions and adds Claude-specific notesmarkdown
    @AGENTS.md
    
    ## Claude Code
    
    Use plan mode for changes under `src/billing/`.

    Checkpoint 5 of 9· Fill the gap

    This project CLAUDE.md is committed to the team repository. The developer wants the Individual Preferences import to bring in their personal notes about this project while keeping those notes out of the repository. Which reference completes the last line?

    See @README for project overview and @package.json for available npm commands for this project.
    
    # Additional Instructions
    - git workflow @docs/git-instructions.md
    
    # Individual Preferences
    -  ? 

    Checkpoint 6 of 9· Check yourself

    To reduce the context used at launch, a team moves the frontend and database sections of its 300-line root CLAUDE.md into docs/frontend.md and docs/db.md. The root file now imports them with @docs/frontend.md and @docs/db.md. What effect does this have on context?

    Sources17

    5.Splitting a monolithic CLAUDE.md into .claude/rules/ topic files

    Large CLAUDE.md files hurt in two ways: they use more context and Claude follows them less reliably. The recommended size is under 200 lines per CLAUDE.md file. When one file grows to cover code style, testing, security and deployment, put each topic in its own markdown file in .claude/rules/ and cut CLAUDE.md down to the core build commands and conventions.

    A project with a slim CLAUDE.md and one rules file per topictext
    your-project/
    ├── .claude/
    │   ├── CLAUDE.md           # Main project instructions
    │   └── rules/
    │       ├── code-style.md   # Code style guidelines
    │       ├── testing.md      # Testing conventions
    │       └── security.md     # Security requirements

    The optional paths: frontmatter decides when a rules file loads. Without it, the file loads every session, the same as CLAUDE.md, and like the project-root CLAUDE.md it is re-injected from disk after compaction. That is the right choice when the goal is better organization while every topic stays loaded. Adding paths: globs turns the file into a conditional rule, which is a different design taught in path-specific rules.

    Where to put guidance split out of a long CLAUDE.md, by when it loads
    DestinationLoadsFits when
    .claude/rules/*.md without pathsEvery sessionEvery topic must stay loaded, split into focused files
    .claude/rules/*.md with paths globsWhen Claude works with a matching fileGuidance applies only to certain file types or directories
    Subdirectory CLAUDE.mdAt launch from that directory, otherwise on demandDirectory owners maintain conventions next to their code
    Skill in .claude/skills/On demand, when invoked or relevantReference material or repeatable workflows, not always-on rules

    If every topic has to be present in every session, only one option in that table works. Subdirectory CLAUDE.md files and path-scoped rules leave a topic out until Claude touches matching files. Skills load only when invoked or judged relevant, which suits a full style guide but not an always-on rule such as a security requirement. How skills are built is covered in custom slash commands and skills. Splitting does not reduce the total text, so delete outdated or contradictory instructions while you split, because Claude may pick either side of a conflict at random.

    Checkpoint 7 of 9· Match them up

    While splitting an oversized CLAUDE.md, a team weighs four places to put each topic. The deciding factor is when each place's content reaches Claude. Pair each destination with its loading behavior.

    Tap a term, then the definition that fits it.

    Checkpoint 8 of 9· Exam question

    An engineer launches Claude Code from the services/billing/ directory inside a larger repository. The repository contains three CLAUDE.md files: one at the repository root, one at services/billing/CLAUDE.md, and one at services/billing/reports/CLAUDE.md. The engineer has not yet read or edited any files in the services/billing/reports/ subdirectory. At the moment the session starts, which files are loaded into context?

    Checkpoint 9 of 9· Exam question

    A project's single CLAUDE.md has grown to over 500 lines covering code style, testing, security requirements, and deployment steps, and the team notices Claude adheres to instructions less reliably than before. The architect wants to reorganize this into focused, maintainable files while keeping everything loaded for every session. Which restructuring best achieves this?

    Sources18

    Sources

    (8)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Personal preferences for all projects”
      ↩︎ Project scope vs user scope: who receives an instruction
      “A new teammate would need the same context to be productive”
      ↩︎ Project scope vs user scope: who receives an instruction
      “Project instructions | ./CLAUDE.md or ./.claude/CLAUDE.md”
      ↩︎ Which files load at launch, which load on demand, and how /memory shows them
      “Organization-wide instructions managed by IT/DevOps”
      ↩︎ Organization-wide instructions developers cannot switch off
      “Imports help you organize a long file but don’t reduce its context cost, because imported files also load at launch.”
      ↩︎ Keeping CLAUDE.md modular with @path imports
      “Claude sees AGENTS.md only if it decides to open the file.”
      ↩︎ Keeping CLAUDE.md modular with @path imports
      “target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence.”
      ↩︎ Splitting a monolithic CLAUDE.md into .claude/rules/ topic files
      “if two instructions contradict each other, Claude may pick one arbitrarily.”
      ↩︎ Splitting a monolithic CLAUDE.md into .claude/rules/ topic files
      “Team members via source control”
      ↩︎ Exam trap 1
      “Project instructions | ./CLAUDE.md or ./.claude/CLAUDE.md”
      ↩︎ Exam trap 3
      “Imports help you organize a long file but don’t reduce its context cost, because imported files also load at launch.”
      ↩︎ Exam trap 4
      “User instructions | ~/.claude/CLAUDE.md | Personal preferences for all projects | Code styling preferences, personal tooling shortcuts | Only you (all projects)”
      ↩︎ Checkpoint
    2. 2.
      “Most teams only need the project-root file. Commit it to git so the whole team benefits.”
      ↩︎ Project scope vs user scope: who receives an instruction
      “Claude looks in a few places and merges what it finds, from broad to specific”
      ↩︎ Which files load at launch, which load on demand, and how /memory shows them
      “That subdirectory (loaded on demand when Claude reads files in that directory, not at session start)”
      ↩︎ Which files load at launch, which load on demand, and how /memory shows them
      “If you edit the file mid-session, the change is picked up the next time you run /compact or open it via /memory”
      ↩︎ Which files load at launch, which load on demand, and how /memory shows them
      “Subdirectory CLAUDE.md files are loaded on demand later, when Claude reads files in that subdirectory.”
      ↩︎ Exam trap 2
      “Subdirectory CLAUDE.md files are loaded on demand later, when Claude reads files in that subdirectory.”
      ↩︎ Prediction
      “See what memory Claude is using | /memory”
      ↩︎ Checkpoint
    3. 3.
      “Auto memory: Claude’s notes to itself across sessions”
      ↩︎ Project scope vs user scope: who receives an instruction
      “Enterprise-enforced settings that your own settings files and --settings values can’t override, apart from narrow exceptions.”
      ↩︎ Organization-wide instructions developers cannot switch off
      “Permissions, hooks, env vars, model defaults”
      ↩︎ Organization-wide instructions developers cannot switch off
      “Enterprise-enforced settings that your own settings files and --settings values can’t override, apart from narrow exceptions.”
      ↩︎ Exam trap 5
    4. 4.
      “Memory file locations across user and project scopes with the option to open each in your editor”
      ↩︎ Project scope vs user scope: who receives an instruction
    5. 5.
      “Files from your working directory and above load at launch; subdirectories load as you work in them.”
      ↩︎ Which files load at launch, which load on demand, and how /memory shows them
      “When instructions conflict, Claude uses judgment to reconcile them.”
      ↩︎ Organization-wide instructions developers cannot switch off
      “CLAUDE.md files are additive: all levels contribute content to Claude’s context simultaneously.”
      ↩︎ Key concept
      “Every session, or when matching files are opened”
      ↩︎ Prediction
      “Loads | Every session | Every session, or when matching files are opened | On demand, when invoked or relevant”
      ↩︎ Checkpoint
    6. 7.
      “Directory owners maintain their own conventions; instructions are versioned with the code”
      ↩︎ Keeping CLAUDE.md modular with @path imports
    7. 8.
      “Project-root CLAUDE.md and unscoped rules | Re-injected from disk”
      ↩︎ Splitting a monolithic CLAUDE.md into .claude/rules/ topic files

    Spotted a mistake, or was something unclear? Tell us.