By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
An incident review found three sessions that ran a migration against the shared staging database without asking. All three engineers had written the rule 'never run a migration without asking' in a CLAUDE.md file. That part was true.
Two of them had written it in their own home directory, so no teammate's session ever saw it. The third had written it in a subdirectory that loads only when a file there opens. Three people held the rule, and the team held none of it.
Claude Code has a memory hierarchy and a settings hierarchy. Memory holds instructions. Settings hold boundaries, and the two do different jobs.
No. CLAUDE.md is context that the model reads and tries to follow. Only a permission rule, a hook or a sandbox check refuses the call. The instruction lowers the chance, and the rule removes it.
Memory is written at four levels. Each level answers a different question about who the instruction is for.
| Level | File | Who it reaches |
|---|---|---|
| Managed policy | the managed location, for example /etc/claude-code/CLAUDE.md | Everyone on the machine, and developers cannot exclude it |
| User | ~/.claude/CLAUDE.md | You, in every project on this machine |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | Everyone who clones the repository |
| Local | ./CLAUDE.local.md | You, in this repository only, and it stays out of git |
The order runs broad to narrow: managed policy, then user, then project, then local. The files are concatenated, not overridden. A later file does not replace an earlier one, so a contradiction leaves the model free to pick either sentence.
Files from the working directory and every directory above it load at launch. A CLAUDE.md in a subdirectory loads the first time the session reads or edits a file there. That is why a convention for one package belongs in that package's file, or in a rule with a glob.
Use @path/to/file.md inside a file to import another one. Imports load with the file that names them, so they organise content without saving any context.
Type /memory to list the memory files a session can see, and open one for editing. It also lists files that do not exist yet, which is how you find the level a new instruction belongs to.
Settings are strict JSON, and four files stack. A single key takes its value from the highest level that sets it.
| Scope | File | Who it affects |
|---|---|---|
| Managed | managed-settings.json, deployed by your organisation | Everyone the policy reaches, and nothing overrides it |
| Command line | --settings with JSON or a file path | One session |
| Project local | .claude/settings.local.json | You, in this project |
| Project | .claude/settings.json | Everyone in the repository, once committed |
| User | ~/.claude/settings.json | You, in every project |
One detail breaks the neat order: lists merge. Permission lists from every file are combined, so a project cannot quietly remove a deny rule that your organisation added.
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Bash(git push --force *)"
],
"ask": [
"Bash(make migrate *)",
"Bash(npm publish *)"
],
"allow": [
"Bash(npm run lint)",
"Bash(npm run test *)"
]
},
"env": {
"NODE_ENV": "test"
}
}A rule names a tool, then the thing it may touch in parentheses. Bash(npm run test *) matches the test command with or without arguments, and the space before the asterisk matters. Read(./.env) matches one path.
deny rule in your own file cannot re-allow something the project or the policy blocks.allow rules are not in force until you accept the folder. deny and ask rules apply at once.-p run prints the reason to stderr and continues.The first two explain most 'the setting did not apply' reports. Run /status to see which settings files loaded, then claude doctor to see which entries were rejected.
One more case looks like a bug and is not. Most settings reload while a session runs, so a permission edit reaches the session you already have open. A few keys, such as model and the effort level, are read once at start, so a change there needs a new session or the matching flag.
Keep the instruction and add the boundary. A CLAUDE.md line tells the model your intent, so it rarely tries the forbidden thing. The deny rule, the hook or the sandbox catches the case where it tries anyway.
Put a fact where it applies. A build command belongs in the project file. A preference for short commit messages belongs in your user file. A convention for one package belongs in that package's file or in a rule.
Move every procedure with steps into a Skill; memory holds facts.
Move every path-scoped convention into .claude/rules/ with a paths list.
Delete anything the code already states, such as the folder layout or the dependency list.
Keep each file under about 200 lines, because longer files cost more context and get followed less.
Run /context all and confirm that the memory files you expect are the ones that loaded.
/context all lists the memory files for the session. A file that is missing there never loaded, and no amount of rewording will help. Fix the path or the level first.
/init writes a starting project file for you. It reads the build commands and conventions it can find, so it fills the parts a new teammate would also discover. Treat the result as a draft: delete what the code already states, then add the pitfalls a reader cannot see.
CLAUDE.md into a deny or ask rule..claude/settings.json and one personal override in .claude/settings.local.json./status to confirm both files loaded, then break one rule on purpose and read the error./context all and check the memory files. Delete any file that loads and does not earn its tokens.Key takeaways
Four memory levels load broad to narrow and are concatenated: managed, user, project, local.
A subdirectory CLAUDE.md loads on demand, when a file there is read or edited.
Settings precedence is managed, command line, project local, project, user; list keys merge instead of overriding.
deny beats allow, and committed project allow rules wait for workspace trust.
CLAUDE.md is context, not enforcement; only permissions, hooks and sandboxes refuse a call.
/context all and /status are how you prove what actually loaded.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.