# Claude Code memory: CLAUDE.md, auto memory, and where the files live

Two systems: the instructions you write and the notes Claude keeps. Where each file lives, what actually gets loaded, and how a team shares the right half.

Published 2026-10-07 by Richard Kaminsky and Mitchell Lipyansky, the co-founders of Poly. Canonical: https://usepoly.co/claude-code-memory
Poly is a multiplayer AI coding workspace: a shared room where your team works with one AI agent, together. Free to start: https://usepoly.co/

**Claude Code has two kinds of memory. CLAUDE.md files are instructions you write: one for your organization, one for you (~/.claude/CLAUDE.md), one per project (./CLAUDE.md, shared through git) and a private CLAUDE.local.md, all loaded at the start of every session. Auto memory is notes Claude writes itself, since February 2026, in ~/.claude/projects/<project>/memory/MEMORY.md, of which the first 200 lines or 25KB load each session. Type /memory to see and edit every file or switch auto memory off. Both stay on your machine; only the files you commit to the repository are shared with your team.**

## Key takeaways

- **CLAUDE.md:** you write it; Claude reads it every session. Keep each file under 200 lines, Anthropic says.
- **Auto memory:** Claude decides what's worth remembering, by project, and it never leaves your machine.
- **Rules:** `.claude/rules/*.md`, optionally scoped to paths so they load only when Claude touches matching files.
- **`/memory`** opens any memory file in your editor and turns auto memory on or off; the old `#` shortcut is gone.
- **"Memory leak"** searches are mostly about RAM: Anthropic has fixed dozens of process memory leaks this year.

*Claude Code's memory files, from Anthropic's docs, October 7, 2026.*

| File | Who writes it | Shared with the team | When it loads |
| --- | --- | --- | --- |
| Managed CLAUDE.md | Your organization | Everyone | Every session |
| ~/.claude/CLAUDE.md | You | No | Every session |
| ./CLAUDE.md | You and your team | Yes, through git | Every session |
| ./CLAUDE.local.md | You | No (gitignored) | Every session |
| .claude/rules/*.md | You and your team | Yes, through git | At start, or when matching files are touched |
| Auto memory (MEMORY.md) | Claude | No, this machine only | First 200 lines or 25KB each session |

## Where are Claude Code's memory files?

From Anthropic's memory guide, in the order they load, broadest first ([Anthropic](https://code.claude.com/docs/en/memory)):

- **Managed policy,** set by your organization: `/Library/Application Support/ClaudeCode/CLAUDE.md` on macOS, `/etc/claude-code/CLAUDE.md` on Linux, `C:\Program Files\ClaudeCode\CLAUDE.md` on Windows.
- **User:** `~/.claude/CLAUDE.md` and `~/.claude/rules/`, for all your projects.
- **Project:** `./CLAUDE.md` or `./.claude/CLAUDE.md`, plus `.claude/rules/`, committed so the team shares them.
- **Local:** `./CLAUDE.local.md`, your own notes for this project; add it to `.gitignore`.
- **Auto memory:** `~/.claude/projects/<project>/memory/MEMORY.md` and topic files beside it.

The files are combined, not overridden. Claude Code also reads AGENTS.md when a folder has no CLAUDE.md ([CLAUDE.md vs AGENTS.md](/claude-md-vs-agents-md)), and a file can pull in another with `@path`, up to four levels deep.

## What is auto memory in Claude Code?

Notes Claude writes for itself, added in v2.1.59 on February 26, 2026. It saves what "would be useful in a future conversation" (your preferences, corrections you've made, project context and pointers to outside resources) and skips anything it can read from the code or that CLAUDE.md already says.

- **Where:** one folder per repository, shared across its worktrees, in `~/.claude/projects/`.
- **What loads:** the first 200 lines or 25KB of MEMORY.md, whichever comes first; other topic files are read when needed.
- **Turn it off:** the toggle in `/memory`, `autoMemoryEnabled: false` in settings, or `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1`.
- **Private:** "Files are not shared across machines or cloud environments."

To make Claude remember something, say "remember that…" and it goes to auto memory; say "add this to CLAUDE.md" and it edits the instructions file.

## How do you edit Claude Code's memory?

Type `/memory`. It lists every CLAUDE.md, CLAUDE.local.md and memory file Claude Code found, opens the one you pick in your editor, and has the auto memory switch ([Anthropic](https://code.claude.com/docs/en/commands)). `/context` shows which ones actually loaded. The `#` quick-add shortcut was removed in December 2025; ask Claude to edit the file instead. `/init` writes a first CLAUDE.md for a project, and `/doctor prompt-audit` checks your instruction files for stale or conflicting lines.

## How long should CLAUDE.md be?

Anthropic's guidance is to "target under 200 lines per CLAUDE.md file"; longer files use more context and "reduce adherence" ([Anthropic](https://code.claude.com/docs/en/memory)). Its best-practices guide is blunter: for each line, ask whether removing it would cause Claude to make mistakes, because "bloated CLAUDE.md files cause Claude to ignore your actual instructions" ([Anthropic](https://code.claude.com/docs/en/best-practices)). Everything in CLAUDE.md is in context for every request, related or not, so move long workflows into skills ([Claude Code skills](/claude-code-skills)) and rules that must hold into hooks ([Claude Code hooks](/claude-code-hooks)).

## Rules and nested CLAUDE.md files

- **Rules** in `.claude/rules/` load at the start unless they have a `paths:` list in their frontmatter; then they load only when Claude reads or edits a matching file.
- **CLAUDE.md in a subfolder** loads when Claude works on a file in that folder.

After the conversation is compacted, the project's root CLAUDE.md, unscoped rules and auto memory are read again from disk; path-scoped rules and subfolder files come back only when triggered again ([Claude Code context window](/claude-code-context-window)).

## Is Claude Code's memory the same as Claude's chat memory?

No. Memory in the Claude app (on by default on Free, Pro and Max) is a separate system ([Anthropic](https://support.claude.com/en/articles/11817273-use-claude-s-chat-search-and-memory-to-build-on-previous-context)), and Anthropic's docs don't say Claude Code reads it. Skills enabled on your claude.ai account do sync into Claude Code.

## What about the "Claude Code memory leak"?

Usually that's about RAM, not your data. Anthropic logged an incident on January 31, 2026 for memory leaks in version 2.1.27, fixed in 2.1.29 ([Anthropic](https://status.claude.com/incidents/rl6pphjrc2r4)), and its changelog lists many more leak fixes since, the latest on October 7. Claude Code now warns when a session uses more than 2.5GB. If it slows down: run `/compact`, restart between tasks (`claude --continue` picks up where you left off), and try `claude --safe-mode` to rule out plugins, MCP servers and hooks ([Anthropic](https://code.claude.com/docs/en/troubleshooting)).

## How does Codex remember things?

- **AGENTS.md:** a global `~/.codex/AGENTS.md`, then one per folder from the repository root down, up to 32 KiB combined ([OpenAI](https://learn.chatgpt.com/docs/agent-configuration/agents-md)).
- **Memories:** off by default; turn them on with `memories = true` under `[features]`, and they're stored in `~/.codex/memories/` ([OpenAI](https://learn.chatgpt.com/docs/customization/memories)).
- **Moving over:** Codex's `/import` brings in project memories from Claude Code.

## Sharing memory with a team

- **Shared:** the project's CLAUDE.md and `.claude/rules/`, through git; a managed CLAUDE.md for the whole organization.
- **Personal:** CLAUDE.local.md, your user files and auto memory, which stays on your machine.

So what one teammate's Claude learns stays with that teammate. In Poly (usepoly.co), a team works with one Claude Code or Codex agent in a shared browser room, using the repository's CLAUDE.md, so everyone's prompts reach the same agent with the same instructions, and any member can approve a change before it happens. Free to start. [What is Poly?](/what-is-poly)

## Common questions

**Where does Claude Code store memory?**

Instructions you write live in CLAUDE.md files: ~/.claude/CLAUDE.md for you, ./CLAUDE.md in the project, and CLAUDE.local.md for private notes. Auto memory, which Claude writes, lives in ~/.claude/projects/<project>/memory/MEMORY.md.

**What is auto memory in Claude Code?**

Notes Claude saves for itself about your preferences, corrections and project context, added in February 2026. The first 200 lines or 25KB of MEMORY.md load each session, and you can switch it off with /memory.

**How do I add something to Claude Code's memory?**

Tell Claude to remember it, and it goes to auto memory, or ask it to add the line to CLAUDE.md. /memory opens any memory file in your editor. The old # shortcut was removed in December 2025.

**How long should a CLAUDE.md file be?**

Anthropic recommends under 200 lines per file. Longer files use more context and Claude follows them less reliably; move long workflows into skills and must-follow rules into hooks.

**Is there a memory leak in Claude Code?**

Claude Code has had several RAM memory leaks, including one Anthropic logged in January 2026, and they are fixed in regular updates. Update with claude update, use /compact, and restart between long tasks.

More guides: https://usepoly.co/guides · Security: https://usepoly.co/security · Pricing: https://usepoly.co/pricing
