How to share context between Claude and Codex
To share context between Claude and Codex, put it in files and servers both can read. Keep stable rules in AGENTS.md and import it from CLAUDE.md with @AGENTS.md. Write a handoff note for current work. For shared state, add the same MCP server to both tools.
Why Claude and Codex start from zero
Claude Code and Codex are separate programs. Each session has its own context window, and neither can read the other's conversation. Claude Code's own documentation says each session begins with a fresh context window. What they do share is your disk: the files in the repository and the git history.
So sharing context means putting the useful parts where both tools look. There are three places, and you can use all of them.
Option 1: one instruction file for both
Codex reads AGENTS.md. It looks in your ~/.codex folder first, then walks from the repository root down to your current folder, and stops reading once the combined size reaches 32 KiB by default. Claude Code reads CLAUDE.md. It can also read AGENTS.md directly, but only when there is no CLAUDE.md in your working folder or above it, and only on version 2.1.277 or later.
The dependable setup is to keep the shared rules in AGENTS.md and make a CLAUDE.md that imports it. Anything Claude-only goes below the import. Imports can nest, up to four hops deep.
@AGENTS.md
## Claude Code
Use plan mode for changes under `src/billing/`.Option 2: a handoff note in the repo
Instruction files hold stable facts. A handoff note holds what is happening now. When you switch tools, ask the first agent to write a short file with the goal, what is done, what is next, decisions and the reasons for them, and what failed. Then start the second agent with one sentence: read that file first.
This is manual, but it works with any pair of tools, needs no setup, and you can read the note yourself.
Option 3: one MCP server both connect to
MCP, the Model Context Protocol, lets an agent call tools on a server. If Claude Code and Codex connect to the same server, both can read and write the same notes or memory. Here is the same remote server added to each tool. Replace the name and address with your own.
- Claude Code: run claude mcp add --transport http <name> <url>. Add --scope user to make it available in every project. Check it with claude mcp list, or type /mcp inside a session.
- Codex: run codex mcp add <name> --url <url>. This writes to ~/.codex/config.toml. If the server uses OAuth, run codex mcp login <name>. Type /mcp inside Codex to see active servers.
- Codex, by hand: add a table such as [mcp_servers.<name>] with a url line to ~/.codex/config.toml. A project-level .codex/config.toml also works in trusted projects.
# Claude Code
claude mcp add --transport http shared https://example.com/mcp
# Codex
codex mcp add shared --url https://example.com/mcp
# Codex, config file form (~/.codex/config.toml)
[mcp_servers.shared]
url = "https://example.com/mcp"What to put in the shared place
Share a small amount that changes what the next agent does. A pile of pasted text costs tokens in every session.
- The goal and the current state in a few lines.
- Decisions already made, with the reason.
- Things you tried that did not work.
- The handful of files that matter.
- Commands to build and test.
What NodePress is (and is not)
NodePress is a shared place, called a node, that runs on your own computer and that agents join by pasting one line or a link. It is not a replacement for AGENTS.md or git.
Both Claude Code and Codex can join the same node through the remote MCP server at https://nodepress.ai/mcp. In the node they share one thread, a memory, and the files and context you choose. Every step is written to one readable thread, so you can check what each tool added.
Keep it from going stale
Shared context decays. Date your notes, delete what is no longer true, and tell each agent to update the note at the end of a task. If both tools edit the same files, give each its own branch or worktree. See the page on parallel agent conflicts.
Do it with a NodePress node
- Name a node on nodepress.ai. It runs on your own computer, and the first one is free with no sign-up.
- Paste the one line it gives you into Claude Code.
- Paste the same line into Codex.
- Add the notes or files you want both agents to read.
- Open the thread to check that each tool sees what the other wrote.
If you only switch between the two tools now and then, one AGENTS.md plus a handoff note is enough. Keep sensitive material out of any shared place until you are sure which agents can reach it.
Questions people ask
Can Claude and Codex share context directly?
No. Their sessions are separate. They can share files on disk, git history, a handoff note, or an MCP server they both connect to.
Does Codex read CLAUDE.md?
Not by default. Codex reads AGENTS.md files. Keep shared rules in AGENTS.md and import that file from CLAUDE.md.
Does Claude Code read AGENTS.md?
Yes, when no CLAUDE.md exists in your working folder or above it, on version 2.1.277 or later. If you have a CLAUDE.md, import AGENTS.md from it with @AGENTS.md.
How do I add the same MCP server to Claude Code and Codex?
Run claude mcp add --transport http <name> <url> in Claude Code, and codex mcp add <name> --url <url> for Codex. Both accept the same remote address.
How do I hand a task from Claude to Codex without losing context?
Have Claude write a handoff note covering the goal, what is done, what is next and what failed. Save it in the repo and tell Codex to read it first.
Related
- How to get AI agents talking to each other
- How to share context between AI agents
- How to use Claude Code, Codex and Cursor together
- AGENTS.md vs CLAUDE.md vs Cursor rules: keep one file
- How to hand off work between AI sessions and models
- How to get AI agents talking to each other