Laojin GlobalAI · GO GLOBAL
Back to list
Seven People Editing One Repo Without Collisions: My Parallel Sessions Protocol
AI Workflows·8 min read

Seven People Editing One Repo Without Collisions: My Parallel Sessions Protocol

Field-proven: one day, 7 worktrees, 8 merged PRs, 6 collision incidents — every mechanism below exists because one of them happened. Draft PR board + resource claiming + merge discipline + three-checkpoint refresh: unbounded parallel sessions.


The problem: multiple AI sessions developing the same repo, how do they avoid stepping on each other?

I run multiple Claude Code / Codex sessions in parallel on the same git repo. At first I thought just use separate branches. Then one day: two tracks claimed the same decision number, four tracks editing shared ledger files caused merge conflicts, git add -A swept another track's four uncommitted files into my commit, and someone asked a question that had been resolved three hours ago — because they hadn't checked the latest state.

That day's tally: 7 simultaneous worktrees, 8 merged PRs, 6 collisions of different kinds.

parallel-sessions-protocol grew out of that incident report.

Mechanism 1: Register before you code (the board)

Before writing any code:

  1. git fetch origin + gh pr list --state open — see the whole board first.
  2. Branch from latest origin/main; take an exclusive working directory (the main checkout counts as one — at most one session may own it at a time).
  3. Immediately open a draft PR with three fixed sections:

- Claimed scope — directories/files this track will touch - Claimed numbers — sequential resources taken; write none if none - Current status — one line, updated at milestones

  1. When the track ends (merged or abandoned), the PR closes and the board self-cleans.

The board is gh pr list. Spawned/background sessions follow the same rule.

Mechanism 2: Claim before you use

ResourceRule
Sequential numbersBefore taking: check max on main and scan every open PR's Claimed numbers. Take the smallest free one; write it into your draft PR.
Files / directoriesDo not touch files inside another track's claimed scope. If you must: wait for its merge, or escalate to the human owner.
Collision anywayThe later merger yields (renumbers / rebases). The earlier merge never changes — renumbering merged history breaks every reference.

Mechanism 3: Ledger writes only at merge time

Shared ledger docs are where parallel tracks collide by construction:

  1. Never touch shared ledger files while the track is alive. Process notes go in the track's own files — zero conflict.
  2. As the final step before merge: rebase onto latest main, then append your ledger entries, then request merge immediately.
  3. Merges are serial, so ledger writes become serial too — conflicts go from guaranteed to rare.
  4. If one still happens: the only correct resolution is keep both sides in full. Dropping either side erases another track's accounting.

Mechanism 4: Merge discipline

  • Merges are serial. Who may merge what follows the project's own rules.
  • Always preview locally before merging: git merge origin/main --no-commit --no-ff. GitHub's MERGEABLE flag lags behind latest main and has reported CLEAN on branches that actually conflict — verified in production.
  • Never park a worktree on the main branch — it blocks every other session's operations that need to check out main.
  • **Never git add -A** when tracks run in parallel; always add explicit paths. A blanket add sweeps other tracks' uncommitted files into your commit, and if their content happens to match main you won't even notice.
  • After rebasing a pushed branch, push with --force-with-lease (plain push is rejected; plain --force can destroy a concurrent update).

Mechanism 5: Refresh at three checkpoints + CI glance

Run git fetch + gh pr list at: start of work, before asking the owner anything or reporting a major conclusion, and before merging.

At start of work, also glance at CI: gh run list --limit 5. If main is red, report it before starting anything new — a red cron once ran 45 consecutive failures over four days because every session assumed someone else was watching.

Mechanism 6: Register at end of work (teardown)

When the session stops — done for now, paused, or interrupted — while the track lives on:

  1. Push or declare. Push unmerged work to the track's branch. If you cannot push, write a WIP declaration into the draft PR.
  2. Worktree hygiene. Remove your worktree when done; if you must leave it, log why in the PR. Orphan worktrees accumulate silently.
  3. Refresh the board. Update the draft PR's Current status line.
  4. Write back triggered items. Any pending item whose trigger condition has already fired gets closed now, not later.

Real incidents vs the mechanisms that killed them

Real incident (one day, one repo)Killed by
Two tracks claimed the same decision number — twiceMechanism 2
Shared ledger files edited by four tracks → merge conflictsMechanism 3
git add -A swept another track's four uncommitted files into a commitMechanism 4
Owner asked four questions another session had already resolvedMechanism 5 ②
A track started work another session didn't know aboutMechanism 1
CI red for 45 consecutive runs, unnoticed by anyoneMechanism 5 glance

Install

bash git clone https://github.com/laojin1900/365Skill.git ./install.sh parallel-sessions-protocol

Repo: github.com/laojin1900/365Skill/tree/main/skills/parallel-sessions-protocol

Made by Laojin · AI that ships

365SkillAn agent-skills lab: 13 in-house skills

365Skill is our public lab for agent skills: a standard SKILL.md format, a deny-by-default publish policy, and an evals harness. It holds 13 original 365 skills — 11 public and 2 internal. Apache-2.0 — star it, install it, file issues.

More from Laojin: Sellenca · 365AIOrg · AllModelsAPI · 365Loopa · 365 Ops

Related

Linked by topic, people and hubs