blog /
Claude Code and Codex Workflow That Actually Works
You pay for Claude Code and Codex and run both on the same repository. The real question is not which one is better. It is how to split the work so the two help instead of overwriting each other. The Claude Code and Codex workflow below gives each agent its own branch and worktree, one shared instructions file, and a review pass in both directions. Nothing here needs an extra platform, and every behavior it relies on is documented by both vendors.
Claude Code and Codex workflow: what actually differs
The failure mode of most two-agent setups is assuming parity. The tools look similar, so people configure them once and expect both to behave the same. They do not. Four areas differ enough to plan around.
First, instruction files. Codex reads AGENTS.md files before doing any work, layering a global file from the Codex home directory with project files found walking from the repository root down to the working directory, at most one file per directory. Claude Code reads CLAUDE.md files, and since version 2.1.277 it also reads AGENTS.md directly, but by default only when no CLAUDE.md or CLAUDE.local.md sits in the working directory or above it.
Second, permissions and sandboxes. Claude Code sets the baseline with a permission mode. Manual mode reads without asking, acceptEdits adds file edits, and dontAsk denies anything that would otherwise prompt, which suits locked-down non-interactive runs. Codex combines a sandbox mode with an approval policy. The Auto preset pairs workspace-write sandboxing with on-request approvals so work inside the working directory runs while edits outside it and network access ask first, and network access stays off by default unless enabled in configuration. Neither tool sees the other's approval.
Third, events and hooks. Claude Code fires hook events including PreToolUse, PostToolUse, PermissionRequest, Stop, and Notification, configured under a hooks key in settings files. Codex organizes hooks the same way, stored in hooks.json or inline in config.toml, with events including PreToolUse, PermissionRequest, PostToolUse, and Stop. A guard script must fail closed on both: a hook that crashes lets the call proceed, so catch errors inside the script and turn them into an explicit block.
Fourth, worktrees. Claude Code can create its own isolated session with the --worktree flag, placing it under .claude/worktrees/ on a new branch and copying gitignored files listed in .worktreeinclude. Codex documents codex exec for non-interactive scripted runs. Underneath both sits plain git: one branch cannot be checked out in two worktrees at once, which is the constraint that keeps two writers apart.
Set up the shared instructions without assuming parity
Keep one shared AGENTS.md at the repository root with the facts both agents need: repository layout, build and test commands, coding conventions, what done means, and the review rules. Put anything Claude specific in CLAUDE.md, and make that file import the shared one as its first line so the shared content loads first:
@AGENTS.md
## Claude Code
Use plan mode for changes under `src/billing/`.
If no Claude specific content exists, a single AGENTS.md and no CLAUDE.md is the simplest setup on current Claude Code versions. When both files must exist, set the Project instructions option to load both files together. On versions before 2.1.277, or in any session where direct AGENTS.md support is unavailable, the @AGENTS.md import is the path that always works.
Confirm what loaded before delegating real work. In Claude Code, run /memory or /context and check that the expected files appear. In Codex, ask it from the repository root to summarize the current instructions and check that global and project files arrive in precedence order.
One shared file also removes a whole class of drift. The moment project rules live in two files with overlapping content, each agent follows a slightly different project, and every disagreement costs a human round trip. For the broader question of when built-in tooling is enough and when a shared layer earns its place, see when native tools are enough and when a cross-vendor layer helps.
Split the work so merges stay boring
Worktrees isolate files, not coordination. Two agents in separate checkouts can still edit separate copies of the same central file and produce an integration conflict, or collide through shared ports, databases, and caches. The split that avoids this is ownership by module boundary, not by turn order.
Before starting either agent, write down three things in a short TASKS.md at the repository root: the contract between the pieces (types, endpoint shapes, function signatures), the files each agent may change, and the exact check that proves each task done. Name one owner per shared file, including lockfiles and configuration, and give the other agent read-only status on it.
Keep each result on its own branch from a known base commit, and let each agent test inside its own checkout. Start both tasks from the same base so later diffs stay comparable. When one agent's output is another's input, hand it off through a file in the repository, not through pasted chat: the first agent writes a short note stating what changed, what the other side needs, and what is unfinished, and the second agent reads that file.
Decide the review direction up front. The cheapest high-value shape for most teams is writer and reviewer: one agent implements, the other checks the result in a fresh session without editing. A reviewer that never saw the implementation reasoning judges the diff on its own terms. For what counts as finished before any merge, the checklist in how to tell whether a coding agent is actually done applies to both branches equally.
Map events, context, and Git state
With the split decided, wire the three things each agent needs: lifecycle events, shared context, and Git state.
| Concern | Claude Code side | Codex side |
|---|---|---|
| Instructions | AGENTS.md, or CLAUDE.md importing it | AGENTS.md layered global then project |
| Non-interactive run | claude -p with piped input, --permission-mode dontAsk for locked-down passes | codex exec for scripted runs |
| Review without editing | claude -p over a piped diff | The documented /review flow, which reports findings without modifying the working tree |
| Gate before edits | PreToolUse hook with an explicit deny | PreToolUse hook with a deny, or PermissionRequest allow or deny |
| Stop signal | Stop hook | Stop hook |
For the review pass, freeze the artifact first. Ask the writer to commit, then point the reviewer at the exact range. In the writer's checkout, pipe the diff into a locked-down Claude Code pass:
git diff main...HEAD | claude -p "Review this diff for correctness bugs. Report each finding as file:line, then one sentence. Do not edit files." --permission-mode dontAsk
Piped stdin is how claude -p consumes outside content, and dontAsk denies anything that would prompt, so the reviewer can read files for context without editing. In the other direction, run the Codex review flow against the same committed range and require file and line references plus the failure mode for each finding.
Keep the reviewer out of the writer's checkout. Either give the reviewer only the committed diff, or give it a second worktree checked out at the candidate commit, since an old checkout produces a confident review of the wrong code. Never let two writers share one directory: in a single checkout both edit the same files on the same branch and their changes land in one diff you cannot split by author afterward.
Test the cross-vendor edge cases
Run through this list before trusting the setup on real work.
Ports and services collide. Worktrees separate files, not the ports your dev servers bind or the databases your migrations touch. Give each worktree its own port and, when tests write data, its own database. Separate local credentials per checkout beat one shared set.
Dependencies and ignored files do not travel. A new worktree holds tracked files only, so install dependencies in each one and copy gitignored files such as .env by hand. Claude Code worktrees pick up patterns from .worktreeinclude automatically; for plain git worktrees, that copy step is yours.
Merge one branch at a time. Read the diff, run the check suite on that branch alone, and merge it through the normal review. Then update the second branch from the base, resolve conflicts, rerun its checks, and merge. Each CLI signs in separately, so configure and update both. For long unattended stretches, Claude Code versus Codex for long-running tasks helps you pick which agent owns the overnight shift.
Two-agent workflow lab
This lab is the original asset for this post: a complete Claude Code and Codex workflow you can run on a practice repository in one sitting. It has seven steps.
- Create the shared instructions. Write
AGENTS.mdwith build, test, and review rules. If aCLAUDE.mdexists, add the@AGENTS.mdimport as its first line. Verify with/memoryin Claude Code and an instructions summary in Codex. - Create one worktree per agent. From a clean checkout, run
git worktree add ../myapp-claude -b claude/taskandgit worktree add ../myapp-codex -b codex/task. Confirm withgit worktree listthat each branch appears exactly once. - Set up each checkout. Install dependencies in both directories, copy the local
.env, and assign different dev server ports. WriteTASKS.mdnaming the contract, the files each agent owns, and the check that proves done. - Start one agent per directory. Launch Claude Code in the first worktree and Codex in the second. Paste each brief, including what to change, what is read-only, and how to verify.
- Freeze and exchange. When the writer commits, pipe its diff into the locked-down reviewer command from the previous section, or run the Codex review flow against the same range. Require file and line references for every finding.
- Fix and retest. Hand accepted findings to the writer, let it fix its own branch, and rerun that branch's checks. Reject vague findings in writing so the next review is sharper.
- Merge in order and clean up. Merge the first branch after reading its diff, update the second from the base, retest, merge, then run
git worktree removeon each finished tree.
Score the lab on three questions: did either agent edit a file it did not own, did any review comment lack a file and line reference, and did the second merge need conflict work you could have prevented with a narrower split. The answers become the task boundaries for the next real assignment.
Keeping both agents visible without babysitting terminals
You can run this entire setup inside qoop. Both agents sit in tabs in one terminal window, and the column beside them shows which one is working, which one is waiting for an answer, and which one has finished, so the two worktrees stop demanding constant tab switching. When an agent gets blocked, fails, or finishes, qoop raises a desktop note naming that agent, and holds the note back while you are already looking at its pane, so brief state flickers do not page you. The same lineup follows you to your phone, where the waiting agent appears first and you can answer it directly.
Give each agent its own checkout with qoop worktree new, which places the tree beside the repository, and remove it with qoop worktree rm when the branch is merged. Removal refuses while a process still works inside or while uncommitted changes remain, which protects a branch mid-review. Detach at any point and both agents keep running; reattaching returns you to the same space, tab, and pane.
Above both agents, qass gets word when an agent stops, then reads the task record together with the plan file and repository rules, settles the steps your rules permit, and turns the remainder into cards you answer with one key. Start it with qoop qass. It never takes the irreversible actions for you: deletion, release, production, money, and anything external always come to you.
Once the lab passes on a practice repository, run it on one real task with a narrow split. If the setup saves more attention than it costs, sign up at https://qoop.si.