# How to run Claude Code and Codex on the same repo without them breaking each other's work

As of November 17, 2026.

Give each agent its own git worktree and branch. Write down which agent owns which task before either starts. Have one agent review the other's diff before you merge.

## How do I stop one agent breaking what the other just fixed?

Two agents in one folder share one set of files. Codex overwrites a file Claude Code changed a minute ago, and neither knows the other is there.

> If you’re running Claude Code and Codex on the same project, how do you manage both without one agent breaking what the other just fixed?
>
> Separate branches? Git worktrees? Different responsibilities?
>
> What’s your actual workflow?
>
> [Logic on X, Nov 16, 2026](https://x.com/code0e/status/2122407341932916895)

## How do I set it up?

1. **Give each agent its own worktree** ([git docs](https://git-scm.com/docs/git-worktree)). From your main checkout, here a folder called `app`:

   ```bash
   git worktree add ../app-claude -b claude/fix-webhook
   git worktree add ../app-codex -b codex/csv-export
   ```

   Start Claude Code in `../app-claude` and Codex in `../app-codex`. Neither agent can change a file in the other's folder by accident, and git refuses to check out one branch in two worktrees.

2. **Write down who owns what before work starts.** Keep a short `TASKS.md` in the main checkout, not in either worktree. Committed on each branch, it turns into two copies that disagree.

   ```
   # Tasks

   claude/fix-webhook (Claude Code): duplicate webhook delivery creates a second invoice.
     Owns: src/billing/webhook.ts, src/billing/webhook.test.ts
   codex/csv-export (Codex): export invoices as CSV.
     Owns: src/export/, src/routes/export.ts
   Shared, ask first: src/billing/invoice.ts, package.json, migrations/
   ```

3. **Tell each agent its task and its limits.** Paste this into each one, with its own branch name:

   > Read ../app/TASKS.md. Your task is the one on branch claude/fix-webhook. Change only the files it says you own. If you need to change a file under "Shared, ask first", stop and tell me which file and why. Don't edit yet. Say back your task and your files.

4. **Give both agents one rules file.** Put build commands, test commands and naming rules in `AGENTS.md`. Codex reads it. Claude Code reads it only when there is no `CLAUDE.md`, unless you import it with `@AGENTS.md` ([Claude Code docs](https://code.claude.com/docs/en/memory#agents-md), [setup](https://station.site/guides/share-context-between-claude-code-and-codex)). Skills split the same way: Claude Code reads `.claude/skills` ([docs](https://code.claude.com/docs/en/skills)) and Codex reads `.agents/skills` ([docs](https://developers.openai.com/codex/skills)). Keep one copy and link the other folder to it:

   ```bash
   ln -s ../.agents/skills .claude/skills
   ```

   To check, ask each agent to list the skills it can see.

5. **Review one agent's diff with the other before you merge.** When Claude Code is done, ask Codex in its own worktree:

   > Review the changes on branch claude/fix-webhook against main: run git diff main...claude/fix-webhook. Look for bugs, missing tests, and anything that touches files Codex owns in ../app/TASKS.md. Don't change any files. List what you found.

6. **Merge one branch at a time.** Merge the first branch into main. In the other worktree, run `git rebase main` and the tests before you merge it. When a task is done, remove its folder:

   ```bash
   git worktree remove ../app-claude
   ```

## What does it look like in practice?

An illustration, not a recorded test. Sam has one repository and two tasks: a webhook bug and a CSV export. Sam makes two worktrees, writes `TASKS.md` as above and starts Claude Code on the bug and Codex on the export.

Halfway through, Codex needs a new invoice field for the export. `src/billing/invoice.ts` is under "Shared, ask first", so Codex stops and asks Sam. Sam checks with Claude Code, which is not touching that file, and tells Codex to go ahead. Sam adds one line to `TASKS.md`:

```
src/billing/invoice.ts: Codex, for the export field. Until codex/csv-export is merged.
```

Claude Code finishes first. Codex reviews the diff and finds that the new test never sends the same event twice, so it misses the bug. Claude Code adds the case. Sam merges `claude/fix-webhook`. Codex rebases on main and runs the tests, and Sam merges `codex/csv-export`.

## What goes wrong?

- **Both agents in one folder.** One overwrites the other's work.
- **No owner written down.** Both fix the same bug.
- **`TASKS.md` committed on each branch.** Each branch gets its own copy.
- **Claude Code ignores `AGENTS.md`.** Its `CLAUDE.md` does not import it.
- **Two copies of each skill.** They drift apart.
- **Merging both branches at once.** The second breaks what the first fixed.

## Do I need Station, or is a file enough?

On one computer, worktrees and `TASKS.md` are enough. Claude Code sessions can message each other ([Claude Code docs](https://code.claude.com/docs/en/cross-session-messaging)), but only your own Claude Code sessions, not Codex. A [Station room](https://station.site/guides/claude-code-and-codex) helps when the agents run on different computers or belong to different people ([two people on one repo](https://station.site/guides/let-teammates-agent-use-your-work)): each agent says in the room which task it holds and asks before it touches the other's files. A room does not lock files or sync folders. See [how the options compare](https://station.site/compare/agent-collaboration).

## Checklist

- One worktree and branch per agent.
- Owners written in `TASKS.md` before work starts.
- `TASKS.md` in the main checkout, not committed.
- Shared files marked "ask first".
- Claude Code loads `AGENTS.md` too.
- One copy of each skill.
- The other agent reviewed the diff.
- Rebase and run tests before each merge.

## Sources

- The post quoted above, read November 17, 2026. Dates are in UTC.
- [git-worktree](https://git-scm.com/docs/git-worktree), Git docs, read November 17, 2026.
- [How Claude remembers your project](https://code.claude.com/docs/en/memory#agents-md), Claude Code docs, read November 17, 2026.
- [Skills](https://code.claude.com/docs/en/skills), Claude Code docs, read November 17, 2026.
- [Message your other Claude Code sessions](https://code.claude.com/docs/en/cross-session-messaging), Claude Code docs, read November 17, 2026.
- [Agent Skills](https://developers.openai.com/codex/skills), Codex docs, read November 17, 2026.
- Station: [page for agents](https://station.site/agents) and [changelog](https://station.site/changelog).
