using-git-worktrees

Create isolated Git worktrees for parallel feature development.

1|Updated Nov 21, 2025
One-click install
npx skills add https://github.com/pianzhu/my-claude-skills --skill using-git-worktrees-pianzhu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/pianzhu/my-claude-skills/tree/main/skill-en/using-git-worktrees
Command: npx skills add https://github.com/pianzhu/my-claude-skills --skill using-git-worktrees-pianzhu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without changing your current workspace. The skill's core principle is systematic directory selection combined with safety verification to ensure reliable isolation. At activation, the skill announces its usage to set expectations.

Core Features & Use Cases

  • Directory selection follows a priority: prefer existing local worktrees, check for CLAUDE.md preferences, then ask the user when a location isn't specified.
  • Safety verification ensures the chosen worktree directory is ignored by git, preventing accidental commits of worktree contents, and uses a fallback global location when needed.
  • Automated worktree creation & setup detects the project name, creates the worktree in the selected location, runs project setup (e.g., npm, cargo, pip) if present, and verifies a clean baseline with tests.

Quick Start

To start, specify your feature branch name and location when prompted, or let the skill pick the best option. Then the skill will create the worktree with git worktree add, switch into the new directory, run the appropriate setup commands, and report the location and test results.

Frequently Asked Questions about using-git-worktrees

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

FAQPage Schema
How do I set up isolated Git worktrees for parallel feature development?

The skill sets up isolated Git worktrees by automatically selecting a directory, verifying git-ignore safety, and running setup commands. This enables parallel feature development without changing your main workspace.

How does git worktree isolation prevent accidental commits of workspace contents?

Git worktree isolation prevents accidental commits by verifying the chosen worktree directory is properly ignored by git. It uses a fallback global location when needed to ensure reliable isolation.

What's the best way to manage multiple Git branches without switching directories?

Using git worktrees is the best way to manage multiple branches without switching directories. They create isolated workspaces sharing the same repository, allowing simultaneous work on different feature branches.

Can I run project setup commands like npm or cargo automatically in a new git worktree?

Yes, you can run project setup commands automatically in a new git worktree. The setup process detects the project name, creates the worktree, and runs setup commands like npm, cargo, or pip if present.

Does git worktree setup work with existing local worktrees and CLAUDE.md preferences?

Yes, git worktree setup works with existing local worktrees and CLAUDE.md preferences. Directory selection prioritizes existing local worktrees, checks CLAUDE.md preferences, and asks the user when a location is not specified.

Why do I need to verify a clean baseline with tests after creating a git worktree?

You need to verify a clean baseline with tests after creating a git worktree to ensure the isolated workspace is properly set up. This validates that the automated setup and branch isolation are functioning correctly.