Guide · Two agents, one repo

Claude Code and Codex, together

How to use Claude Code and OpenAI Codex CLI side by side on the same repository: shared instructions, separate worktrees, different permission models, and what to do when one hits its usage limit.

4 min read

The short version

  • Two subscriptions mean two usage budgets. When one runs out, the other can carry on.
  • Claude Code reads CLAUDE.md; Codex reads AGENTS.md. Keep one source of truth.
  • Give each agent its own worktree, and never let both work the same task at once.
  • Their safety models differ: Claude Code asks through permission modes, Codex runs in a sandbox.

Plenty of developers now pay for both a Claude plan and a ChatGPT plan, and have both Claude Code and Codex installed. Most use them one at a time: Claude Code by default, Codex when Claude says it's out of usage until later. That works, but you can get a lot more from the pair with a little setup.

This guide covers running both on the same repository without them stepping on each other, and how to hand work from one to the other.

Why bother with both

We won't tell you which agent is "better". It changes with every model release, and it depends on your codebase. Try both on your own tasks and keep notes.

Step 1: one set of instructions

Each agent looks for its own instruction file in the repository. Claude Code reads CLAUDE.md. Codex reads AGENTS.md. If you maintain both by hand, they will drift, and the two agents will follow different rules.

Pick one as the source of truth. The simplest options:

# keep AGENTS.md as the real file and link the other to it
ln -s AGENTS.md CLAUDE.md

# or keep CLAUDE.md short and point it at AGENTS.md
echo "Read AGENTS.md for this project's rules." > CLAUDE.md

Put the things both agents need in that file: build and test commands, the install step for a fresh worktree, code style, and what not to touch.

Step 2: separate worktrees, always

Treat the two agents like two developers. Each task gets its own git worktree and branch, whichever agent works on it:

git worktree add ../clankdesk-transcript -b perf/session-transcript
git worktree add ../clankdesk-menubar    -b feat/menu-bar-icon

(cd ../clankdesk-transcript && claude)
codex --cd ../clankdesk-menubar

Never point both agents at the same folder at the same time. They don't know about each other, and each will treat the other's half-finished edits as bugs to fix.

Step 3: understand the two safety models

This is the part that surprises people when they switch back and forth. The two CLIs keep you in control in different ways.

Claude Code

  • Asks before risky tools, depending on its permission mode (--permission-mode)
  • Allow and deny rules in settings
  • Can ask you in the middle of a turn

Codex CLI

  • Runs commands inside a sandbox (--sandbox read-only | workspace-write | danger-full-access)
  • An approval policy decides when it asks (--ask-for-approval)
  • Non-interactive runs (codex exec) have nobody to ask, so the sandbox does the guarding

Both have flags that turn the safety off entirely. Avoid them outside a disposable machine. We go deeper in safe permission prompts for coding agents.

Step 4: hand over cleanly

Switching a task from one agent to the other mid-way is where work gets lost. The new agent has none of the old one's conversation. Make the handover explicit:

  1. Commit what's there. Even half-done work, on the task's branch, with a message saying so.
  2. Write the state down. What was tried, what failed, what the next step was. Three sentences is enough.
  3. Start the other agent in the same worktree with that note and the original request.

The branch carries the code. The note carries the context. Together they're a good handover.

Step 5: compare them on your own work

Benchmarks won't tell you which agent suits your codebase. Your own tasks will. Once in a while, give the same small, well-defined task to both, each in its own worktree:

git worktree add ../try-claude -b try/claude-empty-state
git worktree add ../try-codex  -b try/codex-empty-state
# same prompt to each, then:
git diff --stat main...try/claude-empty-state
git diff --stat main...try/codex-empty-state

Compare more than whether it works: the size of the diff, whether it followed your conventions, how many questions it asked, how long it took and how much of your plan it used. Keep a few notes. After a handful of comparisons you'll know which agent you'd pick for which kind of task, and that knowledge is worth more than any leaderboard. Delete the losing branch when you're done.

How ClankDesk runs the pair

ClankDesk treats Claude Code and Codex as two members of the same team. It finds both CLIs on your Mac, uses your existing logins, and picks one per task:

Sessions come and go: a question, a usage limit, a restart, a different agent. The task, with its brief, branch and history, stays.
Session
A live ClankDesk session showing an agent's edits and a test run
Every task is a real Claude Code or Codex session. Open it to follow along, or don't.

ClankDesk also offers updates for both CLIs when new versions come out, and never interrupts a running session to install one.

The features page has the details, and the demo runs in your browser.