---
title: "How to share context between Codex and Claude Code · Cork"
description: "Make Codex and Claude Code work from the same context: one AGENTS.md, shared MCP servers, handoff files, and live awareness when both edit the same repo."
canonical: "https://corkcli.com/blog/share-context-codex-claude-code"
last_updated: "2026-11-14"
published: "2026-10-03"
author: "Kevin Vera"
---

# How to share context between Codex and Claude Code

Make Codex and Claude Code work from the same context: one AGENTS.md, shared MCP servers, handoff files, and live awareness when both edit the same repo.

By Kevin Vera · October 3, 2026 · [Guides](https://corkcli.com/blog/c/guides) · 6 min read

The simplest way to share context between Codex and Claude Code is one `AGENTS.md` at the repository root: Codex reads it natively, and Claude Code reads it when there is no `CLAUDE.md`, or through an `@AGENTS.md` import when there is. Add the same MCP servers to both tools so they reach the same systems, and pass task state through a handoff file in the repo, since the two tools' session histories are separate and not interchangeable. When both agents edit the same repo at once, you also need a way for each to learn what the other just changed.

## Step 1: one AGENTS.md for both tools

As of October 2026, Codex builds its instructions from `AGENTS.md` files. It checks `~/.codex/AGENTS.override.md` and then `~/.codex/AGENTS.md` for global defaults, then walks from the git root down to the current directory, at each level preferring `AGENTS.override.md` over `AGENTS.md`. Files closer to your working directory come later and win. The combined size is capped by `project_doc_max_bytes`, 32 KiB by default.

Claude Code can now read the same file. Its memory docs list the default behavior:

- An `AGENTS.md` and no `CLAUDE.md` or `CLAUDE.local.md`: Claude reads `AGENTS.md` (Claude Code v2.1.277 or later).
- An `AGENTS.md` and a `CLAUDE.md`: Claude reads only the `CLAUDE.md` files, unless you set Project instructions to `claude-md-and-agents-md`.
- A `CLAUDE.md` that imports `AGENTS.md`: Claude reads both, through the import.

The most portable setup keeps shared rules in `AGENTS.md` and Claude-specific notes in a thin `CLAUDE.md`:

```markdown
@AGENTS.md

## Claude Code
Use plan mode for changes under src/billing/.
```

This also works in sessions where Claude Code cannot read `AGENTS.md` directly. A symlink (`ln -s AGENTS.md CLAUDE.md`) is an alternative, but Anthropic recommends the import if anyone on the team uses Windows, where git may check a symlink out as a plain text file.

To go the other way, Codex can read extra filenames through `project_doc_fallback_filenames` in `~/.codex/config.toml`:

```toml
project_doc_fallback_filenames = ["CLAUDE.md"]
```

Codex then checks `CLAUDE.md` in a directory that has no `AGENTS.md`. Keeping one source of truth in `AGENTS.md` is usually cleaner.

## Step 2: give both agents the same MCP servers

Context is not only instructions; it is also the systems an agent can query. Add each MCP server to both tools.

Claude Code, shared with the team through a committed `.mcp.json`:

```bash
claude mcp add --transport http docs --scope project https://mcp.example.com/mcp
```

Codex, in `~/.codex/config.toml` or a project-scoped `.codex/config.toml`:

```bash
codex mcp add docs --url https://mcp.example.com/mcp
```

```toml
[mcp_servers.docs]
url = "https://mcp.example.com/mcp"
```

OpenAI's docs note that the ChatGPT desktop app, Codex CLI and IDE extension share this one configuration. Claude Code's `/import` command (v2.1.213 or later) can also bring another coding agent's configuration, including instruction files and MCP servers, into Claude Code as a one-time copy.

## Step 3: pass task state through a file, not a transcript

Each tool saves its own sessions: Claude Code under `~/.claude/projects/`, Codex under `~/.codex/sessions/`. Claude Code's docs warn that the transcript format "is internal to Claude Code and changes between versions," so do not build a bridge that parses one tool's history into the other.

Instead, have the outgoing agent write a short handoff file:

```text
Write docs/handoff/payments.md for another coding agent: goal, what is done,
files touched, decisions and why, open questions, the exact next step.
```

Then start the other tool with "Read docs/handoff/payments.md and continue." This works in both directions and keeps the context reviewable in a pull request.

## Step 4: when both edit the same repo at once

Running Codex and Claude Code side by side is common: one on a refactor, one on tests or a feature. The tools have no built-in channel to each other. Claude Code's cross-session messaging reaches only Claude Code sessions, and Codex's guidance for parallel chats is to "avoid letting two chats change the same files. Use worktrees to give parallel coding chats separate checkouts."

So the baseline is:

1. Put each agent in its own worktree and branch (`claude --worktree <name>` for Claude Code; a separate `git worktree add` directory for Codex).
2. Assign each agent different files or modules.
3. Before landing either branch, rebase onto the latest main and run the tests, so a rename by one agent that breaks the other's code shows up before it reaches main.

Both tools also support lifecycle hooks (`SessionStart`, `PreToolUse`, `PostToolUse` and others), configured in `.claude/settings.json` for Claude Code and in `hooks.json` or `[hooks]` in `config.toml` for Codex. A shared script, for example one that prints recent commits on session start, can run from both.

## How Cork helps

The steps above share static context. What they cannot share is live context: that the Codex agent renamed a function a minute ago and the Claude Code agent is about to call the old name. Cork is the [coordination layer](https://corkcli.com/blog/coordination-layer-ai-coding-agents) for multiplayer coding agents: it keeps Claude Code, Codex and Cursor agents, on one machine or across a team's machines, from overwriting each other on one codebase, and hands each agent what the others already learned.

For a Codex plus Claude Code setup:

- **One protocol for both tools:** Cork's hooks in Claude Code, Codex and Cursor run the same coordination with no extra model calls, plus an MCP server any MCP client can use.
- **Briefing:** each agent, whichever tool it runs in, is handed the exact signatures, callers and recent changes of the code it is about to touch.
- **Live awareness and [semantic lint](https://corkcli.com/blog/semantic-lint):** a rename or signature change by the Codex agent reaches the Claude Code agent on its next step, and becomes a lint rule both are checked against.
- **[Write gate](https://corkcli.com/blog/write-gate):** an edit against code the other agent is changing right now is held until your agent has their version.
- **Agent messaging and notes:** message the agent working on a given function, and keep durable notes anchored to code with `remember` and `recall`.

Cork Free covers one machine with no account; the paid plan adds teammates' machines. Install once for every repo:

```bash
curl -fsSL https://corkcli.com/install.sh | sh
```

## Frequently asked questions

### Does Claude Code read AGENTS.md?

Yes, as of Claude Code v2.1.277, when the project has no `CLAUDE.md` or `CLAUDE.local.md`. With a `CLAUDE.md`, add an `@AGENTS.md` import or set Project instructions to `claude-md-and-agents-md`.

### Can Codex read CLAUDE.md?

Codex reads `AGENTS.md` by default. Add `CLAUDE.md` to `project_doc_fallback_filenames` in `~/.codex/config.toml` to have it checked where no `AGENTS.md` exists.

### Can I continue a Claude Code session in Codex?

Not directly; the session formats differ. Have the first agent write a handoff file and point the second agent at it.

### Can Codex and Claude Code run on the same repo at the same time?

Yes. Use separate worktrees and file ownership, and rebase plus test before landing. A coordination layer adds live notice of each other's changes.

## Sources

- <https://learn.chatgpt.com/docs/agent-configuration/agents-md>
- <https://learn.chatgpt.com/docs/extend/mcp?surface=cli>
- <https://developers.openai.com/codex/codex-manual.md>
- <https://code.claude.com/docs/en/memory>
- <https://code.claude.com/docs/en/mcp>
- <https://code.claude.com/docs/en/sessions>
- <https://code.claude.com/docs/en/cross-session-messaging>
- <https://code.claude.com/docs/en/hooks-guide>

## Related reading

- [How to run Codex and Claude Code side by side on one project](https://corkcli.com/blog/run-codex-and-claude-code-side-by-side): Run OpenAI Codex CLI and Claude Code on one repo: one AGENTS.md for both, a worktree each, shared MCP servers, matching hooks, and live coordination.
- [How to coordinate Cursor and Claude Code on the same codebase](https://corkcli.com/blog/coordinate-cursor-and-claude-code-same-codebase): Run Cursor and Claude Code on one repo without clobbered edits: shared AGENTS.md instructions, worktrees, shared MCP servers, hooks, and a coordination layer.
- [How to hand work from one AI coding agent to another](https://corkcli.com/blog/hand-off-work-between-ai-coding-agents): Hand off work between AI coding agents without losing context: commit, write a handoff note, resume or fork sessions in Claude Code and Codex, and verify first.
- [How to share context between Claude Code sessions](https://corkcli.com/blog/share-context-between-claude-code-sessions): Six ways to carry context between Claude Code sessions: CLAUDE.md, auto memory, handoff files, resume and fork, cross-session messaging, SessionStart hooks.

[All articles](https://corkcli.com/blog.md) · [Cork in Markdown](https://corkcli.com/index.md) · [llms.txt](https://corkcli.com/llms.txt)

This page in HTML: https://corkcli.com/blog/share-context-codex-claude-code
