Git Worktree Manager
Manage git worktrees for parallel feature development.
Current Worktrees
!git worktree list
Usage
code
/worktree # List worktrees (default) /worktree add <name> [base] # Create new worktree /worktree remove <name> # Remove worktree /worktree status # Detailed status of all worktrees
Arguments
- •
$1- Subcommand:add,list,remove,status(default:list) - •
$2- Foradd: feature/branch name; Forremove: worktree name/path - •
$3- Foradd: base branch (default: main/master)
Command: add
Create a new worktree in a sibling directory.
Task-Aware Naming: When name matches task-XX:
- •Detect current phase from
specification/ - •Generate branch:
phase-XX/task-YY-description - •Ask for description if not provided
Examples:
- •
/worktree add task-02→phase-01/task-02-shared-kernel - •
/worktree add feature-auth→feature-auth(non-task)
Process:
bash
REPO_ROOT=$(git rev-parse --show-toplevel)
REPO_NAME=$(basename "$REPO_ROOT")
WORKTREE_PATH="${REPO_ROOT}/../${REPO_NAME}-<branch-name>"
git worktree add -b <branch-name> "$WORKTREE_PATH" <base-branch>
Command: list
List all worktrees with their details.
bash
git worktree list
Command: remove
Remove a worktree safely.
Process:
- •If no argument, list worktrees and ask which to remove
- •Check for uncommitted changes
- •If changes exist, WARN and ask for confirmation
- •Remove worktree and prune
bash
git -C "<worktree-path>" status --porcelain git worktree remove "<worktree-path>" git worktree prune
Command: status
Show detailed status of all worktrees.
For each worktree, show:
- •Path and branch name
- •Uncommitted changes (if any)
- •Last commit info
bash
git -C "<path>" status --short git -C "<path>" log --oneline -1
Interactive Mode
When /worktree is called without arguments or unclear input:
- •Show current worktrees
- •Ask what user wants to do (create, remove, view status)
Safety Rules
- •NEVER remove the main worktree
- •ALWAYS check for uncommitted changes before removal
- •ALWAYS confirm destructive operations with user
- •Use
git worktree pruneafter removals
Finishing Work in Worktree
When done working in a worktree, use /finish-task to:
- •Squash merge all commits to main (in main repo)
- •Optionally remove the worktree directory
The /finish-task skill auto-detects WORKTREE mode and handles the merge correctly.