skills/finishing-branch/SKILL.md
Use when implementation is complete, all tests pass, and integration strategy needs to be decided - merge, PR, keep, or discard
npx skillsauth add sipengxie2024/superpower-planning finishing-branchInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide completion of development work by presenting clear options and handling chosen workflow.
Core principle: Verify tests -> Present options -> Execute choice -> Clean up only when the chosen option requires it.
Announce at start: "I'm using the finishing-branch skill to complete this work."
Before presenting options, verify tests pass:
# Auto-detect and run project's test suite
TEST_CMD=$(${CLAUDE_PLUGIN_ROOT}/scripts/detect-test-command.sh)
eval "$TEST_CMD"
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.
${CLAUDE_PLUGIN_ROOT}/scripts/detect-base-branch.sh
Or ask: "This branch split from main - 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.
For local merge flows, keep the safety order explicit: tests were already verified in Step 1, then the merge must succeed, then the merged result must pass verification, and only then may cleanup happen.
Before switching branches, capture the feature branch name and any matching worktree path so cleanup targets stay bound to the feature branch. For worktree-based feature flows, complete the merge from the worktree that already owns <base-branch> rather than trying to check out <base-branch> inside the feature worktree.
FEATURE_BRANCH=<feature-branch>
FEATURE_WORKTREE=$(git worktree list | grep "$FEATURE_BRANCH" | awk '{print $1}')
BASE_BRANCH=<base-branch>
BASE_WORKTREE=$(git worktree list --porcelain | awk -v b="refs/heads/$BASE_BRANCH" '
/^worktree / { w=$2 }
/^branch / && $2==b { print w; exit }
')
if test -z "$BASE_WORKTREE"; then
BASE_WORKTREE=$(cd "$(git rev-parse --git-common-dir)/.." && pwd)
fi
# Return to the worktree that should own the base branch before touching it
cd "$BASE_WORKTREE"
git checkout "$BASE_BRANCH"
# Pull latest
git pull
# Merge feature branch
git merge "$FEATURE_BRANCH"
# Verify tests on merged result
<test command>
If the merge fails or merged-result verification fails, stop. Do not remove the worktree or delete the branch.
If the merge succeeds and merged-result verification passes:
# Remove the feature worktree first if it exists; only then delete the merged branch
if test -n "$FEATURE_WORKTREE"; then
git worktree remove "$FEATURE_WORKTREE"
fi
git branch -d "$FEATURE_BRANCH"
Then: Cleanup is complete for this path unless additional local cleanup is needed.
# Push branch
git push -u origin <feature-branch>
# Create PR
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
<2-3 bullets of what changed>
## Test Plan
- [ ] <verification steps>
EOF
)"
Then: Keep branch and worktree as-is for PR revisions. No cleanup.
Report: "Keeping branch <name>. Worktree preserved at <path>."
Keep branch and worktree as-is. No cleanup.
Confirm first:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.
Wait for exact confirmation.
If confirmed:
FEATURE_BRANCH=<feature-branch>
FEATURE_WORKTREE=$(git worktree list | grep "$FEATURE_BRANCH" | awk '{print $1}')
BASE_BRANCH=<base-branch>
BASE_WORKTREE=$(git worktree list --porcelain | awk -v b="refs/heads/$BASE_BRANCH" '
/^worktree / { w=$2 }
/^branch / && $2==b { print w; exit }
')
if test -z "$BASE_WORKTREE"; then
BASE_WORKTREE=$(cd "$(git rev-parse --git-common-dir)/.." && pwd)
fi
# Return to the worktree that should own the base branch before deleting the feature worktree/branch
cd "$BASE_WORKTREE"
if test -n "$FEATURE_WORKTREE"; then
git worktree remove "$FEATURE_WORKTREE"
fi
git branch -D "$FEATURE_BRANCH"
Then: Cleanup is complete for this discard path unless additional local cleanup is needed.
Only run cleanup for options that truly require it.
discard confirmation, then force-delete the feature branch.If no feature worktree exists, skip cleanup. Do not assume every branch path has a removable worktree.
| Option | Merge | Push | Keep Worktree | Cleanup Branch | |--------|-------|------|---------------|----------------| | 1. Merge locally | yes | - | - | yes | | 2. Create PR | - | yes | yes | - | | 3. Keep as-is | - | - | yes | - | | 4. Discard | - | - | - | yes (force) |
Skipping test verification
Open-ended questions
Automatic worktree cleanup
No confirmation for discard
Never:
Always:
After cleanup, if .planning/findings.md or .planning/progress.md has meaningful content:
.planning/findings.mdAskUserQuestion:Implementation is finished. Before we move on, do you want me to archive this project now?
1. Yes — run /archive now (recommended)
2. Not now — remind me next time work resumes
3. Skip archiving for this task
superpower-planning:archiving.planning/progress.md, for example:
ARCHIVE REMINDER: This task is complete. Run /archive before starting unrelated work.If the user does not archive and .planning/findings.md still has meaningful content:
superpower-planning:archiving/archive later rather than persisting project findings through this skillDefault bias: Prefer /archive over ad-hoc memory writes when a meaningful project has just finished.
Called by:
Pairs with:
development
Use when a spec or requirements exist for a multi-step task and an implementation plan needs to be written before touching code
data-ai
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs.
data-ai
Use when executing implementation plans with parallel task groups or individual tasks too heavy for subagent context limits.
development
Use when implementing any feature or bugfix, before writing implementation code