Can Claude Code and Codex work in the same repo
On this page
  1. Why not just open both in the same folder?
  2. How do I give each agent its own worktree?
  3. How do I stop them doing the same task?
  4. Which files cause most collisions?
  5. How do I merge their work?
  6. What changes when two people run them?
  7. Frequently asked questions
  8. Can Claude Code and Codex share one branch?
  9. Do git worktrees prevent merge conflicts?
  10. Does Codex read CLAUDE.md?
  11. How many agents can work in one repository?
  12. Try it with your team

Guides

Can Claude Code and Codex work in the same repo?

Yes, with one worktree and branch per agent, one owner per task and shared rules in AGENTS.md. The commands, the files that collide, and how to merge.

Yes. Claude Code and Codex can work in the same repository at the same time, as long as each one has its own git worktree on its own branch, each task has one owner, and both read the same rules from AGENTS.md. What goes wrong is two agents in one folder on one branch: they overwrite each other's files and mix their changes into one diff. A worktree per agent fixes the files, and a claim per task fixes the duplicated work.

Why not just open both in the same folder?#

Because both agents write to the same working tree. Claude Code edits src/api.ts, Codex rewrites the same file a minute later from the version it read earlier, and one set of changes disappears. Even when they touch different files, git status shows one pile of changes from two agents, and you cannot review or revert one without the other. Tests get confusing too: a failure may come from the other agent's half-finished edit.

How do I give each agent its own worktree?#

A worktree is a second checkout of the same repository, in another folder, on another branch. It shares the history, so it costs almost nothing.

bash
cd ~/code/shop
git worktree add ../shop-claude -b claude/csv-export
git worktree add ../shop-codex -b codex/refund-emails
git worktree list

Then start each agent in its own folder:

bash
cd ../shop-claude && claude
cd ../shop-codex && codex

Each folder needs its own dependencies and its own environment file, because untracked files are not copied:

bash
cd ../shop-codex
cp ../shop/.env .env
npm ci

If both run a dev server, give them different ports. When the work is merged, remove the worktree so old folders do not pile up:

bash
git worktree remove ../shop-codex
git branch -d codex/refund-emails

Running parallel Claude Code sessions goes deeper on worktrees, including how many sessions are worth running at once.

How do I stop them doing the same task?#

Worktrees keep files apart. They do nothing about two agents picking the same job. The fix is a claim before any code is written, kept somewhere both agents read. A small TASKS.md on the main branch is enough for one person:

md
## Tasks
- [ ] CSV export for orders (claimed: claude, branch claude/csv-export)
- [ ] Refund confirmation emails (claimed: codex, branch codex/refund-emails)
- [ ] Audit the checkout page for accessibility (unclaimed)

And the rule, in AGENTS.md, so both agents follow it:

md
## Working with other agents
- Before starting, read TASKS.md. Take only an unclaimed task.
- Write your name and branch on it, commit, then start.
- Stay inside the files your task needs. If you must change a shared
  file (routes, schema, package.json), say so in TASKS.md first.

Claude Code reads CLAUDE.md, so add a CLAUDE.md that imports the rules with the line @AGENTS.md. Sharing context between Claude Code and Codex shows the file layout.

Which files cause most collisions?#

The same few, in almost every project:

FileWhy both agents touch itWhat helps
package.json, lockfilesBoth add a dependencyOne agent adds dependencies; the other asks
Route tables, navigationEvery feature registers itselfAdd entries at the end; merge often
Database schema, migrationsTwo features need new columnsOne migration owner per day
Shared typesAn API shape changesWrite the decision down before coding
Test fixturesBoth add sample dataSeparate fixture files per feature

Git catches overlapping lines. It does not catch two agents making different assumptions about the same function. Stopping agents from editing the same files covers those quieter conflicts and the instructions that prevent them.

How do I merge their work?#

Through pull requests, one per branch, like any two developers:

bash
cd ../shop-claude
git push -u origin claude/csv-export
gh pr create --fill --draft

Merge the smaller change first, then rebase the other branch on main and run the tests again before it merges. A cross-review helps here: ask Codex to review Claude Code's pull request and the other way round. A reviewer with no memory of writing the code is the main reason to run two agents.

What changes when two people run them?#

On one computer, you are the coordinator. You see both terminals, and TASKS.md is a file on your disk. When Claude Code runs on your laptop and Codex runs on a teammate's, the claims only meet after a push and a pull, and two agents can take the same task within the same minute.

Joxo moves the claim out of a file. Each person pastes one line into their own agent, and the agents share a task board where only one agent can hold a task: a second claim is refused, and that agent is told who has it. A decision one agent publishes reaches the other agent on its next turn, and a handoff carries the branch and the commit. The worktrees and pull requests stay exactly as above. How to use Claude Code and Codex together compares this with the other setups, and the setup page has the line for each agent.

Frequently asked questions#

Can Claude Code and Codex share one branch?#

They can, but only one should be editing at a time. Two agents writing to one branch in one folder overwrite each other's changes. If they must share a branch, hand over explicitly: the first agent commits and pushes, then the second pulls and continues.

Do git worktrees prevent merge conflicts?#

No. Worktrees stop two agents from overwriting each other's files while they work. The branches can still conflict when you merge. Claiming tasks up front and keeping each agent inside the files its task needs makes conflicts rarer and smaller.

Does Codex read CLAUDE.md?#

No. Codex reads AGENTS.md. To give both agents the same rules, keep them in AGENTS.md and make CLAUDE.md import it with the line @AGENTS.md, which Claude Code expands when a session starts.

How many agents can work in one repository?#

As many as you can review. Each extra agent adds a branch to merge and a diff to read. Two or three parallel tasks are a common ceiling for one person; a team can run more because each person reviews their own agent's work.