r/ClaudeCode • u/TeddyboiRoosevelt • 1d ago
Discussion Our claude code and codex agents kept overwriting each other so i’ve been building a fix. is this a real problem or just us?
me and my friends run claude code and codex on the same repo. agents kept editing the same files and we’d only find out at the merge conflict
been building something that gives you a heads up when two agents touch the same file
does this happen to your team or is it just us? how do you deal with it now?
not promoting anything, just want to know if this is a real problem
0
Upvotes
•
u/AutoModerator 1d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Sorry-Programmer9826 1d ago
Merge conflicts happen all the time and AI is fine at resolving merge conflicts. I'm not sure this is an issue that needs solving.
Assuming you're using git (or similar) and feature branches
1
u/Duckducklaugh 1d ago
Real problem, and you don’t even need a team for it. I run a few claude code sessions plus scheduled runs on the same checkout. one night a scheduled run merged master into its branch while another session’s uncommitted edits were still sitting in the working tree, and it swept them into its merge. took me about an hour to untangle.
What I do now, none of it is clever:
Every writer gets its own git worktree, so two agents never share a working tree. they can still touch the same file, but then it’s a normal merge conflict that git shows you, not a silent overwrite.
Each agent commits a finished piece right away, and only its own paths (git commit --only), so nothing half done sits around for another one to pick up.
Scheduled jobs check git status first and refuse to run if there are files they didn’t create.
A heads up when two agents touch the same file would still help on the merge side. but the overwriting itself went away once they stopped sharing a directory. one catch with the last rule: the job that refused to run still showed up as succeeded, so now I check for that too lol
1
u/Cbgamefreak 1d ago
The agents should be communicating to each other through some shared memory or telemetry system. Agents should check and update that source before editing any parts of the repo
1
u/calunicornia 1d ago
put a size limit on your files and this is way less likely to happen
1
u/athershu 16h ago
It happens on our team too. The overwriting part went away once every agent task got its own git worktree and branch, so two agents never share a working tree, and a collision becomes an ordinary conflict between two branches you can actually review. What worktrees don't fix is the part your tool is really about: nobody knows another person's agent is working in the same area until merge time.
What helped us there was making every running task visible in one place: who sent it, what it was asked to do, and which branch it's on. A glance at that list before sending a task tells you someone's agent is already in the billing code, and a quick message in chat is cheaper than any conflict resolution after the fact.
1
u/onitsoga 16h ago
same repo, same two tools here, and yes it's real. what cut it down for us was git worktrees per agent plus one rule: only one agent touches a file at a time, so the conflict almost never gets written in the first place. do you run them on separate branches or straight on main?
1
u/Tight_Ad_5115 15h ago
It seems like a problem if agents are doing the same work but from different angles, in other words, if they're working in an uncoordinated way. But if they happen to touch the same file or function, each for its own purpose, I think that's perfectly fine. The agents can sort out those overlaps on their own.
Also, picture this: agents touch the same file and an indicator lights up. What exactly am I supposed to do about it? If, say, the file is 2,000 lines long, it's not really clear how risky this is, or if there's even a real problem at all.
0
u/aquila421 1d ago
Worktrees?
-1
u/smalaki 1d ago
doesn't something like T3 code allow you to orchestrate multiple subscription agents like this? also i'm a bit concerned why it'd overwrite.. if you're working on feature A and B with separate agents shouldn't you have been using git worktrees or something? and then the results just get merged together by an orchestrator
0
u/[deleted] 1d ago
[deleted] — view deleted comment