Claude Code has two complementary memory mechanisms: CLAUDE.md files for static, human-authored context that is injected into every session, and the auto-memory system for persistent, Claude-authored notes that accumulate across sessions.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sanbuphy/claude-code-source-code/llms.txt
Use this file to discover all available pages before exploring further.
CLAUDE.md files
ACLAUDE.md file is a Markdown file whose content is injected verbatim into Claude’s system prompt at the start of each session. Use it to document project conventions, preferred commands, architecture decisions, and anything Claude should always know about your project.
File locations
Claude Code walks up the directory tree from the current working directory, loading everyCLAUDE.md it finds:
| Path | Scope |
|---|---|
.claude/CLAUDE.md | Project-specific (inside .claude/ directory) |
CLAUDE.md | Project root |
../.claude/CLAUDE.md | Parent directory (continues up the tree) |
~/.claude/CLAUDE.md | Global user memory |
CLAUDE.md files are loaded lazily via
loadMemoryPrompt() — not at startup — so changes take effect on the next session without restarting Claude Code.Excluding specific files
UseclaudeMdExcludes in settings.json to skip loading specific CLAUDE.md files. Patterns are matched against absolute paths using picomatch:
Auto-memory system
The auto-memory system gives Claude a persistent, file-based memory directory where it can store structured notes across conversations. Unlike CLAUDE.md (which you author), auto-memory is maintained by Claude itself.Storage location
By default, auto-memory lives at:CLAUDE_COWORK_MEMORY_PATH_OVERRIDEenvironment variable — full-path overrideautoMemoryDirectoryin settings (user/local/policy only; not project settings for security)- Default derived from git root
MEMORY.md entrypoint
The memory directory usesMEMORY.md as an index file. It must be kept concise — only the first 200 lines (or 25 KB) are loaded into context. Individual memory entries live in separate topic files and are linked from MEMORY.md.
Memory types
Claude organizes memories into four types:| Type | Description |
|---|---|
user | Information about the user’s role, goals, and preferences |
feedback | Guidance about how to approach work — corrections and confirmations |
project | Ongoing work context not derivable from the code or git history |
reference | Pointers to external systems (Linear projects, Grafana dashboards, Slack channels) |
What NOT to save in memory
The auto-memory system is for information that is not derivable from the current project state. Do not save:- Code patterns, architecture, or project structure — Claude can read the files
- Git history or recent changes —
git logis authoritative - Debugging solutions — the fix is in the code and commit messages
- Anything already in CLAUDE.md files
- Ephemeral task state or in-progress work
Enabling and disabling auto-memory
Auto-memory is enabled by default. To disable it:- settings.json
- Environment variable
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 wins over autoMemoryEnabled: false in settings. Set it to 0 or false to force-enable auto-memory even when the settings file disables it.- Bare/simple mode (
--bareorCLAUDE_CODE_SIMPLE=1) - Remote sessions without
CLAUDE_CODE_REMOTE_MEMORY_DIRset
Creating a CLAUDE.md
Open it in the /memory editor
Run
/memory in Claude Code to open the interactive memory file selector. From there you can open and edit any CLAUDE.md file using your $EDITOR./memory slash command
The/memory command opens a UI for selecting and editing memory files. It shows all discoverable CLAUDE.md files for the current project and lets you open them in your configured editor ($VISUAL or $EDITOR).