Skip to content

Trace a rule a teammate never gets

Diagnose why a Claude Code instruction reaches one developer and not another by tracing it through the CLAUDE.md hierarchy, and organize instructions with @imports and .claude/rules/ files.

Scenario

Scenario: Code Generation with Claude Code. Your team builds a freight-tracking platform and uses Claude Code for most new code.

Kofi joined the billing team on Monday. By Wednesday, two of his pull requests store invoice amounts as floating-point numbers. The team rule is clear: money is integer cents in the Money type, never floats. When Ines, the tech lead, asks Claude for the same kind of code, it uses Money every time.

Ines is sure she wrote the rule down months ago. Here is the repository, and what /context lists under Memory files in each of their sessions, both started at the repository root:

freight-platform/
  CLAUDE.md                    committed, 140 lines
  CLAUDE.local.md              on Ines's laptop, gitignored
  .claude/rules/testing.md     committed, no paths field
  services/billing/CLAUDE.md   committed

Ines:  ~/.claude/CLAUDE.md, CLAUDE.md, CLAUDE.local.md, .claude/rules/testing.md
Kofi:  CLAUDE.md, .claude/rules/testing.md

Same repository, same model, different behaviour. Work out where the rule lives before you read the explanation.

Explanation

Claude Code builds its instructions from several files. Who receives an instruction depends on which file it is in.

Level Location Who gets it
Managed policy a system path IT deploys Everyone on managed machines
User ~/.claude/CLAUDE.md Only you, in every project
Project ./CLAUDE.md or ./.claude/CLAUDE.md The team, through version control
Local ./CLAUDE.local.md (gitignore it) Only you, in this project
Subdirectory services/billing/CLAUDE.md Anyone working on files in that directory

How they load. Files in your working directory and every directory above it load at launch. A CLAUDE.md in a subdirectory below loads on demand, the first time Claude reads or edits a file there. All loaded files are added together, not overridden: a deeper file is read later, but if two files contradict each other Claude may follow either one.

How to diagnose. Compare what actually loaded, not what you think is there.

  • /context lists the files loaded at launch under Memory files. A subdirectory CLAUDE.md is missing from that list until it loads on demand, which is normal.
  • /memory lists your CLAUDE.md and other memory files across user and project scope and opens any of them for editing. The exam guide names /memory as the way to see which memory files are loaded; in the current docs, /context is the loaded-at-launch list and /memory is where you open and fix the files.

Keeping it modular.

  • @path imports: a line such as @docs/standards/logging.md pulls that file in. Relative paths resolve from the file that contains the import. Imports organize a file, but they don't save context: imported files load with the file that imports them. A package's CLAUDE.md can import only the standards its maintainers chose, and those load only when Claude works in that package.
  • .claude/rules/: one topic per file (testing.md, api-conventions.md, deployment.md), so each team owns its own file. A rule file without paths frontmatter loads at launch with the same priority as .claude/CLAUDE.md. With paths, it loads only for matching files (the next lessons cover that).

The docs suggest keeping each CLAUDE.md under about 200 lines. An import pulls in a file from outside the repository only after you approve it in a dialog. Decline it and those imports stay disabled.