Guides

Claude Code auto memory: what your team doesn't get

Auto memory stays on the machine that learned it, so the teammate and the CI job hit the same wall. Where it loads, where it's cut, where a team keeps it.

Published · updated

On Tuesday afternoon Marta's Claude Code session gets a 403 from the payments sandbox in staging. Twenty minutes later the cause is clear: the provider is migrating, the sandbox is read-only until December 5, and integration tests that create charges have to use the local mock until then. Claude says "Saved 1 memory". Marta moves on.

On Wednesday morning Tiago's agent, on another laptop, spends forty minutes on the same 403. That night the scheduled CI agent opens an issue about it. Marta's own second checkout of the repository, the one used for reviews, has never heard of it either. Nobody did anything wrong. The memory is a markdown file under ~/.claude/projects/ on Marta's laptop, and that is the only place it exists.

Auto memory is one of the most useful things Claude Code added: the agent writes down what it learns without being asked. It was built for one person on one machine, and the documentation says so. This guide shows what each tool documents about its own memory, what we measured about where Claude Code's auto memory loads and where it stops, and where a team should put the things one agent learns that every other agent needs.

Card: Claude remembered it. On one laptop. Next to the title, the scene: Tuesday, Marta’s laptop, Saved 1 memory; Wednesday, Tiago’s laptop, 40 min on the same 403; that night, the CI agent opens an issue about it. Left, a dark terminal window, claude -p against a local API with no model, Claude Code 2.1.329, on 2026-12-01, in two columns: where the run started, and what reached the model. The repository root, a subdirectory and a git worktree: the index; another CLAUDE_CONFIG_DIR, standing in for another laptop or CI: nothing; a second clone on the same machine: nothing; the topic file the index links to: never at start. Only the three rows that got the index connect to the MEMORY.md panel, in ~/.claude/projects/…/memory/, on the right: with 160 long lines, 39.1 KB, lines 1 to 100 loaded and lines 101 to 160 were cut; the cut is at 200 lines or 25,000 characters, whichever comes first. The warning went only to the model: WARNING: MEMORY.md is 39.1KB (limit: 24.4KB) — index entries are too long. Only part of it was loaded: 60 of 160 lines were cut off, starting at line 101. claude -p printed nothing. In a dark band, where it goes: CLAUDE.md or AGENTS.md for what the team follows, team memory for a state with a date, auto memory for one person on one machine.

What each tool documents

Claude CodeCodexGrok Build
Where the tool's own memory lives~/.claude/projects/<project>/memory/: a MEMORY.md index plus one topic file per memory. "The <project> path is derived from the git repository"Under the Codex home (~/.codex), in memories/ or memories_v2/. "Treat these files as generated state"Agents Window: we found no page on a memory feature, and the old memories address now redirects to a page that does not exist (HTTP 404). Terminal UI: the CLI reference lists --experimental-memory ("Enable cross-session memory") and grok memory clear (with --workspace, --global or --all), and does not say where those files live or whether anyone else reads them. The documented shared context is Rules
Who shares it"Auto memory is machine-local. All worktrees and subdirectories within the same git repository share one auto memory directory. Files are not shared across machines or cloud environments"Settings apply "for the selected machine"; local memories "are off by default"Team Rules, "managed from the dashboard", on Team and Enterprise plans
What reaches the model at start"The first 200 lines or 25KB of MEMORY.md, whichever comes first". Topic files are not loaded at startup: "Claude reads them on demand"Memories are generated in the background after a chat has been idle; memories.use_memories controls whether they are injectedNot applicable
Moving or switching it offautoMemoryDirectory ("must be an absolute path or start with ~/"), autoMemoryEnabled: false, CLAUDE_CODE_DISABLE_AUTO_MEMORY=1, --bare[features] memories = true to turn it on; /memories per chatNot applicable
What it says about team rules"To add instructions to CLAUDE.md instead, ask Claude directly""Keep required team guidance in AGENTS.md or checked-in documentation. Treat memories as a helpful recall layer, not as the only source for rules that must always apply"Rules are the shared, versioned layer

Both vendors that ship a local memory say the same thing in different words: it is personal recall on one machine, and what the team must follow belongs in a file in the repository.

What we measured

On one Linux machine, on December 1, 2026, with Claude Code 2.1.329. Each case builds a fresh git repository and its own config directory (CLAUDE_CONFIG_DIR), writes a MEMORY.md with a marker line and a topic file with another marker, and starts a headless run.

Instead of reading logs, we pointed Claude Code at a local stand-in for the Messages API: a Python server of about sixty lines on 127.0.0.1 that records each request and answers "ok". With a placeholder key and no account, no model call runs, and we see the exact text the model would have received. Auto memory arrives in the first user message, as a block headed "Contents of …/MEMORY.md (user's auto-memory, persists across conversations)".

ANTHROPIC_BASE_URL=http://127.0.0.1:18731 ANTHROPIC_API_KEY=local-lab-placeholder \
  CLAUDE_CONFIG_DIR="$W/cfg" claude -p hi

One correction to the vendor text quoted above: it says 25KB; the probes below show that the implementation counts 25,000 characters, not bytes.

Where the run startedWhat reached the model
Repository rootthe index
A subdirectory of the repositorythe index
A git worktree of the repositorythe index, from the main checkout's directory
The same repository, another config directory (a stand-in for another laptop or a CI runner)nothing
A second clone of the same repository at another path, same machinenothing
Any of the above, the topic file the index links tonever at start
Size of MEMORY.mdWhat reached the model
250 short lineslines 1 to 200, and a warning
160 lines of 250 ASCII characters (40,000 characters and bytes)lines 1 to 100 (25,000 characters), and a warning
160 lines with 122 ç each (39,840 bytes, 20,320 characters)all 160 lines; no warning
160 lines with 245 ç each (79,200 bytes, 40,000 characters)lines 1 to 100 (25,000 characters), and a warning
130 lines of 199 characters including the newline (25,870 characters)lines 1 to 125, and a warning
32 lines of frontmatter, then 200 linesall 200 body lines: the frontmatter did not count
autoMemoryDirectory and switchesWhat reached the model
A shared folder, set in user settingsthat folder's index
An absolute path, in the committed .claude/settings.jsonthat folder's index
./.claude/memory, in the committed .claude/settings.jsonthe default folder's index: the relative path was ignored, with no warning
An absolute path in committed settings, with permissions.blockReadsOutsideWorkingDirectories onnothing
A folder inside the repository, set in user settingsthat folder's index
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1, --bare, or autoMemoryEnabled: false in committed settingsnothing

Five things the lab shows

1. Auto memory follows the path on one machine, not the repository. A subdirectory and a worktree found it. A second clone of the same repository on the same machine did not, and neither did another config directory. In our runs the project folder was named after the checkout's path, with / and . turned into -. A teammate's laptop, a CI runner, a cloud agent and your own second clone all start with nothing.

2. The index loads, the memories it points to don't. The line in MEMORY.md reached the model; the topic file it linked to did not. Claude reads a topic file only when it decides it needs it, with the same file tools it uses for code. A memory that lives in a topic file is one the model has to remember to go and read.

3. The cut is silent where you are looking. A 250-line index lost lines 201 to 250. An index with long lines lost everything after 25,000 characters, including the newline characters, which was line 101. The unit is characters, not bytes: the file with 122 ç per line was 39,840 bytes but only 20,320 characters and arrived whole; the file with 245 ç per line was 79,200 bytes and 40,000 characters and was cut in the same place. Claude Code's warning still prints that character count with a KB label. In the cases that were cut, Claude Code added a warning, and the warning went to the model, not to the terminal: in claude -p nothing was printed. The text it sent was: "WARNING: MEMORY.md is 39.1KB (limit: 24.4KB) — index entries are too long. Only part of it was loaded: 60 of 160 lines were cut off, starting at line 101". The lines at the end of the index are the ones that fall off, and nobody watching a scheduled job sees it.

One probe makes the newline explicit: 126 lines of 198 characters plus a newline have only 24,948 non-newline characters, but line 126 was still cut; counting the newline takes the total to 25,074. Valid YAML frontmatter and HTML comments are excluded from the count, and the warning numbers the body lines without them. We did not probe emoji: in the 2.1.329 bundle the count is the JavaScript string length (byteCount: r.length), so a character outside the Basic Multilingual Plane, such as most emoji, should count as two.

4. autoMemoryDirectory can move the memory, not share it. Any absolute path worked, from user settings or from the repository's committed settings. A relative path, the one setting that would mean the same folder on every checkout, was dropped without a word and the default folder was used. An absolute path is the same for everyone only if everyone's disk looks the same, and with blockReadsOutsideWorkingDirectories on, a folder chosen by the repository's settings was not loaded at all. Pointing every developer's user settings at a folder committed in the repository did load it. It also means every session on every branch edits one index file in git, with no date on any line and no review before an agent writes. We did not test concurrent writes.

5. The off switches work, and a CI job should use one. The environment variable, --bare and autoMemoryEnabled: false in the committed settings all kept the index out. On a fresh runner there is nothing to load anyway. On a self-hosted runner that keeps its home directory and checks out to the same path, what an earlier job left in that folder would load in the next one, by the same rule as the first table. We did not run a CI job to see it.

Where what one agent learns should go

Split it by who needs it next.

A committed file (CLAUDE.md, AGENTS.md)A memory the whole team readsAuto memory
How to build, test and run: "use pnpm, never npm"A state with a date: "the payments sandbox is read-only until December 5"How you like answers
What the tests need: "integration tests need a local Redis"A decision that will change, with who made itYour local setup: ports, paths, your editor
Conventions for this codeWhat one run found that the next run, anywhere, has to knowShortcuts that only make sense on your machine
Reviewed in a pull request, versioned with the codeWritten once, read from every repository, every tool, every machineOne person, one machine

The first column needs no product, only the habit: when the agent says it saved something that a teammate would need too, ask it to put it in CLAUDE.md or AGENTS.md and open the pull request. The second column is the one auto memory was never meant to cover.

Check your own auto memory: five minutes

List every auto memory index on your machine with its size:

for f in "${CLAUDE_CONFIG_DIR:-$HOME/.claude}"/projects/*/memory/MEMORY.md; do
  [ -f "$f" ] || continue
  printf '%5d lines %7d chars  %s\n' "$(wc -l < "$f")" "$(wc -m < "$f")" "$f"
done

wc -m counts newline characters, valid frontmatter and HTML comments too, even though Claude Code excludes those two blocks. Treat the number as a conservative upper bound, unless the index has emoji: wc -m counts each one once, Claude Code most likely twice. An index near 200 lines or 25,000 characters is already being cut, or soon will be, and the lines at the end are the ones the model no longer sees.

Then open the folder for the repository you work in most, with /memory in a session or in your editor, and read each line with one question: would a teammate's agent or the CI job need this too? Every yes is a line that only works on your laptop. Move it to the committed file or to the team's memory, and delete it here so the two copies do not drift apart.

The same setup with ValorBrain

ValorBrain is a memory server for teams of agents, reached over MCP at one URL from every repository, tool and machine. The sandbox finding becomes one keyed fact, written by the agent that found it:

{
  "tool": "upsert_keyed_fact",
  "arguments": {
    "fact_key": "staging.payments.sandbox",
    "fact_value": "read-only until 2026-12-05 (provider migration); integration tests that create charges use the local mock",
    "as_of": "2026-12-01",
    "evidence": "403 from the sandbox on POST /charges; provider status page",
    "authority": "agent"
  }
}

On December 5 someone writes the new value under the same key and it replaces the old one; keyed_facts_as_of still returns what was in force on any earlier date. A teammate's agent, the CI job and Marta's second checkout read the same value, because none of them reads it from a disk.

A few lines in the committed instruction file tell every agent which memory is which:

## What to remember, and where

Auto memory is for personal preferences on this machine.
Anything a teammate's agent or a CI job would also need goes to the team memory:
a state or a decision with a date with `upsert_keyed_fact`, a finding with `memory_store`.
Build commands and conventions go in this file, by pull request.

On a developer's machine, one command adds the server, writes the memory rules into the harness's user-level instruction file and installs hooks:

npx -y @valorbrain/connect@latest --token <vbm_…> --harness <claude-code|codex|cursor>

On Claude Code and Codex a hook fetches memory at session start and on each prompt; the cursor harness gets a session-start hook and no prompt hook. memory_prepare returns the keyed facts whose key shares a word with the request, or whose value shares two, up to 12 by default, so a request about the payments sandbox brings staging.payments.sandbox and "rename this component" does not. A CI runner gets none of the hooks: it needs the MCP entry and a few lines in the job's prompt, as Headless and scheduled agent runs shows.

What ValorBrain does not do

  • It does not save on its own unless you opt in. The start and prompt hooks fetch memory. The stop hook sends counters, and when the server answers with a checkpoint, the agent's own model decides what to record. A fact is written when the agent calls the tool, because its instructions say so, and the four lines above are what makes that happen. With --transcript on (off by default), the stop hook also uploads the session transcript and the server extracts decisions and episodes from it. What leaves your machine lists exactly what each hook sends.
  • It does not reach a harness that is not connected to it. An agent without the server, or a CI job without the token, reads nothing from it.
  • It does not replace the committed file. "Use pnpm" and "integration tests need a local Redis" belong next to the code, reviewed and versioned with it.
  • It does not clean up your auto memory. Lines you moved to the team memory stay in MEMORY.md until you delete them, and a stale local line can still contradict the shared fact.

What we ran and what we did not

Sixteen Claude Code cases, one run each, on one Linux machine, with throwaway repositories, dummy text and a local stand-in for the API. Follow-up probes on December 2 checked the truncation unit, newline handling and ignored blocks. No model call ran, so the lab measures what the model receives, not what it does with it, and not what Claude decides to save in a real session. We did not test the writes: the reminder near the limit, the error over it, two sessions writing to one shared folder. We did not test the trust dialog an interactive session shows before honoring a repository's autoMemoryDirectory, CLAUDE_CODE_PROJECT_DIR_NAME, or macOS and Windows paths. We did not run Codex memories, which are off by default; its column, like Grok Build's, is documentation only.

The lab is one bash script and the stand-in server. Both build everything under /tmp and delete it after.

Checklist

  • You know where each of your agents keeps its own memory, and that a teammate's machine and CI do not have it.
  • Every auto memory index you depend on is well under 200 lines and 25,000 characters.
  • Nothing the team must follow lives only in a topic file or only in auto memory.
  • What a teammate's agent would also need is in the committed file or in a memory every repository reads, with a date.
  • CI jobs run with auto memory off (--bare, CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 or autoMemoryEnabled: false), so a job does not depend on what an earlier one left on the runner.
  • Any autoMemoryDirectory in committed settings is an absolute path, and you checked that it loads with blockReadsOutsideWorkingDirectories as your team has it.

Sources, read on December 1, 2026: Claude Code, How Claude remembers your project (auto memory location, limits, autoMemoryDirectory, switches); Codex, Memories; Grok Build, Rules and CLI reference; the documentation that used to be at cursor.com/docs now redirects to docs.grok.com and calls the product Grok Build.

Next: Subagents and worktrees: what parallel coding agents share for the same question inside one machine, CLAUDE.md, AGENTS.md and .cursor/rules in one repo for keeping the committed file in one place, and Headless and scheduled agent runs for what a job with nobody watching starts with.

On this page