- A practical guide to running Claude Code and Codex simultaneously on the same repo without conflicts, using Git Worktrees, separate branches, and commit/pull sync.
Yes, you can run Claude Code and Codex in parallel on the same repo and give each one a separate task without them overwriting each other's work. The right way to do it is Git Worktrees: a separate working directory and branch for each agent, both sharing the same Git history. But there is no real-time sync between them: handoffs happen only through commit, merge, and pull, not on their own.
In short
| Question | Short answer |
|---|---|
| Can they work in parallel on the same repo? | Yes, with a Git Worktree per agent: separate directory and branch, shared history. |
| Do they see each other's changes in real time? | No. Only after a commit followed by an explicit merge, rebase, or pull. |
| Are worktrees required? | Not strictly, but they are the easiest and recommended approach. A separate clone also works, just heavier. |
| How do you prevent file conflicts? | Each agent writes only inside its own worktree. The main checkout stays off-limits. |
| How does one agent continue from where the other stopped? | Merge the branch into main, then fetch and merge or rebase in the other agent's worktree. |
What Git Worktree actually is
A worktree is an additional working directory of the same repo, with its own files and branch, but sharing the same history and the same object store. Instead of cloning the entire repo again every time you want to work on two things in parallel, you open a second directory that points to the same .git, without duplicating disk space and without losing history.
The practical result: one agent can build a feature in one directory while a second agent fixes a bug in another, and both are working on the same repo without seeing each other's open files.
Claude Code and Codex: built-in worktree support
Neither tool requires you to run git worktree manually anymore. Each has a built-in way to create a worktree directly from within the tool.
| Aspect | Claude Code | Codex |
|---|---|---|
| How to open | claude --worktree <name> in the terminal | Select "Worktree" in the new-chat composer |
| Starting branch | The repo's default branch, unless configured otherwise | Choose an existing branch, including the current branch with uncommitted changes |
| Where it is saved | .claude/worktrees/<name>/ in the repo root | $CODEX_HOME/worktrees |
| Branch state | A new branch named worktree-<name> | Detached HEAD, not a regular branch |
| Cleanup | Periodic sweep, with a prompt before deletion if there is work inside | Keeps roughly 15 worktrees by default and deletes the oldest ones automatically |
One important limitation that comes from Git itself and applies to both tools: you cannot check out the same branch in two worktrees at the same time. This is not a Claude Code or Codex restriction, it is core Git behavior, and it is exactly what prevents two agents from "fighting" over the same branch without anyone asking for that (Anthropic, Worktrees documentation) (OpenAI, Worktrees in Codex documentation) (both checked on 2026-09-28).
Do they see in real time what the other changed?
The short answer is no, and it also depends on where each one is running. There are two completely different scenarios here:
- Both agents run locally, as worktrees of the same repo on the same machine. In this case they share the same
.git, so the moment one agent runsgit commit, that commit is already in the shared history and can be seen withgit logfrom any other worktree of the same repo, without a push or a fetch. But that does not mean the files in the second agent's working directory have updated: they will only update after an explicitmergeorrebase. - Codex runs in a separate cloud environment (as in Codex Cloud tasks). In this case there is no local
.gitsharing at all, and the only sync path goes through a push to the remote (such as GitHub) and a pull from it.
In both scenarios the conclusion is the same: none of these tools "listens" to the other by default. If you want one agent to know that something happened on the other side, you have to tell it, either by running git fetch yourself or through a coordination file. Claude Code also has an internal mechanism called cross-session messaging for passing findings between Claude Code sessions, but it does not bridge Claude Code and Codex, because those are two products from two different vendors.
How to sync between them: through commit and pull, not through magic
This is the practical process for setting up two working environments on the same repo, one per agent:
- Open a worktree for Claude Code from the main repo root:
claude --worktree feature-a. Claude Code creates a directory under.claude/worktrees/feature-aand a new branch namedworktree-feature-a, and you can give it the first task. - Open a worktree for Codex in the terminal or a separate window:
git worktree add -b codex-task-b ../myapp-codex-b main, thencd ../myapp-codex-band run Codex there. You can also do this through the Codex composer by selecting "Worktree", if you are working through the app. - Ask each agent to do its work and commit on its own inside its worktree:
git add -A && git commit -m "...". This is compatible with Claude Code's sandbox protections, becausegit commitwrites to the shared.gitand not to the main checkout. - When one agent finishes a task, go back to the main checkout and run
git merge worktree-feature-a(or open a pull request if you are working through a shared remote like GitHub). - Before the second agent continues, run
git fetchinside its worktree and thengit merge mainorgit rebase main, so it actually sees what was merged. - When work is done, remove the old worktree:
git worktree remove ../myapp-codex-b, so stale open directories do not pile up.
How to have one agent continue from where the other left off
There is no "continue automatically" button. What actually works in practice: before handing a task from one agent to another, make sure the merged branch is at the base of the new worktree. When you set up a new worktree with a base branch of head instead of the default branch, it will start from the already-existing unmerged work rather than from the old main branch. This is useful when you want the second agent to continue directly on top of what the first one already wrote, without waiting for a full merge into main.
Using one agent to review and fix the other's work
This is exactly the situation where the "you cannot check out the same branch twice" rule can get in the way, and there is a simple workaround: open a third worktree in detached HEAD mode, pointed directly at the commit you want to inspect, not at the branch name itself. That way you can give the second agent access to exactly that point in history without conflicting with the branch the first agent still has open. This is precisely the approach Codex itself uses by default when you open a new worktree through the app.
In practice, you give it something like "review the changes in this diff against main, run the tests, and fix anything that broke," and you get a second agent doing a real code review, fixes included, on work that another agent wrote, without touching the original branch.
AGENTS.md: the shared briefing file that prevents some of the conflicts
Since September 21, 2026, if there is no CLAUDE.md file in the directory, Claude Code will check for and read an AGENTS.md file instead, a standard that Codex itself helped popularize. The practical implication: you can write one briefing document, "who works on what," "which files not to touch right now," "which test commands to run before committing," and place it in the repo root so both agents read it, each at the start of its own session, without writing two separate instruction documents (announcement coverage, InfoWorld) (checked on 2026-09-28).
This does not replace Git-based sync, but it greatly reduces the chance that both agents start working on the same file at the same time without knowing it, because both read the same "who does what" list before they touch any code.
Common mistakes that lead to conflicts
- Giving both agents the same main checkout to work in, with no worktree at all. This is the fastest path to a file getting overwritten mid-write.
- Assuming a merge will happen on its own. It will not. Someone, you or the agent, has to actually run
mergeorrebase. - Forgetting untracked files like
.env. A new worktree is a clean checkout, and a file like.envwill not appear in it automatically unless a.worktreeincludehas been configured in the repo root. - Leaving old worktrees open. They take up space and create confusion when you try to figure out which agent is working where, so it is worth running
git worktree listoccasionally and cleaning up. - Expecting to see changes "in real time". As explained above, visibility between agents depends on an explicit commit, not on magic.
The bottom line
The answer to the original question is yes, you can turn Claude Code and Codex into two AI developers working in parallel on the same repo, but the coordination between them does not happen on its own. Git Worktrees give each one its own directory and branch so they do not overwrite files, and commit, merge, and pull are the actual coordination mechanism, not a suggestion. A shared AGENTS.md file adds another coordination layer, so both agents know who is working on what before they touch any code.
If you are just getting started with Codex and want to understand first how to hand it a task and check what came back, before bringing a second agent into the picture, you will find that in the interactive OpenAI Codex 2026 course for 9.90 ILS.
For further reading: What is OpenAI Codex? The complete guide, How to work with Claude Code, a practical guide for beginners, and Claude Code vs. Antigravity, which is better when you already have an existing subscription.
Sources
- Anthropic, official documentation: Run parallel sessions with worktrees (checked on 2026-09-28)
- Anthropic, official documentation: Cross-session messaging (checked on 2026-09-28)
- OpenAI, official documentation: Worktrees in Codex (checked on 2026-09-28)
- OpenAI, official documentation: Codex pricing (checked on 2026-09-28)
- InfoWorld: Claude Code now also accepts instructions in OpenAI's Agents.md format (checked on 2026-09-28)
- Git, official documentation: git-worktree (checked on 2026-09-28)
