git-worktrees

Explain git worktree behavior and safely remove Claude Code worktrees to release locked branches.

Updated Jan 5, 2025
One-click install
npx skills add https://github.com/pkuppens/pkuppens --skill git-worktrees-pkuppens
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-worktrees
Source: https://github.com/pkuppens/pkuppens/tree/main/skills/git-worktrees
Command: npx skills add https://github.com/pkuppens/pkuppens --skill git-worktrees-pkuppens

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Claude Code users often need to work with multiple git worktrees to parallelize tasks or recover from branch locking. This section explains why managing worktrees matters and how it impacts collaboration and workflow reliability.

Core Features & Use Cases

  • Explains what a worktree is and how Claude Code interacts with it to enable parallel tasks.
  • Provides practical steps for creating, using, and removing worktrees, including naming conventions and cleanup to prevent stale references.
  • Use Case: When a branch is locked by an active worktree, follow the removal workflow to release the lock and continue development.

Quick Start

Inspect and safely remove an active Claude Code worktree if a branch cannot be deleted.

Frequently Asked Questions about git-worktrees

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

FAQPage Schema
Why does git say a branch is locked by an active worktree when I try to delete it?

To remove a git worktree, use the explicit removal workflow to delete the worktree directory and prune stale references. This releases any branch locks and ensures the repository remains clean for continued development.

How do I clean up git worktrees created by Claude Code?

Git worktrees allow Claude Code to parallelize tasks by checking out multiple branches simultaneously in separate directories. This enables concurrent development workflows without interfering with the main working directory.

What is the best way to manage git branch locking caused by worktrees?

The best way to manage branch locking is to follow explicit worktree removal steps with safety checks. This ensures the active worktree is properly deleted, releasing the branch lock so you can resume normal branch deletion and management.

How do I create and use git worktrees with Claude Code safely?

Creating worktrees with Claude Code involves using naming conventions and safety checks to manage the worktree lifecycle. This approach enables parallel task execution while preventing stale references and branch locking issues.