Agent skill

Git Worktrees

by xenitV1 in xenitV1/claude-code-maestro

Create isolated git workspaces for feature development. An agent skill from xenitV1/claude-code-maestro.

MITAuto-check: notesDevelopment

Install Git Worktrees

skills CLI
$ npx skills add xenitV1/claude-code-maestro --skill git-worktrees -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install xenitV1/claude-code-maestro git-worktrees --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/xenitV1/claude-code-maestro.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/git-worktrees .claude/skills/git-worktrees && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
git-worktrees
GitHub stars
229
Token cost
~2.1k tokens
SKILL.md length
627 words
Files
1
Skills in repo
13
Repo updated
First seen
Licence
MIT

At a glance

Create isolated git workspaces for feature development. An agent skill from xenitV1/claude-code-maestro.

  • Works in 8 steps: Check Existing Directories → Check CLAUDE.md → Ask User → …
  • Tasks that involve Git worktrees
  • SKILL.md covers 🎯 OVERVIEW, 📋 WHEN TO USE, 📁 DIRECTORY SELECTION PROCESS and 🔒 SAFETY VERIFICATION, plus 8 more sections
  • Calls git, npm and pytest

What it does

Git Worktrees is an agent skill from xenitV1/claude-code-maestro. Create isolated git workspaces for feature development. Smart directory selection, safety verification, and cross-platform support (Windows/Unix).

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Git worktrees. It works with Git. The licence is MIT.

When your agent uses it

  • Tasks that involve Git worktrees

Example prompts

  • “/git-worktrees”

Requirements

  • Python 3
  • Node.js
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Glob, Grep, Bash

Workflow steps

8 steps, taken from the step headings in SKILL.md.

  1. Check Existing Directories
  2. Check CLAUDE.md
  3. Ask User
  4. Detect Project Name
  5. Create Worktree
  6. Run Project Setup
  7. Verify Clean Baseline
  8. Report Location

What it can do on your machine

Read from SKILL.md and the folder at commit 924315b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Glob
    • Grep
    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git
    • npm
    • pytest
    • cargo
    • go

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git and npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Git Worktrees loads about 2.1k tokens when it runs. Until then it costs about 40 tokens; SKILL.md has 627 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~40
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Glob, Grep, Bash

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from xenitV1/claude-code-maestro at commit 924315b, republished under its MIT licence (© xenitV1). 627 words, ~2,149 tokens.

Download SKILL.mdSave it as .claude/skills/git-worktrees/SKILL.md (or your agent's skills folder).
name
git-worktrees
description
Create isolated git workspaces for feature development. Smart directory selection, safety verification, and cross-platform support (Windows/Unix).
allowed-tools
Read, Write, Edit, Glob, Grep, Bash

<domain_overview>

🌳 GIT WORKTREES: ISOLATED WORKSPACES

Philosophy: Isolation prevents contamination. Work on features without affecting the main workspace. Systematic directory selection + safety verification = reliable isolation. ISOLATION INTEGRITY MANDATE (CRITICAL): Never create worktrees in directories that are not explicitly ignored by Git. AI-generated workflows often fail by polluting the primary repository with tracked worktree data. You MUST verify that the destination directory is within .gitignore before execution. Furthermore, you MUST ensure a 'Clean Baseline' by running tests before starting any feature work in a new worktree to avoid cross-contamination of artifacts. </domain_overview>


<directory_selection>

🎯 OVERVIEW

Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching. Benefits:

  • Work on feature branch without stashing changes
  • Test in isolation without affecting main workspace
  • Run long processes without blocking other work
  • Easy cleanup when feature is complete

📋 WHEN TO USE

Use before:

  • Starting new feature development
  • Implementing plans from @planning-mastery
  • Making experimental changes
  • Working on multiple features in parallel Skip for:
  • Quick bug fixes on current branch
  • Documentation updates
  • Configuration changes

📁 DIRECTORY SELECTION PROCESS

Follow this priority order:

1. Check Existing Directories

Unix/macOS:

bash
ls -d .worktrees 2>/dev/null     # Preferred (hidden)
ls -d worktrees 2>/dev/null      # Alternative

Windows (PowerShell):

powershell
if (Test-Path ".worktrees") { ".worktrees" }
elseif (Test-Path "worktrees") { "worktrees" }

If found: Use that directory. If both exist, .worktrees wins.

2. Check CLAUDE.md
bash
grep -i "worktree.*director" CLAUDE.md 2>/dev/null

If preference specified: Use it without asking.

3. Ask User

If no directory exists and no CLAUDE.md preference:

No worktree directory found. Where should I create worktrees?
1. .worktrees/ (project-local, hidden)
2. %USERPROFILE%\.config\maestro\worktrees\<project>\ (global location)
Which would you prefer?

</directory_selection> <safety_verification>

🔒 SAFETY VERIFICATION

For Project-Local Directories

MUST verify directory is ignored before creating worktree: Unix/macOS:

bash
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null

Windows (PowerShell):

powershell
git check-ignore -q .worktrees 2>$null
if ($LASTEXITCODE -ne 0) {
    git check-ignore -q worktrees 2>$null
}

If NOT ignored:

  1. Add appropriate line to .gitignore
  2. Commit the change
  3. Proceed with worktree creation Why critical: Prevents accidentally committing worktree contents to repository.
For Global Directory

No .gitignore verification needed - outside project entirely. </safety_verification> <creation_and_setup>

🔨 CREATION STEPS

1. Detect Project Name

Unix/macOS:

bash
project=$(basename "$(git rev-parse --show-toplevel)")

Windows (PowerShell):

powershell
$project = Split-Path -Leaf (git rev-parse --show-toplevel)
2. Create Worktree

Unix/macOS:

bash
# Project-local
path=".worktrees/$BRANCH_NAME"
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"
# Or global
path="$HOME/.config/maestro/worktrees/$project/$BRANCH_NAME"
mkdir -p "$(dirname "$path")"
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"

Windows (PowerShell):

powershell
# Project-local
$path = ".worktrees\$BRANCH_NAME"
git worktree add $path -b $BRANCH_NAME
Set-Location $path
# Or global
$path = "$env:USERPROFILE\.config\maestro\worktrees\$project\$BRANCH_NAME"
New-Item -ItemType Directory -Force -Path (Split-Path $path)
git worktree add $path -b $BRANCH_NAME
Set-Location $path
3. Run Project Setup

Auto-detect and run appropriate setup: Cross-platform:

bash
# Node.js
if [ -f package.json ]; then npm install; fi
# Python
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi
# Rust
if [ -f Cargo.toml ]; then cargo build; fi
# Go
if [ -f go.mod ]; then go mod download; fi

Windows (PowerShell):

powershell
# Node.js
if (Test-Path "package.json") { npm install }

# Python
if (Test-Path "requirements.txt") { pip install -r requirements.txt }
if (Test-Path "pyproject.toml") { poetry install }

# Rust
if (Test-Path "Cargo.toml") { cargo build }

# Go
if (Test-Path "go.mod") { go mod download }
4. Verify Clean Baseline

Run tests to ensure worktree starts clean:

bash
# Use project-appropriate command
npm test
pytest
cargo test
go test ./...

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

5. Report Location
Worktree ready at <full-path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>

</creation_and_setup> <audit_and_reference>

📊 QUICK REFERENCE

SituationAction
.worktrees/ existsUse it (verify ignored)
worktrees/ existsUse it (verify ignored)
Both existUse .worktrees/
Neither existsCheck CLAUDE.md → Ask user
Directory not ignoredAdd to .gitignore + commit
Tests fail during baselineReport failures + ask
No package.json/Cargo.tomlSkip dependency install

Show full SKILL.md (250 more words)Show less

🧹 CLEANUP

When feature work is complete: List worktrees:

bash
git worktree list

Remove worktree:

bash
git worktree remove .worktrees/feature-name
# or force if uncommitted changes
git worktree remove --force .worktrees/feature-name

Prune stale entries:

bash
git worktree prune

🚫 COMMON MISTAKES

Skipping ignore verification
  • Problem: Worktree contents get tracked, pollute git status
    • Fix: Always use git check-ignore before creating project-local worktree
Assuming directory location
  • Problem: Creates inconsistency, violates project conventions
    • Fix: Follow priority: existing > CLAUDE.md > ask
Proceeding with failing tests
  • Problem: Can't distinguish new bugs from pre-existing issues
    • Fix: Report failures, get explicit permission to proceed
Hardcoding setup commands
  • Problem: Breaks on projects using different tools
    • Fix: Auto-detect from project files (package.json, etc.)
Forgetting to cleanup
  • Problem: Disk space consumed, stale branches accumulate
    • Fix: Remove worktree when feature is merged

📝 EXAMPLE WORKFLOW

You: I'm using the git-worktrees skill to set up an isolated workspace.
[Check .worktrees/ - exists]
[Verify ignored - git check-ignore confirms .worktrees/ is ignored]
[Create worktree: git worktree add .worktrees/auth -b feature/auth]
[Run npm install]
[Run npm test - 47 passing]
Worktree ready at C:\Users\Dev\myproject\.worktrees\auth
Tests passing (47 tests, 0 failures)
Ready to implement auth feature

🚨 RED FLAGS

Never:

  • Create worktree without verifying it's ignored (project-local)
  • Skip baseline test verification
  • Proceed with failing tests without asking
  • Assume directory location when ambiguous
  • Skip CLAUDE.md check Always:
  • Follow directory priority: existing > CLAUDE.md > ask
  • Verify directory is ignored for project-local
  • Auto-detect and run project setup
  • Verify clean test baseline
  • Report full path when done

🔗 INTEGRATION

Called by:
  • @brainstorming - After design approved, before implementation
  • @planning-mastery - When executing plan
Pairs with:
  • @planning-mastery - Work happens in this worktree
  • @tdd-mastery - Implementation methodology
  • @verification-mastery - Complete development after all tasks

🔗 RALPH WIGGUM INTEGRATION

When Ralph Wiggum is active:

  1. Before first iteration: Create worktree for isolated work
  2. During iterations: All work happens in worktree
  3. After completion: Merge or create PR from worktree
  4. Cleanup: Remove worktree after merge

  • @brainstorming - Design before worktree creation
  • @planning-mastery - Plan to execute in worktree
  • @verification-mastery - Verify before finishing branch </audit_and_reference>

© xenitV1, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/git-worktrees of xenitV1/claude-code-maestro.

Open the folder on GitHubat commit 924315b

Compare with similar skills

Git Worktrees next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Git Worktrees compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Git Worktrees this skillxenitV1/claude-code-maestro229—~2.1kAutomated safety check: NotesMIT
Git Worktree IsolationjnMetaCode/superpowers-zh8.3k1 repos~982Automated safety check: PassMIT
WorktreeAgentsMesh/AgentsMesh2.4k—~553Automated safety check: NotesCustom licence
Cursor Composer Task DelegateChachamaru127/claude-code-harness3.2k—~4.4kAutomated safety check: NotesMIT
Git Worktree Setupk8zdev/k8z155—~930Automated safety check: PassNone
New Featuremichaelshimeles/skills1.3k1 repos~699Automated safety check: PassNone

Similar skills

  • Git Worktree Isolation

    jnMetaCode/superpowers-zh

    Sets up an isolated workspace before feature work or plan execution, preferring native worktree tools and falling back to git worktree, with instructions in Chinese.

    8.3k GitHub starsUsed in 1 repo~982 tokens
    DevelopmentAuto-check passed
  • Worktree

    AgentsMesh/AgentsMesh

    Creates or reuses an isolated AgentsMesh Git worktree from a verified base branch, preserves existing changes, and optionally starts the worktree-scoped development environment.

    2.4k GitHub stars~553 tokensUpdated 14 days ago
    DevelopmentAuto-check: notes
  • Cursor Composer Task Delegate

    Chachamaru127/claude-code-harness

    Hands one implementation task to Cursor Composer in an isolated git worktree, then reviews its diff and cherry-picks the result into the main branch.

    3.2k GitHub stars~4.4k tokensUpdated 3 days ago
    DevelopmentAuto-check: notes
  • Automate git worktree creation and copy private files (not tracked in git) to new workdirs.

    155 GitHub stars~930 tokensUpdated 3 mo ago
    DevelopmentAuto-check passed
  • New Feature

    michaelshimeles/skills

    Start a new task in an isolated Git worktree branched from origin/main so multiple agents can work on the same repo in parallel without conflicts.

    1.3k GitHub starsUsed in 1 repo~699 tokens
    DevelopmentAuto-check passed
  • Use Mori CLI to enable agent-to-agent communication and coordination across Mori-managed panes.

    303 GitHub stars~1.7k tokensUpdated 2 mo ago
    DevelopmentAuto-check passed

More from xenitV1/claude-code-maestro

All 13 skills in this repo
  • Ralph Wiggum

    xenitV1/claude-code-maestro

    Surgical Debugger & Code Optimizer. An agent skill from xenitV1/claude-code-maestro.

    229 GitHub starsUsed in 1 repo~795 tokens
    Auto-check: notes
  • Maestro

    xenitV1/claude-code-maestro

    A skill your agent uses when you need to act as an Elite Software Architect (Maestro) to manage complex repositories.

    229 GitHub starsUsed in 1 repo~1.1k tokens
    Auto-check passed
  • Clean Code

    xenitV1/claude-code-maestro

    The Foundation Skill. An agent skill from xenitV1/claude-code-maestro.

    229 GitHub stars~1.5k tokensUpdated 8 mo ago
    Auto-check passed
  • Backend Design

    xenitV1/claude-code-maestro

    Elite Tier Backend standards, including Vertical Slice Architecture, Zero Trust Security, and High-Performance API protocols.

    229 GitHub stars~2.1k tokensUpdated 8 mo ago
    Auto-check: notes
  • Brainstorming

    xenitV1/claude-code-maestro

    Design-first methodology. An agent skill from xenitV1/claude-code-maestro.

    229 GitHub stars~2k tokensUpdated 8 mo ago
    Auto-check passed
  • Browser Extension

    xenitV1/claude-code-maestro

    Master specialized skill for building 2025/2026-grade browser extensions.

    229 GitHub stars~1.2k tokensUpdated 8 mo ago
    Auto-check: notes

Works with

Questions about Git Worktrees

What does Git Worktrees do?

Create isolated git workspaces for feature development. An agent skill from xenitV1/claude-code-maestro. Git Worktrees is an agent skill from xenitV1/claude-code-maestro. Create isolated git workspaces for feature development.

When should I use Git Worktrees?

Git Worktrees fits situations like: tasks that involve Git worktrees.

How do I install Git Worktrees in Claude Code?

Run `npx skills add xenitV1/claude-code-maestro --skill git-worktrees -a claude-code`. Or copy the skill folder (skills/git-worktrees in xenitV1/claude-code-maestro) into .claude/skills/git-worktrees in your project. Claude Code loads it when a task matches its description.

How do I install Git Worktrees in Codex?

Run `npx skills add xenitV1/claude-code-maestro --skill git-worktrees -a codex`. Or copy the skill folder (skills/git-worktrees in xenitV1/claude-code-maestro) into .agents/skills/git-worktrees in your project. Codex loads it when a task matches its description.

Can I use Git Worktrees in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add xenitV1/claude-code-maestro --skill git-worktrees -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/git-worktrees, .gemini/skills/git-worktrees, .github/skills/git-worktrees and .opencode/skills/git-worktrees in your project.

What does Git Worktrees need to run?

Going by SKILL.md and its folder, Git Worktrees needs the command-line tools its instructions call (git, npm, pytest, cargo and go). Our summary lists: Python 3; Node.js. Its frontmatter pre-approves these tools: Read, Write, Edit, Glob, Grep, Bash.

Does Git Worktrees access the network?

SKILL.md contains no URLs. Its commands use git and npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Git Worktrees safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Git Worktrees use?

Git Worktrees is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Git Worktrees use?

About 2.1k tokens (SKILL.md is roughly 8.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Git Worktrees?

Skills that share tags, products or a category with Git Worktrees: Git Worktree Isolation (jnMetaCode/superpowers-zh, 8.3k stars), Worktree (AgentsMesh/AgentsMesh, 2.4k stars), Cursor Composer Task Delegate (Chachamaru127/claude-code-harness, 3.2k stars) and Git Worktree Setup (k8zdev/k8z, 155 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Git Worktrees?

xenitV1 (a GitHub user) maintains it in xenitV1/claude-code-maestro, which has 229 GitHub stars. The repository holds 13 skills in this directory. The repository was last updated on January 24, 2026.

Source: xenitV1/claude-code-maestro on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.