/worktree
Create isolated git worktrees for parallel feature development without disrupting your main working directory.
Syntax
/worktree [feature-description] # Standalone repo
/worktree [project] [feature-description] # Monorepo
How It Works
- Analyzes repo type (standalone/monorepo/superproject)
- Detects branch prefix from description
- Converts description to kebab-case slug
- Creates worktree in smart default location
- Auto-installs dependencies based on lock files
Branch Prefixes
Auto-detected from description keywords:
| Keywords | Prefix |
|---|---|
| fix, bug, error, issue | fix |
| refactor, restructure, rewrite | refactor |
| docs, documentation, readme | docs |
| test, spec, coverage | test |
| chore, cleanup, deps | chore |
| perf, performance, optimize | perf |
| Default | feat |
Examples
/worktree add authentication system
# → Creates: worktrees/project-add-auth
# → Branch: kai/feat/add-auth
/worktree fix login validation bug
# → Creates: worktrees/project-login-validation-bug
# → Branch: kai/fix/login-validation-bug
Monorepo
/worktree api add webhook support
# → Creates: worktrees/api-add-webhook-support
# → Branch: kai/feat/add-webhook-support
/worktree frontend refactor dashboard layout
# → Creates: worktrees/frontend-refactor-dashboard
# → Branch: kai/refactor/refactor-dashboard
Worktree Location
Smart defaults based on repo structure:
- Superproject:
<superproject>/worktrees/ - Monorepo:
<monorepo>/worktrees/ - Standalone:
<parent-dir>/worktrees/
Override with --worktree-root <path> if needed.
Dependency Installation
Auto-runs based on lock files:
bun.lock→bun installpnpm-lock.yaml→pnpm installyarn.lock→yarn installpackage-lock.json→npm installpoetry.lock→poetry installrequirements.txt→pip installCargo.toml→cargo buildgo.mod→go mod download
Environment Files
Template files (.env*.example) auto-copied with .example suffix removed.
Related Commands
- /wt - Monorepo worktree variant