From nbl.superpowers
Finishes git development branches post-implementation: verifies tests pass, detects inline/serial/parallel worktree modes, identifies base branch, and presents merge/PR/cleanup options.
npx claudepluginhub icefrag/nbl-superpowers --plugin nbl.superpowersThis skill uses the workspace's default tool permissions.
Guide completion of development work by presenting clear options and handling chosen workflow.
Finishes development branches: verifies tests pass, presents options for local merge, push and GitHub PR, keep as-is, or discard; executes git commands and cleans up worktrees.
Guides finishing git development branches after tests pass: verifies tests, presents options to merge locally, create GitHub PR, keep as-is, or discard, executes with git/gh, cleans worktrees.
Verifies tests pass on completed dev branch, then presents options to merge locally, create GitHub PR, keep as-is, or discard; executes choice and cleans up worktree.
Share bugs, ideas, or general feedback.
Guide completion of development work by presenting clear options and handling chosen workflow.
Core principle: Verify tests → Present options → Execute choice (merge if selected) → Clean up.
Announce at start: "I'm using the finishing-a-development-branch skill to complete this work."
NON-NEGOTIABLE: All worktree operations MUST use scripts from nbl.using-git-worktrees skill. Never use raw git worktree commands directly.
Before presenting options, verify tests pass:
# Run project's test suite
npm test / cargo test / pytest / go test ./...
If tests fail:
Tests failing (<N> failures). Must fix before completing:
[Show failures]
Cannot proceed with merge/PR until tests pass.
Stop. Don't proceed to Step 2.
If tests pass: Continue to Step 2.
Check which mode produced this branch:
# Check if a merge worktree exists (parallel mode indicator)
ls .worktrees/*-merge 2>/dev/null
| Mode | Detection | Worktree Layout |
|---|---|---|
| Inline | No worktree, on dev branch directly | Working on dev branch itself |
| Serial | Single worktree from dev branch | .worktrees/{name}/ |
| Parallel | Merge worktree exists | .worktrees/{name}-merge/ + (task worktrees already cleaned) |
If parallel mode detected: Execute Step 2A (detect only, no auto-merge).
Parallel mode detected when merge worktree exists (feature/{name}-merge branch at .worktrees/{name}-merge/).
The merge worktree contains all accumulated changes from all parallel tasks. Do NOT merge automatically. The merge will be performed after user selection in Step 5. Continue directly to Step 3.
# Get the primary worktree's current branch (first entry in git worktree list)
# This is the branch we created the current worktree from — the correct merge target
PRIMARY_WORKTREE=$(git worktree list | head -1)
BASE_BRANCH=$(echo "$PRIMARY_WORKTREE" | sed -n 's/.*\[\(.*\)\]$/\1/p')
# Fallback if branch name could not be extracted
if [[ -z "$BASE_BRANCH" ]]; then
if git show-ref --verify --quiet refs/heads/main; then
BASE_BRANCH="main"
else
BASE_BRANCH="master"
fi
fi
Logic:
git worktree list first entry is always the primary worktree — the branch it's on is where this worktree was created from[...] at end of linemain/master only if extraction fails<base-branch> - is that correct?"Present exactly these 4 options:
Implementation complete. What would you like to do?
1. Merge back to <base-branch> locally
2. Push and create a Pull Request
3. Keep the branch as-is (I'll handle it later)
4. Discard this work
Which option?
Don't add explanation - keep options concise.
Parallel mode only: First merge merge branch to development branch:
# Switch to development branch (base branch in parallel mode)
git checkout <development-branch>
# Merge the completed merge branch
git merge --ff-only feature/<name>-merge
# Verify tests on merged result
<test command>
If tests fail: Stop and fix before proceeding.
If tests pass: Continue with merge to base branch:
# Switch to base branch
git checkout <base-branch>
# Pull latest
git pull
# Merge development branch
git merge <feature-branch>
# Verify tests on merged result
<test command>
# If tests pass
git branch -d <feature-branch>
Then: Cleanup worktree (Step 6)
Parallel mode only: First merge merge branch to development branch:
# Switch to development branch
git checkout <development-branch>
# Merge the completed merge branch
git merge --ff-only feature/<name>-merge
# Verify tests on merged result
<test command>
If tests fail: Stop and fix before proceeding.
If tests pass: Continue with push:
# Push branch
git push -u origin <feature-branch>
# Create PR/MR body template
PR_BODY=$(cat <<'EOF'
## Summary
<2-3 bullets of what changed>
## Test Plan
- [ ] <verification steps>
EOF
)
# Create PR/MR - auto-detect GitHub/GitLab
if command -v gh >/dev/null 2>&1; then
# GitHub CLI
gh pr create --title "<title>" --body "$PR_BODY"
elif command -v glab >/dev/null 2>&1; then
# GitLab CLI
glab mr create --title "<title>" --description "$PR_BODY"
else
echo "No GitHub CLI (gh) or GitLab CLI (glab) found."
echo "Branch pushed to <feature-branch>, please create your PR/MR manually."
fi
Then: Cleanup worktree (Step 6)
Parallel mode: Do NOT merge merge branch to development branch. Do NOT cleanup merge worktree.
Report: "Keeping branch . Merge worktree preserved at .worktrees/{name}-merge/. You can finish the merge later."
Don't cleanup any worktree.
Serial/Inline mode: Same as before - keep worktree as-is.
Confirm first:
This will permanently delete:
- Branch <name>
- All commits in merge branch: <commit-list>
- Merge worktree at <path>
Type 'discard' to confirm.
Wait for exact confirmation.
If confirmed:
# Parallel mode: Delete merge branch directly, do not merge
git checkout <base-branch>
git branch -D feature/<name>-merge
Then: Cleanup merge worktree (Step 6)
NON-NEGOTIABLE: All cleanup MUST be performed via nbl.using-git-worktrees skill. The skill provides proper safety checks and handles platform detection.
For Options 1, 2, 4:
Invoke nbl.using-git-worktrees cleanup:
Invoke via: /nbl.superpowers:nbl.using-git-worktrees cleanup <base_name> [--force]
Parallel mode additional cleanup:
After cleaning up the main worktree, also clean up the merge worktree:
Invoke via: /nbl.superpowers:nbl.using-git-worktrees cleanup <name>-merge --force
For Option 3: Keep worktree.
| Option | Auto-merge Merge WT → Dev | Merge Dev → Base | Push | Keep Worktree | Cleanup Branch | Cleanup Merge WT |
|---|---|---|---|---|---|---|
| 1. Merge locally | ✓ | ✓ | - | - | ✓ | ✓ (parallel only) |
| 2. Create PR | ✓ | - | ✓ | - | - | ✓ (parallel only) |
| 3. Keep as-is | ✗ | - | - | ✓ | - | - (keep) |
| 4. Discard | ✗ (no merge) | - | - | - | ✓ (force) | ✓ (parallel only) |
Key change (parallel mode): Merge from merge worktree to development branch only happens after user selects Option 1 or 2. Option 3 keeps everything as-is for later completion.
.worktrees/{name}/cleanup-worktree script with base_name.worktrees/{name}-merge/ — NOT merged automaticallysub-to-sub-merge script)Skipping test verification
Open-ended questions
Using raw git commands for worktree cleanup
nbl.using-git-worktrees skill for cleanupForgetting merge worktree in parallel mode
No confirmation for discard
Never:
git worktree commands — always invoke nbl.using-git-worktrees skillAlways:
nbl.using-git-worktrees skill for all worktree cleanup operationsCalled by:
Pairs with: