# Run Claude Code and Codex in parallel with Git worktrees

> Create separate worktrees, launch Claude Code and Codex, divide ownership, and review the combined result. Includes commands and a reusable task brief.

- **Category:** Workflows
- **Updated:** 2026-09-22
- **Reading time:** 5 min
- **Canonical page:** https://cmdbrief.com/guides/run-claude-code-and-codex-in-parallel

## The setup: two checkouts, two tasks, one review

Run Claude Code and Codex in separate Git worktrees when both will edit the same repository. Each gets its own directory and branch; you then review and integrate their changes one at a time. Two terminal tabs in the same directory still share every file and the Git index.

Start with two tasks you can review independently: Claude fixes a parser bug while Codex adds a help page, for example. If both tasks change the same public interface, agree on that interface first or do them in sequence. More agents only help when useful work can proceed independently.

> **Tip:** These commands use an existing, committed Git repository and already installed, authenticated CLIs. The Git sequence was checked in a disposable repository; CLI flags were checked against installed help on 7 September 2026. This is a workflow recipe, not a model performance benchmark.

## 1. Create both worktrees from an explicit starting commit

From your repository root, inspect the working tree and record HEAD. Commit the work you want both agents to start from. Uncommitted edits and ignored files do not become part of the new checkouts. Use unused branch and directory names; Git will refuse collisions.

**From the original repository**

```bash
git status --short
git rev-parse --short HEAD
git worktree add -b agent/claude-task ../app-claude HEAD
git worktree add -b agent/codex-task ../app-codex HEAD
git worktree list
```

Both commands use HEAD explicitly, so the agents begin at the same commit, including local commits on your current branch. Each worktree shares repository history but has its own checked-out files. Install dependencies using your project’s documented setup in each checkout. Create a local development configuration from the example file when needed.

Keep dev-server ports, test databases, and build output paths separate too. Worktrees isolate tracked files; they do not isolate services, credentials, the network, or the rest of your machine. Review each CLI’s permissions and repository instructions before allowing writes.

## 2. Launch one CLI in each checkout

**Terminal 1: Claude Code**

```bash
cd ../app-claude
claude
```

**Terminal 2: Codex, starting from the original repository**

```bash
codex --cd ../app-codex
```

You can use ordinary terminal tabs for this. In CmdBrief, open each checkout in the relevant pane or workspace. For a tool that creates and tracks the worktrees for you instead, [CmdBrief vs Conductor](https://cmdbrief.com/compare/conductor) sets out where each model fits. The development preview adds independent Claude Code and Codex Standard panes. Separate panes do not isolate files: create and manage the worktrees yourself, and review each result before merging. The downloadable release may differ from the preview.

Claude also offers `claude --worktree <name>` to create a checkout and launch a session together. The explicit Git setup above keeps the branch names and starting commit identical for both vendors. See [multiple Claude sessions](https://cmdbrief.com/guides/manage-multiple-claude-code-sessions) for that shortcut.

## 3. Give each agent an independent task contract

Copy this brief into each session, replacing the bracketed fields. Make ownership precise enough that a reviewer can tell whether an unrelated change belongs in the result. Give both agents the same shared interface notes, but a different write scope.

**Reusable task brief**

```text
Outcome: [one observable result]
Working directory: [absolute worktree path]
Write scope: [specific files or component]
Shared interface: [agreed inputs and outputs]
Acceptance: [expected behavior, including a failure case]
Verify with: [the repository's documented commands]
Preserve unrelated changes. Stop if the task needs a shared interface change.
Report the diff, checks run, remaining issues, and any assumptions.
Leave committing, merging, and deployment to me.
```

For a copy you can keep with a task, [download the parallel-agent brief](https://cmdbrief.com/examples/parallel-agent-brief.md). For an independent review, give the reviewer a frozen commit or diff after the implementation is ready; a review of moving files becomes stale as soon as the implementation changes.

## 4. Review and integrate one result at a time

When a session finishes, check its worktree rather than relying on its final message. These commands show tracked changes; the status check also catches new, untracked files that a diff alone will miss. Inspect those files explicitly.

**Review each checkout from the original repository**

```bash
git -C ../app-claude status --short
git -C ../app-claude diff --check
git -C ../app-claude diff
git -C ../app-codex status --short
git -C ../app-codex diff --check
git -C ../app-codex diff
```

Run the relevant checks inside each worktree. Commit only the reviewed files there. Return to a clean integration branch in the original repository and merge the first branch. Run checks, then merge the second and run the combined suite. Two individually passing branches can still conflict in behavior, even when Git merges them cleanly.

**After both worktrees contain reviewed commits**

```bash
git merge --no-ff agent/claude-task
# Run the project's checks and inspect the result.
git merge --no-ff agent/codex-task
# Run the combined checks before publishing anything.
```

## 5. Recover from the common failures

| Symptom | What to check | Next action |
| --- | --- | --- |
| Changes appear in the wrong pane | Actual working directory and branch | Run pwd and git branch --show-current in both panes. |
| One dev server replaces the other | Port and output-directory settings | Assign distinct ports and temporary paths. |
| A formatter changes both tasks’ files | Write scope and repository-wide scripts | Narrow the command or sequence the shared change. |
| Both sessions stop at a usage limit | Provider account and current usage | Parallel sessions share provider capacity; inspect the account’s meter. |
| An agent waits silently | Permission or clarification prompt | Resolve the specific request before launching more work. |

To return later, enter the intended worktree and use `claude --resume` or `codex resume`. Confirm the directory and branch before continuing. Conversation history and uncommitted files are separate: resuming a chat does not replace preserving your checkout.

## 6. Remove only finished worktrees

After both branches are merged, stop their agents and dev servers. Check for uncommitted and ignored files you want to keep before cleanup. Git normally refuses to remove a dirty worktree; do not add a force flag just to bypass that signal.

**After integration and inspection**

```bash
git -C ../app-claude status --short --ignored
git -C ../app-codex status --short --ignored
git worktree remove ../app-claude
git worktree remove ../app-codex
git branch -d agent/claude-task agent/codex-task
```

If review time or interruptions outweigh the saved implementation time, return to one implementation session and one later review. The useful metric is time to an accepted, verified change. The [Claude Code vs Codex evaluation guide](https://cmdbrief.com/guides/claude-code-vs-codex) includes a scorecard for measuring it.

## Questions

### Can Claude Code and Codex edit the same repository at the same time?

Yes. Give each a separate worktree and branch, divide the tasks, and review the combined changes. Two tabs in one directory share files and can overwrite each other’s work.

### Do Git worktrees provide a security sandbox?

No. They provide separate checkouts, not a security boundary. Permissions, services, credentials, and network access still need the appropriate configuration.

### Do I need a paid workspace manager?

No. Git and two terminal tabs are sufficient. A workspace manager can make attention, diffs, and session navigation easier as the number of tasks grows.

## Primary sources

Provider terms and product behavior can change. Confirm plan, pricing, model, and permission details in the current official documentation.

- [Git worktree documentation](https://git-scm.com/docs/git-worktree)
- [Claude Code worktrees](https://code.claude.com/docs/en/worktrees)
- [Claude Code CLI reference](https://code.claude.com/docs/en/cli-reference)
- [OpenAI Codex documentation](https://developers.openai.com/codex/)

## Keep reading

- Comparisons: [Claude Code vs Codex (2026): benchmarks, cost per task, and a fair trial](https://cmdbrief.com/guides/claude-code-vs-codex)
- Workflows: [Codex CLI workflow for local product development (2026)](https://cmdbrief.com/guides/codex-cli)
- Workflows: [Run multiple Claude Code sessions on a Mac: 6 ways (2026)](https://cmdbrief.com/guides/manage-multiple-claude-code-sessions)

---

Markdown mirror of https://cmdbrief.com/guides/run-claude-code-and-codex-in-parallel, generated at build time from the same data the HTML page renders. Machine-readable index: https://cmdbrief.com/llms.txt
