
Claude Code Memory: CLAUDE.md, Auto Memory & Persistent Memory

Claude Code memory is the set of mechanisms that carry knowledge from one claude session into the next. Every session starts with an empty context window, so anything Claude should know on Monday that it learned on Friday has to be written somewhere on disk: a CLAUDE.md or AGENTS.md file you maintain, a path-scoped rule under .claude/rules/, or the Auto Memory notes Claude writes for itself. This guide answers the questions engineers actually search for, where the files live, what loads when, what the /memory command does, and where the built-in surface stops, then shows how to add persistent, cross-project agent memory through an MCP memory server. Every path, setting and limit below is taken from Anthropic's Claude Code memory documentation as of October 2026.
Does Claude Code retain memory between sessions?
Yes, but only through files on disk. Each session opens with a fresh context window; nothing from the previous conversation carries over by itself. Two mechanisms persist: CLAUDE.md files (or AGENTS.md) that you write, and Auto Memory, where Claude saves preferences and corrections under ~/.claude/projects/<project>/memory/. Both are read at the start of every session.
The distinction that matters is who writes what. CLAUDE.md is authored by you and holds instructions: build commands, conventions, architecture notes, "always do X" rules. Auto Memory is authored by Claude and holds learnings: your role, corrections you gave, project decisions it cannot derive from the code, and pointers to external references. According to Anthropic, Claude skips anything it can infer from the codebase and anything CLAUDE.md already says, and it does not save something every session.
Two things that look like memory are not. The conversation transcript is stored (Claude Code keeps .jsonl transcripts under ~/.claude/projects/ and deletes them after the cleanupPeriodDays retention window), and --continue / --resume reload a transcript, but that is resuming a session, not remembering across sessions. And context compaction, which summarizes the conversation when the window fills, is lossy: the project-root CLAUDE.md is re-read from disk after /compact, but any decision that lived only in chat is reduced to whatever the summary kept.
How does Claude Code check memory at session start?
At launch Claude Code walks from your working directory up to the filesystem root, collecting every CLAUDE.md and CLAUDE.local.md it finds, then loads ~/.claude/CLAUDE.md, rules in ~/.claude/rules/ and .claude/rules/, and the first 200 lines (or 25 KB) of Auto Memory's MEMORY.md. Run /context to see which files loaded and /memory to browse them.
The resolution order, from broadest to most specific, is:
- Managed policy
CLAUDE.mddeployed by IT (see paths below), or theclaudeMdkey inmanaged-settings.json. - User instructions at
~/.claude/CLAUDE.md, plus user-level rules in~/.claude/rules/. - Project instructions:
CLAUDE.md,.claude/CLAUDE.mdandCLAUDE.local.mdfrom the root of the filesystem down to your working directory. Content is concatenated, not overridden, and files closer to where you launched Claude are read last. Within a directory,CLAUDE.local.mdis appended afterCLAUDE.md. - Project rules in
.claude/rules/that have nopathsfrontmatter; they load with the same priority as.claude/CLAUDE.md. - Auto Memory index
MEMORY.md, loaded up to its 200-line / 25 KB threshold.
Two kinds of files are deliberately not loaded at launch. CLAUDE.md files in subdirectories below your working directory load on demand, the first time Claude reads, writes or edits a file in that subdirectory. Rules with paths frontmatter load when Claude touches a matching file. Both are lazy so a monorepo does not pay for every team's instructions on every session.
Inside each file, @path/to/file imports are expanded at load time, up to four hops deep, and imported files count against context exactly like the file that imported them. Block-level HTML comments are stripped before injection, so you can leave notes for human maintainers at zero token cost.
If there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md anywhere on the path, Claude Code (v2.1.277 and later) reads AGENTS.md instead and prints a line such as no CLAUDE.md found; AGENTS.md loaded: /home/you/repo/AGENTS.md. The precedence rules are covered in the AGENTS.md section below.
For debugging, the InstructionsLoaded hook fires every time an instruction file enters context and reports file_path, memory_type (User, Project, Local, Managed) and load_reason (session_start, nested_traversal, path_glob_match, include, compact). It is the fastest way to find out why a path-scoped rule did or did not load.
Where does Claude Code write its memory?
Claude Code writes Auto Memory to ~/.claude/projects/<project>/memory/, with MEMORY.md as the index and one topic file per memory. Instruction files are written by you: ./CLAUDE.md or ./.claude/CLAUDE.md (project), ./CLAUDE.local.md (gitignored personal), ~/.claude/CLAUDE.md (all your projects), .claude/rules/*.md (modular rules), and a managed CLAUDE.md for organization-wide policy.
| Scope | Path | Written by | Shared with |
|---|---|---|---|
| Managed policy | macOS /Library/Application Support/ClaudeCode/CLAUDE.md; Linux/WSL /etc/claude-code/CLAUDE.md; Windows C:\Program Files\ClaudeCode\CLAUDE.md | IT / DevOps | Everyone on the machine |
| User | ~/.claude/CLAUDE.md, ~/.claude/rules/*.md | You | All your projects, this machine |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md, ./.claude/rules/**/*.md, ./AGENTS.md | Team, via git | Everyone who clones the repo |
| Local | ./CLAUDE.local.md | You | This checkout only (add to .gitignore) |
| Auto Memory | ~/.claude/projects/<project>/memory/MEMORY.md + topic files | Claude | This machine, all worktrees of the repo |
Three details about these paths matter in practice.
The <project> segment is derived from the git repository, so every worktree and subdirectory of the same repo shares one Auto Memory directory. Outside a git repo, the project root path is used. If you set CLAUDE_CODE_PROJECT_DIR_NAME together with CLAUDE_CONFIG_DIR, that name replaces the derived segment so several checkouts can share memory. To relocate the directory entirely, set autoMemoryDirectory in any settings.json scope; the value must be absolute or start with ~/.
CLAUDE.local.md is per-checkout, not per-repo. A gitignored local file exists only in the worktree where you created it. To share personal instructions across worktrees, import a home-directory file from the project CLAUDE.md instead: @~/.claude/my-project-instructions.md. The first time a project-level file imports from outside the working directory, Claude Code shows an approval dialog listing the external files.
Auto Memory is excluded from transcript cleanup. Old session transcripts are deleted after cleanupPeriodDays, but MEMORY.md and topic files stay until you or Claude edits or deletes them. They are plain markdown; /memory opens the folder.
CLAUDE.md vs AGENTS.md: which should you use?
AGENTS.md is the cross-vendor instruction file read by Codex, Cursor, Copilot and others. Claude Code reads it natively since v2.1.277, so a repository already set up for other agents works with no CLAUDE.md, import or setting. The default behaviour, according to Anthropic's docs, is:
| Your repository has | Claude reads |
|---|---|
AGENTS.md, and no CLAUDE.md / CLAUDE.local.md in the working directory or above | AGENTS.md (and .claude/AGENTS.md) |
AGENTS.md and a CLAUDE.md or CLAUDE.local.md on the path | CLAUDE.md files only |
A CLAUDE.md that imports @AGENTS.md | CLAUDE.md, with AGENTS.md included once through the import |
Note the trap in row two: adding a personal CLAUDE.local.md to a repo that relies on AGENTS.md silently stops AGENTS.md from loading. Files that do not count toward that check, and keep loading alongside AGENTS.md, are ~/.claude/CLAUDE.md, the managed CLAUDE.md, and .claude/rules/. AGENTS.local.md, AGENTS.override.md and anything under .agents/ are never read.
To change the default, open /config and set Project instructions to one of claude-md-or-agents-md (default), claude-md-and-agents-md (both, each directory's CLAUDE.md first), claude-md, or managed-only. The same value can be set in ~/.claude/settings.json:
The practical recommendation: if you only use Claude Code, write CLAUDE.md. If the repo is shared with other agents, keep AGENTS.md as the single source of truth and either let Claude read it directly or add a two-line CLAUDE.md for Claude-specific additions:
A symlink (ln -s AGENTS.md CLAUDE.md) also works, with two caveats from the docs: Claude's Edit and Write tools refuse to write through a symlink, and on Windows a committed symlink checks out as a one-line text file unless core.symlinks is enabled. Use the import if anyone on the team is on Windows. An AGENTS.md read directly also behaves slightly differently from CLAUDE.md: InstructionsLoaded hooks do not fire for it, and --add-dir directories do not contribute their AGENTS.md.
How to write path-specific rules in .claude/rules/
.claude/rules/ splits a long CLAUDE.md into topic files. Every .md file under the directory is discovered recursively, so rules/frontend/ and rules/backend/ subfolders work. A rule with no frontmatter loads at launch like .claude/CLAUDE.md. A rule with a paths field loads only when Claude uses Read, Write or Edit on a matching file (or views it with cat/head in Bash):
paths is the only frontmatter key Claude Code reads from a rule; other keys are ignored without error, and if the YAML fails to parse the rule loads unconditionally (run claude --debug to see the parse error). Patterns are globs relative to the directory that contains the rule's .claude folder (for user rules, the session's working directory). Brace expansion is supported, so "src/**/*.{ts,tsx}" matches both extensions; a rule's whole paths list shares a budget of 1,000 expanded patterns.
Rules compose with CLAUDE.md rather than replacing it. CLAUDE.md is for facts every session needs; rules are for instructions that only matter in part of the tree; @path imports are for organizing a long CLAUDE.md without reducing its context cost, because imported files load at launch too. User-level rules in ~/.claude/rules/ apply to every project and load before project rules; neither overrides the other, so a conflicting user rule and project rule leave Claude free to follow either.
Rules can be shared across repositories with symlinks (ln -s ~/shared-claude-rules .claude/rules/shared). A symlink whose target is outside the working directory is treated like an external import: it needs one-time approval, and after approval only rules without paths load from it. To skip another team's rules in a monorepo, add glob patterns to claudeMdExcludes in .claude/settings.local.json.
What is Auto Memory and MEMORY.md?
Auto Memory is the memory Claude Code writes without being asked. It is on by default in local sessions and off by default in self-hosted environments. According to Anthropic, Claude records four kinds of notes, tagged with a type field in each memory file's frontmatter:
user: your role, expertise and working preferencesfeedback: corrections you give Claude and approaches you confirmproject: ongoing work, deadlines and decisions not derivable from code or git historyreference: where to find information outside the project, such as an issue tracker
The directory has a fixed shape:
Only MEMORY.md is loaded at session start, and only its first 200 lines or 25 KB, whichever comes first. Content past that threshold is silently dropped on the next load. After each write Claude Code measures the file; near the limit it reminds Claude to shorten it (one line per entry, move detail into topic files, merge or drop stale entries), and over the limit the write succeeds but returns an error telling Claude to rewrite the index. Topic files are never loaded at startup; Claude opens them with its normal file tools when it needs them. When Claude writes a memory file that begins with YAML frontmatter, Claude Code stamps a modified field with an ISO 8601 timestamp, so both you and Claude can see how fresh a fact is.
Auto Memory is machine-local and per-repository. It is not shared across machines, not shared across repositories, and not loaded into subagents (except a fork, which inherits the parent conversation). A subagent can keep its own separate Auto Memory via the memory field in its configuration.
To turn it off: toggle it in /memory (which writes autoMemoryEnabled to ~/.claude/settings.json), set "autoMemoryEnabled": false in a project's settings to disable it for one repo, or export CLAUDE_CODE_DISABLE_AUTO_MEMORY=1. To clear it, delete files in the memory directory; they are plain markdown. When you see "Saved 2 memories" or "Recalled 2 memories" in the interface, Claude is reading or writing this directory.
How to use the /memory and /init commands
/memory is the management view for everything above. It lists your CLAUDE.md, CLAUDE.local.md and other memory file locations across user and project scopes, including entries for files that do not exist yet; selecting one creates and opens it in your editor. It toggles Auto Memory on and off, and it offers to open the Auto Memory folder. Since v2.1.280 it also lists an AGENTS.md that was read directly. GUI editors open in a separate window so the session stays usable; terminal editors take over until you exit. To check which files actually loaded at launch (as opposed to where they could live), run /context and read the list under Memory files.
/init bootstraps a project CLAUDE.md. Claude analyzes the codebase and writes build commands, test instructions and conventions it discovers; if a CLAUDE.md already exists it proposes improvements instead of overwriting. It also reads other tools' instruction files (.cursor/rules/, .cursorrules, .github/copilot-instructions.md) and folds in the relevant parts. With CLAUDE_CODE_NEW_INIT=1 set, /init becomes an interactive flow that asks which artifacts to create (CLAUDE.md files, skills, hooks), explores the repo with a subagent, and shows a reviewable proposal before writing; in that mode it also migrates AGENTS.md, .windsurf/rules/ and .clinerules.
Two related commands round out the set. /doctor prompt-audit (v2.1.283+) scans CLAUDE.md, CLAUDE.local.md, AGENTS.md, rules, skills and subagents for stale or contradictory instructions and proposes edits without applying them. And asking Claude in plain language, "remember that the API tests need a local Redis," writes to Auto Memory, whereas "add this to CLAUDE.md" edits the instruction file.
What does the Claude Code memory skill do?
A Claude Code memory skill is a SKILL.md file, in .claude/skills/<name>/ or shipped by a plugin, that tells Claude how and when to store or retrieve memory, typically by calling an MCP tool or a bundled script. Unlike Auto Memory, which Claude Code runs on its own, a skill loads only when you invoke /<name> or Claude judges it relevant.
Skills are the right container for memory procedures because of how they load. CLAUDE.md content is in context every session; a skill's body costs nothing until it is used. Anthropic's guidance is explicit: when a section of CLAUDE.md has grown into a multi-step procedure rather than a fact, move it to a skill. A memory skill is exactly that kind of procedure: "search the store for X, present the top results with sources, offer to save a follow-up." Skills live at ~/.claude/skills/<name>/SKILL.md (personal), .claude/skills/<name>/SKILL.md (project, committed), or <plugin>/skills/<name>/SKILL.md (plugin, invoked as /plugin-name:skill-name or the bare /skill-name when unambiguous). Skills follow the open Agent Skills standard, so the same SKILL.md can run under other agents that implement it.
This is how the Cognee plugin packages its memory operations. Installing cognee-memory@cognee registers a set of skills alongside the hooks: cognee-remember stores a fact, preference or decision in the knowledge graph tagged as user, project or agent memory; cognee-search runs a deeper graph search than the automatic per-prompt recall, with options for more results, a single category, cited sources or another dataset; cognee-forget finds and deletes matching documents and their graph knowledge; cognee-sync pushes the current session into the permanent graph immediately; and cognee-handoff, cognee-standup, cognee-timeline and cognee-digest produce notes and summaries from recorded sessions. Each is a SKILL.md you can read in the cognee-integrations repository.
The distinction to keep straight: Auto Memory and CLAUDE.md are storage; a memory skill is behaviour. A skill with no backend still has to write to a file somewhere; the value comes from pairing it with a store that supports retrieval, which is what the MCP sections below cover.
What are the limits of Claude Code's built-in memory?
The native surface is well designed for its purpose, per-repository instructions, and stops exactly at that boundary. Four limits show up in day-to-day use.
Retrieval is by position, not relevance. CLAUDE.md and the first 200 lines of MEMORY.md are injected whole. There is no query step: if a fact is on line 201, or in a topic file Claude did not think to open, it is not in context. Anthropic recommends keeping CLAUDE.md under 200 lines and warns that longer files reduce adherence; a file over 4 MiB is skipped entirely. Memory that grows with the project has to be pruned to stay useful.
Scope is one repository on one machine. Auto Memory keys on the git repo and is never synced across machines or cloud environments. CLAUDE.md travels with the repo but says nothing about the other repos a platform team touches. Lessons learned in the API service are invisible when you open the frontend.
Compaction loses conversation state. When the window fills, Claude Code summarizes. Project-root CLAUDE.md is re-read from disk and path-scoped rules reload on demand, but a decision made in chat and never written down survives only if the summary happened to keep it. Anthropic's own troubleshooting entry for "instructions seem lost after /compact" says to add conversation-only instructions to CLAUDE.md.
No cross-agent or cross-team memory. Auto Memory is Claude's private notebook. Cursor, Codex and Claude Desktop each keep their own. CLAUDE.md and AGENTS.md are the only shared layer, and they are instructions, not accumulated knowledge. Instructions are also context, not enforcement: to guarantee an action never happens, the docs point you to a PreToolUse hook, not a CLAUDE.md line.
The same shape appears in Claude.ai's memory: useful within its boundary, with no retrieval layer, no cross-surface sharing and no notion of when a fact stopped being true.
How to keep Claude Code memory current: maintenance workflows and hooks
Memory files decay. The maintenance loop that keeps them useful has four parts.
Write to CLAUDE.md at the trigger points. Anthropic's list is a good checklist: Claude made the same mistake a second time; a code review caught something Claude should have known; you typed a correction you also typed last session; a new teammate would need the same context. Prefer verifiable instructions ("Run npm test before committing") over vague ones ("Test your changes").
Review on a cadence. Run /doctor prompt-audit monthly or after large refactors; it flags references to files or commands that no longer exist and files that contradict each other. Run /context when behaviour seems off to confirm the file you edited is the one that loaded. Open the Auto Memory folder from /memory and delete stale project entries; Claude will not do it for you unless MEMORY.md hits its size limit.
Move procedures out. When a CLAUDE.md section becomes a how-to, convert it to a skill; when it only applies to one directory, convert it to a path-scoped rule. Both reduce what every session pays for.
Automate with hooks. Hooks are shell commands, HTTP calls or MCP tool calls that run at fixed lifecycle events, configured in ~/.claude/settings.json, .claude/settings.json (committed) or .claude/settings.local.json. Four events map directly onto memory maintenance: SessionStart (matchers startup, resume, clear, compact, fork) can inject context, and its plain-text stdout is added to Claude's context; PreCompact (matchers manual, auto) runs before the window is summarized and receives transcript_path, so it can snapshot what is about to be condensed; PostCompact receives the generated compact_summary; and Stop fires when Claude finishes a turn and receives last_assistant_message. The example below re-injects a per-project notes file on every start and resume, archives the transcript before compaction, and appends the final message of each turn to a log:
Hooks read a JSON payload on stdin (session_id, transcript_path, cwd, hook_event_name, plus event-specific fields), so jq is the usual glue. SessionStart on compact is how you re-inject memory after compaction without waiting for the next session. A PreCompact hook that exits 2 blocks compaction, which is occasionally useful for manual /compact and almost never for auto. Note that at launch SessionStart runs before MCP servers are connected, so a hook that needs a memory server must be type: "command" and call the server over HTTP itself; mcp_tool hooks on SessionStart only run on later clear and compact events. Hook matchers also accept regular expressions such as mcp__memory__.*, which lets a PostToolUse hook observe every call into an MCP memory server.
How to add persistent cross-session memory with MCP
The Model Context Protocol is how Claude Code talks to external tools, and a memory server is just an MCP server whose tools store and retrieve facts. Any server that exposes a save tool and a search tool gives Claude a store that survives sessions, machines and repositories, because the data lives in the server, not in ~/.claude/. The protocol's reference implementation includes a simple knowledge-graph memory server that stores entities, relations and observations in a local JSON file; hosted and self-hosted servers add embeddings, graph databases, multi-user permissions and temporal reasoning on top of the same tool contract.
Registering a server is one command, with the scope deciding who sees it:
--scope user writes to your user config; --scope project writes .mcp.json at the repo root so teammates get the same server on clone. Once connected, Claude sees the server's tools as mcp__<server>__<tool> and can call them when prompted or when a skill or CLAUDE.md line tells it to.
An MCP server on its own changes storage, not behaviour. Three additions turn it into working memory. A CLAUDE.md instruction or a skill tells Claude when to search and what to save, otherwise recall only happens when you ask. A UserPromptSubmit hook can query the server with each prompt and return results as additionalContext, which makes recall automatic. And PreCompact / SessionEnd hooks can flush the session into the store before context is lost. This capture-inject-flush loop is what distinguishes a memory system from a database with an MCP endpoint, and it is the pattern the MCP memory guide and the memory servers comparison evaluate across vendors.
What to look for in a server: automatic capture (so nothing depends on remembering to save), relevance-ranked retrieval rather than "load the whole file", temporal handling so superseded facts are kept with validity windows instead of overwritten, and a transport every client in your stack supports (stdio for local, Streamable HTTP for shared).
How Cognee gives Claude Code persistent memory
Cognee is an open-source (Apache 2.0, ~32.5k GitHub stars) AI memory engine that stores facts in a knowledge graph plus vector index and exposes them over MCP with four verbs: remember, recall, improve and forget. For Claude Code it ships as a plugin that implements the full capture-inject-flush loop described above, so none of the hooks have to be hand-written:
The plugin's hooks.json registers handlers on SessionStart (initialize memory and the status line), UserPromptSubmit (inject relevant graph context into every prompt), PreToolUse and PostToolUse (capture significant tool calls, with credentials and .env contents redacted and never stored), Stop and StopFailure (record the assistant turn), PreCompact (write a memory anchor before the window is summarized) and SessionEnd (sync the session into the permanent graph). The skills listed earlier, cognee-remember, cognee-search, cognee-forget, cognee-sync, cognee-handoff, cognee-standup, cognee-timeline, cognee-digest, give you explicit control on top of the automatic loop.
Two deployment modes. Local mode (default) starts a Cognee server on localhost:8011 and keeps all memory on your machine; it builds the graph with the LLM provider you configure, or, with no LLM_API_KEY set, through your Claude Code login. Cloud mode points the plugin at Cognee Cloud with COGNEE_API_KEY; register the hosted MCP endpoint directly with claude mcp add --scope user --transport http cognee https://mcp.aws.cognee.ai/mcp and authenticate via /mcp → cognee → Authenticate. Self-hosters can run the whole stack on a single Postgres instance, or on Neo4j, Kuzu, FalkorDB, LanceDB or pgvector backends, and the same server is reachable from Cursor, Codex, Cline, Continue and Claude Desktop, so one graph serves every agent. See the step-by-step tutorial for the full walkthrough.
In cloud mode the plugin turns off native Auto Memory from the next session (COGNEE_DISABLE_AUTO_MEMORY=false opts out), keeping the previous value so it can be restored; existing memory files are left intact. It reads hook payloads only, never your transcripts or Claude Code's memory files. Memory is temporal by default, so superseded facts keep their validity windows, and opt-in contradiction detection (CONTRADICTION_DETECTION=true) records conflicts with both texts, a reason and a confidence score instead of overwriting. Datasets carry read/write/delete/share permissions; each client gets its own dataset by default (claude_code_memory, cursor_vscode_memory) unless you point them at a shared one with cognee-switch-datasets. Pricing as of October 2026: self-hosted is free; Cognee Cloud has a free tier with 1M tokens and one workspace, and Standard is $1.00 per 1M tokens processed plus $5 per additional workspace (pricing).
Next steps
Start with the native layer and get it right: run /init, keep CLAUDE.md under 200 lines, move procedures to skills and directory-specific instructions to .claude/rules/, and check /context once so you know what actually loads. Add the hooks above if you want compaction snapshots and re-injection without any external service. When the limits bite, cross-repo recall, cross-agent sharing, retrieval instead of position, that is the point to add an MCP memory server, and the Cognee plugin is the two-command way to get there. For the surrounding surfaces, see the guides on Claude memory, Cursor memory, Codex memory, Hermes Agent memory, OpenClaw memory and MCP memory. To give Claude Code a structural model of the repository rather than just a record of decisions, see codebase memory; to make the skills it runs improve with use, see building self-improving skills for agents. Setup references: Claude Code integration, MCP overview, MCP tools and Claude Code on Cognee Cloud.
FAQ
Does Claude Code retain memory between sessions?
Yes, through files on disk rather than the conversation itself. Every session starts with an empty context window. What persists is CLAUDE.md (or AGENTS.md) instruction files you write and Auto Memory notes Claude writes to ~/.claude/projects/<project>/memory/. Both load at the start of each session; anything that lived only in chat is gone unless it was written to one of them.
How does Claude Code check memory at session start?
It walks from the working directory up to the filesystem root collecting CLAUDE.md and CLAUDE.local.md, loads ~/.claude/CLAUDE.md and rules in ~/.claude/rules/ and .claude/rules/ (those without paths frontmatter), expands @path imports, and reads the first 200 lines or 25 KB of Auto Memory's MEMORY.md. Subdirectory files and path-scoped rules load later on demand. /context shows what loaded; /memory lists and opens the files.
Where does Claude Code write its memory?
Auto Memory is written to ~/.claude/projects/<project>/memory/, with MEMORY.md as the index and one topic file per memory. Instruction files are yours to write: ./CLAUDE.md or ./.claude/CLAUDE.md for the project, ./CLAUDE.local.md for gitignored personal notes, ~/.claude/CLAUDE.md for all projects, .claude/rules/*.md for modular rules, and a managed CLAUDE.md (for example /etc/claude-code/CLAUDE.md on Linux) for organization policy.
What does the Claude Code memory skill do?
A memory skill is a SKILL.md in .claude/skills/<name>/ or a plugin that tells Claude how and when to save or retrieve memory, usually by calling an MCP tool. Unlike Auto Memory, which Claude Code runs itself, a skill loads only when invoked with /<name> or when Claude judges it relevant. The Cognee plugin ships skills such as cognee-remember, cognee-search and cognee-forget that operate on its knowledge graph.
What is the difference between CLAUDE.md, Auto Memory, and MEMORY.md?
CLAUDE.md is written by you, holds instructions, and is loaded from managed, user, project and local scopes as Claude walks up the directory tree; AGENTS.md can stand in for it. Auto Memory is written by Claude into ~/.claude/projects/<project>/memory/ and holds learnings: preferences, corrections, project decisions. MEMORY.md is the index file inside that directory; only its first 200 lines or 25 KB load at startup, and topic files are opened on demand.
How do you add persistent cross-session memory to Claude Code?
Register an MCP memory server with claude mcp add, then add the behaviour around it: a CLAUDE.md line or skill that says when to search and save, a UserPromptSubmit hook for automatic recall, and PreCompact/SessionEnd hooks to flush the session. The Cognee plugin does all of that in two commands:
Cloud users can also register the hosted endpoint with claude mcp add --scope user --transport http cognee https://mcp.aws.cognee.ai/mcp and authenticate via /mcp → cognee → Authenticate.
How does Cognee compare to Mem0 and claude-mem?
Mem0 runs as a hosted MCP server at mcp.mem0.ai/mcp, requires a Mem0 Platform account, and expects the user to instruct it what to remember and when to search; file edits and command runs are not captured automatically. claude-mem is a Claude Code plugin, not an MCP server, that compresses tool output into observations in a local SQLite database at ~/.claude-mem/claude-mem.db. Cognee is graph-native, captures automatically through session hooks, and serves one endpoint that Claude Code, Cursor, Codex, Cline and Continue all read and write.
How much does Cognee cost for Claude Code memory?
The open-source package is Apache 2.0 and free to self-host, including on a single Postgres instance. Cognee Cloud, as of October 2026, has a free tier with 1M tokens and one workspace; Standard is $1.00 per 1M tokens processed plus $5 per additional workspace. Enterprise adds bring-your-own-cloud deployment, a dedicated support engineer and SLAs for organizations that need isolation or contractual commitments.
Related reading





