How to Run Claude Code and Codex Side by Side on One Project
Run Claude Code and Codex side by side on one repo using two git worktrees. Free setup, plus plan costs and fixes for common errors.
Quick answer: Give each tool its own git worktree, then start Claude Code in one terminal and Codex in another. Free? The method is free, but each tool needs its own plan or API key.
A git worktree is a second folder for the same repository, with its own branch. Claude Code's docs say each session in its own worktree gets a separate copy of the files, so one session can build a feature while another fixes a bug. The same idea works for Codex, using plain git.
This guide covers the terminal versions of both tools. Last checked against vendor docs: 16 October 2026.
What do you need before you start?
You need a git repository, a terminal, and a sign-in for each tool. Without git, worktrees do not work: Claude Code's docs say they require a git repository.
- Claude Code: a Claude Pro, Max, Team or Enterprise plan, or a Claude Console account, per the quickstart. Install on macOS, Linux or WSL with
curl -fsSL https://claude.ai/install.sh | bash, then check withclaude --version. Our Claude Code install guide covers Windows too. - Codex CLI: a ChatGPT plan or an API key. On macOS or Linux, OpenAI's docs give
curl -fsSL https://chatgpt.com/codex/install.sh | sh, and the same page has Windows, npm and Homebrew tabs. Runcodexin a project folder and choose Sign in with ChatGPT. See our beginner guide to OpenAI Codex for more. - Git: installed, with your project already committed to a repository.
One billing trap: if the ANTHROPIC_API_KEY environment variable is set, Anthropic says Claude Code uses that key instead of your subscription, which causes API charges.
How do you run Claude Code and Codex side by side? (Method 1: two terminals, two worktrees)
Open two terminals in the same repository. Start Claude Code with claude --worktree <name> in the first, and create a git worktree for Codex in the second. Each agent then edits its own folder and its own branch.
- Open your repository in a terminal. Run
git statusand make sure your work is committed. - Add this line to your
.gitignorefile:.claude/worktrees/. The Claude Code docs recommend it so worktree files do not show up as untracked in your main checkout. - If you have never run Claude Code in this folder, run
claudeonce and accept the trust dialog, then exit. The docs say--worktreeexits with an error otherwise. - In Terminal 1, start Claude Code in a worktree:
claude --worktree claude-task
By default this creates .claude/worktrees/claude-task/ on a new branch named worktree-claude-task.
- In Terminal 2, create a worktree for Codex. The path sits outside your repo folder so the two do not mix. Replace
myrepowith your folder name:
git worktree add -b codex-task ../myrepo-codex-task main
cd ../myrepo-codex-task
codex
The -b codex-task part creates a new branch. Naming main at the end starts it from main, which matches Claude Code's default starting point (explained below). Change main if your default branch has another name.
6. Give each agent a different job, ideally touching different files. For example, ask Claude Code to write a feature and ask Codex to add tests for a different module.
7. When both finish, review each diff, commit on each branch, and merge the branches one at a time into main.
8. Clean up. Run git worktree list to see what exists. Remove the Codex one with git worktree remove ../myrepo-codex-task. Claude Code asks what to do when you exit.
Why name main in step 5? The Claude Code docs say new worktrees branch from the repository's default branch on the remote. The git docs say that without a starting point, a new branch is based on your current HEAD. Naming the branch keeps both agents on the same base.
How do you make both tools follow the same project rules?
Put your rules in one AGENTS.md file at the repository root. Codex reads AGENTS.md files before doing any work, and Claude Code can read the same file.
Claude Code's behaviour depends on what else is in the folder, per its memory docs:
| Your repository has | Claude Code reads |
|---|---|
AGENTS.md, no CLAUDE.md | AGENTS.md |
AGENTS.md and CLAUDE.md | CLAUDE.md only |
CLAUDE.md that imports AGENTS.md | CLAUDE.md, with AGENTS.md included |
If you already have a CLAUDE.md, make its first line the import below. Add Claude-only notes underneath:
@AGENTS.md
## Claude Code
Use plan mode for changes under src/billing/.
Three details to know:
- Reading
AGENTS.mddirectly requires Claude Code v2.1.277 or later. The import works regardless. - A symlink (
ln -s AGENTS.md CLAUDE.md) also works, but the docs warn it can break on Windows. Use the import there. - Codex stops adding instruction files once the combined size reaches 32 KiB by default. Keep
AGENTS.mdshort.
Run /context in Claude Code and confirm CLAUDE.md appears under Memory files. That is the check the docs suggest.
What is Method 2: the desktop apps?
Both vendors let you start a worktree from their desktop apps, with no git commands. This suits you if you prefer clicking to typing.
- Codex app: in the new chat view, select Worktree under the composer, pick a starting branch, then submit your prompt. OpenAI's guide says Codex creates a git worktree and, by default, works in a detached HEAD. Use Create branch here in the chat header to turn it into a named branch.
- Claude Code desktop app: the docs say to select the worktree option when you start a session.
Git only allows one branch to be checked out in one place at a time, per OpenAI's guide. If Codex's worktree holds a branch, you cannot check out that same branch in your main folder.
What is Method 3: letting one tool review the other?
Run one agent, commit its work, then pipe the diff to the other agent for a read-only review. This uses two documented behaviours of codex exec: by default it runs in a read-only sandbox, and when you pipe input and give a prompt, the prompt is the instruction and the piped text is context.
From your main folder, after Claude Code has committed on its branch, try this example:
git diff main...worktree-claude-task | codex exec "Review this diff for bugs and missing tests. Do not edit any files."
Read the answer, then decide what to change. Because the sandbox is read-only, Codex cannot edit files in this run. Do not add --sandbox danger-full-access for a review. The docs say to use it only in a controlled environment such as an isolated CI runner or container.
Which method should you choose?
Method 1 gives you the most control. The desktop apps are easiest. Method 3 adds a second opinion on top of either.
| Method | Cost | Difficulty | Limits | Best for |
|---|---|---|---|---|
| 1. Two terminals, two worktrees | Free (plus plans) | Medium | Needs git commands | Developers comfortable in a terminal |
| 2. Desktop apps | Free (plus plans) | Easy | Each app manages its own worktrees | Beginners who prefer a visual tool |
3. Cross-review with codex exec | Free (plus plans) | Medium | Review only, read-only by default | Catching mistakes before merging |
For a plain-English comparison of the tools themselves, see Claude Code vs Codex vs Cursor. New to Claude Code? Start with What Is Claude Code?.
What is free, and what costs money?
Git worktrees are free. You pay for the two AI plans or for API usage. Prices below are as of 16 October 2026 and can change.
| Item | Price | Notes |
|---|---|---|
| Claude Pro | $20 per month billed monthly, $17 per month on annual billing ($200 up front) | Includes Claude Code |
| Claude Max | From $100 per month | Choice of 5x or 20x more usage than Pro |
| ChatGPT Plus | $20 per month | Lists Codex in the CLI |
| ChatGPT Pro | From $100 per month ($100, $200 or $500 plans) | Higher usage tiers |
| ChatGPT Free and Go | $0 and $8 per month | The pricing page entries mention only the desktop app |
| API key (either tool) | Pay by usage | Codex bills at API pricing; Claude Console uses pre-paid credits |
Usage limits matter more when you run two sessions at once. Anthropic says Pro and Max plans have a five-hour session limit and a weekly limit, shared across Claude and Claude Code. OpenAI's pricing page says ChatGPT Work and Codex share usage. Two agents working in parallel will draw down a plan faster than one, though neither vendor publishes a figure for that.
What can go wrong, and how do you fix it?
Most problems come from branches, missing files and instruction-file rules.
--worktreeexits with an error. You have not accepted the trust dialog in that folder. Runclaudeonce there, accept it, and try again.- Git says the branch is already checked out. Git refuses to add a worktree for a branch another worktree already uses. Pick a new branch name with
-b, or finish and remove the other worktree. - The app will not start because
.envis missing. A worktree is a fresh checkout, so gitignored files are not there. For Claude Code, list them in a.worktreeincludefile at your project root. For the Codex worktree you made with git, copy the file by hand. - Claude Code ignores your
AGENTS.md. If aCLAUDE.mdexists, Claude reads only that. Add@AGENTS.mdas its first line. - You see unexpected API charges. Check for an
ANTHROPIC_API_KEYvariable in your shell. If it is set, Claude Code uses it instead of your subscription. - Leftover worktrees pile up. Claude Code does not clean up worktrees from
claude -pruns. Rungit worktree list, thengit worktree remove <path>for each one you no longer need.
Is it safe to let two AI agents edit your project?
It is safer with worktrees, because each agent works on its own branch and nothing reaches main until you merge it. Still, keep human review in the loop.
Claude Code asks you to accept workspace trust before running --worktree interactively. Codex has sandbox settings: codex exec is read-only by default, and --sandbox workspace-write allows edits. Start with the narrowest setting that gets the job done. Never paste real API keys into prompts or commit them to AGENTS.md.
What's still unclear?
- Is two agents better than one? The vendors' docs do not claim that running both tools together improves results. The documented benefit is isolation: separate folders and branches. Comparing two answers to the same task is a choice you make, not a proven gain.
- Codex CLI worktrees. OpenAI's worktree guide covers the desktop app. This post uses plain git for the terminal, because that approach works with any tool.
- Different starting points. Claude Code and
git worktree addchoose different default base branches, as explained above. Name your base branch to avoid surprises. - Plan limits for parallel use. The vendors publish limits per plan, not per parallel session. Watch your usage meters in the first week.
- Plans change. Prices and included features on both vendors' pages can change without notice.
Frequently asked questions
Can Claude Code and Codex edit the same folder at the same time?
They can, but you should not. Two agents writing to one checkout can overwrite each other's edits. Give each tool its own git worktree, which is a separate folder with its own branch that shares the same repository history. Claude Code's docs describe worktrees as the way to keep parallel sessions from colliding, and git's own docs explain how to create them.
Do I need two paid subscriptions to use both tools?
Each tool needs its own sign-in. As of 16 October 2026, Claude Pro is $20 per month billed monthly and includes Claude Code, and ChatGPT Plus is $20 per month and lists Codex in the CLI. Both vendors also offer API-key access that bills by usage instead of a flat plan. Check each pricing page before you subscribe, because plans change.
Which instruction file should I use so both tools follow the same rules?
Use AGENTS.md. Codex reads it before it starts work. Claude Code reads AGENTS.md only when your project has no CLAUDE.md, so if you already have a CLAUDE.md, add a line containing @AGENTS.md at the top. Claude Code's docs say reading AGENTS.md directly needs version 2.1.277 or later.
Does Codex have a built-in worktree flag like Claude Code's --worktree?
OpenAI's worktree guide describes the ChatGPT desktop app, where you select Worktree under the composer. The guide does not describe a CLI flag. For the terminal, this post uses plain git (git worktree add), which works the same for any tool.
How do I clean up worktrees when I am done?
Merge or discard the branch first. For a Codex worktree you created with git, run git worktree remove with its path. For Claude Code, exiting an interactive session prompts you to keep or remove the worktree if it holds work. Sessions started with claude -p do not clean up, so remove those with git worktree remove.
Sources
- Run parallel sessions with worktrees - Claude Code Docs, Anthropic (2026-10-16)
- How Claude remembers your project - Claude Code Docs, Anthropic (2026-10-16)
- Quickstart - Claude Code Docs, Anthropic (2026-10-16)
- Use Claude Code with your Pro or Max plan, Anthropic (Claude Help Center) (2026-10-16)
- Claude pricing, Anthropic (2026-10-16)
- Codex CLI, OpenAI (2026-10-16)
- Custom instructions with AGENTS.md, OpenAI (2026-10-16)
- Worktrees (Codex app), OpenAI (2026-10-16)
- Non-interactive mode (codex exec), OpenAI (2026-10-16)
- Codex pricing, OpenAI (2026-10-16)
- git-worktree documentation, Git project (2026-10-16)