# Git Worktree

> Manage git worktrees with smart automation. Create worktrees with auto-setup (dependencies, env files), list worktrees with merge status, clean up stale worktrees, and switch between worktrees. Use when working on multiple branches simultaneously, doing quick bug fixes, or reviewing PRs without stashing.

- Skill: `qian-yu-db/git-worktree` (Agent Skill)
- Install (CLI): `npx skillmds@latest add qian-yu-db/git-worktree`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qian-yu-db/git-worktree/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: qian-yu-db (https://skillmd.com/u/qian-yu-db)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/qian-yu-db/git-worktree

---


# Git Worktree Skill

Enhanced git worktree management with automation beyond raw CLI commands.

## Available Commands

| Command | Description |
|---------|-------------|
| `/worktree-add <branch>` | Create worktree with auto-setup |
| `/worktree-list` | List worktrees with merge status |
| `/worktree-clean` | Remove merged worktrees |

## Quick Examples

```bash
# Create worktree for a branch
/worktree-add feature/auth

# See all worktrees with status
/worktree-list

# Clean up merged worktrees
/worktree-clean --dry-run
/worktree-clean
```

## When to Use

- Working on multiple branches simultaneously
- Quick bug fixes without stashing
- Reviewing PRs in isolation
- Testing different versions in parallel

## Key Features

- **Auto-setup**: Installs dependencies and copies env files
- **Smart listing**: Shows merge status and staleness indicators
- **Safe cleanup**: Only removes merged branches, with confirmation

## Path Convention

Worktrees are created as sibling directories:
```
/project/               → main worktree
/project-feature-auth/  → feature/auth branch
/project-bugfix-42/     → bugfix/42 branch
```

## Package Manager Detection

Automatically detects and runs:
- `uv sync` for Python (uv.lock/pyproject.toml)
- `npm install` for Node (package-lock.json)
- `yarn install` for Yarn (yarn.lock)
- `pnpm install` for pnpm (pnpm-lock.yaml)

See individual command files in `commands/` for detailed documentation.

