# How Claude Code remembers across sessions

> Source: https://minniai.com/learn/claude-code-memory-across-sessions (canonical HTML page)

[Guides](https://minniai.com/learn)


Every Claude Code session starts with an empty context window; the conversation itself does not carry over. Two things do: the CLAUDE.md files you write (with the files they import) and auto memory, the notes Claude writes for itself in a folder per repository. Both load at the start of every session, so the more they hold, the more every turn costs.

Updated 2026-11-16

## What carries over and what does not

|  | Carries over? | Who writes it | When it loads |
| --- | --- | --- | --- |
| The conversation | No. A new session starts empty. `/resume` reopens an old one, which is a different thing from memory. | You and Claude | Only while the session runs |
| CLAUDE.md files | Yes | You | At launch, every session |
| Files a CLAUDE.md imports with `@path` | Yes | You | At launch, with the file that imports them |
| `.claude/rules/*.md` | Yes | You | At launch; a rule with a `paths` field loads when Claude touches a matching file |
| Auto memory | Yes | Claude | At launch: the start of `MEMORY.md`; topic files when Claude opens them |
| A CLAUDE.md in a subfolder | Yes | You | On demand, once Claude works in that subfolder |

Source: [Anthropic’s memory docs](https://code.claude.com/docs/en/memory). Claude treats all of it as context, not as enforced rules: an instruction it must never skip belongs in a hook, not a memory file.

## CLAUDE.md: the memory you write

CLAUDE.md files load in a fixed order, broadest first, so a project instruction lands after a user instruction:

- **Managed policy**, set by an organization: `/Library/Application Support/ClaudeCode/CLAUDE.md` on macOS, `/etc/claude-code/CLAUDE.md` on Linux, `C:\Program Files\ClaudeCode\CLAUDE.md` on Windows.
- **Your user file**, `~/.claude/CLAUDE.md`: loads in every project.
- **The project file**, `./CLAUDE.md` or `./.claude/CLAUDE.md`, shared through git. A repository can use `AGENTS.md` in its place.
- **`./CLAUDE.local.md`**: your own notes for one project, kept out of git.

A line like `@docs/testing.md` imports that file at launch, and an imported file can import more, up to four hops deep. An import is never on demand: it loads every session, with the file that names it. A path in backticks stays text and is not imported.

To see what loaded, run `/context all` and read the list under Memory files. `/memory` opens the files for editing.

## Auto memory: the memory Claude writes

As it works, Claude saves notes for itself: your role and preferences, corrections you gave it, project decisions it cannot read from the code, and pointers to things outside the repo. It skips what the code already says and what your CLAUDE.md already covers.

The notes live in one folder per repository, `~/.claude/projects/<project>/memory/`, with `MEMORY.md` as the index and one topic file per note. All worktrees and subfolders of a repository share that folder; it is machine-local and never shared across machines. The start of `MEMORY.md` loads in every session; the topic files are read when a task needs them.

Auto memory is on by default in a local session. `/memory` has a toggle, which writes `autoMemoryEnabled` to `~/.claude/settings.json`; a project can set it to `false` in its own settings, and `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` turns it off everywhere. `autoMemoryDirectory` in settings moves the folder.

The paths, with what MinniMemoryMCP adds beside them, are listed in [Where Claude Code keeps its memory](https://minniai.com/learn/claude-code-memory-directory).

## Why memory that carries over costs tokens

Everything in the first two rows of the table above is sent with every turn, not once per session: each turn re-sends the whole conversation, and the memory files are at the front of it. A CLAUDE.md that grew from twenty lines to four hundred, plus three imported files, is paid for on every turn of every session, whether or not the task touches it.

The fix is the same one Anthropic’s own docs describe for large projects: keep in the always-loaded part only what every turn needs, and move the rest to files that load on demand. [MinniMemoryMCP](https://minniai.com/minnimemorymcp) makes that split and keeps it current: a small AlwaysOnMemory part plus OnDemandMemory files, every line kept, `undo` to go back.

install it for Claude Code

```
$ npm i -g minnimemory
$ minnimemory install
```

With MinniMemoryMCP 1.6.0 on our test memory, the agent went looking in its memory 17 times instead of 89 over the same 87 answers, and the run used 47.2% fewer tokens.

How the split is made, by hand or with the tool, is in [Claude Code memory: CLAUDE.md vs MinniMemoryMCP](https://minniai.com/learn/claude-code-memory-claude-md-vs-minnimemorymcp). What a session costs turn by turn is in [Why Claude Code sessions get expensive](https://minniai.com/learn/why-claude-code-sessions-get-expensive).

Try MinniMemoryMCP

Free, runs on your computer, and every change can be undone. Two commands install it for Claude Code; the [docs](https://minniai.com/minnimemorymcp/docs) cover Codex and the rest.

install it for Claude Code

```
$ npm i -g minnimemory
$ minnimemory install
```

## More guides

- [How to reduce Claude Code token usage](https://minniai.com/learn/reduce-claude-code-token-usage) Where the tokens go each turn, and eight ways to spend fewer.

Updated 2026-11-16 · Minni AI

- [Claude Code usage limit reached: what to do, and how to hit it less](https://minniai.com/learn/claude-code-usage-limit-reached) What each limit message means, what to do now, and how to send less every turn.

Updated 2026-11-16 · Minni AI

- [CLAUDE.md too long: what Claude Code does with it, and how to split it](https://minniai.com/learn/claude-md-too-long) What a long CLAUDE.md costs, the real size limits, and four ways to cut it.

Updated 2026-11-16 · Minni AI

- [Claude Code context window keeps filling up: why it compacts, and what to do](https://minniai.com/learn/claude-code-context-window-full) What fills the window, what compaction keeps, and how to compact less often.

Updated 2026-11-16 · Minni AI

- [How to reduce Codex token usage](https://minniai.com/learn/reduce-codex-token-usage) Where Codex spends tokens, and seven ways to spend fewer.

Updated 2026-11-16 · Minni AI

- [Codex usage limits: why they drain and how to use fewer tokens](https://minniai.com/learn/codex-usage-limits) How the windows work, how to check what is left, and what uses the allowance up.

Updated 2026-11-11 · Minni AI

- [AGENTS.md too large: what Codex cuts off and how to split it](https://minniai.com/learn/agents-md-too-large) The 32 KiB cap, how to see which files load, and five ways back under it.

Updated 2026-11-11 · Minni AI

- [How to lower a Claude Code or Codex API bill](https://minniai.com/learn/lower-claude-code-codex-api-bill) What a coding agent bills on an API key, and the levers that move it.

Updated 2026-11-16 · Minni AI

- [Why Claude Code sessions get expensive](https://minniai.com/learn/why-claude-code-sessions-get-expensive) Every turn re-sends the whole session. What makes that grow.

Updated 2026-11-05 · Minni AI

- [Claude Code memory: CLAUDE.md vs MinniMemoryMCP](https://minniai.com/learn/claude-code-memory-claude-md-vs-minnimemorymcp) What belongs in CLAUDE.md, and splitting the rest out by hand or with a tool.

Updated 2026-11-16 · Minni AI

- [MinniMemoryMCP vs Mem0, Zep, supermemory and Letta](https://minniai.com/learn/minnimemorymcp-vs-mem0-zep-supermemory-letta) Four tools add memory to an agent. MinniMemoryMCP cuts what the agent already loads. When each fits.

Updated 2026-11-16 · Minni AI

- [Where Claude Code keeps its memory](https://minniai.com/learn/claude-code-memory-directory) Every memory path on your machine, what each file is for, and which ones load every turn.

Updated 2026-11-07 · Minni AI

- [How to run a coding agent on free, open models](https://minniai.com/learn/run-a-coding-agent-on-free-open-models) What a free key gets you, what a local model can do, and where the tokens go.

Updated 2026-10-25 · Minni AI

- [Get a free NVIDIA API key for a coding agent](https://minniai.com/learn/free-nvidia-api-key-for-a-coding-agent) Where the key comes from, where to keep it, and how to run a coding agent on it.

Updated 2026-11-07 · Minni AI

- [What a Windows PC optimization agent should and should not touch](https://minniai.com/learn/what-a-pc-optimization-agent-should-touch) The settings worth changing, the ones that are placebo, and the ones that break things.

Updated 2026-10-25 · Minni AI

---

Index for agents: https://minniai.com/llms.txt. Doing a task: https://minniai.com/agents.md
