using-git-worktrees
When running long feature implementations, parallel branch work, or build/test scripts that must not interfere with the user's active working directory. Creates isolated execution environments via git worktrees in sibling directories.
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 13
- Forks
- 3
01 前言 Front Matter
- name
- using-git-worktrees
- license
- MIT
- description
- When running long feature implementations, parallel branch work, or build/test scripts that must not interfere with the user's active working directory. Creates isolated execution environments via git worktrees in sibling directories.
03 SKILL.md 正文
Using Git Worktrees Skill
Purpose: Keep the active repo clean. Work happens in a sibling directory — no nested git repos, no IDE re-indexing loops.
When to Use
| Situation | Use worktree? |
|---|---|
| Long feature run (> ~30 min) | Yes |
| Parallel branch comparison | Yes |
| Running full build/test suite against a branch | Yes |
| Quick hotfix or single-file change | No — use normal branch |
Setup
- Confirm the feature branch exists (created by
git-flowbefore any code):BRANCH=<branch-name> REPO=$(basename $(git rev-parse --show-toplevel)) WORKTREE_PATH="../${REPO}-${BRANCH}" - Create the worktree:
git worktree add "$WORKTREE_PATH" "$BRANCH" - Enter the worktree before running any build or test commands:
cd "$WORKTREE_PATH" - All implementation, build, and test commands execute inside
$WORKTREE_PATH. The main repo directory is effectively read-only during this session.
Rules
- Sibling directories only. Never place a worktree inside the repo (e.g.,
./worktrees/). Nested paths cause IDE indexing loops and nested-git errors. - One worktree per branch. Do not create multiple worktrees for the same branch.
- Do not edit files in the main repo directory while a worktree session is active.
Cleanup (after PR is merged)
- Return to main repo directory, then:
git worktree remove "$WORKTREE_PATH" git branch -d "$BRANCH" # only after merge is confirmed
Gate: Do not run build or test scripts in the main repo directory when a worktree exists for the active branch.
04 同仓库更多 Skills
setup-project
When setting up agentskel on a new project that does not yet have .memory/ or .agents/. Use when the user says "set up agentskel", "install agentskel", or "add agent memory to this project".
test-engineer
When designing test strategy, analysing coverage, or writing tests outside the TDD cycle. Also use when working with CI pipelines or validating changes end-to-end.
test-driven-development
When implementing logic changes during develop-feature or implement-task. Use the Red-Green-Refactor cycle to write a failing test before any production code.
task-planner
When decomposing a feature or spec into implementable subtasks, estimating scope, or orchestrating multi-step work across subagents.
systematic-debugger
When applying debugging techniques during any investigation — root cause tracing, bisect, defense-in-depth. Enforces hypothesis-first analysis and prohibits guess-and-check changes. Use standalone or inside the debug-issue workflow.
domain-expert
When working on features that require domain knowledge — business rules, terminology, or invariants specific to this project. [Replace this description and the content below with your project's domain.]