Skip to content
OpenAgentSkill
Browsing is open · Catalog captured 2026-11-21 · Automatic updates and account services are paused.
Development

using-git-worktrees

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools

roundpilot · Static checks on file

Installation

Read the source and dependencies before running a command. Copying does not install or execute anything.

npx skills add roundpilot/superpowers-antigravity --skill using-git-worktrees

About this skill


name: using-git-worktrees description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools

Using Git Worktrees

Overview

Ensure work happens in an isolated workspace using Antigravity 2.0's native workspace isolation.

Core principle: Detect existing isolation first. Then use Workspace: "branch" on invoke_subagent. Never use manual git worktree add.

Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."

Step 0: Detect Existing Isolation

Before creating anything, check if you are already in an isolated workspace.

Verify Git Repository Existence:

If not inside a git repository, you cannot use worktrees. Check if you need to run git init first.

if ! git rev-parse --is-inside-work-tree &>/dev/null; then
    echo "ERROR: Not inside a Git repository."
    exit 1
fi
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
BRANCH=$(git branch --show-current)

Submodule guard: GIT_DIR != GIT_COMMON is also true inside git submodules. Verify:

git rev-parse --show-superproject-working-tree 2>/dev/null

If GIT_DIR != GIT_COMMON (and not a submodule): Already isolated. Skip to Step 2.

If GIT_DIR == GIT_COMMON (or in a submodule): Normal repo. Proceed to Step 1.

Step 1: Create Isolated Workspace

For subagent tasks: Use Workspace: "branch" parameter on invoke_subagent. This creates an isolated workspace on a new git branch automatically. The platform handles directory placement, branch creation, and cleanup.

For parent orchestrator feature branches: Use git checkout -b <branch> directly. No worktree needed — the orchestrator works in place on a feature branch.

Step 2: Project Setup

Auto-detect and run appropriate setup:

# Node.js
if [ -f package.json ]; then npm install; fi

# Rust
if [ -f Cargo.toml ]; then cargo build; fi

# Python
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi

# Go
if [ -f go.mod ]; then go mod download; fi

Step 3: Verify Clean Baseline

Run tests to ensure workspace starts clean:

npm test / cargo test / pytest / go test ./...

If tests fail: Report failures, ask whether to proceed or investigate. If tests pass: Report ready.

Quick Reference

SituationAction
Already in linked worktreeSkip creation (Step 0)
In a submoduleTreat as normal repo (Step 0 guard)
Subagent taskWorkspace: "branch" on invoke_subagent
Parent orchestratorgit checkout -b <branch>
Tests fail during baselineReport failures + ask

Workspace Mode Decision Table

Antigravity 2.0 supports three workspace modes for subagents. Choose based on the agent's role:

ModeSyntaxUse forExample
branchWorkspace: "branch"Agents that need isolated write accessImplementers, fixers
inheritWorkspace: "inherit"Read-only agentsReviewers, analyzers
shareWorkspace: "share"Agents editing different files in same repoParallel fixers on separate test files

Rules of thumb:

  • If the agent writes code → branch
  • If the agent only reads and reports → inherit
  • If multiple agents edit non-overlapping files → share

Red Flags

Never:

  • Use git worktree add — use Workspace: "branch" instead
  • Create a worktree when Step 0 detects existing isolation
  • Skip baseline test verification
  • Proceed with failing tests without asking

Always:

  • Run Step 0 detection first
  • Use native workspace isolation
  • Auto-detect and run project setup
  • Verify clean test baseline