From nbl.superpowers
Creates isolated git worktrees for parallel feature development with smart branch naming and safety verification. Useful when starting work that needs workspace isolation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/nbl.superpowers:nbl.using-git-worktreesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
Core principle: Scripts handle all worktree operations reliably.
Announce at start: "I'm using the using-git-worktrees skill to set up an isolated workspace."
Invoke via skill command:
| Operation | Command |
|---|---|
| Create | /nbl.using-git-worktrees create <base_name> [--parent <branch>] [task_id] |
| Cleanup | /nbl.using-git-worktrees cleanup <base_name> [task_id] [--force] |
| Sub-to-sub Merge (parallel mode) | /nbl.using-git-worktrees merge-sub <base_name> <task_id> |
branch_namedocs/nbl/plans/YYYY-MM-DD-{name}.mduser-auth)| Mode | Branch Name | Worktree Path | Base Branch |
|---|---|---|---|
| Work (Serial) | feature/{name}-work | .worktrees/{name}-work | feature/{name} |
| Merge | feature/{name}-merge | .worktrees/{name}-merge | feature/{name} |
| Parallel Task | feature/{name}-task{id} | .worktrees/{name}-task{id} | feature/{name}-merge |
基于主开发分支创建工作 worktree:
./skills/nbl.using-git-worktrees/scripts/create-worktree.sh "<name>-work" --parent "feature/<name>"
基于主开发分支创建 merge worktree:
./skills/nbl.using-git-worktrees/scripts/create-worktree.sh "<name>-merge" --parent "feature/<name>"
基于 merge 分支创建 task worktree:
# Create multiple worktrees for parallel tasks
for task_id in 1 2 3; do
./skills/nbl.using-git-worktrees/scripts/create-worktree.sh <base_name> --parent "feature/<base_name>-merge" $task_id
done
After creating the worktree, assess whether setup and baseline verification are needed before starting implementation:
Skip to step 3 (Report Status) if ALL of the following are true:
~/.m2 for Maven)Otherwise, run project setup:
cd <worktree_path>
# Java Maven
if [ -f pom.xml ]; then mvn install -DskipTests; fi
# Node.js
if [ -f package.json ]; then npm install; fi
# Python
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi
Skip if this is a parallel task worktree and another worktree in the same set has already verified the baseline.
Otherwise, run tests to verify clean baseline:
# Use project-appropriate test command
mvn test # Java Maven
npm test # Node.js
pytest # Python
If tests fail: Report failures and ask whether to proceed or investigate. Do not proceed silently with failing baseline tests.
Worktree ready at <worktree_path>
Baseline: <N> tests passing, 0 failures | skipped (shared baseline verified)
Setup: <dependencies installed / skipped (shared cache)>
Ready to implement <feature-name>
# Check for unmerged commits first
./skills/nbl.using-git-worktrees/scripts/cleanup-worktree.sh <base_name>
# Force delete if needed
./skills/nbl.using-git-worktrees/scripts/cleanup-worktree.sh <base_name> --force
# Cleanup each task's worktree
for task_id in 1 2 3; do
./skills/nbl.using-git-worktrees/scripts/cleanup-worktree.sh <base_name> $task_id [--force]
done
用于并行模式下任务完成后将任务分支合并回merge工作树:
# All-in-one: rebase task -> merge to merge branch -> cleanup task worktree
./skills/nbl.using-git-worktrees/scripts/sub-to-sub-merge.sh <base_name> <task_id>
可从任何位置执行 - 脚本自动检测并跳转到主仓库根目录,通过 git -C 在正确的 worktree 中执行命令。
| Script | Purpose | Key Features |
|---|---|---|
scripts/create-worktree.sh | Create/reuse worktree | Auto git init, gitignore check, smart recovery |
scripts/cleanup-worktree.sh | Remove worktree | Unmerged commit check, --force option |
scripts/sub-to-sub-merge.sh | Sub-to-sub merge | Rebase + merge + cleanup in one step |
scripts/lib/common.sh | Shared utilities | JSON output, naming helpers |
Called by:
Pairs with:
在 Windows 平台上使用 Git Bash 时,skill 脚本的完整路径由 Claude Code 以 Windows 格式给出(C:\Users\...),必须转换为 Git Bash 格式后再调用:
C:\ → /c/ (盘符小写)\ → 正斜杠 /,禁止混合❌ 错误 1 - 混合斜杠(前半反斜杠,后半正斜杠):
bash C:\Users\icefr\.claude\plugins\marketplaces\nbl-dev\skills\nbl.using-git-worktrees/scripts/create-worktree.sh log-analyzer-merge
反斜杠被 Bash 当作转义符逐个吃掉,路径完全损坏。这是最常见的错误。
❌ 错误 2 - 无引号全反斜杠:
bash C:\Users\icefr\.claude\plugins\marketplaces\nbl-dev\skills\nbl.using-git-worktrees\scripts\create-worktree.sh log-analyzer-merge
即使全部反斜杠,不加引号时所有反斜杠依然会被 Bash 转义吃掉。
✅ 正确调用(全正斜杠 + 引号):
bash "/c/Users/icefr/.claude/plugins/marketplaces/nbl-dev/skills/nbl.using-git-worktrees/scripts/create-worktree.sh" log-analyzer-merge
C:\ / D:\ 等 Windows 盘符开头 → 需要完整转换/ 开头 → macOS/Linux,直接调用,仍需加引号所有脚本调用都必须遵守此规则,避免路径转义错误。
npx claudepluginhub icefrag/nbl-superpowers --plugin nbl.superpowersCreates isolated git worktrees for feature branches with smart directory selection, gitignore checks, auto project setup detection, and baseline test verification. Use for task isolation from main workspace.
Creates isolated Git worktrees for parallel development, risky refactoring, or multi-feature work without branch switching or conflicts.
Creates isolated git worktrees for parallel development without disrupting the main workspace. Includes safety verification to prevent accidental commits of worktree contents.