Skip to main content
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.

CLAUDE.md files

A CLAUDE.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 every CLAUDE.md it finds: Files higher in the tree are loaded first. Project-level files take precedence in the final assembled prompt.
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

Use claudeMdExcludes in settings.json to skip loading specific CLAUDE.md files. Patterns are matched against absolute paths using picomatch:
Only User, Project, and Local memory types can be excluded. Managed/policy files cannot be excluded.

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:
The directory is keyed on the canonical git root so all worktrees of the same repository share one memory store. Override options (in priority order):
  1. CLAUDE_COWORK_MEMORY_PATH_OVERRIDE environment variable — full-path override
  2. autoMemoryDirectory in settings (user/local/policy only; not project settings for security)
  3. Default derived from git root

MEMORY.md entrypoint

The memory directory uses MEMORY.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: Each memory file uses YAML frontmatter:

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 log is 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:
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.
Auto-memory is also automatically disabled in:
  • Bare/simple mode (--bare or CLAUDE_CODE_SIMPLE=1)
  • Remote sessions without CLAUDE_CODE_REMOTE_MEMORY_DIR set

Creating a CLAUDE.md

1

Create the file

Create a CLAUDE.md at your project root or inside .claude/:
2

Document project conventions

Add sections that Claude should always know:
3

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.
4

Verify it is loaded

Start a new Claude Code session and ask: “What do you know about this project?” — Claude should reflect the content of your CLAUDE.md.

/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).
After selecting a file, Claude Code reports which editor it used and how to change it:

Best practices for CLAUDE.md

Keep each CLAUDE.md focused on the directory it lives in. Put global user preferences in ~/.claude/CLAUDE.md and project-specific conventions in .claude/CLAUDE.md at the repo root.
Document the “why” behind non-obvious conventions. Knowing that bun is required because of a lockfile constraint is more useful than just saying “use bun”.
Keep the file under a few hundred lines. Very large CLAUDE.md files consume context budget that could otherwise go to code. Move verbose documentation into referenced files and summarize in CLAUDE.md.
Avoid duplicating information available in code. CLAUDE.md is for conventions, preferences, and context that Claude cannot infer by reading the source.

Example CLAUDE.md