git-worktrees
Git Worktrees
Directory Convention
Worktrees live in a sibling directory named <project>_worktrees:
parent/
├── myproject/ # main repo
└── myproject_worktrees/ # worktrees directory
├── feature_1/
└── feature_2/
Branch Naming
Use <feature>_<N> pattern when creating multiple worktrees:
auth-refactor_1,auth-refactor_2api-migration_1,api-migration_2
Workflow
- Get project name from current directory
- Create worktrees directory if needed:
../<project>_worktrees/ - Create worktree with new branch:
git worktree add <path> -b <branch>
Creating Multiple Worktrees
When asked for N worktrees for a feature:
PROJECT=$(basename "$PWD")
WORKTREES_DIR="../${PROJECT}_worktrees"
mkdir -p "$WORKTREES_DIR"
for i in $(seq 1 N); do
git worktree add "${WORKTREES_DIR}/<feature>_${i}" -b "<feature>_${i}"
done
Cleanup
Remove worktree and branch:
git worktree remove <path>
git branch -d <branch>
List all worktrees: git worktree list
More from lexler/skill-factory
hexagonal-architecture
Applies hexagonal (ports & adapters) architecture. Use when designing application structure, separating domain from infrastructure, creating testable boundaries, or when user mentions ports, adapters, hexagonal, or clean architecture.
13using-uv
Python package and project management with UV. Use when creating Python scripts, initializing projects, or managing dependencies.
5approval-tests
Writes approval tests (snapshot/golden master testing) for Python, JavaScript/TypeScript, or Java. Use when verifying complex output, characterization testing legacy code, testing combinations, or working with .approved/.received files.
5refactoring
Refactoring process. Invoke immediately when user or document mentions refactoring, or proactively when code gets too complex or messy.
5creating-process-files
Creates process files - text as code instructions for reliable AI workflows. Use when creating new process files.
4writing-bash-scripts
Bash script style guide. Always use when writing bash scripts, shell scripts, or CLI bash tools.
4