Where your coding agent's memory lives
Claude Code keeps a separate memory for each login, repository folder and computer. See which sessions load which memory, how to spot a split, and four ways to fix it.
Claude Code and Codex can keep notes between sessions. Where those notes are saved decides which sessions see them. If you use several logins, clones or computers, one repository can end up with several memories that never see each other. Vendor facts on this page were checked against the linked vendor pages on November 27, 2026.
Claude Code keeps one memory per login, folder and computer
Section titled “Claude Code keeps one memory per login, folder and computer”Claude Code’s auto memory is a folder of notes plus an index file, MEMORY.md. By default it lives in ~/.claude/projects/ under a folder named after your repository’s path. If a login sets CLAUDE_CONFIG_DIR, its memory lives under that folder instead.
- Each login has its own memory. Two Claude Code logins on one Mac, each with its own config folder, keep two separate memories for the same repository. A note saved in one is not seen by the other.
- Claude Desktop accounts may or may not share a config folder. Run
/memoryin each to see which folder it uses. - Worktrees share. Git worktrees and subfolders of one checkout use the same memory.
- Clones split. Two clones of one repository at different paths keep two memories.
- Computers split. Memory is never synced between machines.
At the start of each session Claude Code loads the first 200 lines of MEMORY.md, up to about 25,000 characters. Anything past that is left out until Claude reads it on purpose.
Sources: How Claude remembers your project, The .claude directory.
Which sessions load which memory
Section titled “Which sessions load which memory”| Session | Repository instructions (CLAUDE.md, AGENTS.md) |
Your local auto memory |
|---|---|---|
| Claude Code on your computer | Yes | Yes, the memory of the login you started it with |
| Another login on the same computer | Yes | Its own, separate memory |
| A worktree of the same checkout | Yes | Shared with the main checkout |
| A second clone at another path | Yes | Its own, separate memory |
| Another computer | Yes | Its own, separate memory |
| Claude Code cloud session or cloud scheduled task | Yes, from the repository | No. Cloud Projects keep their own project memory |
| GitHub Actions | Yes, from the repository | No |
| Subagent started by Claude | Yes, except the built-in Explore and Plan agents | No. A fork keeps the parent’s conversation, memory included |
--bare run |
No | No |
| Auto memory turned off | Yes | No |
| Codex | AGENTS.md |
Codex Memories, off by default, one store per Codex home |
Sources: Subagents, Cloud environments, Codex Memories.
How to check for a split
Section titled “How to check for a split”- In each login, run
/memory. It shows the memory folder that session uses. Different folders for the same repository mean separate memories. - Run
/contextto see which memory files loaded and how many tokens they take. - Watch for a startup warning that only part of
MEMORY.mdwas loaded. That index is over its limit, and its newest notes are being left out. - To see every memory folder for a login, list
projects/*/memoryinside its config folder (~/.claudeor the folder inCLAUDE_CONFIG_DIR).
Ottto’s Optimize screen flags a MEMORY.md that is near or past its load limit and shows its size under Session start. It does not yet show that one repository has several separate memories, so check by hand today.
Four ways to fix it
Section titled “Four ways to fix it”Work through them in order.
1. Move lasting lessons into the repository
Section titled “1. Move lasting lessons into the repository”The repository is the only place every login, computer, cloud session, Codex session and teammate reads. Move rules that are true everywhere (how to run tests, workflow rules, known gotchas) into CLAUDE.md, AGENTS.md or your docs. Keep only notes about one computer or one person in memory.
2. Share one memory across the logins on one computer
Section titled “2. Share one memory across the logins on one computer”Merge the memories into one folder first and keep MEMORY.md under 200 lines. Then point every login at that folder with autoMemoryDirectory in its user settings.json:
{ "autoMemoryDirectory": "~/agent-memory/my-repo" }In user settings this one folder is used for every repository the login opens. If a login works in several repositories, set it per checkout in .claude/settings.local.json instead. Claude Code uses it after you trust the folder. That file is not committed, so give each worktree its own copy.
Anthropic does not document what happens when two sessions write the same memory at the same moment. Check MEMORY.md after busy days.
Source: autoMemoryDirectory.
3. Merge the rest on a schedule
Section titled “3. Merge the rest on a schedule”Separate computers can’t share a folder. Merge their memories every week or so. Ask Claude Code in that repository:
Merge my Claude Code auto memory for this repository.Source folders (read only): <folder 1>, <folder 2>Target folder: <target folder>Drop notes that repeat CLAUDE.md, AGENTS.md or the docs, or that the code shows are stale.List lasting notes that belong in the repository and propose the edits.Copy the rest into the target, one file per fact; when two notes disagree, keep the newer one.Rewrite the target MEMORY.md as one short line per file, under 200 lines.Do not change the source folders. Report what you merged and dropped.To run it on a schedule, use something that runs on your computer, such as cron or a local scheduled task. Cloud scheduled tasks can’t see your memory folders.
4. Turn auto memory off where it only adds drift
Section titled “4. Turn auto memory off where it only adds drift”A login that only runs unattended automation can pile up notes nobody reviews. Move anything useful into the repository, then turn auto memory off for that login:
- add
"autoMemoryEnabled": falseto itssettings.json, or - set
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1in the automation’s environment.
This keeps one reviewed source of truth. It saves very few tokens, so don’t delete notes from logins people use just to make context smaller.
Source: Environment variables.
AGENTS.mdis the shared layer. Every Codex session reads the repository’sAGENTS.md, and Claude Code can load it with@AGENTS.mdinCLAUDE.md.- Codex Memories are off by default. When you turn them on, each Codex home (
CODEX_HOME,~/.codexby default) keeps its own store. Several Codex homes means several memories, with no sync. - Codex adds a summary of its memory to each chat, about 2,500 tokens at most. A longer summary loses its middle.
Sources: Codex Memories, AGENTS.md.
For the other kinds of memory an agent can use, see Seven layers of agent memory.