Blog · Guide
Run multiple Codex CLI agents in git worktrees
To run multiple Codex CLI agents safely, start each one in its own git worktree so their edits stay on separate branches. Zoes, a free MIT Mac app, creates the worktree from a branch or pull request, runs Codex in a terminal or as a chat, and flags each session as Working, Needs you, Done or Failed.
This is the Codex version of How to run multiple Claude Code agents in parallel. The method is the same; the Codex-specific parts are below.
Why one worktree per Codex agent
Two codex sessions in the same folder share one working tree and one branch. Each sees the other's half-written files in its builds and tests, a commit from one can sweep up the other's edits, and the final diff mixes both tasks. A git worktree gives each agent its own checkout on its own branch, from the same repository, without a second clone.
Plain git first
Add a worktree per task, then start Codex in each folder, in its own terminal:
cd ~/code/app
git worktree add -b fix-auth ../app-fix-auth
git worktree add -b flaky-tests ../app-flaky-tests
cd ~/code/app-fix-auth && codex
cd ~/code/app-flaky-tests && codex
A new worktree holds only committed files, so install dependencies and copy untracked config before Codex starts. When a branch is merged, git worktree remove its folder.
Codex changes between releases. Check the Codex CLI docs for any worktree support built into the version you run. The commands above work with any version.
What git doesn't give you is an overview: which Codex is waiting on an approval, which one finished, and what each one changed. That's the part Zoes takes over.
Running several Codex agents in Zoes
Set up Codex once
- Install the Codex CLI from the Codex CLI install page and run
codex login. Zoes runs thecodexit finds on your loginPATH. If you install it while Zoes is open, restart Zoes. - To make Codex the agent new sessions start with, open Settings › Agents, click Codex under Providers, and click Set as default. Or pick it per session on the new session page.
- Settings › Accounts can hold more than one Codex account, and shows each account's usage.
Terminal or chat
Codex runs both ways, and reports its status from both:
- Chat. Zoes's own chat view. pocketd drives Codex through the Codex app-server. New sessions start as a chat while Settings › Agents › Start as a chat is on, the default.
- Terminal. Codex's own terminal interface, in your login shell. Zoes reads its status from Codex session events. Turn Start as a chat off, or start Codex from a tab's + menu.
One caveat from the docs: a codex that runs without its app-server isn't attached, and then Zoes shows only its terminal activity, never Needs you or Done.
A worktree per session, from a branch or a pull request
Press ⌘⇧N and the new session page opens with Worktree picked. Pick the base branch on the branch chip, or click the pull request button and enter 123, #123, or a pull request URL to start from that pull request. Setup commands in .zoes/config.json or .zoes/setup.sh run in the new worktree before Codex starts. Worktrees go in ~/.zoes/worktrees by default. See Start an agent in a new worktree.
From a shell, the same thing is one command:
zoes session create --new-worktree --base main --provider codex --prompt "Fix the flaky login test"
Status, review, and access
- Each session is Working, Needs you, Done, Failed, or Idle. Needs you, Failed, and Done reach the sidebar, the Inbox, the Dock badge, and banners. ⌘J jumps to the next session that needs you. See Sessions and status.
- The Changes panel shows each worktree's diff beside its session, and can compare it with the base branch. The pull request card's Send hands a failed check's log or a review comment back to Codex.
- The access chip sets what Codex can do without asking: Ask, Edits, Auto, or Full, or Codex's own settings. Codex doesn't start in plan mode.
Zoes is free and MIT licensed, and runs the Codex you already have.
Star Zoes on GitHub Download for MacCodex and Claude Code side by side on one repo
Codex and Claude Code are the two agents that report their status from a terminal as well as from a chat. Mixing them on one project works the same as running two of either:
- Separate worktrees. Start a Codex session in one worktree and a Claude Code session in another. Both sit under the same project in the sidebar, in tabs and splits.
- Delegation. A Claude Code or Codex chat can hand work to sessions of another agent through pocketd's orchestrator. Ask in plain words, for example "Split this into three parts and delegate each one to its own session. Use Codex for the tests." Each delegated session runs in a new worktree made from the parent's latest commit, with the parent's access. See Let a chat delegate work to other sessions.
- The Board. Write tickets and give each its own agent. A started ticket gets its own worktree and session, and the Board runs up to four at once by default. See Plan work on the Board.
The other eight agents Zoes supports run as a chat. The full list, with install and sign-in commands, is on Supported agents. To drive all of this from scripts, see Script coding agents from your shell.
FAQ
Can I run several Codex agents on one repository?
To run multiple Codex CLI agents safely, start each one in its own git worktree so their edits stay on separate branches. Zoes, a free MIT Mac app, creates the worktree from a branch or pull request, runs Codex in a terminal or as a chat, and flags each session as Working, Needs you, Done or Failed.
Can Codex and Claude Code work on the same project at once?
Yes. Give each agent its own worktree of the project. In Zoes, pick the agent on the new session page for each one. Both run in a terminal or as a chat and report their status from either, and a Claude Code or Codex chat can delegate part of its work to a session of the other agent.
How do I know when a Codex agent is done?
Zoes marks the session Done when a Codex turn ends and you haven't seen it yet, and shows it in the Inbox, on the Dock badge and in a macOS banner. Codex reports its status from a chat and from a terminal. From a script, zoes session wait exits with code 0 when the session is done.