agentleFS
AkashPriyadarshiiAkashPriyadarshii/cookbook/cross/SKILL.md

multi-agent-git

Skill0 starsChanged 3 months agoMITView on GitHub

Multi-agent git coordination: shared working directories cause commit theft, worktree isolation protocol, handoff-log discipline. Use when running multiple AI agents (or humans+agents) on one repo across different branches.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    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. Very specific:

    Check: after another agent pushes, git show <their-tip> --stat — none of your in-flight files should appear.

    line 29

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

Multi-Agent Git Coordination

Lessons from a repo run by two AI agents on separate branches simultaneously.

1. A checkout in a shared dir steals uncommitted edits

Bug: agent B ran git checkout <branch-B> in the directory where agent A was mid-edit. A's uncommitted changes rode along and were swept into B's next commit. Recovery meant diffing B's tip against intent and porting files back by hand.

Fix: one worktree per agent, created up front:

git worktree add ../<repo>-<topic> <branch>

Agents never git checkout in a directory another agent occupies, and commit only files inside their declared territory (never git add -A).

Check: after another agent pushes, git show <their-tip> --stat — none of your in-flight files should appear.

2. Handoff log beats memory

Parallel agents don't see each other's sessions. A root-level HANDOFF.md with a mandatory append-before-exit entry (did / in-flight / don't-touch), newest first, plus a territory table in AGENTS.md ("read FIRST"), prevents both collision and duplicated work. The log entry costs 30 seconds; untangling a stolen commit costs an hour.

3. Background work must die with the activity or the hand-off races the destroy

Bug: a zero-UI trampoline activity ran the strip on a raw Executors.newSingleThreadExecutor() and called startActivity() from runOnUiThread when done. Back-press mid-strip destroyed the activity under the running executor; the UI runnable then fired startActivity on a dead activity and threw IllegalStateException in the originating app's face. Home press orphan-marked the completion the same way.

Fix: three guards, cheap and independent:

  • swallow back-press (onBackPressed no-op) while the short strip window is open — the chooser after it has its own back handling;
  • bail in the UI runnable (if (isDestroyed || isFinishing) return) before any Toast/startActivity;
  • shutdownNow() the executor in onDestroy.

Check: share → press Back mid-strip → app stays alive, no crash, no toast, no chooser; second share during a strip re-reads via onNewIntent.

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.