agentleFS
xenitV1xenitV1/claude-code-maestro/skills/git-worktrees/SKILL.md

git-worktrees

Skill229 starsChanged 10 months agoMITView on GitHub

Create isolated git workspaces for feature development. Smart directory selection, safety verification, and cross-platform support (Windows/Unix).

  • Installs packages

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use workflow-orchestration, data-analysis and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • shyamsridhar123Skill

    workflow-orchestration

    Build multi-agent workflows and graph-based orchestration using Microsoft Agent Framework. Use this skill when creating agent pipelines, connecting multiple agents, implementing human-in-the-loop patterns, streaming, checkpointing, or time-travel debugging.

    Also in 3 projects that use this

  • shanggqmSkill

    data-analysis

    数据分析技能,提供结构化的数据查询、统计分析和报告生成工作流。当用户需要查询数据库、进行数据统计分析、生成分析报告时使用。按规范输出原始数据、计算结果、Markdown报告和HTML可视化报告。

    Also in 4 projects that use this

  • mrgoonieSkill

    context-engineering

    Master context engineering for AI agent systems. Use when designing agent architectures, debugging context failures, optimizing token usage, implementing memory systems, building multi-agent coordination, evaluating agent performance, or developing LLM-powered pipelines. Covers context fundamentals, degradation patterns, optimization techniques (compaction, masking, caching), compression strategies, memory architectures, multi-agent patterns, LLM-as-Judge evaluation, tool design, and project development.

    Also in 4 projects that use this

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 3 projects that use this

  • OpenAISkill

    executing-plans

    Use when you have a written implementation plan to execute in a separate session with review checkpoints

    Also in 4 projects that use this

  • ElasticSkill

    create-skill

    Interactively create a new Claude Code skill and add it to the elastic-docs-skills catalog. Use when the user wants to generate a new skill, scaffold a slash command, or build automation for docs tasks.

    Also in 3 projects that use this

  • +4 more from openai

The file

Show its rules and text

We split this skill into the rules it gives an agent

21 rules. 0 are common, 20 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 20

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Test in isolation without affecting main workspace

    line 17
  2. Distinctive:

    Run long processes without blocking other work

    line 18
  3. Distinctive:

    Follow this priority order:

    line 34
  4. Very specific:

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

    line 46
  5. Distinctive:

    If preference specified: Use it without asking.

    line 51
  6. Distinctive:

    If no directory exists and no CLAUDE.md preference:

    line 53
  7. Distinctive:

    Add appropriate line to .gitignore

    line 77
  8. Distinctive:

    Run tests to ensure worktree starts clean:

    line 152
  9. Distinctive:

    When feature work is complete:

    line 182
  10. Distinctive:

    Fix: Always use git check-ignore before creating project-local worktree

    line 202
  11. Distinctive:

    Fix: Follow priority: existing > CLAUDE.md > ask

    line 205
  12. Distinctive:

    Fix: Remove worktree when feature is merged ---

    line 214
  13. Distinctive:

    Create worktree without verifying it's ignored (project-local)

    line 232
  14. Distinctive:

    Follow directory priority: existing > CLAUDE.md > ask

    line 238
  15. Distinctive:

    Verify directory is ignored for project-local

    line 239
  16. Distinctive:

    Verify clean test baseline

    line 241
  17. Distinctive:

    When Ralph Wiggum is active:

    line 254
  18. Distinctive:

    Before first iteration: Create worktree for isolated work

    line 255
  19. Distinctive:

    During iterations: All work happens in worktree

    line 256
  20. Distinctive:

    Cleanup: Remove worktree after merge ---

    line 258
  21. Distinctive:

    @verification-mastery: - Verify before finishing branch </audit_and_reference>

    line 263

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

<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:

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

Windows (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

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:

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

Windows (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:

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

Windows (PowerShell):

$project = Split-Path -Leaf (git rev-parse --show-toplevel)

2. Create Worktree

Unix/macOS:

# 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):

# 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:

# 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):

# 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:

# 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

🧹 CLEANUP

When feature work is complete: List worktrees:

git worktree list

Remove worktree:

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

Prune stale entries:

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

🔗 RELATED SKILLS

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

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.