agentleFS
MicrosoftKnown publishermicrosoft/WindowsAppSDK/.github/skills/worktree-manager/SKILL.md

worktree-manager

Skill4.7k starsChanged 11 months agoMITView on GitHub

Create and manage Git worktrees for parallel development workflows. Use when multiple self-contained issues should NOT be fixed in a single branch, when human-Copilot iteration requires isolated environments with separate chat history and commits, or when parallel work items need independent build/test results. Triggers on requests involving branch isolation, work item separation, parallel development, or avoiding messy branch switching.

6 other projects use a version of this.

Trending

Quiet this year.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/WindowsAppSDK repository that our weekly crawl found. There is no adoption data for this file yet.

Most recently taken up by

Who's talking about microsoft/WindowsAppSDK

The biggest 5 of 17 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 17

Talked about on GitHub, Hacker News and Bluesky (17 times).

On GitHub · 13

8 more on GitHub

On Bluesky · 1

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 12 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 12

    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:

    Keep each VS Code window focused on one task

    line 22
  2. Distinctive:

    Run builds/tests independently without cross-contamination

    line 23
  3. Distinctive:

    Create or reuse a worktree for an existing local or remote branch.

    line 44
  4. Distinctive:

    Start a new work item branch with consistent naming and create a worktree for it.

    line 70
  5. Distinctive:

    Remove a worktree and optionally its associated branch.

    line 102
  6. Distinctive:

    Use Git directly to list worktrees:

    line 132
  7. Distinctive:

    Create work item branch and worktree:

    line 143
  8. Distinctive:

    Commit, push, and open PR

    line 148
  9. Distinctive:

    Delete worktree when PR is merged:

    line 149
  10. Distinctive:

    Create worktrees for each feature:

    line 156
  11. Distinctive:

    Keep ≤ 3 active worktrees to manage cognitive load

    line 162
  12. Very specific:

    No destructive operations without explicit -Force flag

    line 212
  13. Distinctive:

    All implementation is self-contained within this skill folder:

    line 216

“Common” is measured: kept by at least 6 in 10 of the 5 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

Git Worktree Manager

This skill provides helper scripts and workflows for creating and managing Git worktrees, enabling parallel development across multiple branches without cloning the repository multiple times.

When to Use This Skill

Primary triggers — Create a new worktree when:

  1. Multiple self-contained issues exist — Different problems should NOT be fixed together in a single branch. Each issue deserves its own branch with isolated commits, separate PR, and independent review.
  2. Human-Copilot iteration is needed — Step-by-step collaboration requires an isolated environment where:
    • Each worktree has its own Copilot chat history and context
    • Plan and TODO progress stays scoped to that specific issue
    • Commits are atomic and traceable to one problem
  3. Parallel work avoids branch-switching chaos — Instead of constantly switching branches (which mixes up build artifacts, test results, and Copilot context), worktrees let you:
    • Keep each VS Code window focused on one task
    • Run builds/tests independently without cross-contamination
    • Resume work instantly without stashing or context loss

Anti-patterns — Do NOT use worktrees when:

  • A quick one-liner fix can be committed directly
  • Changes are tightly coupled and belong in the same PR
  • You're just reading code (no commits planned)

Prerequisites

  • Git installed and configured
  • PowerShell 5.1+ (Windows) or PowerShell Core (cross-platform)
  • VS Code installed (for automatic workspace opening)
  • Repository must be a Git repository (not inside a worktree already)

Available Scripts

This skill provides focused scripts for each worktree operation.

New-WorktreeFromBranch.ps1

Create or reuse a worktree for an existing local or remote branch.

Location: ./scripts/New-WorktreeFromBranch.ps1

./scripts/New-WorktreeFromBranch.ps1 -Branch <branch-name> [-NoFetch]
ParameterRequiredDefaultDescription
-BranchYes-Branch name (local or origin/<name> form)
-NoFetchNo$falseSkip remote fetch if branch missing locally

Examples:

# From a local or remote branch
./scripts/New-WorktreeFromBranch.ps1 -Branch feature/login

# From origin remote (normalizes automatically)
./scripts/New-WorktreeFromBranch.ps1 -Branch origin/bugfix/nullref

New-WorktreeFromIssue.ps1

Start a new work item branch with consistent naming and create a worktree for it.

Location: ./scripts/New-WorktreeFromIssue.ps1

./scripts/New-WorktreeFromIssue.ps1 -Number <workitem-number> [-Title <description>] [-Base <ref>]
ParameterRequiredDefaultDescription
-NumberYes-Azure DevOps work item number for branch naming
-TitleNo-Descriptive title (slugified into branch name)
-BaseNoorigin/mainBase ref to branch from

Examples:

# Work item branch with title
./scripts/New-WorktreeFromIssue.ps1 -Number 1234 -Title "Crash on launch"
# Creates: workitem/1234-crash-on-launch

# Work item branch from different base
./scripts/New-WorktreeFromIssue.ps1 -Number 42 -Base origin/develop

# Simple work item branch (no title slug)
./scripts/New-WorktreeFromIssue.ps1 -Number 999
# Creates: workitem/999

Delete-Worktree.ps1

Remove a worktree and optionally its associated branch.

Location: ./scripts/Delete-Worktree.ps1

./scripts/Delete-Worktree.ps1 -Pattern <pattern> [-Force] [-KeepBranch]
ParameterRequiredDefaultDescription
-PatternYes-Partial branch name or path to match
-ForceNo$falseForce removal even with uncommitted changes
-KeepBranchNo$falseDon't delete the local branch

Examples:

# Delete worktree by branch pattern
./scripts/Delete-Worktree.ps1 -Pattern feature/perf-tweak

# Force delete with uncommitted changes
./scripts/Delete-Worktree.ps1 -Pattern workitem/1234 -Force

# Delete worktree but keep the branch
./scripts/Delete-Worktree.ps1 -Pattern feature/ui -KeepBranch

List Worktrees

Use Git directly to list worktrees:

git worktree list --porcelain

Step-by-Step Workflows

Workflow 1: Work on an Azure DevOps Work Item

  1. Note the work item number and title
  2. Create work item branch and worktree:
    ./scripts/New-WorktreeFromIssue.ps1 -Number 1234 -Title "Fix null reference"
  3. Build, test, and develop as normal
  4. Commit, push, and open PR
  5. Delete worktree when PR is merged:
    ./scripts/Delete-Worktree.ps1 -Pattern workitem/1234

Workflow 2: Parallel Feature Development

  1. Create worktrees for each feature:
    ./scripts/New-WorktreeFromBranch.ps1 -Branch feature/login
    ./scripts/New-WorktreeFromBranch.ps1 -Branch feature/dashboard
  2. Work on each independently (different VS Code windows)
  3. Keep ≤ 3 active worktrees to manage cognitive load

Worktree Naming & Locations

SourceLocal Branch NameWorktree Folder
Local/remote branchSame as branch<RepoName>-<hash>/
Work itemworkitem/<number>-<slug><RepoName>-<hash>/

Worktrees are created as sibling folders to the repository root (e.g., MyRepo/ and MyRepo-ab12/).

Best Practices

  • Keep ≤ 3 active worktrees per developer to reduce cognitive load
  • Delete stale worktrees early — each adds file watchers and build churn
  • Avoid editing the same file across multiple worktrees simultaneously
  • Run git fetch --all --prune periodically in the primary repo, not every worktree
  • Use targeted builds inside worktrees instead of full builds

Troubleshooting

SymptomSolution
Cannot lock ref (*.lock error)Run git worktree prune or delete stale .lock file manually
Worktree already existsUse git worktree list to find existing path; reuse that folder
Local branch missing for remoteRun git branch --track <name> origin/<name> then retry
Submodules not initializedRun git submodule update --init --recursive in the worktree

Common Commands Reference

# List all worktrees
git worktree list --porcelain

# List local branches with tracking info
git branch -vv

# List remotes
git remote -v

# Prune stale worktree references
git worktree prune

# Force remove a worktree with uncommitted changes
git worktree remove --force <path>

Security Notes

  • Scripts do not store credentials — they rely on your existing Git credential helper
  • No destructive operations without explicit -Force flag

Script Locations

All implementation is self-contained within this skill folder:

Scripts (master source):

  • New-WorktreeFromBranch.ps1 — create worktree from branch
  • New-WorktreeFromIssue.ps1 — create worktree for work item
  • Delete-Worktree.ps1 — remove worktree and branch
  • WorktreeLib.ps1 — shared helper functions

Human-friendly wrappers (in tools/git/):

  • tools/git/New-WorktreeFromBranch.cmd — delegates to skill's master script
  • tools/git/New-WorktreeFromIssue.cmd — delegates to skill's master script
  • tools/git/Delete-Worktree.cmd — delegates to skill's master script
  • tools/git/Worktree-Guidelines.md — quick reference for developers

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.