Claude Code and Codex on the same repo: a division of labor that works
How to run Claude Code and Codex together on one codebase: who plans, who builds, who reviews, how they hand off, and how to stop them colliding.
You can run Claude Code and OpenAI Codex on the same repository, and it is worth doing, because a second model catches mistakes the first one makes. The setup that works has three rules: one agent writes at a time per working folder, every handoff goes through a file rather than your memory, and the reviewer is never the author. The rest of this guide is how to put those rules into practice.
Why use two agents at all
A single model reviewing its own work tends to approve it. It made the same assumptions when it wrote the code that it brings to the review. A different model, from a different vendor, with a fresh context, does not share those assumptions.
This matters more as you delegate more. Anthropic's study of agent autonomy found that new users fully auto-approve about 20 percent of sessions, and that rises above 40 percent with experience (Measuring AI agent autonomy, February 2026). The more you let run without reading every step, the more an independent check is worth.
Three ways to split the work
| Pattern | How it works | Best for |
|---|---|---|
| Builder and reviewer | One agent implements, the other reviews the diff and runs the tests | Everyday feature work |
| Planner and builder | One agent writes the plan and acceptance criteria, the other implements against it | Larger changes where a wrong design is expensive |
| Parallel attempts | Both implement the same task in separate worktrees, you keep the better one | Hard problems with more than one reasonable approach |
Start with builder and reviewer. It adds the least process and catches the most.
Rule 1: one writer per working folder
Two agents editing the same files at the same moment produce half-applied changes that neither understands. Pick one of these:
- Take turns. The builder finishes and commits. Only then does the reviewer start, in the same folder, with instructions to read and test but not edit.
- Separate worktrees. Each agent gets its own folder and branch. This is required for parallel attempts. On Windows there are specific traps, covered in Git worktrees for AI coding agents on Windows.
Rule 2: hand off through a file
The weak point of any two-agent setup is you, carrying context from one window to the other by copy and paste. Replace that with a handoff file in the repository that both agents read and update.
# HANDOFF.md
## Task
Add rate limiting to the public API (ticket 142).
## Plan (planner)
1. Token bucket per API key, limits in config
2. Return 429 with a Retry-After header
3. Tests for burst, refill, and missing key
## Done (builder)
- Steps 1 and 2 implemented in src/middleware/rate-limit.ts
- Step 3: burst and refill tests pass. Missing-key test not written yet
## Review notes (reviewer)
- Retry-After is in milliseconds, should be seconds
The prompt for each agent then becomes short: "Read HANDOFF.md, do your part, update your section." The file also survives a closed terminal, which your short-term memory does not.
Rule 3: the reviewer does not edit
Tell the reviewing agent to report findings, not to fix them. If the reviewer rewrites the code, you no longer have a review, you have a second author and nobody checking either. A good review prompt:
Review the diff on this branch against the plan in HANDOFF.md. Run the tests. List each problem with file and line. Do not change any files.
Then give the findings back to the builder. Two rounds is usually enough. If they are still disagreeing on round three, the disagreement is a design question for you.
Keep one set of rules for both
Claude Code reads CLAUDE.md. Codex reads AGENTS.md. If your conventions live in only one, the other agent will not follow them. Keep both files carrying the same project rules. We cover the options in One set of rules for Claude Code, Codex and Antigravity.
What goes wrong
- Both agents think they own the branch. Fix: name the roles in the first line of each prompt.
- The reviewer approves without running anything. Fix: ask for the test command's actual output in the review.
- Usage limits. Two agents use two subscriptions' worth of quota, and parallel sessions burn it faster. Rate limits are the most-discussed complaint in both tools' issue trackers. Use the second agent for review, where it reads more than it writes.
- You lose track of which window is waiting. See Knowing which agent session needs you.
Doing this in CPLai
CPLai's Terminal puts a Claude Code session, a Codex session and a plain shell in one window as columns, so builder, reviewer and test runner sit side by side. A tab flags itself when its session asks for input. CPLai also writes the same managed project block into CLAUDE.md and AGENTS.md, which takes care of the shared-rules problem (Agent Memory Files).
For the third pattern, Parallel runs two to five agents on one task, each in its own worktree, and lets you compare results before applying one. For a design question rather than code, Council asks several models the same question and has them critique each other. Council does not implement anything. It gives you a second and third opinion before you commit to an approach.
Sources
- Measuring AI agent autonomy in practice, Anthropic, February 18, 2026
- Claude Code worktrees, Anthropic, read November 2026
- Codex agent approvals and security, OpenAI, read November 2026