agentleFS
0SxD0SxD/agent-skills-plugin-v01/skills/worktree-isolation/SKILL.md

worktree-isolation

Skill0 starsChanged 7 months agoMITView on GitHub

Create and manage git worktrees for parallel coding agent isolation. Invoke when two independent coding tasks need to run simultaneously (max 2).

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 11 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 11

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the EnterWorktree tool or bash equivalent:

    line 16
  2. Distinctive:

    ALL gates must PASS before merge is allowed.

    line 43
  3. Distinctive:

    After Stage 1 PASS + Austin approval:

    line 47
  4. Distinctive:

    After merge to local main:

    line 63
  5. Distinctive:

    NEVER share files between worktrees

    line 70
  6. Distinctive:

    NEVER run more than 2 worktrees simultaneously

    line 71
  7. Distinctive:

    ALWAYS delete worktree after merge (no stale worktrees)

    line 72
  8. Distinctive:

    ALWAYS run full audit before merge

    line 73
  9. Distinctive:

    All coding agents use worktrees — not just Claude sub-agents:

    line 78
  10. Distinctive:

    No two agents share a worktree

    line 89
  11. Distinctive:

    All worktree output goes through Claude's 5-gate audit pipeline before merge

    line 90

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “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

Worktree Isolation Pattern

When to Use

  • Two independent coding tasks can run in parallel (no shared files)
  • Each task is self-contained (different feature branches)
  • Max 2 worktrees active at any time (= max 2 concurrent agents)

Step 1 — Create Worktree

Use the EnterWorktree tool or bash equivalent:

git worktree add _worktrees/{task-id} -b feature/{task-id}-{short-description}

Each worktree gets its own:

  • Working directory: _worktrees/{task-id}/
  • Feature branch: feature/{task-id}-{short-description}
  • Complete copy of the codebase (shares .git objects, not files)

Step 2 — Dispatch Agent to Worktree

In Agent tool call, direct the agent to work within the worktree path:

  • Agent reads/writes ONLY within _worktrees/{task-id}/
  • Agent has NO access to main working tree files
  • Agent has NO knowledge of what the other worktree agent is doing

Step 3 — Stage 1 Audit (before merge)

Each worktree's output goes through the full 5-gate audit pipeline:

  1. Semgrep (plugin)
  2. CodeRabbit (plugin)
  3. Code-review + pr-review-toolkit (plugins)
  4. Security-guidance (plugin)
  5. Clone repo comparison (_repos/)

ALL gates must PASS before merge is allowed.

Step 4 — Merge Back

After Stage 1 PASS + Austin approval:

# Return to main working tree
git checkout main

# Merge the feature branch (no fast-forward for audit trail)
git merge feature/{task-id}-{short-description} --no-ff

# Clean up
git worktree remove _worktrees/{task-id}
git branch -d feature/{task-id}-{short-description}

Step 5 — Stage 2 (GitHub PR Airlock)

After merge to local main:

  1. Push branch → open PR (Austin approval required)
  2. GitHub Actions: remote semgrep + CodeRabbit
  3. Austin reviews → merges

Rules

  • NEVER share files between worktrees
  • NEVER run more than 2 worktrees simultaneously
  • ALWAYS delete worktree after merge (no stale worktrees)
  • ALWAYS run full audit before merge
  • Worktree directory: _worktrees/ (gitignored)

Multi-Agent Worktree Usage

All coding agents use worktrees — not just Claude sub-agents:

AgentWorktree?Branch patternNotes
Claude (Opus)NO — stays on mainn/aOrchestrator. Never leaves main working tree.
Claude (Sonnet)YESfeature/{task-id}-claude-{desc}Dispatched by Opus
Gemini (AntiGravity)YESfeature/{task-id}-gemini-{desc}Works in IDE on its own worktree
CodexYESfeature/{task-id}-codex-{desc}Works in IDE on its own worktree
  • Opus NEVER works in a worktree — it stays on main to orchestrate and review
  • Each coding agent gets its own worktree and feature branch
  • No two agents share a worktree
  • All worktree output goes through Claude's 5-gate audit pipeline before merge

Emergency Cleanup

git worktree list              # see all active worktrees
git worktree remove --force _worktrees/{task-id}  # force remove
git worktree prune             # clean up stale entries

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.