Agent skill

Git Worktree

by NikiforovAll in NikiforovAll/claude-code-rules

This skill should be used when the user wants to manage Git worktrees - creating worktrees from local or remote branches, listing active worktrees with details, deleting worktrees, or switching…

Apache-2.0Auto-check passedDevelopment

Install Git Worktree

skills CLI
$ npx skills add NikiforovAll/claude-code-rules --skill git-worktree -a claude-code

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

GitHub CLI
$ gh skill install NikiforovAll/claude-code-rules git-worktree --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/NikiforovAll/claude-code-rules.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/handbook-git-worktree/skills/git-worktree .claude/skills/git-worktree && 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-worktree
GitHub stars
141
Token cost
~1.8k tokens
SKILL.md length
683 words
Files
1
Skills in repo
26
Repo updated
First seen
Licence
Apache-2.0

At a glance

This skill should be used when the user wants to manage Git worktrees - creating worktrees from local or remote branches, listing active worktrees with details, deleting worktrees, or switching…

  • Works in 7 steps: List Worktrees → Create Worktree from Remote Branch → Create Worktree from Local Branch → …
  • Wants to manage Git worktrees - creating worktrees from local
  • SKILL.md covers Overview, When to Use This Skill, How It Works and Core Operations, plus 3 more sections
  • Calls git

What it does

Git Worktree is an agent skill from NikiforovAll/claude-code-rules. This skill should be used when the user wants to manage Git worktrees - creating worktrees from local or remote branches, listing active worktrees with details, deleting worktrees, or switching between worktrees. Ideal for working on multiple branches simultaneously without stashing changes.

Its SKILL.md is about 1.8k 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 repository describes itself as: Learn practical techniques to enhance your AI-assisted development workflow with Claude Code. The licence is Apache-2.0.

When your agent uses it

  • Wants to manage Git worktrees - creating worktrees from local
  • Remote branches
  • Listing active worktrees with details
  • Deleting worktrees

Example prompts

  • “/git-worktree”

Workflow steps

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

  1. List Worktrees
  2. Create Worktree from Remote Branch
  3. Create Worktree from Local Branch
  4. Create Worktree with New Branch
  5. Delete Worktree
  6. Prune Worktrees
  7. Switch Helper

What it can do on your machine

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

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

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

  • Network

    No URLs in SKILL.md. Its commands use git, 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 Worktree loads about 1.8k tokens when it runs. Until then it costs about 76 tokens; SKILL.md has 683 words of instructions outside code blocks.

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

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 passed

The automated check found no risky patterns in SKILL.md.

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 NikiforovAll/claude-code-rules at commit 281c063, republished under its Apache-2.0 licence (© NikiforovAll). 683 words, ~1,812 tokens.

Download SKILL.mdSave it as .claude/skills/git-worktree/SKILL.md (or your agent's skills folder).
name
git-worktree
description
This skill should be used when the user wants to manage Git worktrees - creating worktrees from local or remote branches, listing active worktrees with details, deleting worktrees, or switching between worktrees. Ideal for working on multiple branches simultaneously without stashing changes.

Git Worktree Management

Overview

This skill provides comprehensive Git worktree management capabilities, enabling work on multiple branches simultaneously in isolated directories. Worktrees eliminate the need for stashing when switching contexts and are ideal for parallel development, quick bug fixes, and code reviews.

When to Use This Skill

Use this skill when the user wants to:

  • Create a new worktree from a local branch, remote branch, or new branch
  • List all active worktrees with detailed information
  • Delete and clean up worktrees
  • Get navigation commands to switch between worktrees
  • Set up parallel development environments

How It Works

Configuration

Location Strategy: Sibling directory pattern

  • Worktrees are created outside the main repository: ../<project>-<branch>
  • Example: Main repo at ~/dev/myproject, worktree at ~/dev/myproject-feature-x
  • Benefits: Clean separation, no nested repos, IDE-friendly

Naming Convention: <project>-<branch>

  • Project name extracted using: basename "$(git rev-parse --show-toplevel)"
  • Example: myproject-feature-auth, myapp-bugfix-login
Interface

Hybrid Mode: Accepts arguments when provided, prompts when missing

Usage patterns:

# Interactive menu
User: "Manage my worktrees"
User: "Create a worktree"

# Direct with arguments
User: "Create worktree from remote branch feature-x"
User: "List all worktrees"
User: "Delete worktree for branch hotfix-123"

Core Operations

1. List Worktrees

Purpose: Show all active worktrees with detailed information

What to display:

  • Index number for easy reference
  • Worktree path
  • Branch name
  • HEAD commit hash (short)
  • Commit message (first line)
  • Indicator for current worktree

Implementation:

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

# List worktrees with details
git worktree list -v

Output format:

Git Worktrees for myproject:

1. /Users/dev/myproject (main)
   abc1234 Initial commit
   [CURRENT]

2. /Users/dev/myproject-feature-x (feature-x)
   def5678 Add authentication logic

3. /Users/dev/myproject-hotfix (hotfix-123)
   789abcd Fix login bug
2. Create Worktree from Remote Branch

Purpose: Fetch and create a worktree from a remote branch

Steps:

  1. Validate we're in a git repository
  2. Get project name: project=$(basename "$(git rev-parse --show-toplevel)")
  3. Extract branch name from remote reference (e.g., origin/feature-x → feature-x)
  4. Check if worktree already exists (warn and skip if it does)
  5. Fetch remote branch: git fetch origin <branch-name>
  6. Verify remote branch exists (check exit code)
  7. Determine worktree path: ../<project>-<branch-name>
  8. Create worktree: git worktree add ../<project>-<branch-name> origin/<branch-name>
  9. Show success message with path and navigation command

Error handling:

  • Not in git repo: Show clear error message
  • Worktree already exists: "Worktree for branch 'X' already exists at Y. Use 'list' to see all worktrees."
  • Remote branch doesn't exist: "Remote branch 'origin/X' not found. Available branches: [list]"

Success output:

✓ Created worktree for remote branch 'feature-x'

Location: /Users/dev/myproject-feature-x
Branch: feature-x (tracking origin/feature-x)

To switch to this worktree:
  cd ../myproject-feature-x

To start working:
  cd ../myproject-feature-x && code .
3. Create Worktree from Local Branch

Purpose: Create a worktree from an existing local branch

Steps:

  1. Validate we're in a git repository
  2. Get project name
  3. Verify local branch exists: git rev-parse --verify <branch-name>
  4. Check if worktree already exists
  5. Create worktree: git worktree add ../<project>-<branch-name> <branch-name>
  6. Show success message with navigation

Error handling:

  • Local branch doesn't exist: "Local branch 'X' not found. Available branches: [list local branches]"
  • Worktree already exists: Same as remote case
Show full SKILL.md (312 more words)Show less
4. Create Worktree with New Branch

Purpose: Create a worktree with a brand new branch

Parameters needed:

  • New branch name
  • Base branch (optional, default: current branch)

Steps:

  1. Validate we're in a git repository
  2. Get project name
  3. Get base branch (use current if not specified)
  4. Check if worktree directory already exists
  5. Create worktree with new branch: git worktree add -b <new-branch> ../<project>-<new-branch> <base-branch>
  6. Show success message

Success output:

✓ Created new worktree with branch 'experiment-auth'

Location: /Users/dev/myproject-experiment-auth
Branch: experiment-auth (based on main)

To switch to this worktree:
  cd ../myproject-experiment-auth
5. Delete Worktree

Purpose: Remove a worktree and show prune command

Steps:

  1. If no branch specified, list all worktrees for selection
  2. Verify worktree exists for specified branch
  3. Remove worktree: git worktree remove <path> or manually rm -rf <path>
  4. Show manual prune command (don't auto-execute per user preference)

Output:

✓ Removed worktree at /Users/dev/myproject-feature-x

To clean up metadata, run:
  git worktree prune
6. Prune Worktrees

Purpose: Clean up worktree metadata

Steps:

  1. Run: git worktree prune
  2. Show what was cleaned

Output:

✓ Pruned stale worktree metadata

Run 'git worktree list' to see remaining worktrees.
7. Switch Helper

Purpose: Show easy navigation to worktrees

Implementation:

  1. List all worktrees (numbered)
  2. Provide copy-ready cd commands

Output:

Available worktrees:

1. main (current)
   cd /Users/dev/myproject

2. feature-x
   cd /Users/dev/myproject-feature-x

3. hotfix-123
   cd /Users/dev/myproject-hotfix

Interactive Flow

When invoked without arguments:

  1. Show menu:

    Git Worktree Management
    
    1. List all worktrees
    2. Create from remote branch
    3. Create from local branch
    4. Create new branch
    5. Delete worktree
    6. Prune metadata
    7. Switch between worktrees
  2. Prompt for selection

  3. For create operations, prompt for required info (branch name, base branch, etc.)

  4. Execute operation

  5. Show results with clear next steps

Direct Command Parsing

When arguments are provided, parse intent:

  • "list" → List operation
  • "create remote <branch>" → Create from remote
  • "create local <branch>" → Create from local
  • "create new <branch> [from <base>]" → Create new branch
  • "delete <branch>" → Delete worktree
  • "prune" → Prune metadata
  • "switch" → Switch helper

Error Handling Checklist

Before any operation:

  • ✓ Verify in git repository: git rev-parse --git-dir
  • ✓ Get project name successfully
  • ✓ Validate branch exists (for remote/local operations)
  • ✓ Check worktree doesn't already exist (for create operations)
  • ✓ Provide actionable error messages with suggestions

© NikiforovAll, Apache-2.0. 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 plugins/handbook-git-worktree/skills/git-worktree of NikiforovAll/claude-code-rules.

Open the folder on GitHubat commit 281c063

Compare with similar skills

Git Worktree 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 Worktree compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Git Worktree this skillNikiforovAll/claude-code-rules141—~1.8kAutomated safety check: PassApache-2.0
Build Px4 macOSPX4/PX4-Autopilot13k—~1.1kAutomated safety check: PassBSD-3-Clause
WorktreeAgentsMesh/AgentsMesh2.4k—~553Automated safety check: NotesCustom licence
Git Worktree IsolationjnMetaCode/superpowers-zh8.3k1 repos~982Automated safety check: PassMIT
Cursor Composer Task DelegateChachamaru127/claude-code-harness3.2k—~4.4kAutomated safety check: NotesMIT
Git Worktree Setupk8zdev/k8z155—~930Automated safety check: PassNone

Similar skills

  • Build Px4 macOS

    PX4/PX4-Autopilot

    Build PX4 board firmware on macOS in the px4-dev Docker container, including git worktrees, and stage commit-labeled artifacts without flashing hardware.

    13k GitHub stars~1.1k tokensUpdated today
    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
  • 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
  • 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

More from NikiforovAll/claude-code-rules

All 26 skills in this repo
  • Reflect Solution

    NikiforovAll/claude-code-rules

    Summarize WHAT WAS SHIPPED in a Claude Code session as a self-contained HTML slide deck — the elevator pitch (problem, solution, decisions, artifacts, verification, gaps), not a play-by-play of tool…

    141 GitHub stars~3.8k tokensUpdated 5 days ago
    Auto-check passed
  • Dotnet Analyzers

    NikiforovAll/claude-code-rules

    Run dotnet format to fix code style and analyzer diagnostics (IDE0005, CA, SA).

    141 GitHub stars~1.9k tokensUpdated 5 days ago
    Auto-check passed
  • Ilspy Decompile

    NikiforovAll/claude-code-rules

    Understand implementation details of .NET code by decompiling assemblies.

    141 GitHub starsUsed in 2 repos~760 tokens
    Auto-check passed
  • Reflect Tree

    NikiforovAll/claude-code-rules

    Visualize a Claude Code session as a quest/skill tree — a navigable SVG graph where nodes are turns and edges show flow, with distinct visual encoding for normal flow, dead-ends, corrections…

    141 GitHub stars~2.8k tokensUpdated 5 days ago
    Auto-check passed
  • Structured Plan Mode

    NikiforovAll/claude-code-rules

    This skill should be used when planning and tracking complex feature implementations that require systematic task decomposition.

    141 GitHub stars~4.2k tokensUpdated 5 days ago
    Auto-check passed
  • Glab

    NikiforovAll/claude-code-rules

    Expert guidance for using the GitLab CLI (glab) to manage GitLab issues, merge requests, CI/CD pipelines, repositories, and other GitLab operations from the command line.

    141 GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed

Works with

Questions about Git Worktree

What does Git Worktree do?

This skill should be used when the user wants to manage Git worktrees - creating worktrees from local or remote branches, listing active worktrees with details, deleting worktrees, or switching…. Git Worktree is an agent skill from NikiforovAll/claude-code-rules. This skill should be used when the user wants to manage Git worktrees - creating worktrees from local or remote branches, listing active worktrees with details, deleting worktrees, or switching between worktrees.

When should I use Git Worktree?

Git Worktree fits situations like: wants to manage Git worktrees - creating worktrees from local; remote branches; listing active worktrees with details; deleting worktrees.

How do I install Git Worktree in Claude Code?

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

How do I install Git Worktree in Codex?

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

Can I use Git Worktree 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 NikiforovAll/claude-code-rules --skill git-worktree -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-worktree, .gemini/skills/git-worktree, .github/skills/git-worktree and .opencode/skills/git-worktree in your project.

What does Git Worktree need to run?

Going by SKILL.md and its folder, Git Worktree needs the command-line tools its instructions call (git).

Does Git Worktree access the network?

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

Is Git Worktree safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Git Worktree use?

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

How many tokens does Git Worktree use?

About 1.8k tokens (SKILL.md is roughly 7.2k 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 Worktree?

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

Who maintains Git Worktree?

NikiforovAll (a GitHub user) maintains it in NikiforovAll/claude-code-rules, which has 141 GitHub stars. The repository holds 26 skills in this directory. The repository was last updated on October 2, 2026.

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