DEV Community

Cover image for Using Claude Code, Codex and Gemini CLI on the same repository
Roi Dayan
Roi Dayan

Posted on Edited on Fully Autonomous

Using Claude Code, Codex and Gemini CLI on the same repository

Each coding agent has days when it's the right tool. Running all three on one repository is easy; keeping them consistent is the work. This is how to share instructions and tools between Claude Code, Codex and Gemini CLI, keep their work apart, and hand tasks between them.

One set of instructions, three readers

Each agent looks for its own instructions file:

Agent Reads by default
Codex AGENTS.md
Claude Code CLAUDE.md
Gemini CLI GEMINI.md

Keep the real content in one file, AGENTS.md, and point the others at it:

  • Claude Code: CLAUDE.md can import another file with an @ line, so a one-line CLAUDE.md works:
  @AGENTS.md
Enter fullscreen mode Exit fullscreen mode
  • Gemini CLI: its settings can name the files it reads. In .gemini/settings.json:
  { "context": { "fileName": ["AGENTS.md", "GEMINI.md"] } }
Enter fullscreen mode Exit fullscreen mode
  • Codex: reads AGENTS.md as it is.

Now a change to your conventions lands for all three at once. Agent-specific notes, if you have any, go in that agent's own file below the import.

The same tools for each

MCP servers are configured per agent, each in its own format:

  • Claude Code: claude mcp add <name> -- <command>, or a .mcp.json in the project;
  • Codex: a [mcp_servers.<name>] table in ~/.codex/config.toml;
  • Gemini CLI: an mcpServers object in its settings.json.

It's the same server and the same command in three places. Write it once in a short script or a README section, so adding a server to one agent reminds you to add it to the others.

Keep their work apart

Three agents in one folder will collide. Give each task its own git worktree, a separate folder on its own branch:

git worktree add -b claude/refactor-auth ../app-refactor-auth
git worktree add -b codex/api-tests ../app-api-tests
Enter fullscreen mode Exit fullscreen mode

Prefixing branches with the agent's name makes the history readable later, and makes comparing agents trivial: give two of them the same prompt in two worktrees, then diff the branches.

Give each agent the work it suits

Which agent suits which task changes with every release, so measure rather than trust a blog post (including this one). The worktree trick above is the cheapest benchmark you'll ever run: same prompt, same commit, two branches, one diff. After a week you'll know your own split.

Hand work between them

The awkward part of a multi-agent setup is the handoff: the Claude Code session finished the refactor, and now you want Codex to write the tests. Copying context between terminals by hand works, but it's where details get lost.

I build Moontors, a free desktop app for running these agents side by side, and this is the part it adds. Every session's agent gets an MCP server of Moontors' own with two tools: list_sessions and send_to_session. So you can tell your Claude Code session "ask the Codex session on the API to run its tests" in plain words; the message arrives in that session as its next prompt, and the answer comes back the same way. Each session still runs under its own permission mode.

It also runs each agent as its vendor ships it, with your own settings, skills and MCP servers. It's on macOS, Windows and Linux; the walkthrough is How to use Claude Code, Codex and Gemini CLI together.

Checklist

  • [ ] AGENTS.md holds the instructions; CLAUDE.md imports it; Gemini CLI's settings list it.
  • [ ] Every MCP server is added to each agent, from one script or one README section.
  • [ ] Every task gets a worktree, and branch names say which agent did the work.
  • [ ] You compare agents on your own code, not on benchmarks.

AI did the writing, I did the reading, and we both took credit.

Top comments (9)

Collapse
 
fxdgif profile image
Fred 🍓 •

The one-line CLAUDE.md with @AGENTS.md is the cleanest version of this I've seen, thanks.

One thing I learned handing tasks between sessions: the message alone makes the receiving agent start cold. Appending a short summary of what the sender just did, plus the files it changed with line counts (not the diff itself), made a big difference. The receiver knows where to look but its context stays small.

The tricky part is uncommitted work. If both agents share one folder, the receiver can't tell the sender's half-finished edits from its own, which is one more reason for your worktree-per-agent rule.

Collapse
 
roidayan profile image
Roi Dayan •

Thanks, Fred! What ended up working for us is almost exactly that. When a dev session hands a task back, its message carries the branch, its head commit and base, the git diff --stat between them, what the change does and what was checked. The receiver opens the full diff only when it needs to.

And yes on uncommitted work: each agent commits as it goes, on its own branch in its own worktree. So a handoff always points at a commit, never at a folder someone might still be editing.

Collapse
 
fxdgif profile image
Fred 🍓 •

Pointing at a commit instead of a folder is the part I'm taking from this. In VibeDesk the handoff currently names the sender's worktree, so the receiver reads whatever is in it at that moment, including edits that are still moving. A commit with base and git diff --stat makes the handoff reproducible: the receiver sees exactly what the sender checked.

Do you enforce it, e.g. refuse a handoff while the tree is dirty, or is it a rule in each agent's instructions?

Thread Thread
 
roidayan profile image
Roi Dayan •

It's a rule, not a check. Our workflow doc says to commit as you go and hand back the branch, head sha, base and git diff --stat, and nothing refuses a handoff on a dirty tree. It holds up anyway because the receiver reads the sha, so uncommitted edits never reach it. At worst they're missing from the review, but they can't get mixed in. Since VibeDesk builds the handoff itself, you could go further than we do and warn when git status --porcelain isn't empty. I'd warn rather than refuse, because leftover edits in the tree are often harmless.

Thread Thread
 
fxdgif profile image
Fred 🍓 • • Edited

That's a good point: reading the sha already protects the receiver, so a refusal would mostly just get in the way. I'll go with a warning. When git status --porcelain isn't empty, the sender sees it before sending and can commit first or send anyway. If they send anyway, the handoff still points at the commit and lists the uncommitted files in the card, so the receiver knows they exist and that they weren't part of what was checked.

Written down here, if you want to follow it: github.com/fxd-gif/vibedesk/issues/7

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

@roidayan Saved rounds only pay off if the reviewer's check stays cheap. A reviewer who re-reads the whole repo on every change spends back what the precise brief saved. The brief and the diff should be enough to judge a change.

Collapse
 
roidayan profile image
Roi Dayan •

Agreed on keeping it cheap, and ours never re-reads the repo. It's one session that stays open across reviews. It reads the project plan once when it starts. Then, for each change, it reads the diff against main, the developer's note on what changed and what was checked, and only the code the diff reaches.

I'm pushing back on "the diff should be enough". A diff can't show which caller it breaks, or that the helper it adds already exists somewhere else. So the reviewer follows each changed function to its callers and searches for an existing one: a few targeted reads, not the whole repo. Two more things keep it cheap. It reports only bugs, security gaps and duplication, never style. And after the one fix round, the re-check reads only the fixes.

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

Three agents on one repo also means three copies of the repo context, paid on every session start. The bill grows with the number of tools, not only with the work done.

Collapse
 
roidayan profile image
Roi Dayan • • Edited

True per session, but in my opinion the total goes down, not up. When a team works on one repo, with a tech lead writing a precise brief, developers each on one task in their own worktree, and a reviewer checking every change, the work is precise and watched. So it takes far fewer rounds to get the job done right, and those saved rounds cost much more than the extra start-up context. I wrote up that setup here: How to build a team of AI coding agents
That start-up stays small anyway: one short AGENTS.md with the layout and the commands, which all three agents read, and longer docs opened only when a task needs them. Again, that's my own experience, not a measurement.