From superpowers
Use when implementation is complete, all tests pass, and you need to integrate the work - defaults to local merge unless the project CLAUDE.md specifies otherwise
How this skill is triggered — by the user, by Claude, or both
Slash command
/superpowers:finishing-a-development-branchThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guide completion of development work. **Default action is local merge** — no menu, no questions asked.
Guide completion of development work. Default action is local merge — no menu, no questions asked.
Core principle: Verify tests → Code review → Merge locally → Clean up.
Override: If the project-level CLAUDE.md contains explicit instructions about how to finish branches (e.g. "create a PR", "push for review"), follow those instead of the default merge. Only then present options or follow the project's specified workflow.
Announce at start: "I'm using the finishing-a-development-branch skill to complete this work."
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.
# Try common base branches
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
Or ask: "This branch split from main - is that correct?"
BASE_SHA=$(git merge-base HEAD <base-branch>)
# What changed (summary)
git diff --stat $BASE_SHA..HEAD
# Full diff
git diff $BASE_SHA..HEAD
# Commit history on this branch
git log --oneline $BASE_SHA..HEAD
Spawn a branch-reviewer subagent. It gets the diff and reviews with fresh context — no anchoring to the implementation decisions made during development.
Agent:
subagent_type: branch-reviewer
prompt: |
Review this feature branch for merge readiness.
Branch: <branch-name>
Base: <base-branch> (SHA: <BASE_SHA>)
Commits: <N> commits
Worktree path: <worktree-path>
Run these commands to get the changes (always use git -C, never cd):
git -C <worktree-path> diff --stat <BASE_SHA>..HEAD
git -C <worktree-path> diff <BASE_SHA>..HEAD
Review for bugs, design issues, refactoring opportunities, efficiency
improvements, and code quality. Read surrounding code (callers,
interfaces, related modules) whenever the diff alone isn't enough
context to judge.
When the agent returns, present its findings to the user in severity order (critical first):
## Code Review — <branch-name>
Verdict: <GOOD TO GO / FIX BEFORE MERGE / NEEDS REWORK>
<Summary paragraph>
<N> findings: <X> critical, <Y> important, <Z> minor
---
**[BUG-1] Title** (critical)
File: path/to/file:lines
What: ...
Why: ...
Fix: ...
→ Apply? [yes / skip / discuss]
**[DESIGN-1] Title** (important)
...
If the verdict is GOOD TO GO with no critical/important findings, keep it brief:
## Code Review — <branch-name>
Verdict: GOOD TO GO
<Summary>. No critical or important issues found.
<list any minor findings briefly>
Ready to proceed to merge options.
Never auto-apply fixes — the user drives all decisions.
For each finding the user approved:
Commit the fixes:
git add <changed-files>
git commit -m "Refactor: apply code review improvements
- <one line per fix applied>"
Skip this step if nothing was approved.
Re-run the test suite if any fixes were applied:
npm test / cargo test / pytest / go test ./...
If tests fail, fix before continuing. Don't proceed with broken tests.
Unless the project CLAUDE.md specifies a different workflow, proceed directly with a local merge. Do not present a menu — just merge.
Cleanup worktree first (Step 9), then merge and delete branch:
# 1. Move CWD out of worktree (separate Bash call — never chain cd && git)
cd <main-repo>
# 2. Remove worktree (Step 9) — CWD is now safely outside
git worktree remove <worktree-path>
# 3. Switch to base branch and pull latest
git checkout <base-branch> && git pull
# 4. Merge feature branch
git merge <feature-branch>
# 5. Verify tests on merged result
<test command>
# 6. If tests pass, delete feature branch
git branch -d <feature-branch>
If the project CLAUDE.md specifies a non-merge workflow, or if you cannot determine the right action from it, present these 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.
Same as Step 7 above.
# 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
)"
Report: "PR created. Worktree preserved at for any follow-up changes."
Don't cleanup worktree — the PR may need revisions.
Report: "Keeping branch . Worktree preserved at ."
Don't cleanup worktree.
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, cleanup worktree first (Step 9), then delete branch:
# 1. Move CWD out of worktree (separate Bash call — never chain cd && git)
cd <main-repo>
# 2. Remove worktree (Step 9) — CWD is now safely outside
git worktree remove <worktree-path>
# 3. Delete feature branch
git checkout <base-branch>
git branch -D <feature-branch>
For Options 1 and 4 only: Clean up worktree and branch (worktree remove first, then branch delete).
Critical: Before removing a worktree, CWD must be outside it — otherwise deleting the directory crashes the session. Use a separate Bash call to cd <main-repo> first — never chain cd && git (chained commands trigger permission prompts in worktrees).
For Options 2 and 3: Keep worktree.
| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
Skipping test verification
Presenting options when not needed
Skipping code review
Removing worktree while CWD is inside it
git worktree remove deletes the directory; if the shell's CWD is inside it, the session crashescd <main-repo> before the remove call — never chain cd && git (triggers permission prompts)Automatic worktree cleanup
No confirmation for discard
Never:
Always:
Called by:
Pairs with:
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
npx claudepluginhub emilelemoine/superpowers --plugin superpowers