Get the FREE Ultimate OpenClaw Setup Guide →

worktree-isolation

Scanned
npx machina-cli add skill a5c-ai/babysitter/worktree-isolation --openclaw
Files (1)
SKILL.md
2.0 KB

worktree-isolation

You are worktree-isolation -- the git worktree management skill for Pilot Shell.

Overview

This skill manages git worktrees for isolated feature development, ensuring that work-in-progress never pollutes the main branch. Worktrees provide full filesystem isolation with shared git history.

Capabilities

1. Worktree Creation

# Create worktree with feature branch
git worktree add .claude/worktrees/<slug> -b feature/<slug>
cd .claude/worktrees/<slug>
npm install  # or equivalent package manager

2. Worktree Detection

  • Check if currently inside a worktree
  • Identify the base branch
  • Detect worktree state (clean, dirty, conflicts)

3. Worktree Sync

  • Pull latest changes from base branch into worktree
  • Rebase feature branch on updated base
  • Resolve conflicts if needed

4. Worktree Diff

  • Generate diff between worktree and base branch
  • Summarize changes by file and type
  • Calculate diff statistics

5. Worktree Cleanup

  • Remove worktree after successful merge
  • Delete feature branch
  • Prune stale worktree references

6. Worktree Status

  • List all active worktrees
  • Show branch and status for each
  • Identify orphaned worktrees

Branch Naming Convention

ModePatternExample
Featurefeature/<slug>feature/add-user-auth
Bugfixbugfix/<slug>bugfix/fix-payment-race
Quickquick/<number>quick/042

Multiple Parallel Sessions

Worktrees enable multiple Pilot Shell sessions to work simultaneously without interference, as each operates in its own filesystem directory with its own branch.

Source

git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/methodologies/pilot-shell/skills/worktree-isolation/SKILL.mdView on GitHub

Overview

worktree-isolation manages Git worktrees to keep feature development isolated from the main branch. It supports creating, syncing, diffing, and cleaning up worktrees with clear branch naming patterns and dependency setup. This reduces risk of polluting main and enables multiple parallel sessions.

How This Skill Works

The skill creates a dedicated directory under .claude/worktrees/<slug> with a named feature branch using git worktree add -b feature/<slug>. It then changes into that directory to install dependencies and work in an isolated environment. It also provides detection, sync, and cleanup capabilities including pulling base changes, rebasing, resolving conflicts, diffing against the base, and removing worktrees when done.

When to Use It

  • To develop a new feature without touching the main branch
  • When running parallel experiments in separate worktrees across multiple sessions
  • To reproduce or fix a bug in an isolated base environment
  • Before creating a PR to keep the base branch clean and up to date
  • When finished with a feature and ready to clean up and prune references

Quick Start

  1. Step 1: git worktree add .claude/worktrees/<slug> -b feature/<slug>
  2. Step 2: cd .claude/worktrees/<slug> && npm install
  3. Step 3: When done, git worktree remove .claude/worktrees/<slug> and prune references

Best Practices

  • Follow the branch naming convention feature/<slug> or bugfix/<slug> to keep worktrees organized
  • Always sync with the latest base before starting worktree work
  • Use worktree diff and status to track changes and avoid drift
  • Clean up worktrees promptly after a successful merge or discard
  • Prune stale worktree references to prevent orphaned directories

Example Use Cases

  • Create a feature worktree for adding user authentication and install dependencies in the isolated dir
  • Open a bugfix worktree to investigate a race condition in payment processing
  • Spin up a quick experiment in quick/042 without affecting ongoing development
  • Sync a worktree with the latest base, rebase the feature branch, and resolve conflicts
  • After merging the feature, remove the worktree and delete feature/<slug> branch

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers