parallel-agent-git-isolation
Skill0 starsChanged 3 months agoMITView on GitHub
Use when planning to dispatch 2+ sub-agents that will each perform git operations (add/commit/branch). Mandates worktree isolation or sequential dispatch — never share a working directory + git index across concurrently-committing agents.
In this repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- a11y-auditSkill
- ai-engineerSkill
- api-clientSkill
- changelog-enforcerSkill
- code-cleanup-guardianSkill
- code-reviewerSkill
- contract-testSkill
- db-migrateSkill
- dep-auditSkill
- devops-automatorSkill
- env-configSkill
- error-observabilitySkill
- frontend-designSkill
- git-commit-helperSkill
- github-issues-managerSkill
- git-issue-syncSkill
- git-protocolSkill
- handoffSkill
- incident-responseSkill
- init-projectSkill
- karpathy-guidelinesSkill
- market-researcherSkill
- product-strategistSkill
- pr-workflowSkill
- rapid-builderSkill
- release-managerSkill
- resumeSkill
- scrutinizeSkill
- shadcn-uiSkill
- skill-builderSkill
- sprint-plannerSkill
- state-machine-diagramsSkill
- state-managementSkill
- surveySkill
- system-architectSkill
- tech-docsSkill
- unstuckSkill
- ux-design-systemSkill
- ux-researchSkill
- webapp-testingSkill
- web-dev-fundamentalsSkill
- workflow-optimizerSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Before dispatching parallel agents, classify their work:
- Very specific: line 40
Commit recovered files atomically with corrective titles (feat(#N): … — content-bearing commit)
- Distinctive: line 41
Add audit comments on affected GitHub issues mapping content-SHA → issue
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Parallel Agent Git Isolation
The Rule
Parallel agents that perform git operations MUST use git worktrees (one per agent) OR be dispatched sequentially. Agents that read/write files only (no git ops) may share a working directory; the orchestrator handles the single commit. Never run multiple agents concurrently against a shared git index.
Why
Concurrent agents in the same cwd corrupt each other's commits:
- Each agent reads the working tree at
git addtime - Files written by sibling agents (still uncommitted) leak into the staging set
- Sibling
git reset --softcalls can orphan in-flight commits - Result: commits with titles that don't match their tree contents; sometimes whole files disappear (orphaned in reflog only)
How to Apply
Before dispatching parallel agents, classify their work:
Will any agent run git add / git commit / git branch ?
├── No (read/write only) → safe to share cwd; orchestrator commits at end
└── Yes → MUST isolate. Pick one:
├── Worktree-per-agent (preferred): invoke superpowers:using-git-worktrees,
│ give each agent a fresh worktree path
├── Sequential dispatch: one at a time, await completion before next
└── Files-only contract: agents do NOT commit; they only write to disk;
orchestrator scans output, stages by path, commits in named groupsRecovery (when the race has already happened)
git reflog— map orphaned SHAs (commits that were reset away)git show --name-only <sha>for every recent commit — title may not match content- Recover orphaned files from the working tree (they're often still there as untracked)
- Commit recovered files atomically with corrective titles (
feat(#N): … — content-bearing commit) - Add audit comments on affected GitHub issues mapping content-SHA → issue
- Never
--force,--amend, or rebase a pushed branch to fix the labels. Additive corrective commits + audit comments are the only safe path.
Reference
This rule exists because the failure is silent. Six parallel agents committing in one shared working directory will interleave git add and git commit calls, and the result is commits whose message describes work that landed in a different commit — plus orphaned changes attributed to nothing. Nothing errors. The branch looks fine. You find out weeks later when you try to revert one change and take three others with it.
Worktrees cost about a second to set up. Use them.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

