Memory System
Claude Code does not remember the conversation once a session ends. But there are six memory layers that compensate for this. Use this system well and you keep a consistent AI partner without the hassle of explaining everything from scratch each time.
Memory Layer Hierarchyโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Managed policy (system path/CLAUDE.md) โ
โ โ Enforced org-wide, managed by IT/DevOps, top priority โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ User memory (~/.claude/CLAUDE.md, ~/.claude/rules/) โ
โ โ Personal global settings, applies to all projects โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Project memory (./CLAUDE.md, .claude/CLAUDE.md) โ
โ โ Shared with the whole team, committed to git, permanent โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Project rules (.claude/rules/*.md) โ
โ โ Modular per-topic rules, conditional per-path application โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Local memory (./CLAUDE.local.md) โ
โ โ Personal, per-project, not tracked by git โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Auto memory (~/.claude/projects/<project>/memory/) โ
โ โ Saved automatically by Claude, per-project learnings โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
All memory is loaded automatically at session start. More specific (narrower-scoped) instructions take precedence over broader ones.
1. Managed Policy (Enterprise)โ
A CLAUDE.md deployed at the system level by an organization administrator. It is enforced for all users and cannot be overridden by any setting.
| OS | Path |
|---|---|
| macOS | /Library/Application Support/ClaudeCode/CLAUDE.md |
| Linux | /etc/claude-code/CLAUDE.md |
| Windows | C:\Program Files\ClaudeCode\CLAUDE.md |
Deploy it with configuration management systems such as MDM, Group Policy, or Ansible.
2. User Memoryโ
Location: ~/.claude/CLAUDE.md (Windows: C:\Users\{name}\.claude\CLAUDE.md)
Lifetime: permanent
Scope: all of my projects
What to Store in User Memoryโ
# Personal Settings
## Coding Style Preferences
- Prefer functional programming
- Dislike short variable names (avoid things like i, j, k)
- Comments should focus on "why" (the "what" belongs in the code)
## Communication Style
- Always explain the plan before changing code
- Don't change too much at once โ work incrementally
## Frequently Used Technologies
- Mostly use Next.js, TypeScript, Prisma
- Prefer Vitest for testing
- Tailwind CSS for styling
User-Level Rulesโ
Create personal rule files in ~/.claude/rules/ and they apply to all your projects:
~/.claude/rules/
โโโ preferences.md # Personal coding preferences
โโโ workflows.md # Preferred workflows
Initial Global Memory Setupโ
If you just installed Claude Code, start by creating the global CLAUDE.md:
mkdir -p ~/.claude
claude
> Interview me about my coding style and preferences. Save the results to ~/.claude/CLAUDE.md.
Claude Code asks a few questions and creates your global settings.
3. Project Memory: CLAUDE.mdโ
Location: {project root}/CLAUDE.md or .claude/CLAUDE.md
Lifetime: permanent (committed to git)
Scope: every team member on the project
Covered in depth in the Writing CLAUDE.md chapter.
What to Store in Project Memoryโ
# My Project
## Tech Stack
[Permanent tech stack information]
## Team Conventions
[Rules the whole team must share]
## Architecture Decision Records (ADR)
[Important technical decisions and their rationale]
## Build/Test Commands
[Frequently used commands โ avoids repeated lookups]
The /init command can automatically generate a CLAUDE.md tailored to your current project.
4. Project Rules: .claude/rules/โ
In large projects, manage modular rule files instead of a single CLAUDE.md.
.claude/rules/
โโโ code-style.md # Code style
โโโ testing.md # Testing rules
โโโ frontend/
โ โโโ react.md # React conventions
โ โโโ styles.md # Style guide
โโโ backend/
โโโ api.md # API rules
The paths field in the YAML frontmatter enables conditional rules that apply only to specific files:
---
paths:
- "src/api/**/*.ts"
---
# API Development Rules
- Include input validation on every endpoint
- Use the standard error response format
See the Writing CLAUDE.md โ .claude/rules/ section for details.
5. Local Memory: CLAUDE.local.mdโ
Location: {project root}/CLAUDE.local.md
Lifetime: permanent (local only)
Scope: just me, just this project
It is automatically added to .gitignore, so you can safely store personal information. Useful for testing instructions before sharing them with the team, or for machine-specific settings.
6. Auto Memory: Claude's Automatic Memoryโ
Auto Memory is a feature where Claude automatically saves learnings, patterns, and insights it discovers while working. Unlike CLAUDE.md, it isn't something you write โ it's notes Claude keeps for itself.
Auto Memory is enabled by default. You can toggle it on and off with the /memory command.
What Claude Remembersโ
- Project patterns: build commands, testing conventions, code style
- Debugging insights: solutions to tricky problems, common error causes
- Architecture notes: key files, module relationships, important abstractions
- User preferences: communication style, workflow habits, tool choices
Auto Memory File Structureโ
Each project has its own memory directory:
~/.claude/projects/<project>/memory/
โโโ MEMORY.md # Concise index (auto-loaded every session)
โโโ debugging.md # Detailed debugging pattern notes
โโโ api-conventions.md # API design decisions
โโโ ... # Created by Claude as needed
The <project> path is derived from the git repository root. All worktrees and subdirectories of the same git repository share a single Auto Memory directory.
The 200-Line Limit of MEMORY.mdโ
Only the first 200 lines of MEMORY.md are auto-loaded at session start. Content beyond 200 lines is not loaded. Claude automatically splits detailed notes into separate topic files (e.g., debugging.md, patterns.md) to keep MEMORY.md concise.
Topic files are not loaded at session start; Claude reads them directly when needed.
Managing Auto Memoryโ
/memory # Open memory files + toggle
You can also tell Claude directly what to remember:
> Remember that this project uses pnpm
> Save to memory that API tests need a local Redis
Disabling Auto Memoryโ
// ~/.claude/settings.json (disable globally)
{ "autoMemoryEnabled": false }
// .claude/settings.json (disable per project)
{ "autoMemoryEnabled": false }
An environment variable overrides all settings (useful in CI/managed environments):
export CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 # Force disable
export CLAUDE_CODE_DISABLE_AUTO_MEMORY=0 # Force enable
Auto-dream: Automatic Memory Cleanup (Unofficial, Undocumented)โ
Auto-dream is a feature not listed in Anthropic's official documentation (code.claude.com/docs/en/memory, /settings, or the /changelog up to v2.1.117). Anthropic's release plans and rollout policy are unannounced โ this chapter is a synthesis of external user reports and GitHub Issues.
Observed exposure change (verified firsthand):
| When | Environment | /memory toggle |
|---|---|---|
| About a month ago (around v2.1.81) | macOS | โ Showed "Auto-dream: on ยท never ยท /dream to run" |
| Now (v2.1.117) | Windows | โ Only "Auto-memory: on" shown; Auto-dream toggle gone |
The changelog contains no withdrawal or deprecation notice. The settings.json autoDreamEnabled key remains, but whether it works is unknown. It is safest to assume the toggle is generally not visible in your audience's environments.
If Auto Memory stores learnings, Auto-dream is a background task that organizes the accumulated memory. It automatically deduplicates, merges related content, and consolidates stale information.
Currently verified status:
| Item | Status |
|---|---|
| Background memory cleanup behavior | โ Confirmed working (multiple user reports) |
autoDreamEnabled: true key in ~/.claude/settings.json | โ Recognized in some environments |
"AutoDream" toggle exposed in the /memory menu | โ ๏ธ Varies by user (Anthropic's exposure criteria unpublished) |
dreaming indicator in the status bar | โ Not implemented; bug reported (Issue #38461) |
Manual trigger /dream command | โ Returns "Unknown skill" โ not implemented (Issue #38426) |
How to try enabling it:
- Run
/memoryโ if the "AutoDream" toggle is visible, turn it on - If the toggle isn't visible, add it directly to
~/.claude/settings.json:{ "autoDreamEnabled": true } - In some environments this setting alone may not work (Anthropic's activation conditions are unpublished)
Mechanism (synthesized from external reports โ no official confirmation):
- The system prompt reportedly includes the phrase
"You are performing a dream โ a reflective pass over your memory files"(source: Sakeeb Rahman's Threads analysis) - A background subagent reportedly reviews memory files โ deduplicates โ refreshes โ reorganizes topic files (source: multiple external builder reports)
- Trigger conditions: reported as a dual condition of session count + time (source: Tessl and Skool blogs)
- Duration example: one reported case of about 8-9 minutes to consolidate 913 sessions of memory (source: Antonio Cortes blog post)
All four items above are external user/builder reports with no official confirmation from Anthropic. Behavior may vary by environment and version.
Verified external report sources:
- Multiple reports of the
/memorytoggle appearing in v2.1.83+ environments - Tessl blog: "Anthropic tests 'auto dream'" (framed as a testing phase)
- Around ten pieces of English-language builder content confirmed (Korean-market coverage not surveyed)
Auto-dream is not an officially released feature (not listed anywhere in Anthropic's official docs, news, changelog, or support, as of 2026-04-22). When citing it, always include these three disclaimers:
- "Officially undocumented, gradual rollout in progress"
- "The toggle may not be visible depending on your environment"
- "The manual trigger
/dreamand status bar indicator are currently in a buggy state (GitHub Issues 38461 and 38426)"
Teaching it as a stable feature risks damaging your credibility when it doesn't reproduce in your viewers' or readers' environments.
Session Memory: The Conversation Contextโ
The contents of the current conversation. It disappears when the session ends.
A Pattern for Making Session Memory Permanentโ
Save important decisions or information before the session ends:
> I finished the payment module today.
If there are important decisions, update CLAUDE.md with them.
Claude: I updated CLAUDE.md:
- Refund policy: within 72 hours, direct Stripe API calls
- Webhook secret: STRIPE_WEBHOOK_SECRET environment variable
- Payment failure retries: 3 attempts, exponential backoff
Strategies by Memory Layerโ
Team Projectsโ
Managed policy (IT/DevOps)
โโ Org security policies, coding standards
Project CLAUDE.md (committed to git)
โโ Team conventions, tech stack, architecture
.claude/rules/ (committed to git)
โโ Fine-grained per-topic rules
Personal ~/.claude/CLAUDE.md
โโ Personal coding style, communication style
CLAUDE.local.md
โโ Personal test environment, local settings
Auto Memory
โโ Each person's work patterns, debugging experience
Personal Projectsโ
Project CLAUDE.md
โโ Project status, technical decisions
Personal ~/.claude/CLAUDE.md
โโ Global settings (applies to all projects)
Auto Memory
โโ Project patterns, learnings
Memory Management Tipsโ
Review and Edit with /memoryโ
/memory
The /memory command opens memory files in your system editor and includes the Auto Memory toggle. You can see the full list of loaded memory files.
Update CLAUDE.md Regularlyโ
Update the status whenever a piece of work is done:
> Done for today. Update the status section in CLAUDE.md.
Clean Out Stale Informationโ
Accumulated memory eventually creates confusion:
> Clean up the completed items in CLAUDE.md.
Keep only what's currently in progress.
Loading Memory from Additional Directoriesโ
CLAUDE.md files in directories added with --add-dir are not loaded by default. To load them:
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 claude --add-dir ../shared-config
The Memory System End to Endโ
New session starts
โ
โโ Load managed CLAUDE.md (org policy)
โโ Load ~/.claude/CLAUDE.md + rules/ (user memory)
โโ Load ./CLAUDE.md + .claude/rules/ (project memory)
โโ Load ./CLAUDE.local.md (local memory)
โโ Load first 200 lines of MEMORY.md (auto memory)
โ
โ [Work proceeds]
โ
โ Important decision mid-session
โ โ Record it in CLAUDE.md immediately
โ
โ Claude discovers a pattern
โ โ Saved automatically to Auto Memory
โ
โ /compact (context compression)
โ โ Key summary retained
โ
Session ends
โ
โโ "Update CLAUDE.md with today's work"
โ Saves what the next session needs to continue