Agent skill
worktree
Manage git worktrees for parallel feature development. Use when user mentions worktree, wants to work on multiple branches simultaneously, or runs /worktree. Supports task-aware naming (phase-XX/task-YY-description).
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/worktree
SKILL.md
Git Worktree Manager
Manage git worktrees for parallel feature development.
Current Worktrees
!git worktree list
Usage
/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:
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.
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
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
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.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?