全部文章

Claude Code memory: keep context between sessions (CLAUDE.md and MCP)

CLAUDE.md and auto memory keep a repository's context on your machine. To find it elsewhere, and in your other AIs, you need an MCP server.

发布于 2026年10月30日 · 7 min read

Updated 30 October 2026. Facts and commands taken from the official Claude Code documentation, read on 30 October 2026.

Every Claude Code session starts with an empty context window. Two built-in mechanisms carry knowledge from one session to the next: CLAUDE.md files, which you write, and auto memory, notes Claude writes itself. Both stay on your machine. To get the same context on another computer, or in Claude, ChatGPT and Cursor, add an MCP memory server: claude mcp add --transport http --scope user …, then /mcp to sign in.

What Claude Code already remembers

  • CLAUDE.md: instructions you write. ~/.claude/CLAUDE.md applies to all your projects; a CLAUDE.md at the repository root applies to that project and can be shared with your team.
  • Auto memory: notes Claude writes from your corrections and preferences, stored per repository in ~/.claude/projects/<project>/memory/. It is on by default in local sessions.
  • /memory: the command lists your CLAUDE.md files, opens the auto memory folder and lets you turn auto memory on or off.

Per Anthropic's documentation, both are loaded at the start of every session, and the project-root CLAUDE.md is re-read after /compact. An instruction given only in conversation, on the other hand, can be lost at compaction: if it should last, it belongs in CLAUDE.md.

Where it stops

  • One machine. The docs say so: auto memory is machine-local, and its files are not shared across machines or cloud environments.
  • One tool. What Claude Code learned about your project doesn't exist for Claude on the web, ChatGPT or Cursor.
  • One repository at a time. Auto memory is stored per git repository: a decision made in one project is unknown in another, unless you write it in ~/.claude/CLAUDE.md.

If you work on one machine, with Claude Code only, CLAUDE.md and auto memory are enough. An external memory only helps if one of these three limits gets in your way.

Add a shared MCP memory

An MCP (Model Context Protocol) memory server keeps your decisions, solved bugs and preferences off the machine, and makes them available to every AI that connects to it. The example below uses Pryzm Memory, a memory hosted in the EU; the command is the same for any remote MCP server.

  1. Add the server for all your projects with the command below. Without --scope user, it would only be added for the current folder: the default scope is “local”.
  2. Start Claude Code in any folder.
  3. Sign in. Nothing opens after the add: type /mcp, pick pryzm, then Authenticate. Your browser opens the Pryzm page: enter your Pryzm username (not your email) and password.
  4. Check. /mcp shows pryzm as connected, with its tools. Outside a session, claude mcp list lists the server; before you sign in, its status says it needs authentication.
  5. Add the instruction. Paste the “main memory” instructions into ~/.claude/CLAUDE.md, so Claude Code checks the memory and saves what matters in all your projects.
  6. Test: “Check Pryzm for what we decided on this project.”
Terminal
claude mcp add --transport http --scope user pryzm https://pryzm-memory.com/mcp

The ready-to-paste instructions are on the connection page. Scope and sign-in options are described in Claude Code's MCP documentation.

Over SSH or in a container

The OAuth sign-in returns to the machine running Claude Code. Without a browser there, use the variant Anthropic provides: Claude Code prints the authorization URL, you open it in your own computer's browser, then paste the redirect URL back into the terminal.

Terminal
claude mcp login pryzm --no-browser

As a team

The --scope project scope writes the configuration to a .mcp.json file at the repository root, to commit: every developer who opens the project sees the server, approves it on first use, then signs in with their own account through /mcp. Memories stay with each account.

CLAUDE.md, auto memory or MCP: who does what

  • CLAUDE.md for stable rules: code conventions, build commands, what must never be done.
  • Auto memory for what Claude learns while working on this repository, on this machine.
  • MCP memory for what should follow you everywhere: decisions and their reasons, client context, preferences, and anything you also tell Claude, ChatGPT or Cursor.

If something doesn't work

  • Pryzm missing in another folder: it was added without --scope user. Remove it with claude mcp remove pryzm, then run the command again.
  • “Needs authentication” status: you haven't signed in yet, or the sign-in expired. Run /mcp → Authenticate again, or claude mcp login pryzm.
  • “Incorrect username or password”: use your Pryzm username, not your email. On the free plan, the account's email must be confirmed.
  • Claude Code saves nothing: check the instruction in ~/.claude/CLAUDE.md, or ask: “save this to Pryzm”.

One limit to know: at Pryzm, each account is encrypted with its own key (AES-256-GCM), with servers in Germany, but during a session the server decrypts your memories in memory so it can search them. It is not end-to-end encryption: don't put API keys or passwords in it (the server refuses them anyway). See what to store in an AI memory.

For Claude on the web and the desktop app, see the custom connector guide; for Cursor, the Cursor guide.

Frequently asked questions

Does Claude Code remember previous sessions?

Partly. Every session loads your CLAUDE.md files and its auto memory, notes stored per repository on your machine. The rest of the previous conversation is not carried over.

Where is Claude Code's auto memory stored?

In ~/.claude/projects/<project>/memory/, on your machine. Per Anthropic's documentation, it is not shared across machines or cloud environments.

Why add --scope user?

Without it, the MCP server is only added for the folder where you run the command (the default “local” scope). With --scope user, it is available in all your projects.

Should a window open after claude mcp add?

No. You sign in afterwards, with /mcp → Authenticate in a session, or with claude mcp login pryzm from the terminal.