worktree-agent-isolation

Run parallel coding agents in isolated git worktrees and integrate via GitHub pull requests.

2|Updated Jul 18, 2026
One-click install
npx skills add https://github.com/Arasz/ai-badger --skill worktree-agent-isolation-arasz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-agent-isolation
Source: https://github.com/Arasz/ai-badger/tree/main/features/common/skills/worktree-agent-isolation
Command: npx skills add https://github.com/Arasz/ai-badger --skill worktree-agent-isolation-arasz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Running multiple coding agents in the same directory causes build failures from shared obj/ directories, file-modification races, and test corruption from process-global state. This Skill gives each agent its own git worktree branched from origin/main, keeps the main checkout read-only, and integrates completed work through GitHub PRs. ## Core Features & Use Cases - Parallel agent isolation: Create N worktrees from origin/main (after fetching), dispatch agents with absolute worktree paths, and merge sequentially via draft PRs with admin bypass when CI limits block merging. - Blast-radius and dirty-file guards: PreToolUse hook scripts deny unscoped process kills (pkill, killall, shared-cache deletes) while multiple agent lanes are live, and warn when an edit targets a file dirty in another worktree. - Machine-load management: A run_suite.py wrapper applies macOS background QoS (taskpolicy -b) and computes a per-tool worker budget exported as AI_BADGER_TEST_WORKERS so parallel lanes do not oversubscribe the machine. - Use Case: You ask the agent to implement three GitHub issues at once. It creates three worktrees, dispatches three subagents in parallel, verifies builds and tests in each, opens draft PRs, merges them sequentially with rebases, and cleans up the worktrees. ## Quick Start Ask the agent to run these tasks in parallel using worktrees only, without touching the main checkout.

Frequently Asked Questions about worktree-agent-isolation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run multiple coding agents in parallel without conflicts?

Create a separate git worktree per agent with git worktree add, branching each from origin/main after fetching. Pass each agent the absolute worktree path so their working directories never overlap, then integrate results through GitHub pull requests.

Why should worktrees branch from origin/main instead of local main?

Local main often lags behind after other agents or users merge PRs through the GitHub UI. Fetching first and branching from origin/main ensures all worktrees share the same up-to-date ancestor, reducing rebase conflicts during sequential merges.

How do I prevent one agent from killing another agent's processes?

The blast_radius_kill_guard.py PreToolUse hook denies unscoped kills like pkill, killall, and shared-cache deletes when two or more agent lanes are live. Re-issuing the exact same command three times opens an escape valve for genuinely needed operations.

Why do tests time out when running parallel agents with QoS enabled?

The taskpolicy -b background QoS class makes wrapped processes about 2.11x slower, shrinking the margin on fixed startup timeouts. Raise fixed timeouts by at least 2.5x, never wrap long-lived infrastructure like dev servers, or set AI_BADGER_QOS=off to exempt a lane.

What happens if git worktree add is used without -b?

Using git worktree add with a remote branch and no -b flag creates a detached HEAD, so commits silently vanish and git push reports everything up-to-date. Always create an explicit local branch with -b or reuse an existing local branch.

When should I not use worktree isolation for agents?

Avoid it when tasks must share one worktree deliberately, when tooling like Rider MCP binds only to the main checkout, or when two tasks rewrite the same file — in that case defer the shared section to one owning task instead of duplicating the work.