worktree-isolation

Verify worktree context before executing git write operations.

4|1|Updated Oct 29, 2025
One-click install
npx skills add https://github.com/samjhecht/wrangler --skill worktree-isolation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-isolation
Source: https://github.com/samjhecht/wrangler/tree/main/skills/worktree-isolation
Command: npx skills add https://github.com/samjhecht/wrangler --skill worktree-isolation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Git worktrees enable isolated workspaces, but Claude Code's Bash invocations can reset or misalign the working directory, causing changes to bleed into the main branch. This Skill provides explicit verification protocols and command patterns to ensure all changes stay contained within the intended worktree.

Core Features & Use Cases

  • Mandatory pre-flight verification before any git operation to confirm current worktree
  • Patterned command chaining (cd && git ...) to preserve context across tool invocations
  • Use of absolute paths (git -C /path/to/worktree ... or cd to path first)
  • Clear prompts for subagents to preserve execution context and prevent bleed

Quick Start

  • Announce usage: "Using Skill: worktree-isolation | [context-specific purpose]"
  • Always run commands in the target worktree, e.g.: cd /path/to/worktree && git status
  • Before write operations, print verification details (current directory, git root, branch) and STOP if mismatched

Frequently Asked Questions about worktree-isolation

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

FAQPage Schema
How do I prevent git changes from bleeding between worktrees?

Git worktrees can leak changes between branches if your working directory resets during operations. This Skill enforces mandatory verification of your current worktree before each git command, uses absolute paths or chained commands to preserve context, and stops write operations if the worktree context doesn't match your intent.

What's the best way to ensure git operations stay in the right worktree?

Chain commands to preserve context (cd /path/to/worktree && git ...), use absolute paths with git -C, and always verify your current directory and branch before writes. This Skill provides verification protocols and patterns to keep changes isolated and prevent accidental modifications to the wrong branch.

Can I use git worktrees without changes affecting my main branch?

Yes. Git worktrees create isolated workspaces by design, but working directory resets can cause changes to bleed into main. This Skill applies pre-operation verification blocks, explicit worktree-context propagation, and command chaining patterns to guarantee isolation and protect your main branch.

Why do my git worktree changes sometimes affect the wrong branch?

Working directory context can reset between tool invocations, causing subsequent git operations to run in unintended worktrees. This Skill prevents that by requiring verification before writes, using absolute paths, and enforcing explicit context handling so all changes stay contained in the designated worktree.

How do I set up git worktrees for multi-branch development?

Create separate worktrees with git worktree add, then use this Skill's patterns: announce usage, verify your current worktree before operations, chain commands to preserve context, and apply absolute paths. This ensures each worktree remains isolated and changes don't cross branches during collaborative or feature-parallel workflows.

What verification should I do before running git commands in a worktree?

Print your current directory, git root, and branch name before any write operation. Stop and re-check context if the worktree path or branch doesn't match your intent. This Skill builds verification into every workflow to catch misalignment early and prevent accidental commits to the wrong branch.