name: worktree description: Create git worktrees for parallel feature development. Use when working on multiple features simultaneously. argument-hint: [branch-name]
Worktree Management Skill
Instructions
When the user invokes this skill:
Fetch latest changes
git fetch originEnsure .gitignore is configured
- Check if
.worktrees/is in.gitignore - If not, append
.worktrees/to.gitignore
- Check if
Determine branch type - Check if the branch already exists:
git branch -a | grep -E "(^|\s)feat/<name>$|origin/feat/<name>"Determine base branch (only needed for new branches):
git branch -r | grep -E "origin/(develop|master)$"- Use
origin/developif it exists - Fall back to
origin/masterifdevelopdoesn't exist
- Use
Create the worktree
If branch does NOT exist → create new branch from base branch:
# If origin/develop exists: git worktree add .worktrees/<name> -b feat/<name> origin/develop # If origin/develop doesn't exist, use origin/master: git worktree add .worktrees/<name> -b feat/<name> origin/masterIf branch EXISTS → use existing branch:
git worktree add .worktrees/<name> feat/<name>Report the result
- Show
git worktree list - Provide the worktree path:
.worktrees/<name>
- Show
Examples
User: /worktree auth-refactor
→ Branch feat/auth-refactor doesn't exist
→ origin/develop exists
→ Creates .worktrees/auth-refactor on NEW branch feat/auth-refactor (from origin/develop)
User: /worktree new-feature
→ Branch feat/new-feature doesn't exist
→ origin/develop doesn't exist, using origin/master
→ Creates .worktrees/new-feature on NEW branch feat/new-feature (from origin/master)
User: /worktree metaknow_url_header
→ Branch feat/metaknow_url_header already exists
→ Creates .worktrees/metaknow_url_header using EXISTING branch
Cleanup
git worktree remove .worktrees/<name>
git worktree list