CLAUDE.md and Claude Code memory, explained.
CLAUDE.md is a markdown file of instructions that Claude Code reads at the start of every session. You write it. Auto memory is the other half: notes Claude writes for itself from your corrections. Both are context Claude tries to follow, not enforced rules, so keep CLAUDE.md short and specific.
By Marcel, who makes Mote·Updated
On this page
What is a CLAUDE.md file?
A CLAUDE.md file is plain markdown that gives Claude Code persistent instructions: build commands, conventions, project layout, “always do X” rules. Each session starts with a fresh context window, and Claude reads CLAUDE.md at the start of every one, so you stop re-explaining the same things (Anthropic: memory).
Claude Code has two memory systems that carry knowledge across sessions, and they’re easy to mix up. You write CLAUDE.md. Claude writes auto memory. Here’s how they split:
CLAUDE.md
- Who writes it
- You
- What it holds
- Instructions and rules
- Loaded
- Every session, at launch
- Use it for
- Commands, conventions, project layout
Auto memory
- Who writes it
- Claude
- What it holds
- Learnings and patterns
- Loaded
- First 200 lines or 25KB of
MEMORY.md, whichever comes first - Use it for
- Your preferences and corrections, context Claude can’t get from the code
One rule covers both: Claude treats them as context, not enforced configuration. To block an action no matter what Claude decides, Anthropic’s docs point to a PreToolUse hook instead.
Where does CLAUDE.md go?
Put a project CLAUDE.md at the root of your repo, as ./CLAUDE.md or ./.claude/CLAUDE.md, and commit it so your team shares it. Personal rules for every project go in ~/.claude/CLAUDE.md. Personal rules for one project go in ./CLAUDE.local.md, which you add to .gitignore (Anthropic: memory).
Organization
- Location
- macOS:
/Library/Application Support/ClaudeCode/CLAUDE.mdLinux and WSL:/etc/claude-code/CLAUDE.mdWindows:C:\Program Files\ClaudeCode\CLAUDE.md - Shared with
- Everyone on the machine
- Good for
- Company standards, set by IT
User
- Location
~/.claude/CLAUDE.md- Shared with
- Only you, every project
- Good for
- Your style and tooling preferences
Project
- Location
./CLAUDE.mdor./.claude/CLAUDE.md- Shared with
- Your team, through git
- Good for
- Architecture, commands, conventions
Local
- Location
./CLAUDE.local.mdAdd it to.gitignoreyourself.- Shared with
- Only you, this project
- Good for
- Your sandbox URLs, test data
How Claude Code loads those files:
- Up the tree at launch. When it starts, Claude Code loads the CLAUDE.md and CLAUDE.local.md in your working directory and every directory above it.
- They add up. Files don’t override each other: everything is concatenated, from the filesystem root down, so the file closest to where you launched Claude is read last.
- Local comes second. Within each folder, CLAUDE.local.md comes after CLAUDE.md.
- Subfolders wait. CLAUDE.md and CLAUDE.local.md files in subdirectories load later, once Claude reads, writes or edits a file in that folder.

To see which files loaded at launch, run /context all in a session and look under Memory files. Subdirectory CLAUDE.md files don’t appear there, because they load on demand.
How do you create a CLAUDE.md file?
Run /init inside Claude Code. It reads your codebase and drafts a CLAUDE.md with the build commands, test instructions and conventions it finds; if you already have one, it suggests improvements instead of overwriting it. Then cut what Claude could work out on its own and add what it couldn’t (Anthropic: memory).
Open a terminal in your project and start Claude Code with
claude.Run
/initand review the draft it writes.Trim it to facts Claude needs in every session, and add the ones it can’t discover from the code: why a folder exists, which command is the real one, what not to touch.
Start a new session, run
/context allto confirm the file appears under Memory files, then commit it.
Here’s the shape of a good one. Short, concrete, grouped under headings:
# Project
Next.js app, exported as a static site to out/.
## Commands
- npm run dev: local server on port 3000
- npm run build: production build (runs the sitemap script first)
- npm test: unit tests. Run before committing.
## Conventions
- Page copy lives in src/lib/*.ts, not in components.
- Prices come from src/lib/site.ts. Never hard-code them in copy.
## Don't
- Don't edit files in out/. They're generated.
- Don't add a dependency without asking first.
Anthropic’s test for what to add: Claude makes the same mistake twice, a code review catches something Claude should have known, or you type the same correction you typed last session. If you’d have to tell a new teammate, it belongs here.
What should you put in CLAUDE.md?
Instructions specific enough to check. “Use 2-space indentation”, not “format code properly”; “run npm test before committing”, not “test your changes”. Anthropic suggests staying under 200 lines per file, using headings and bullets, and removing anything that contradicts another instruction (Anthropic: memory).
- Keep it short. Longer files use more context and are followed less reliably. Claude Code warns at startup and in
/statuswhen a file runs past the recommended length, or when several files add up past a combined limit. - Be concrete. A rule you can verify gets followed more consistently than a vague one.
- Remove contradictions. If two instructions disagree, Claude may pick either one, and that includes a user rule against a project rule.
- Move procedures out. A multi-step workflow belongs in a skill, which loads only when it’s needed, rather than in every session’s context.
- Scope the rest. Instructions for one part of the codebase belong in
.claude/rules/, which can load only for matching files.
Path-scoped rules are markdown files in .claude/rules/ with a paths field at the top. They load when Claude reads, writes or edits a matching file, so your API rules don’t take up context while it works on CSS. A rule file without paths loads at launch, like CLAUDE.md:
---
paths:
- "src/api/**/*.ts"
---
# API rules
- Every endpoint validates its input.
- Use the standard error response format.
Two smaller features are worth knowing. The first is imports: an @ followed by a path imports that file into CLAUDE.md. It helps organize a long file but doesn’t save context, since the import loads with it.
Write the path bare. Wrapped in backticks or a code block it stays literal text, and a path with spaces needs a backslash before each space:
See @README.md for the project overview.
## More docs
- Git workflow: @docs/git-instructions.md
- Design notes: @Design\ Docs/api.md
The second is comments. Block-level HTML comments (<!-- like this -->) are stripped before the file goes into Claude’s context, so you can leave notes for people at no context cost. Comments inside code blocks stay.
Leave out what Claude can work out from the code. Claude Code’s own /doctor checkup proposes cutting exactly that from a CLAUDE.md: directory layouts, dependency lists and architecture overviews.
How does Claude Code’s auto memory work?
Auto memory is on by default in local sessions. As it works, Claude saves notes about you, your corrections, ongoing project decisions and where to find things, in ~/.claude/projects/<project>/memory/. The first 200 lines or 25KB of its MEMORY.md index load at the start of each session; topic files are read when needed (Anthropic: memory).
Claude doesn’t save something every session. It skips what it can work out from the code, such as architecture and file paths, and anything your CLAUDE.md already says. Everything in the folder is plain markdown you can read, edit or delete. It’s machine-local: shared across worktrees of the same git repo, but not across machines.
~/.claude/projects/<project>/memory/
├── MEMORY.md # index, one line per memory
├── user_role.md # one memory per file
└── feedback_testing.md- Say “remember that the API tests need a local Redis instance” and Claude saves it to auto memory.
- Say “add this to CLAUDE.md” and it goes into CLAUDE.md instead.
- Run
/memoryto browse your memory files, open the folder, or turn auto memory off. - To turn it off for one project, add
autoMemoryEnabledto that project’s.claude/settings.local.json(just you) or.claude/settings.json(everyone in the repo), as below (settings reference).
{
"autoMemoryEnabled": false
}
To turn it off through the environment, start Claude Code with CLAUDE_CODE_DISABLE_AUTO_MEMORY set to 1. In a macOS or Linux shell:
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 claude
When you see “Saved 2 memories” or “Recalled 2 memories” in Claude Code, that’s auto memory being written or read.
CLAUDE.md, rules, skills, hooks or auto memory: which one?
Use CLAUDE.md for what Claude should always know, path-scoped rules for one part of the codebase, skills for reference material and workflows it needs only sometimes, and hooks for anything that must happen every time. Auto memory is Claude’s own notebook, so leave it to Claude and correct it when it’s wrong (Anthropic: extend Claude Code).
| Who writes it | When it loads | Use it for | |
|---|---|---|---|
| CLAUDE.md | Who writes it: You | When it loads: Every session, at launch | Use it for: Commands, conventions, “always do X” rules |
| .claude/rules/ | Who writes it: You | When it loads: At launch, or only for matching files when it has paths | Use it for: Instructions for one part of the codebase |
| Skills | Who writes it: You | When it loads: Descriptions at launch, full content when used or run as /name | Use it for: Reference docs and repeatable workflows |
| Hooks | Who writes it: You | When it loads: Nothing loads: they run on matching events | Use it for: What must happen every time, or must be blocked |
| Auto memory | Who writes it: Claude | When it loads: First 200 lines or 25KB of MEMORY.md | Use it for: Your preferences and corrections |
Anthropic’s rule of thumb: keep CLAUDE.md under 200 lines, and when it grows, move reference content into skills or split it into .claude/rules/ files. If you paste the same multi-step procedure into chat a third time, that’s a skill; if you want something to happen every time without asking, that’s a hook (Anthropic: extend Claude Code).
Why is Claude ignoring my CLAUDE.md?
Usually because the file didn’t load, the instruction is vague, or two instructions conflict. CLAUDE.md reaches Claude as a message after the system prompt, so it guides Claude rather than binding it. Run /context all to check the file loaded, then make the instruction more specific (Anthropic: memory).
- Not loaded. A CLAUDE.md in a subdirectory doesn’t show under Memory files at launch. It loads once Claude reads, writes or edits a file in that folder.
- Too vague. Rewrite the rule so you could check it was followed.
- Conflicting. Look across your user, project and subdirectory files, and
.claude/rules/, for two rules that disagree. - Must always happen. If something has to run before every commit or after every edit, make it a hook, which runs as a shell command regardless of what Claude decides (Anthropic: hooks).
- Lost after /compact. Your project-root CLAUDE.md is re-read from disk after compaction. Instructions you only gave in chat are gone, and subdirectory CLAUDE.md files and path-scoped rules stay unloaded until Claude touches a matching file again.
Claude Code v2.1.283 and later can also run /doctor prompt-audit, which looks for outdated instructions, references to files or commands that don’t exist, and files that contradict each other, then proposes edits without changing anything until you ask. It runs through Claude Code’s bundled /claude-api skill, so it’s unavailable if that skill is turned off.
Using your CLAUDE.md outside the terminal.
Your CLAUDE.md belongs to Claude Code, not to the terminal, so any app that runs Claude Code can load it. In Mote for Mac, Agent mode runs your own Claude Code beside your notes, and one setting decides whether your CLAUDE.md, skills and connected tools come along.
Full disclosure: I make Mote, and it’s paid (Mac only, macOS 15 or later).
Agent mode is off until you turn it on in Settings → Agents, and it uses the Claude Code you already have, on your own account.

The setting is “Include my Claude setup”. It’s on by default for regular chats with Claude and off for Quick Chat (the quick question window from any app), so it answers sooner. To change it:
- Per chat, from the permissions menu inside the model picker.
- For new chats, in Settings → Agents, on the Defaults tab, with Claude as the provider. Quick Chat has its own tab.
Which CLAUDE.md loads depends on the chat’s folder. New chats start in Mote’s own folder, so you get your personal ~/.claude/CLAUDE.md. To load a project’s CLAUDE.md, choose that project’s folder from the chat’s welcome screen, the same as starting claude there in a terminal.
If you keep notes in Obsidian, a CLAUDE.md at the vault root is how you tell Claude what the vault is and what it may change: see how to connect Claude Code to Obsidian. More on Mote’s side: Agent mode.
CLAUDE.md and Claude Code memory: common questions
Something else? Ask in the Discord
No account, no card. $18.99 once after that.