# Use Claude Code and Codex together: one instructions file, a worktree each, and handing work across

*Run Claude Code and Codex on one project: an AGENTS.md both read, a worktree each, OpenAI's Codex plugin for Claude Code, and two separate usage limits.*

Dmitriy Solodukha, checked 2026-11-27 · https://caprock.dev/guides/claude-code-and-codex-together/

Keep one instructions file both agents read — `AGENTS.md`, which Codex
reads and Claude Code reads too — give each agent its own git worktree, and
hand work across with OpenAI's Codex plugin for Claude Code
(`/codex:review`, `/codex:rescue`). The two draw on separate usage limits,
Anthropic's and OpenAI's, so when one runs out the other usually has room.

**In short**
- **Instructions:** rules in `AGENTS.md`; `CLAUDE.md` is one line,
  `@AGENTS.md`, plus anything only Claude needs.
- **Isolation:** `claude --worktree <name>` and `codex exec --worktree`, never
  one checkout for both.
- **Hand-off:** `/plugin install codex@openai-codex` in Claude Code.
- **What Caprock adds:** both in one window with both plan windows, and a
  session continued in the other agent.

## One instructions file for both

*What each agent reads, from Anthropic's memory docs and OpenAI's AGENTS.md docs, read 27 November 2026.*

| File | Claude Code | Codex |
| --- | --- | --- |
| `CLAUDE.md` | yes | only if listed in `project_doc_fallback_filenames` |
| `AGENTS.md` | from v2.1.277, when there is no `CLAUDE.md`; always through `@AGENTS.md` or the *Project instructions* setting | yes |
| `AGENTS.override.md` | no | yes, before `AGENTS.md` |

Write the project's rules — commands, conventions, what not to touch — in
`AGENTS.md`. If you also need a `CLAUDE.md`, start it with the import so
both agents read the same rules:

```
@AGENTS.md

# Claude only
- Use the test-runner subagent for the integration suite.
```

Codex reads at most one instructions file a folder, from the repository root
down to where it runs, 32 KiB in all by default; Claude Code follows imports
up to four levels deep. What belongs in the file:
[CLAUDE.md](https://caprock.dev/guides/claude-md/).

## Give each agent its own worktree

Two agents editing one checkout overwrite each other's work and confuse each
other's view of the tree. A git worktree each keeps them apart:

- **Claude Code:** `claude --worktree feature-a` makes
  `.claude/worktrees/feature-a/` on a branch `worktree-feature-a`. A
  `.worktreeinclude` file copies gitignored files such as `.env`.
- **Codex CLI:** `codex exec --worktree "…"`, `codex fork <id> --worktree`,
  or `/worktree` in the terminal UI.
- **The Codex app** puts its worktrees under `$CODEX_HOME/worktrees` on a
  detached HEAD and keeps the 15 most recent; create a branch before you
  push.

Setup, cleanup and the base branch: [Claude Code
worktrees](https://caprock.dev/guides/claude-code-worktrees/).

## Hand work from Claude Code to Codex

OpenAI publishes a Claude Code plugin (Apache-2.0) that calls Codex from
inside a Claude Code session:

1. /plugin marketplace add openai/codex-plugin-cc: `undefined`
2. /plugin install codex@openai-codex: `undefined`
3. /reload-plugins: `undefined`
4. /codex:setup: `undefined`

- **`/codex:review`** — a read-only Codex review of your changes, against a
  base with `--base <ref>`; `/codex:adversarial-review` argues against them.
- **`/codex:rescue`** — hands a task to Codex through a subagent, in the
  background if you ask.
- **`/codex:transfer`** — turns the Claude session into a Codex thread and
  prints the `codex resume` command to open it.

It needs a ChatGPT plan (Free included) or an OpenAI API key, and Node 18.18
or later; what it does counts against your Codex limits. Older posts add
Codex to Claude Code as an MCP server with `codex mcp-server`: OpenAI has
removed it.

## The other direction, and plain files

No plugin goes from Codex to Claude Code. The plain way works both ways: one
agent writes its plan to a file in the repository, the other is told to read
it. A plan in a file survives either agent's context compaction, and you can
read it before anything runs.

## Two usage limits, not one

- **Claude:** Pro and Max have a 5-hour and a weekly limit, shared between
  claude.ai and Claude Code.
- **Codex:** Plus and Business have a 5-hour limit, weekly limits may also
  apply, and Pro currently has no 5-hour limit; they are shared with your
  ChatGPT plan's other uses.

So running both is also how people keep working when one stops. Prices and
what each cost on one machine: [Codex vs Claude Code](https://caprock.dev/guides/codex-vs-claude-code/).

## What Caprock adds: both agents in one window

Caprock is a free, open-source desktop app for macOS, Windows and Linux that
runs Claude Code, Codex, OpenCode and Gemini CLI in real terminal tabs:

- **Side by side.** Up to four panes a tab; *New agent* or the palette starts
  an agent in a new worktree when you choose.
- **Two sessions, one checkout.** When two live sessions work in the same
  folder, a chip says so, turns amber once files are touched by both, and
  offers *Move to a worktree…*.
- **Continue in the other agent.** *Continue in…* starts Codex (or Claude
  Code, OpenCode, Gemini CLI) in the same folder with a summary of the
  session as its first message; you read and edit it before anything is
  sent.
- **Which one has room.** Claude's and Codex's 5-hour and weekly windows on
  two matching cards.
- **What each cost.** Both priced at list price per repository, the sessions
  you start in your own terminal included.

What it does not do: route a task to an agent on its own. You pick the agent;
Caprock shows the windows and the cost.

## Which setup to use

- **AGENTS.md and two terminals** — you switch now and then; nothing to
  install.
- **The Codex plugin** — Claude Code is your main agent and you want Codex's
  review or a second pair of hands from inside it.
- **Caprock** — you run both every day and want them, their limits and their
  cost in one window.

## Sources

- [Claude Code docs — How Claude remembers your project: AGENTS.md, @imports, read 27 November 2026](https://code.claude.com/docs/en/memory)
- [OpenAI — Custom instructions with AGENTS.md: discovery order, project_doc_fallback_filenames, read 27 November 2026](https://learn.chatgpt.com/docs/agent-configuration/agents-md)
- [openai/codex-plugin-cc on GitHub (Apache-2.0): Codex plugin for Claude Code, read 27 November 2026](https://github.com/openai/codex-plugin-cc)
- [OpenAI — Codex CLI reference: --worktree, the removed mcp-server, read 27 November 2026](https://developers.openai.com/codex/cli/reference.md)
- [OpenAI — Codex app: Git worktrees, read 27 November 2026](https://learn.chatgpt.com/docs/environments/git-worktrees)
- [Claude Code docs — Worktrees: --worktree, .worktreeinclude, read 27 November 2026](https://code.claude.com/docs/en/worktrees)
- [Claude Help Center — Using Claude Code with your Pro or Max plan: five-hour and weekly limits, read 27 November 2026](https://support.claude.com/en/articles/11145838-using-claude-code-with-your-pro-or-max-plan)
- [OpenAI — Codex pricing and limits, read 27 November 2026](https://learn.chatgpt.com/docs/pricing)
- [Caprock CHANGELOG — 0.63.0 Codex plan limits, 0.70.0 Continue in another agent, 0.78.0 split panes, 0.116.0 files touched by both](https://github.com/dspv/caprock/blob/master/CHANGELOG.md)
