Codex vs Claude Code memory: what each keeps between sessions
Both agents start each session from a file you write: Codex reads AGENTS.md, Claude Code reads CLAUDE.md. Both also have a memory the agent writes itself, and that’s where they differ most. Claude Code’s auto memory is on by default and loads every session. Codex’s Memories feature is off until you turn it on, and then builds memory files in the background from chats that have gone quiet.
Neither one sees the other’s memory. A rule you write can live in one AGENTS.md that both read; what each agent learns stays in its own folder on one machine.
Two lines that rank for this question are out of date. Claude Code does read AGENTS.md now (from v2.1.277, with conditions below). And it’s no longer true that neither tool remembers anything by default: Claude Code’s auto memory is on out of the box.
An AI drafted this page from the sources below and another AI checked it. No person has run these steps for this page: it’s a research summary of OpenAI’s Codex docs and Anthropic’s Claude Code docs, read 3 December 2026. Both tools ship changes weekly, so check the dates. Counterparts, which this page names, is ours.
This page is about Codex on your computer: the CLI, the IDE extension and the desktop app. OpenAI’s docs say ChatGPT on the web uses ChatGPT’s own memory, a separate store.
Side by side
| Codex (CLI, IDE, desktop app) | Claude Code | |
|---|---|---|
| Instruction file |
|
|
| Where it’s read from |
| Managed policy file, |
| Size | Stops adding files at 32 KiB combined by default ( | Anthropic suggests under 200 lines per file; skips a file over 4 MiB |
| Built-in memory | Memories: Codex turns past chats into local memory files and adds them to later sessions | Auto memory: Claude writes notes to a |
| On by default? | No | Yes, in local sessions |
| When it writes | In the background, after a chat has been idle (6 hours by default) | During the session, as Claude decides something is worth keeping |
| What loads | Generated memory files under | The first 200 lines or 25 KB of |
| Controls |
|
|
| Old chats |
|
|
| Compaction |
|
|
| Across machines | Memories belong to one machine; AGENTS.md travels in git | Auto memory and transcripts stay on one machine; CLAUDE.md travels in git |
Which fits whom
- You use only one of them. The instruction file is the part to get right. In Codex, also decide whether to turn Memories on: it’s the only built-in way Codex learns from past chats (unless you use an add-on such as Counterparts, below, in which case keep it off). In Claude Code, auto memory is already running; open
/memoryto see what it kept. - You switch between both on one repository. Write the shared rules once in
AGENTS.mdand let both read it (how). Expect each agent’s own memory to stay separate: a fix Claude Code noted on Monday won’t be in Codex’s memory on Tuesday. - You want one memory that follows you across both, and across every project. That takes an add-on both tools connect to. Add-ons lists four whose own docs name Codex, ours first.
- Your problem is a long session losing the thread. That’s compaction, and an instruction file or memory only helps after it. See Compaction.
Instruction files: AGENTS.md vs CLAUDE.md
Codex builds an instruction chain once per run. It reads ~/.codex/AGENTS.override.md if it exists, otherwise ~/.codex/AGENTS.md. Then it walks from the project root (usually the git root) down to your working folder, taking at most one file per folder: AGENTS.override.md, then AGENTS.md, then any names you list in project_doc_fallback_filenames. Files are joined root first, so a deeper file’s guidance comes later and overrides the broader one.
Codex skips empty files and stops adding files once the total reaches project_doc_max_bytes, 32 KiB by default. (OpenAI’s configuration page calls it a per-file limit; Codex’s source treats it as one budget for all the files, so the deepest file is cut short or left out.) Raise the limit in config.toml if you hit it. OpenAI’s personalization page adds that your personal instructions for Codex live in that global ~/.codex/AGENTS.md.
Claude Code reads CLAUDE.md files from four places, broadest first: an organization’s managed file, your ~/.claude/CLAUDE.md, the project’s CLAUDE.md (or .claude/CLAUDE.md), and your CLAUDE.local.md. Files in folders above where you started load at launch; files in subfolders load once Claude works there. Anthropic’s advice is to keep each file under 200 lines, and to move rules that only matter for part of the codebase into path-scoped rules.
The practical difference: Codex walks down from the root and caps the total, while Claude Code walks up from where you are and loads deeper files on demand. Does Claude Code remember between sessions? goes through CLAUDE.md’s layers one by one.
Built-in memory: Codex Memories vs Claude Code auto memory
Codex Memories are off by default. Turn them on in the ChatGPT desktop app under Settings > Personalization > Enable Codex memories, or in config.toml:
[features]
memories = trueOnce on, Codex turns useful context from eligible past chats into local memory files. It skips chats that are still active or short-lived, redacts secrets from the generated fields, and works in the background rather than at the end of each chat. A chat has to sit idle for memories.min_rollout_idle_hours (6 by default) before it’s considered, and only chats from the last 30 days by default. It also skips a pass when less than 25% of your Codex rate limit is left, so memory doesn’t eat your quota.
The files live under your Codex home: ~/.codex/memories_v2/ for a fresh setup, or ~/.codex/memories/ if you already had one (that’s the CLI; the desktop app may write to both while OpenAI moves between them). OpenAI calls them generated state: you can read them, but editing them by hand shouldn’t be your main control. Two settings do most of the work: memories.generate_memories (can new chats feed memory) and memories.use_memories (are memories added to new sessions). Chats that used MCP tools or web search still feed memory unless you set memories.disable_on_external_context = true.
OpenAI’s own framing is worth copying: keep rules that must always apply in AGENTS.md, and treat memories as “a helpful recall layer, not as the only source for rules that must always apply.”
Claude Code auto memory is on by default in local sessions. Claude writes notes as it works into ~/.claude/projects/<project>/memory/, with a MEMORY.md index and topic files. Every worktree and subfolder of one git repository shares the same folder. At the start of each session the first 200 lines or 25 KB of MEMORY.md load, whichever comes first. Turn it off with the toggle in /memory, or with "autoMemoryEnabled": false in a project’s settings.
Claude Code can note a correction the moment you make it; Codex’s memories arrive hours later, after the chat has gone quiet.
Old chats: resume, history and deleted sessions
Codex saves each session under ~/.codex/sessions/, which is what resume opens, and keeps a log of your prompts in ~/.codex/history.jsonl. OpenAI’s docs say history.persistence = "none" stops saving transcripts, but Codex’s source shows it stops only the prompt log, so don’t count on it to keep sessions off disk. codex resume reopens a chat, and --last picks the newest one in the current folder (add --all for every folder). Inside a session, /resume opens a picker you can widen from this folder to the repository’s worktrees or to everything. codex fork copies an old chat into a new one.
If chats seem to have vanished, check whether they were archived: codex archive hides a session from the lists without deleting its transcript, and codex unarchive brings it back. codex delete and /delete remove the transcript for good.
Claude Code keeps each session as a JSONL file under ~/.claude/projects/. claude --continue reopens the most recent one in the current folder, claude --resume or /resume opens a picker, and /branch forks. Transcripts are deleted after 30 days by default, silently; raise cleanupPeriodDays in settings.json to keep them longer.
Resuming brings back the transcript, not a memory. A session from three weeks ago is still there in full, but nothing in it reaches a new session unless an instruction file or memory carried it.
Compaction
Both agents summarize a long conversation when it nears the context limit, and both let you do it by hand with /compact.
Codex replaces earlier turns with a summary. You can set the threshold (model_auto_compact_token_limit), compact at the end of a turn past a percentage of the window, or replace the summary prompt (compact_prompt). Its hooks fire around it: PreCompact, PostCompact, and SessionStart with source compact, which runs before the next model request, even when compaction happens mid-turn. That last hook is how an add-on can put context back after a compaction. The Codex pages we read don’t say whether AGENTS.md is re-read after one.
Claude Code keeps your requests and key code in the summary, though detailed instructions from early in the conversation may be lost. Anthropic’s docs say the project-root CLAUDE.md survives: it’s re-read from disk after /compact. You can add a “Compact Instructions” section to CLAUDE.md to steer what’s kept. When context compaction keeps failing covers loops, thrashing errors and recovery.
Across machines
Neither built-in memory leaves the machine. OpenAI’s settings turn Codex memories on or off “for the selected machine”, and deleting them resets that machine’s store. Anthropic’s docs say auto memory files “are not shared across machines or cloud environments.” Transcripts for both stay local too.
What travels is what you commit: a repository’s AGENTS.md and CLAUDE.md come with every clone. Your global files (~/.codex/AGENTS.md, ~/.claude/CLAUDE.md) stay put unless you copy them.
Using both on one repository
One AGENTS.md can serve both, with care.
- Put the shared rules in
AGENTS.mdat the repository root. Codex reads it by default. - For Claude Code, either have no CLAUDE.md, or import it. Claude Code (v2.1.277 or later) reads
AGENTS.mddirectly only when there’s noCLAUDE.md,.claude/CLAUDE.mdorCLAUDE.local.mdin your working folder or any folder above it. Your~/.claude/CLAUDE.mddoesn’t count against it. If you need a CLAUDE.md for Claude-only notes, put this line in it, and Claude Code pulls AGENTS.md in without reading it twice:@AGENTS.md - Watch
CLAUDE.local.md. Adding one for your own notes counts as a CLAUDE.md, so Claude Code stops readingAGENTS.mdfor you. Set Project instructions toclaude-md-and-agents-mdin/config, or use the import above. - Don’t rely on Codex’s override file in Claude Code. Claude Code never reads
AGENTS.override.md,AGENTS.local.md, or anything under.agents/. - A symlink works, with a catch.
ln -s AGENTS.md CLAUDE.mdlets Claude Code read the same file, but Anthropic recommends the import if anyone on the team works on Windows, where symlinks need admin rights or Developer Mode.
Going the other way, Codex can read a CLAUDE.md if you add it to project_doc_fallback_filenames, but only in folders with no AGENTS.md. If you’re starting fresh, AGENTS.md as the shared file is the simpler direction, since both tools read it without extra setup.
To check: in Codex, run codex --ask-for-approval never "Summarize the current instructions." from the repository root. In Claude Code (v2.1.280 or later), run /memory and look for the AGENTS.md path in the list; on older versions, ask Claude what its project instructions say.
The shared file covers rules. Each agent’s own memory still stays in its own folder: Codex under ~/.codex, Claude Code under ~/.claude/projects.
Add-ons that connect to both
Four memory add-ons whose own docs name Codex, as of 3 December 2026. Each adds the shared memory neither tool has built in.
| Add-on | Codex | Claude Code | Where memory lives | Account needed |
|---|---|---|---|---|
| Counterparts (ours) | New in 0.4.0, hooks and memory tools; not on Windows | Plugin or npm install | One SQLite file on your computer | No |
| claude-mem | Its installer sets up Codex among other agents | Plugin or installer |
| No (optional sign-in and paid observer) |
| Basic Memory | Codex plugin ( | MCP server | Markdown files on your computer, or Basic Memory Cloud | Only for cloud |
| Mem0 | Codex plugin or remote MCP server | Plugin | Mem0’s cloud platform | Yes, Mem0 API key |
Counterparts (ours)
Counterparts is a memory the agent keeps in its own words: what matters sticks and the rest fades unless it comes up again. Each session opens with a short “who I am, who you are, where we left off”, and related memories come up as you talk. It’s one memory for the whole working relationship, so what it knows about you reaches every project, while notes about a project’s work show up there.
Since 0.4.0, Codex can use the same memory Claude Code uses. In Codex it gives a wake at the start of each session, recall on each prompt, a question at the end of the session about what to keep, and each turn kept for write-up. Codex reads the memory as itself, and what it saves is labelled with Codex and the model, so you can tell later which agent learned what.
If you use Claude Code and Codex (Mac or Linux):
- In a terminal, install it (Node 22.15 or newer):
npm install -g counterparts@latest, then runcounterpartsand restart Claude Code. - Run
counterparts connect --host codex. It adds four hooks to Codex’shooks.jsonand acounterpartsmemory server to itsconfig.toml, backing both up first. - In Codex, approve the Counterparts hooks (
/hooksin the CLI; Review hooks or Settings > Hooks in the ChatGPT desktop app), then restart Codex. - Keep Codex’s own Memories off (leave
memories = trueout of[features], or leave Enable Codex memories off in the ChatGPT desktop app), or the two memories will disagree.
counterparts disconnect --host codex takes out only what connect added. It’s free to use (Business Source License 1.1), with its source on GitHub, no accounts and no API keys. Get started has the install, and the manual’s Codex section has the details.
Where it falls short in Codex today:
- It’s new. We shipped the Codex connection in 0.4.0, and nobody here has run the released command on a real setup yet. Tell us how it goes.
- Not on Windows. Counterparts in Claude Code runs on Windows (also new); the Codex connection isn’t wired there yet.
- No nights there. Dreams, reflection and the self page run in Claude Code only.
In Claude Code alone, Claude Code memory plugins compares Counterparts with the other add-ons in more detail.
The others
- claude-mem runs a second agent beside yours that takes notes while it works, and opens the next session with a short index. Its README says it works with Claude Code, Codex, Cursor, OpenCode and more, installed with
npx claude-mem install. By default each agent’s session start shows only its own notes; a setting includes all of them. Anonymous usage analytics are on by default (npx claude-mem telemetry disableturns them off). Apache 2.0. See claude-mem. - Basic Memory keeps notes as Markdown files and connects over MCP. Its Codex page covers the Codex app and CLI, local or cloud, and a Codex plugin that adds a session-start briefing and a checkpoint after compaction. AGPL-3.0. See Basic Memory’s Codex guide.
- Mem0 connects Codex to its cloud memory through a plugin (automatic capture and recall, a search tool, six memory skills) or a direct MCP server, with a Mem0 Platform API key and Python 3.10 or newer. See Mem0’s Codex guide.
The directory lists more memory systems, with what each says about Codex.
What we haven’t tested
Nobody here has run the AGENTS.md setup above in both tools, turned on Codex Memories, or run counterparts connect --host codex on a released build. Everything on this page about Codex and Claude Code comes from their own docs as read on 3 December 2026, and everything about the add-ons from each project’s own docs.
Questions people ask
Does Codex remember between sessions?
Only what you set up. Codex reads your AGENTS.md files at the start of every session, and codex resume reopens an old chat. Its built-in Memories feature, which turns past chats into local memory files, is off by default: turn it on with memories = true under [features] in ~/.codex/config.toml, or Enable Codex memories in the ChatGPT desktop app’s Settings > Personalization.
Do ChatGPT and Codex share memory?
No, apart from Computer History (ChatGPT desktop app on macOS, off by default, on some paid plans), which builds memories both can reference. OpenAI’s Memories page says ChatGPT on the web uses ChatGPT memory, while local Codex clients (the CLI, the IDE extension and the desktop app) use a separate local memory store with its own controls.
Does Claude Code read AGENTS.md?
Yes, from Claude Code v2.1.277, but by default only when there’s no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working directory or above it. To read both, set Project instructions to claude-md-and-agents-md in /config, or put an @AGENTS.md import in your CLAUDE.md. Claude Code never reads AGENTS.override.md.
Does Codex read CLAUDE.md?
Not by default. Add it to project_doc_fallback_filenames in ~/.codex/config.toml and Codex treats it as an instructions file, but only in a directory that has no AGENTS.md.
Can Codex and Claude Code share one memory?
Their built-in memories don’t cross: Codex keeps memories under ~/.codex, Claude Code keeps auto memory under ~/.claude/projects. A shared AGENTS.md covers the rules you write. For what the agent learns, you need an add-on that both connect to, such as Counterparts (ours), claude-mem, Basic Memory or Mem0.
Questions? Ask in r/AIMemorySystems.
References
- OpenAI: Memories
- OpenAI: Custom instructions with AGENTS.md
- OpenAI: Configuration reference
- OpenAI: Advanced configuration
- OpenAI: Codex CLI command line options and slash commands
- OpenAI: Hooks
- OpenAI: Personalize ChatGPT
- Claude Code docs: How Claude remembers your project
- Claude Code docs: How Claude Code works
- Claude Code docs: Manage sessions
- Claude Code docs: Settings reference, cleanupPeriodDays
- claude-mem: README
- Basic Memory: OpenAI Codex, README
- Mem0: Codex, Claude Code
- Counterparts: Get started, Manual: Codex, Changelog, 0.4.0