<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/eoNgX6nqT" -->

---
title: Two coding agents in one checkout overwrite each other,...
description: Running Claude Code and Codex at the same time on one repo breaks in predictable ways, and each has a fix. Give each agent its own git worktree so they don't...
canonical: https://daily.dev/posts/two-coding-agents-in-one-checkout-overwrite-each-other-so-i-gave-each-its-own-git-worktree-gotchas-eongx6nqt
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Two coding agents in one checkout overwrite each other, so I gave each its own git worktree. Gotchas: one branch can't be in two worktrees, .env doesn't come along, stash is shared, rm -rf leaves a stale worktree until prune. Commands in the post. | daily.dev
og:description: Running Claude Code and Codex at the same time on one repo breaks in predictable ways, and each has a fix. Give each agent its own git worktree so they don't...
og:url: https://daily.dev/posts/two-coding-agents-in-one-checkout-overwrite-each-other-so-i-gave-each-its-own-git-worktree-gotchas-eongx6nqt
og:image: https://api.daily.dev/og/posts/eoNgX6nqT.png
og:image:alt: Two coding agents in one checkout overwrite each other, so I gave each its own git worktree. Gotchas: one branch can't be in two worktrees, .env doesn't come along, stash is shared, rm -rf leaves a stale worktree until prune. Commands in the post.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Two coding agents in one checkout overwrite each other, so I gave each its own git worktree. Gotchas: one branch can't be in two worktrees, .env doesn't come along, stash is shared, rm -rf leaves a stale worktree until prune. Commands in the post.

**[AI](https://daily.dev/sources/ai)** · [@arunbhatia](https://daily.dev/arunbhatia) · 13 upvotes · 4 comments

## Summary

Running Claude Code and Codex at the same time on one repo breaks in predictable ways, and each has a fix. Give each agent its own git worktree so they don't clobber each other's files. Git blocks checking out the same branch in two worktrees, worktrees don't inherit .env or node_modules, the stash is shared across all worktrees, and a deleted worktree folder stays registered until you run 'git worktree prune'. For review, pipe the uncommitted diff to a different model (Codex's 'review --uncommitted' or 'git diff HEAD | claude -p') since a model misses different bugs than the one that wrote the code. Separate logins via CLAUDE_CONFIG_DIR and CODEX_HOME let you switch accounts when one hits its usage limit; writing a HANDOFF.md lets the next session pick up where the last left off. Tested with git 2.50.1, Claude Code 2.1.296 and Codex CLI 0.162.1.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dev.to/offrun/running-claude-code-and-codex-in-parallel-on-one-repo-git-worktree-gotchas-and-cross-review-41eg>

## Community discussion

Top comments from developers on daily.dev.

**@swarnasharmin** · 1 upvotes

> How do you handle shared stash conflicts when multiple git worktrees are active simultaneously?

**@laouadirabah** · 0 upvotes

> Worktrees isolate working files, but not every Git operation. I'd give each agent a dedicated branch, avoid a shared stash, and review the exact diff before merging. Do you also isolate build output directories to prevent concurrent builds from interfering?

## Similar posts on daily.dev

- [Git Worktree Guide: Parallel Branches and Claude Code](https://daily.dev/posts/git-worktree-guide-parallel-branches-and-claude-code-froeaqrpw) · Alex CloudStar · 5 upvotes · 3 comments
- [How to Run Claude Code Agents in Parallel](https://daily.dev/posts/how-to-run-claude-code-agents-in-parallel-48pijeifu) · Towards Data Science · 1 upvotes · 0 comments
- [Inside the Development Workflow of Claude Code's Creator](https://daily.dev/posts/inside-the-development-workflow-of-claude-code-s-creator-rmtwa51nd) · InfoQ · 2 upvotes · 1 comments

---

Tags: [#ai](https://daily.dev/tags/ai), [#ai-agents](https://daily.dev/tags/ai-agents), [#git](https://daily.dev/tags/git), [#claude-code](https://daily.dev/tags/claude-code), [#openai-codex](https://daily.dev/tags/openai-codex)

[View this post on daily.dev](https://daily.dev/posts/two-coding-agents-in-one-checkout-overwrite-each-other-so-i-gave-each-its-own-git-worktree-gotchas-eongx6nqt)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/two-coding-agents-in-one-checkout-overwrite-each-other-so-i-gave-each-its-own-git-worktree-gotchas-eongx6nqt","headline":"Two coding agents in one checkout overwrite each other, so I gave each its own git worktree. Gotchas: one branch can't be in two worktrees, .env doesn't come along, stash is shared, rm -rf leaves a stale worktree until prune. Commands in the post.","text":"Shared: Running Claude Code and Codex in parallel on one repo: git worktree gotchas and cross-review","url":"https://daily.dev/posts/two-coding-agents-in-one-checkout-overwrite-each-other-so-i-gave-each-its-own-git-worktree-gotchas-eongx6nqt","datePublished":"2026-10-25T08:20:23.093Z","dateModified":"2026-10-25T08:23:47.745Z","author":{"@type":"Person","name":"arun bhatia","url":"https://daily.dev/arunbhatia","image":"https://lh3.googleusercontent.com/a/ACg8ocJ3p5nBkc0FbZHDLRdPoVeQ-srhLqTn7liU6DylrPzbynl4xQ=s96-c","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":180}},"image":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":13},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":4}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/rDtFnIU9S"},"comment":[{"@type":"Comment","text":"How do you handle shared stash conflicts when multiple git worktrees are active simultaneously?","datePublished":"2026-11-01T07:19:07.738Z","url":"https://daily.dev/posts/eoNgX6nqT#c-mfRionWlu","author":{"@type":"Person","name":"Swarna Sharmin","url":"https://daily.dev/swarnasharmin","image":"https://media.daily.dev/image/upload/s--joHEq_jD--/f_auto/v1791022797/avatars/avatar_ZL6bebyCVkszL2cr0g8ab?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Worktrees isolate working files, but not every Git operation. I’d give each agent a dedicated branch, avoid a shared stash, and review the exact diff before merging. Do you also isolate build output directories to prevent concurrent builds from interfering?","datePublished":"2026-11-05T14:18:48.997Z","url":"https://daily.dev/posts/eoNgX6nqT#c-OJDxSZixP","author":{"@type":"Person","name":"Laouadi Rabah","url":"https://daily.dev/laouadirabah","image":"https://media.daily.dev/image/upload/s--6KWipDP0--/f_auto,pg_1/v1793809646/avatars/avatar_9vh1jiHAayxjAF8edWIJq?_a=BAMAMiiw0"}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/ai","name":"AI"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"AI","item":"https://daily.dev/squads/ai"},{"@type":"ListItem","position":3,"name":"Two coding agents in one checkout overwrite each other, so I gave each its own git worktree. Gotchas: one branch can't be in two worktrees, .env doesn't come along, stash is shared, rm -rf leaves a stale worktree until prune. Commands in the post."}]}
```

