From finishing-a-development-branch
Use when implementation work is complete and you need to decide how to integrate the branch — merging locally, creating a PR, keeping the branch, or discarding the work.
How this skill is triggered — by the user, by Claude, or both
Slash command
/finishing-a-development-branch:finishing-a-development-branchThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- Implementation work on a feature or fix is complete (all code changes made)
TESTS MUST PASS BEFORE OPTIONS 1–3 ARE PRESENTED
If tests are failing, do not present Options 1–3 (merge, PR, keep) — fix or report the failure first. The skill enforces this boundary: verify test status, present options only on green, handle blockers if red. Exception: Option 4 (Discard) is always available when the user explicitly wants to abandon the failing branch.
| Signal | Route |
|---|---|
| Tests passing, ready to integrate | → Present Four Options |
| Tests failing or not run | → Fix or report; do not present options |
| User rejects all four options or requests custom flow | → Clarify intent; escalate if outside standard paths |
| Worktree is dirty (uncommitted changes) | → Commit/stage first, then proceed |
Announce at start: "I'm using the finishing-a-development-branch skill to complete this work."
Then:
Before presenting any option, confirm:
If tests are not passing or cannot be run → stop, fix the failure, and report it. Do not present the options below.
Merge locally — git checkout <base>, git pull, git merge <feature>, verify tests, git branch -d <feature>, cleanup worktree
Push and create PR — push branch, gh pr create with summary and test plan, keep worktree
Keep as-is — report branch and worktree location, no cleanup
Discard — require typed "discard" confirmation, force-delete branch, cleanup worktree
Tests are the gate — Do not present options if tests are failing, blocked, or not run. Announce the blocker and stop.
No false progress — Do not mark the task done until the integration option is executed and verified (branch pushed, merged, or explicitly kept/discarded).
Dirty worktree safety — Before any integration action, verify the working tree is clean. If there are uncommitted changes, halt and ask the user to commit or stash.
Branch existence — Confirm the feature branch still exists and has the expected commits before starting an integration action.
Base branch freshness — Before merging locally, pull the latest base branch to avoid silent conflicts or divergence.
PR creation safety — Before gh pr create, confirm the branch is already pushed to the remote and is reachable from origin.
Confirmation for destructive actions — Require explicit typed confirmation (the word "discard") for Option 4 to prevent accidental data loss.
Cleanup idempotency — Worktree cleanup commands should succeed even if the worktree is partially cleaned or already removed; use mr_worktree_remove with appropriate safety checks.
After presenting and executing an option, validate:
Option 1 validation: Base branch is updated; feature branch is deleted locally; tests pass on base; worktree is removed
Option 2 validation: Branch is pushed; PR exists and links to the right base; PR title and summary are clear; worktree persists
Option 3 validation: Branch and worktree locations are reported clearly; user acknowledges; no cleanup yet
Option 4 validation: User typed "discard"; branch is force-deleted; worktree is removed; no residual files
Smoke test:
github-cli-pr-workflow)Each example below walks through the full decision boundary: verify tests, check worktree cleanliness, present all four options, execute the chosen one.
Work complete on feature/auth-jwt:
- Tests pass: 247 passed
- Ready to integrate
Announce: "I'm using the finishing-a-development-branch skill to complete this work."
Verify tests: ✓ All 247 tests passing
Verify worktree clean: ✓ No uncommitted changes
No blockers.
Presenting Four Integration Options:
1. Merge locally → git checkout main && git pull && git merge feature/auth-jwt
2. Push and create PR
3. Keep as-is
4. Discard
User selects: 1
Action:
$ git checkout main
$ git pull
$ git merge feature/auth-jwt
$ npm test # retest on main
Tests pass: ✓
$ git branch -d feature/auth-jwt
$ mr_worktree_remove auth-jwt
Worktree cleaned up
✓ Integration complete: main now includes auth-jwt; branch removed.
Work complete on fix/linting-errors:
- Tests pass: All 890 tests passing
- Ready for review
Announce: "I'm using the finishing-a-development-branch skill to complete this work."
Verify tests: ✓ All 890 tests passing
Verify worktree clean: ✓ No uncommitted changes
No blockers.
Presenting Four Integration Options:
1. Merge locally
2. Push and create PR → gh pr create --title "fix: resolve linting errors" --body "Fixes..."
3. Keep as-is
4. Discard
User selects: 2
Action:
$ git push origin fix/linting-errors
$ gh pr create --title "fix: resolve linting errors" --body "Resolves #123. Tests: 890 passed." --base main
PR created: https://github.com/owner/repo/pull/456
✓ Integration in progress: PR #456 created; worktree remains active for feedback cycles.
Work complete on explore/experimental-feature:
- Tests pass but feature incomplete for production
- User wants to preserve branch for later
Announce: "I'm using the finishing-a-development-branch skill to complete this work."
Verify tests: ✓ All applicable tests passing
Verify worktree clean: ✓ No uncommitted changes
No blockers.
Presenting Four Integration Options:
1. Merge locally
2. Push and create PR
3. Keep as-is → Branch and worktree stay; cleanup later
4. Discard
User selects: 3
✓ Integration paused: Branch explore/experimental-feature and worktree remain active.
Worktree path: .worktrees/experimental-feature
Branch: origin/explore/experimental-feature (not pushed; local only)
Next step: User pushes when ready, or deletes via Option 4 later.
Work incomplete on experiment/failed-approach:
- Tests failing; approach not viable
- Ready to abandon
Announce: "I'm using the finishing-a-development-branch skill to complete this work."
Verify tests: ✗ 12 tests failing; approach not viable
Blocker: Tests failing — Options 1–3 are unavailable (merge, PR, keep all require passing tests).
Exception: Option 4 (Discard) is available when the user explicitly wants to abandon.
Presenting available option:
4. Discard → Type "discard" to confirm; branch and worktree removed
(Options 1–3 are blocked until tests pass.)
User selects: 4 and types: discard
Action:
$ git branch -D experiment/failed-approach
$ mr_worktree_remove failed-approach --deleteBranch
Worktree cleaned up; branch removed
✓ Integration complete: Branch and worktree discarded; workspace clean.
Called by: Any multi-step implementation workflow after all tasks complete and before final handoff.
Pairs with:
git-worktrees — cleanup via mr_worktree_removeworktrunk — prefer wt merge for Option 1 when Worktrunk is installedgithub-cli-pr-workflow — use for Option 2 PR creation/update and check-watch handoff after pushingreview-comment-resolution — after Option 2 receives feedbackActivates: When implementation is complete and tests pass; agent is deciding final branch fate.
Deactivates: After user confirms one of four options and execution is complete (merge verified, PR created, branch kept, or discarded).
git-worktrees — worktree lifecycle management and cleanup via mr_worktree_removeworktrunk — wt merge for Option 1 when Worktrunk is installedreview-comment-resolution — handling review feedback cycles after Option 2 (PR creation)Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub matt-riley/lucky-hat --plugin finishing-a-development-branch