Blog · Guide · 27 November 2026

Claude Code and Codex Together on the Same Repository

To run Claude Code and Codex together on one repository, give each its own checkout (a git worktree or a separate clone), decide which files each one owns before they start, and check that their changes merge before either one stops. Both agents support hooks with nearly the same events, so one coordination layer can refuse an edit to a file the other agent owns, pass messages and patches between them, and hold an agent at the end of its turn until its work merges with its peer's. This guide sets that up step by step.

Why run Claude Code and Codex together, and what breaks

Mixed setups are common for ordinary reasons. Simon Willison wrote in October 2025 that his daily drivers were Claude Code and Codex CLI, used in parallel. Teams end up with both because different people prefer different agents, because one is better at a given kind of task, or because one person's subscription ran out at 4 pm.

What breaks is the same as with any two agents, plus a little more:

  • Two writers, one working tree. If both run in the same directory, each one's uncommitted edits leak into the other's builds and tests, and a git add -A commits the other's work.
  • The same file from two sides. Each agent edits router.ts in its own checkout; the conflict appears only at merge.
  • No shared view. Claude Code does not know what Codex decided, and neither tells you what the other is doing.
  • Different edit shapes. Codex edits files through apply_patch, so a tool that watches for Claude's Edit and Write tools misses Codex's changes.

Step 1: separate checkouts

Give each agent its own working directory. With Claude Code:

claude --worktree billing-refactor

Claude Code's docs say this creates the worktree under .claude/worktrees/billing-refactor/ on a new branch named worktree-billing-refactor. For Codex, create one yourself:

git worktree add ../app-codex -b codex/search
cd ../app-codex && codex

A worktree isolates files, not ports or databases; the worktree setup guide covers those. Separate checkouts stop the agents trampling each other's working tree, but they also hide the overlap until merge time. That is what the next steps fix.

Step 2: one owner per file

Before they start, split the work by files: Claude Code takes src/billing/, Codex takes src/search/. Shared files (the router, the package manifest, a registry) go to one of them. Say it in both prompts.

Prompts are advice. A claim is enforced. With Forkit, an agent claims paths for a time (30 minutes by default, at most 4 hours); a pattern that overlaps another agent's exclusive claim is refused, with the holder's name and expiry, and both agents are told. The hook's PreToolUse check then denies an edit under another agent's exclusive claim before it happens. Claims expire rather than lock, are renewed while the agent keeps working, and are released when its session ends. More in file locking for AI agents.

Step 3: connect both agents

One command connects both:

npx forkit-cli init

It signs you in, creates one API key per agent it finds on your PATH (the key's name is the agent's name), adds Forkit's hooks to ~/.claude/settings.json, and for Codex 0.133 or later writes ~/.codex/hooks.json with SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PermissionRequest, Stop and SessionEnd. Backups are made first.

Codex then needs one manual step. Its documentation says "Non-managed hooks must be reviewed and trusted before they run": open Codex and run /hooks once to trust them. Trust is tied to each hook's hash, so a changed hook asks again.

From then on both agents' sessions appear as threads in one workspace: what each was asked, the commands it ran, the files it changed, and any question it is waiting on.

Step 4: let them talk, briefly

Two agents that split the work still need to agree on things: the shape of a function, who adds the shared import. Forkit's messages between agents are typed, not chat:

Type Use
question Ask the other agent something (one open question per sender)
answer Reply to that question (only its recipient may answer, once)
handoff A finished result for a planner
notice A note on a topic, read on demand

Messages reach a running agent after its next tool call or at the end of its turn, through the hooks. The server enforces limits: 30 messages a minute per session, a repeat within 60 seconds dropped, and 20 messages between a pair of agents before a person has to write on one of their threads. A question nobody answers within 2 minutes goes to a person. Two agents cannot talk each other into a loop for an afternoon.

A message from another agent is never treated as a person: it cannot approve a review, answer a permission request or close a thread.

Step 5: hand work across as a patch

Sometimes they agree that one agent should make both edits to a shared file. The other then needs that change itself, not a description. One agent sends its change since HEAD as a patch on a message:

forkit share --to codex -m "Both validators are in; please take this and drop yours" -- src/validate.ts

The other applies it:

forkit apply MESSAGE_ID --check   # does it apply cleanly?
forkit apply MESSAGE_ID --replace # theirs over my own change to those files

--replace keeps the agent's own change to those files in .git/forkit/<id>-mine.patch, restores them as at HEAD, and applies the peer's. Without it, agents tend to refuse to discard their own edits unasked. A patch that writes agent or CI settings (.claude/, .github/, CLAUDE.md and similar) is refused unless given --allow-config. Sharing patches between agents has the background.

Step 6: check the merge before either stops

The last step catches what the plan missed. In a fan-out (a group of agents started together with short-lived keys), each agent sends its change since the commit it started from, and Forkit compares it with every peer's the way git's merge does: changes to the same or adjacent base lines conflict unless identical. The check compares agents of the same fan-out, so for two agents you start by hand, give them keys from one fan-out (forkit fanout create --name billing --agents 2 prints two keys; set FORKIT_API_KEY in each terminal) rather than your personal keys. Run it by hand with forkit check-merge (exit 0 clean, 1 conflict, 2 could not check), or let the Stop hook ask for you: it holds the agent at the end of its turn, says where and with whom it conflicts, and waits a while for peers that have not checked in yet. Hard caps (14 minutes of waiting, 10 holds by default) stop a stuck peer from holding an agent forever.

Checked against the merges recorded in CooperBench runs, the check agreed with git on every merge tested, 37 of 37. See checking agent work will merge.

What differs between the two agents

Claude Code Codex
Hooks file ~/.claude/settings.json ~/.codex/hooks.json
Trust step Workspace trust /hooks once, re-asked on change
Edits arrive as Edit, Write, MultiEdit apply_patch (files read from the patch)
Permission prompts to a remote queue Yes (PermissionRequest) Yes (PermissionRequest)
Receives messages Yes, through hooks Through hooks; not if connected only through the older notify line

Two caveats. A Codex session connected only through notify reports but cannot receive messages; the thread page says so under the reply box. And in the one production run with real agents (17 Nov 2026, Claude Code and Codex 0.160.1), sessions, commands, changed files, messages and questions all arrived, but Codex's hook trust was bypassed with its flag, so the /hooks step itself has not been exercised.

When not to bother

If the two agents work on different repositories, or one reviews the other's pull request after the fact, none of this is needed. It is also overkill for one sequential task in the same files, where a single session avoids the overlap altogether. Run both agents together when the work splits by files and you want it done in one sitting. For a broader look at running several sessions, see how to run Claude Code in parallel and the Codex hooks guide.

Checklist

  • A separate checkout per agent.
  • Files split by owner, shared files assigned.
  • npx forkit-cli init, then /hooks in Codex.
  • Claims made before editing.
  • Patches, not descriptions, when one agent does both edits.
  • forkit check-merge (or the Stop hook) before either stops.

Forkit has a Free plan; Pro is $20 a month and Team $40 per seat a month, billed per person, never per agent. More at forkit-mcp.com.

Sources

Read on 27 Nov 2026: