Harness Notes

Memories

Updated 2026-11-22,

On this page

Memory here means notes the harness saves from your sessions and brings back in later ones. Instruction files you write yourself, such as AGENTS.md or CLAUDE.md, are on the Instructions page.

Built-in memory

QuestionClaude CodeOn by default, checked at 2.1.299
Is it on, and how do I switch it?

Auto memory is on by default in local sessions. Toggle it in a session with /memory (writes autoMemoryEnabled to ~/.claude/settings.json), set "autoMemoryEnabled": false in any settings file (user, project, local or managed) to turn it off, or set CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 for a session (=0 forces it on even over autoMemoryEnabled: false or --bare).

--bare (CLAUDE_CODE_SIMPLE=1) and --safe-mode start without auto memory.

Sessions in a self-hosted environment have auto memory off by default.

From a background session, or a claude started by another Claude Code session, /memory can turn auto memory off but not back on.

Who writes memories, and when

Claude itself writes memories during the session, when it judges something will be useful later: your role and preferences (user), corrections and confirmed approaches (feedback), ongoing work and decisions not visible in the code (project), and pointers to outside resources (reference). It skips anything derivable from the codebase or already in CLAUDE.md, and doesn't save something every session; you see a "Saved N memories" notice when it does.

Each memory file's frontmatter records its kind in a type field, and Claude Code stamps a modified ISO 8601 timestamp on every write (v2.1.214+) so stale facts are visible.

Where they are kept

Memories live in ~/.claude/projects/<project>/memory/ (under $CLAUDE_CONFIG_DIR/projects/ if you set that): a MEMORY.md index plus one markdown file per memory. <project> comes from the git repository, so all worktrees and subdirectories of one repo share a single memory directory; outside git the project root is used. Set autoMemoryDirectory (absolute or ~/ path, any settings scope) to store it elsewhere.

An autoMemoryDirectory from a repo's .claude/settings.json only takes effect after workspace trust, and is ignored entirely while permissions.blockReadsOutsideWorkingDirectories is on.

With CLAUDE_CODE_PROJECT_DIR_NAME set beside CLAUDE_CONFIG_DIR (v2.1.234+), every project launched with that config dir shares one memory directory.

Memory files are excluded from the cleanupPeriodDays transcript cleanup and stay until edited or deleted.

What a new session loads

At the start of every session Claude Code loads the first 200 lines or first 25KB of MEMORY.md, whichever comes first; anything past that is dropped. Topic files are not loaded at startup; Claude reads them on demand with its file tools (shown as "Recalled N memories").

When a write leaves MEMORY.md near or over the limit, Claude Code tells Claude to compact the index (one line per entry, details in topic files).

Recalled memories come with a note on how old they are.

See and edit them

Run /memory and choose the auto memory folder to open it; the same dialog lists your CLAUDE.md files and has the auto memory toggle. Memories are plain markdown in ~/.claude/projects/<project>/memory/, so you can also open and edit them in any editor. In the VS Code extension, the Memory dialog lets you view, edit and delete saved memories.

Make it remember something

Ask in plain language, e.g. "remember that the API tests require a local Redis instance" or "always use pnpm, not npm", and Claude saves it to auto memory. To make it a standing instruction instead, say "add this to CLAUDE.md" or edit CLAUDE.md via /memory.

Correct or forget something

Edit or delete the markdown files (and their line in MEMORY.md) through /memory or any editor, or ask Claude to update or remove a memory. To wipe a project's memory, delete its ~/.claude/projects/<project>/memory/ directory; there is no dedicated reset command.

Share with a team or another machine

Partly

The main auto memory is machine-local: it is shared across worktrees of one repo but not across machines or cloud environments, and it lives outside the repo. To share, put the facts in a checked-in CLAUDE.md, or point autoMemoryDirectory at a synced folder yourself. Subagent memory with memory: project lives in .claude/agent-memory/ and is meant to be committed.

Remote sessions can also recall from mounted team memory stores (CLAUDE_MEMORY_STORES), which are set up outside the CLI.

Memory for subagents

Yes. Add memory: user, memory: project or memory: local to a subagent's frontmatter to give it its own memory directory (~/.claude/agent-memory/<agent>/, .claude/agent-memory/<agent>/, or .claude/agent-memory-local/<agent>/); it loads the first 200 lines/25KB of its own MEMORY.md and gets Read/Write/Edit to maintain it. Subagents never see the main conversation's auto memory (forks excepted), and the field does nothing when auto memory is turned off.

project is the recommended scope; local keeps it out of version control.

Notes and sources

Claude Code, 9 sources
  • Directory configuration does not establish a cross-harness import or merge protocol.
  • Topic frontmatter observed in a local store is not a documented parser contract.
  • 2.1.311 publisher fixes stale MEMORY.md immediately after automatic compaction when edited earlier in the session; no new memory loading budget is established.
Is it on, and how do I switch it?, 5
Who writes memories, and when, 2
Where they are kept, 3
What a new session loads, 3
See and edit them, 2
Make it remember something, 1
Correct or forget something, 1
Share with a team or another machine, 2
Memory for subagents, 2