agentleFS
roborracleroborracle/agent-workflow-kit/skills/parallel-agent-git-isolation/SKILL.md

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.

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
  1. Distinctive:

    Before dispatching parallel agents, classify their work:

    line 22
  2. Very specific:

    Commit recovered files atomically with corrective titles (feat(#N): … — content-bearing commit)

    line 40
  3. Distinctive:

    Add audit comments on affected GitHub issues mapping content-SHA → issue

    line 41

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 add time
  • Files written by sibling agents (still uncommitted) leak into the staging set
  • Sibling git reset --soft calls 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 groups

Recovery (when the race has already happened)

  1. git reflog — map orphaned SHAs (commits that were reset away)
  2. git show --name-only <sha> for every recent commit — title may not match content
  3. Recover orphaned files from the working tree (they're often still there as untracked)
  4. Commit recovered files atomically with corrective titles (feat(#N): … — content-bearing commit)
  5. Add audit comments on affected GitHub issues mapping content-SHA → issue
  6. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.