Finishing a development branch
Skill heymegabyte/claude-skills/20-superpowers/finishing-a-development-branch
14-category autonomous product-building OS for 32+ AI coding tools. One-line prompts → deployed products.
npx -y skills add heymegabyte/claude-skills --skill finishing-a-development-branchAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 18 stars18 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
SKILL.md
3.2 KB, as published. Nobody here has run it
Finishing a Development Branch
Integrate finished work: verify → detect environment → choose integration → execute → clean up.
Under [[no-staging-doctrine]] + [[main-only-branch]] the default is merge to main + auto-push — diffs clearing all gates auto-merge. Don't offer "keep the branch as-is, handle it later"; finish the work this turn. PR only when a human review is explicitly wanted.
Announce: "Using the finishing-a-development-branch skill to complete this work."
Step 1 — gate before integrating
- Run the project test suite. Failures block — show them, fix first, do NOT integrate broken code.
- Full deploy + prod-E2E gate is
[[verification-loop]]— local green ≠ done.
Step 2 — detect environment
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
GIT_DIR == GIT_COMMON→ normal repo, no worktree cleanup.GIT_DIR != GIT_COMMON, named branch → worktree, provenance-based cleanup (Step 4).- Detached HEAD → externally managed; no local-merge, no cleanup (push-as-branch or discard only).
- Base branch:
git merge-base HEAD main || git merge-base HEAD master, or confirm with the user.
Step 3 — integrate
-
Merge to base (default).
cdto main repo root first (CWD safety), merge, re-run tests on the merged result, then Step 4 cleanup, thengit branch -d. Always auto-push the merged base.MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel); cd "$MAIN_ROOT" git checkout <base> && git pull && git merge <feature> && <test cmd> && git push -
PR (review wanted).
git push -u origin <feature>. Do NOT clean up the worktree — it's needed to iterate on feedback. -
Discard (abandon). Require a typed
discardconfirmation listing branch + commits + worktree path. Thencdto main root, Step 4 cleanup,git branch -D <feature>.
Step 4 — cleanup (merge + discard only; PR preserves the worktree)
WORKTREE_PATH=$(git rev-parse --show-toplevel)
- Normal repo (
GIT_DIR == GIT_COMMON) → nothing to remove. - Worktree under
.worktrees/orworktrees/→ we own it. From main root (never from inside the worktree):git worktree remove "$WORKTREE_PATH" && git worktree prune. - Anywhere else → harness-owned; use its exit tool (
ExitWorktree) or leave in place. Never remove a worktree you didn't create.
Ordering invariants (why the sequence is fixed)
- Merge BEFORE removing the worktree —
git branch -dfails while a worktree references the branch. cdto main root BEFOREgit worktree remove— fails silently when CWD is inside the target.git worktree pruneafter removal self-heals stale registrations.
See
[[no-staging-doctrine]]·[[main-only-branch]]·[[verification-loop]]using-git-worktrees— the isolation setup this finishes