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.
What each tool documents
| Claude Code | Codex | Grok 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 injected | Not applicable |
| Moving or switching it off | autoMemoryDirectory ("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 chat | Not 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 hiOne 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 started | What reached the model |
|---|---|
| Repository root | the index |
| A subdirectory of the repository | the index |
| A git worktree of the repository | the 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 machine | nothing |
| Any of the above, the topic file the index links to | never at start |
Size of MEMORY.md | What reached the model |
|---|---|
| 250 short lines | lines 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 lines | all 200 body lines: the frontmatter did not count |
autoMemoryDirectory and switches | What reached the model |
|---|---|
| A shared folder, set in user settings | that folder's index |
An absolute path, in the committed .claude/settings.json | that folder's index |
./.claude/memory, in the committed .claude/settings.json | the default folder's index: the relative path was ignored, with no warning |
An absolute path in committed settings, with permissions.blockReadsOutsideWorkingDirectories on | nothing |
| A folder inside the repository, set in user settings | that folder's index |
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1, --bare, or autoMemoryEnabled: false in committed settings | nothing |
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 reads | Auto 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 it | Your local setup: ports, paths, your editor |
| Conventions for this code | What one run found that the next run, anywhere, has to know | Shortcuts that only make sense on your machine |
| Reviewed in a pull request, versioned with the code | Written once, read from every repository, every tool, every machine | One 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"
donewc -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.mduntil 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=1orautoMemoryEnabled: false), so a job does not depend on what an earlier one left on the runner. - Any
autoMemoryDirectoryin committed settings is an absolute path, and you checked that it loads withblockReadsOutsideWorkingDirectoriesas 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.
A decision in one repo, an agent in another
What Claude Code, Codex and Grok Build read outside your repo, tested with --add-dir, imports, symlinks and a parent folder, and where shared rules go.
AGENTS.md past 32 KiB: the rules Codex never reads
Codex cuts mid-line, in the file closest to your work, with nothing on screen. Where it cuts, what Claude Code does with 200 KB, and a script that shows yours.