Skip to content
Schemory
Article doesn’t workNew

Two parallel Claude Code sessions changed the same business rule and collided on main

Log in to cache0 cached it

Two sessions in separate worktrees each rewrote the same scoring rule in a different way; the second push was rejected and the rebase conflicted, and only the agent stopping to ask kept one version from silently overwriting the other.

Reported by @juliandierker · Verified 2026-11-21

Agent
Claude Code
Model
claude-opus-5-5
Stack
TypeScript

Problem

I run several Claude Code sessions at once, each in its own git worktree, and each one pushes straight to main with a deploy when I say "push and deploy". Two of them had separate tasks: one changed how items are scored, the other added a new kind of user action. Both tasks touched the same scoring rule, and I hadn't noticed. Session B's feature also folded the new action into the score, with weights different from the ones I had just given session A. It also deleted the UI component where session A's new score display lived.

Session B pushed first. Session A's push was rejected because main had moved while A's pre-push checks were running.

Setup

  • Claude Code desktop, two sessions started from the same main, each in its own worktree on its own branch.

  • Each session pushed with git push origin HEAD:main, and pre-push hooks ran tests and lint first.

  • No locking or ownership of shared files across sessions. Each prompt described only its own feature.

What happened

After the rejected push, session A rebased onto the new main and hit conflicts in four UI files and in the scoring rule itself. It didn't pick a side. It aborted the rebase, left both versions intact (its work on its branch, main as the other session left it) and reported the clash as decisions for me:

  • Weights: session B used a three-way split. Session A used the two-way split I had asked for.

  • UI: session B deleted the component holding A's new display.

  • Empty values: session B counted zero votes as "halfway", and session A counted them as 0.

I answered in one line (treat the two community signals as one). The agent then rebased, kept the other session's layout, moved its own display into it, merged the rule, updated the docs and reran the full suite (463 tests, typecheck, lint, dead-code scan). One more check caught something: the auto-mode permission check blocked the final push, and the agent didn't retry. My earlier "push and deploy" approved the old version, so it asked again before pushing the merged one.

So it failed at the workflow level. Parallel sessions with no shared view of the business rules both changed them. Nothing was lost only because the agent treated a conflict in a rule file as a product decision, not a merge chore.

Reproduce

  1. Start two Claude Code sessions in separate worktrees from the same main.

  2. Give them different features that both touch one shared rule or config, such as scoring weights or a pricing table, without telling either session about the other.

  3. Let both push to main. The second push is rejected and the rebase conflicts in the shared file.

  4. To prevent it: before starting parallel sessions, list the files each one may change. Add to each prompt: "If a rebase conflicts in business rules or docs, abort it and ask me which rule wins. Don't resolve it yourself, and don't push again without a fresh yes."

  5. To see the conflict before the push: have each session run git fetch && git diff HEAD...origin/main -- <shared rule files> before it starts and again before it pushes.

Worth keeping?

Cache it and it lands on your page, next to everything else you keep.

Score 0 from caches on Schemory

Log in to cache0 cached it

NewAt 10 caches a report turns Trusted.