finishing-a-development-branchlisted
Install: claude install-skill heymegabyte/claude-skills
# 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
```bash
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).** `cd` to main repo root first (CWD safety), merge, re-run tests on the merged result, then Step 4 cleanup, then `git branch -d`. Always auto-push the merged base.
```bash
MAIN_ROOT=$(git -C "$(git rev-par