Claude Code has a layered memory system that lets you give Claude persistent context — coding standards, project architecture, personal preferences — without repeating yourself in every session. Memory is stored in plain Markdown files that Claude reads at startup.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/VineeTagarwal-code/claude-code/llms.txt
Use this file to discover all available pages before exploring further.
Memory types
Files are loaded in order from lowest to highest priority. Later files override earlier ones.| Type | File location | Description |
|---|---|---|
| Managed | /etc/claude-code/CLAUDE.md | Organization-wide instructions set by administrators. Users cannot edit these. |
| User | ~/.claude/CLAUDE.md | Your personal global instructions applied to every project. |
| Project | CLAUDE.md, .claude/CLAUDE.md, .claude/rules/*.md | Instructions checked into the project repository. Shared with everyone who works on the project. |
| Local | CLAUDE.local.md | Your private project instructions. Not checked into version control (add to .gitignore). |
| AutoMem | ~/.claude/MEMORY.md | Auto-extracted memory that Claude builds up over time (when the feature is enabled). |
The maximum recommended size for a single memory file is 40,000 characters. Files beyond this limit may be truncated before being injected into the context window.
CLAUDE.md
CLAUDE.md is the primary memory file for a project. Place it in the root of your repository to give Claude standing instructions for every session in that project.
Example CLAUDE.md
Where to put CLAUDE.md
Claude Code traverses the directory tree from the current working directory up to the filesystem root, loading memory files at each level. You can have multipleCLAUDE.md files in nested directories; files nearer to the working directory take higher priority.
.claude/CLAUDE.md
An alternative placement is.claude/CLAUDE.md inside the project root. This is useful when you want to keep the repository root clean or when your team’s convention reserves the root directory.
.claude/rules/*.md
You can split instructions into multiple focused files in.claude/rules/. All .md files in this directory (and its subdirectories) are loaded as project memory. This is useful for organizing rules by topic:
paths frontmatter field to make them conditional — they are only injected when Claude is working on files matching the glob pattern:
User memory (~/.claude/CLAUDE.md)
Your user memory file applies to every project on your machine. Use it for personal preferences:The /memory command
Use/memory to open an interactive file selector that lets you choose which memory file to view or edit:
$EDITOR (or $VISUAL). The file is created if it does not yet exist.
After you save and close the editor, Claude Code refreshes its in-memory cache so the changes take effect immediately in the current session.
@include directives
Memory files can include other files using@ notation:
@./relative/path— relative to the including file@~/home/path— relative to your home directory@/absolute/path— absolute path
HTML comment stripping
Block-level HTML comments (<!-- ... -->) in memory files are stripped before the content is injected into the context. You can use this to add authorial notes visible when editing the file but invisible to Claude:
Memory and context
All loaded memory files are concatenated and prepended to Claude’s system prompt with the instruction:Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.The label next to each file’s content tells Claude where it came from:
(project instructions, checked into the codebase)— Project type(user's private project instructions, not checked in)— Local type(user's private global instructions for all projects)— User type
Excluding memory files
You can exclude specific memory files from being loaded using theclaudeMdExcludes setting. This accepts glob patterns:
Team memory (AutoMem)
When the auto-memory feature is enabled, Claude Code maintains a~/.claude/MEMORY.md file that it updates automatically as you work. This file stores facts Claude has learned about your preferences and workflows that are worth remembering across sessions.
The AutoMem file is truncated to a line and byte cap before injection to stay within context limits.