# How to run Claude Code and Codex on the same project

Use Claude Code and Codex on one repo without them getting in each other’s way: split the work, give each agent its own worktree, port and database, share one AGENTS.md, and have each agent review the other’s changes.

By Simone Zamparini · Published November 7, 2026 · Updated November 8, 2026\
https://concors.dev/guides/claude-code-and-codex-side-by-side

## In short

-   Give each agent a different job, in its own Git worktree. Both can create one: claude --worktree in Claude Code, /worktree in Codex.
-   A worktree only separates files. Give each worktree its own port and database, and copy your .env with one .worktreeinclude that both agents read.
-   Keep the shared rules in AGENTS.md. Codex reads it, and so does Claude Code when there’s no CLAUDE.md (or when CLAUDE.md imports it). Then let each agent review the other’s work.

## How should I split work between Claude Code and Codex?

If you pay for both Claude and ChatGPT, you have two capable agents. Pointing both at the same task mostly gets you two answers to reconcile. Pointing them at different tasks doubles what gets done. Splits that work well:

| Agent A | Agent B |
| --- | --- |
| Builds the feature | Investigates an unrelated bug |
| Writes the change | Reviews the diff and lists problems |
| Works on the app code | Writes tests for it |
| Refactors one module | Updates the docs for it |

Neither OpenAI nor Anthropic publishes guidance on which agent is better at which job, so pick roles by what each has built in. Both have a review command, both run headless for work that runs while you’re away (`claude -p "…"` and `codex exec "…"`), and Claude Code subagents can each run in their own worktree. Start with the agent you use most as the builder and the other as the reviewer, then swap after a week and keep whichever split leaves you less to fix.

## How do I stop the agents overwriting each other’s files?

Two agents editing the same file at the same time overwrite each other’s work. Pick one of these three approaches:

1.  **Split by folder**
    
    Tell each agent which folders it may change, for example the API for one and the UI for the other. It is the simplest option, and fine when the tasks don’t overlap.
    
2.  **Give each agent its own worktree**
    
    A Git worktree is a second checkout of the same repo, in its own folder and on its own branch. Each agent edits its own copy, and you merge when both are done. Both agents can create one for you. Claude Code:
    
    ```
    claude --worktree feature-auth   # new worktree in .claude/worktrees/feature-auth
    ```
    
    Add `.claude/worktrees/` to your `.gitignore`. In the Codex CLI, type `/worktree` in a session, or for a one-off run:
    
    ```
    codex exec --worktree "write tests for src/lib/price.ts"
    ```
    
    In the ChatGPT desktop app, select **Worktree** under the composer; Codex keeps those worktrees without a branch (detached HEAD). For any agent, or a folder of your choosing, use Git directly:
    
    ```
    git worktree add ../my-app-review -b review   # second checkout on a new branch
    cd ../my-app-review && codex                  # start the agent there
    ```
    
3.  **Take turns on shared files**
    
    Let one agent finish and commit before the other touches the same module.
    

## How do I get my .env files into a new worktree?

A worktree is a fresh checkout, so files Git ignores, like `.env`, aren’t in it. Claude Code and the Codex desktop app both read a file named `.worktreeinclude` in your repo root, written in `.gitignore` syntax, and copy the ignored files it lists into each worktree they create. One file covers both agents:

```
# .worktreeinclude
.env
```

-   Only files that match a pattern *and* are gitignored get copied.
-   Claude Code applies it to worktrees it creates; Codex to the worktrees its desktop app manages, not ones you make with `git worktree add`. Copy those yourself (see the script below).
-   Don’t list a file that should differ per worktree, such as one holding the dev server port.

## How do I keep the agents’ dev servers and databases apart?

A worktree separates files and nothing else. Both agents still run on the same computer, so two dev servers want the same port, and two agents pointed at one local database run each other’s migrations. Give each worktree its own port and database. This script creates a sibling worktree, copies your shared `.env`, creates a Postgres database and writes the worktree’s own values to `.env.local`:

```
#!/bin/sh
# Usage: scripts/new-worktree.sh <branch> <port>
set -eu
branch="$1"
port="$2"
repo=$(basename "$(git rev-parse --show-toplevel)")
dir="../$repo-$branch"
db=$(printf '%s_%s' "$repo" "$branch" | tr 'A-Z' 'a-z' | tr -c 'a-z0-9_\n' '_')

git worktree add "$dir" -b "$branch"
[ -f .env ] && cp .env "$dir/.env"    # shared, gitignored settings
createdb "$db"                          # skip if you don't use Postgres
printf 'PORT=%s\nDATABASE_URL=postgresql://localhost/%s\n' "$port" "$db" > "$dir/.env.local"
echo "Ready: $dir  port $port  database $db"
```

Pass the port on the command line rather than relying on `.env` files: Next.js reads `PORT` from the environment or `-p`, but not from `.env`, and Vite takes `--port`. If the project uses Docker Compose, give each worktree its own project name with `-p` or `COMPOSE_PROJECT_NAME`, or the agents share containers and volumes. Run your install command in each worktree before the agent starts. When the branch is merged, clean up:

```
git worktree remove ../my-app-review   # refuses if there are uncommitted changes
git branch -d review
dropdb my_app_review
```

## How do Claude Code and Codex share one AGENTS.md?

Codex reads `AGENTS.md` before it does any work. Claude Code reads it too, from v2.1.277, as long as there’s no `CLAUDE.md` or `CLAUDE.local.md` in your folder or above it; if there is one, Claude reads only the CLAUDE files. (Several popular guides still say Claude Code ignores AGENTS.md; that stopped being true with v2.1.277.) The safest setup: keep the shared rules in `AGENTS.md`, and if you need a `CLAUDE.md`, import the shared file from it:

```
# CLAUDE.md
@AGENTS.md

## Claude Code
Claude-only notes go here.
```

|     | Claude Code | Codex |
| --- | --- | --- |
| Reads AGENTS.md | When no CLAUDE.md or CLAUDE.local.md is in the folder or above it, or through @AGENTS.md | Always |
| Personal, uncommitted rules | ~/.claude/CLAUDE.md (loads alongside AGENTS.md) | ~/.codex/AGENTS.md |
| Size limit | None stated | 32 KiB combined by default |
| Check what loaded | Run /context all | Ask it to summarize the current instructions |

Keep the file short; every line costs context in both tools. An example for a repo where both agents work at the same time:

```
# AGENTS.md

One-line description of the project.

## Commands
- Install: `npm install`
- Dev server: `set -a; . ./.env.local; set +a; npm run dev -- --port "$PORT"`
- Tests for one file: `npx vitest run path/to/file.test.ts`
- Full checks before committing: `npm run lint && npm test`

## Working alongside another agent
- Another agent may be working in a different worktree on another branch.
  Only change files in your own checkout.
- Your port and database are in .env.local. Don't change them.
- Only one branch adds database migrations at a time. Ask before creating one.

## Code Review Rules
- Flag changes to auth or payments that lack a test.
```

`## Code Review Rules` is a Codex convention: Codex’s GitHub code review reads that section from the AGENTS.md closest to the changed code.

## Can I use Codex from inside Claude Code?

Yes. OpenAI publishes an official plugin, [openai/codex-plugin-cc](https://github.com/openai/codex-plugin-cc), that adds Codex commands to Claude Code. It needs Node.js 18.18 or later and a ChatGPT account or an OpenAI API key, and its usage counts toward your Codex limits. In Claude Code, run:

```
/plugin marketplace add openai/codex-plugin-cc
/plugin install codex@openai-codex
/reload-plugins
/codex:setup
```

-   `/codex:review`: a read-only Codex review of your uncommitted changes, or of your branch with `--base main`.
-   `/codex:adversarial-review`: a review that questions the design.
-   `/codex:rescue`: hands a task to Codex, such as investigating a failing test.

The plugin runs your local Codex CLI in the same checkout Claude is working in. A review is read-only and safe anytime; a rescue task can change files, so run it when Claude is idle. Its optional “review gate” runs a Codex review every time Claude stops, and the README warns it can drain usage limits quickly.

**Can Codex use Claude Code?** Not as a plugin, but Codex can bring over your Claude Code setup: type `/import` in the Codex CLI and choose Claude Code. Going the other way, `/import codex` in Claude Code brings over Codex’s setup. Both make a one-time copy, so for a repo both agents keep using, a live `@AGENTS.md` import stays in sync and a copy doesn’t.

## How do I keep an eye on both agents?

You’ll want a terminal running the tests and one running the dev server, so you can check each agent’s change as it lands. With plain terminals that is four or more tabs: two agents, tests, server. The hard part is noticing which agent is waiting for an answer.

![Two terminals side by side in one Concors tab: the Vite dev server on the left and Vitest in watch mode on the right, with all 5 tests passing.](https://concors.dev/assets/concors-split-panes-dev-server-and-tests-iw_V0DYM.webp)

*The dev server and the test watcher side by side in one Concors tab.*

A review loop catches problems before you merge: one agent writes, the other reviews, read-only.

1.  **Agent A finishes a step and commits**
    
    Small commits make the review easier.
    
2.  **Codex reviews Claude’s work**
    
    ```
    codex review --base main      # this branch against main
    codex review --uncommitted    # staged, unstaged and untracked changes
    ```
    
    Or run `/review` in a Codex session, or `/codex:review` inside Claude Code with the plugin.
    
3.  **Claude reviews Codex’s work**
    
    Start Claude Code in Codex’s worktree and run `/code-review`. From a script, pipe the diff in:
    
    ```
    git diff main | claude -p "Review this diff. List bugs and missing tests with file:line."
    ```
    
4.  **Hand the findings back**
    
    Paste them to agent A, or fix them yourself.
    

## What’s different between Claude Code and Codex when you run both?

|     | Claude Code | Codex |
| --- | --- | --- |
| Project instructions | CLAUDE.md, or AGENTS.md when there’s no CLAUDE.md (v2.1.277+) | AGENTS.md (plus ~/.codex/AGENTS.md) |
| Start in a new worktree | claude --worktree <name> | /worktree, codex exec --worktree, or Worktree in the desktop app |
| Copy ignored files into worktrees | .worktreeinclude | .worktreeinclude (desktop app worktrees) |
| Built-in code review | /code-review | /review, codex review |
| Bring over the other’s setup | /import codex | /import → Claude Code |
| Run without prompts (scripts, CI) | claude -p "…" | codex exec "…" |
| Included in | Claude Pro, Max, Ultra, Team, Enterprise (not Free) | ChatGPT plans, from Free |
| Entry paid plan (checked Nov 8, 2026) | Pro: $20 a month, or $17 billed yearly | Plus: $20 a month |

Prices from claude.com/pricing and OpenAI’s Codex pricing page, checked November 8, 2026. The Codex CLI is open source under Apache-2.0.

## How do I set this up in Concors?

Concors is a desktop app for macOS, Windows and Linux that runs Claude Code, Codex and OpenCode as their real CLIs with your own accounts, in one window with your terminals.

![The Concors app with two chats side by side in one tab: Claude Code (left) added a test for formatPrice with a negative number to src/lib/price.test.ts, and Codex (right) read src/lib/price.ts and listed two edge cases its tests don't cover, without changing files. The sidebar shows the pricing-page workspace and its dev server under Previews.](https://concors.dev/assets/concors-claude-and-codex-side-by-side-LVjbXQqR.webp)

*Claude Code and Codex working side by side on the same project in Concors, each in its own pane.*

1.  **Open your repo**
    
    [Download Concors](https://concors.dev/) and open the repo as a workspace. No account is needed on your own computer.
    
2.  **Start both agents**
    
    Start a Claude Code chat in one tab and a Codex chat in another, or split one tab into two panes to watch both.
    
3.  **Add the terminals**
    
    Open terminals for the tests and the dev server in the same workspace. Running servers appear under **Previews**.
    
4.  **Watch the sidebar**
    
    Each agent shows whether it is working, needs your input, is done, or hit an error, so you see who is waiting without opening every tab.
    

> **Worktrees in Concors**
>
> Agents in one workspace share its files, and Concors doesn’t create a worktree per agent yet. Create worktrees with the commands above and open each one as its own workspace, then start each agent from inside its worktree’s workspace: Claude and Codex tie a conversation to the folder where it started.

To keep both agents going after you close your laptop, run the same setup on a machine that stays on. See [how to keep Claude Code running 24/7](https://concors.dev/guides/run-claude-code-24-7).

## Questions

### Can Claude Code and Codex work on the same repo at once?

Yes, as long as they don’t edit the same files at the same time. Give each agent a different task and its own Git worktree, plus its own dev server port and database.

### Can Claude Code and Codex share one instructions file?

Yes. Codex reads AGENTS.md. Claude Code v2.1.277 and later reads AGENTS.md when the repository has no CLAUDE.md or CLAUDE.local.md; if it has one, add the line @AGENTS.md to CLAUDE.md so Claude Code imports the shared rules.

### What is AGENTS.md for?

AGENTS.md is a README for coding agents: build and test commands, code style and rules for the repo. Codex reads it before doing any work. Claude Code reads it when the repo has no CLAUDE.md, or through an @AGENTS.md line in CLAUDE.md.

### Should AGENTS.md be committed?

Yes. It holds the rules every agent and teammate should follow, so commit it at the repo root. Put personal rules in ~/.claude/CLAUDE.md for Claude Code and ~/.codex/AGENTS.md for Codex. Avoid a CLAUDE.local.md in a repo that relies on AGENTS.md: Claude Code treats it as a CLAUDE.md and stops reading AGENTS.md.

### Is AGENTS.md a standard?

It is an open format rather than a formal standard, stewarded by the Agentic AI Foundation under the Linux Foundation. It has no required fields; it’s plain Markdown.

### Can I use Codex inside Claude Code?

Yes, with OpenAI’s official plugin, openai/codex-plugin-cc. Install it with /plugin marketplace add openai/codex-plugin-cc, then /plugin install codex@openai-codex. It adds /codex:review, /codex:adversarial-review and /codex:rescue and runs your local Codex CLI.

### Can Codex use Claude Code?

Codex can’t run Claude Code as a plugin, but it can import your Claude Code setup: type /import in the Codex CLI and choose Claude Code.

### Is Claude Code or Codex free?

Codex is included in ChatGPT plans from Free, and its CLI is open source (Apache-2.0). Claude Code isn’t on Claude’s Free plan; it comes with Pro, Max, Ultra, Team and Enterprise. Prices checked November 8, 2026.

### Does Claude Code support Git worktrees?

Yes. Start it with claude --worktree <name> (or -w) and Claude Code creates an isolated worktree on a new branch and starts in it. Run the command again with another name in a second terminal for a second isolated session.

### Do Git worktrees keep ports and databases separate?

No. A worktree only separates files. Both agents still share your computer’s ports and your local database, so give each worktree its own port and database, for example with a .env.local that a setup script writes.

### Do Claude Code and Codex use the same .worktreeinclude file?

Yes. Both read .worktreeinclude from the repo root, in .gitignore syntax, and copy matching gitignored files such as .env into new worktrees. Claude Code does this for worktrees it creates; Codex for worktrees its desktop app creates.

## Sources

-   [Claude Code docs: run parallel sessions with worktrees](https://code.claude.com/docs/en/worktrees)
-   [Claude Code docs: CLAUDE.md, AGENTS.md and imports](https://code.claude.com/docs/en/memory)
-   [Claude Code docs: commands (/code-review, /import)](https://code.claude.com/docs/en/commands)
-   [Codex docs: AGENTS.md](https://learn.chatgpt.com/docs/agent-configuration/agents-md)
-   [Codex docs: developer commands (/worktree, codex review)](https://learn.chatgpt.com/docs/developer-commands.md)
-   [Codex docs: Git worktrees](https://learn.chatgpt.com/docs/environments/git-worktrees.md)
-   [Codex docs: import](https://learn.chatgpt.com/docs/import.md)
-   [OpenAI: Codex plugin for Claude Code](https://github.com/openai/codex-plugin-cc)
-   [agents.md](https://agents.md/)
-   [Next.js CLI (PORT)](https://nextjs.org/docs/app/api-reference/cli/next)
-   [Git documentation: git-worktree](https://git-scm.com/docs/git-worktree)
-   [Claude pricing](https://claude.com/pricing)
-   [Codex pricing](https://developers.openai.com/codex/pricing)
