bundles/github/skills/finishing-a-development-branch/SKILL.md
Structured "done coding, now what?" workflow: verify tests pass, detect the repository environment (normal repo vs worktree, named branch vs detached HEAD), present exactly the right merge / PR / keep / discard options, and execute the chosen path including safe worktree cleanup. Use when implementation is complete and the branch needs to be integrated, published, or abandoned.
npx skillsauth add shipshitdev/library finishing-a-development-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 the chosen workflow end-to-end.
Core principle: Verify tests → Detect environment → Present options → Execute choice → Clean up.
Inputs:
Outputs:
Creates/Modifies:
External Side Effects:
git push, gh pr create, branch deletion, and worktree removal.Confirmation Required:
Delegates To:
git-safety for history secret scrubbing before publishing.code-review for a pre-merge correctness pass when requested.Before presenting any options, run the project's test suite:
# Use whichever test runner the project uses
npm test / bun 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. Do not continue to Step 2 while tests are red.
If tests pass, continue to Step 2.
Determine workspace state before presenting options:
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)
| State | Menu | Cleanup |
|-------|------|---------|
| GIT_DIR == GIT_COMMON (normal repo) | 4-option menu | No worktree to clean up |
| GIT_DIR != GIT_COMMON, named branch | 4-option menu | Provenance-based (see Step 6) |
| GIT_DIR != GIT_COMMON, detached HEAD | 3-option menu (no local merge) | Externally managed — do not remove |
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
If neither resolves, ask the user: "This branch appears to split from main —
is that correct?"
Normal repo and named-branch worktree — exactly 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 (handle it later)
4. Discard this work
Which option?
Detached HEAD — exactly 3 options:
Implementation complete. You're on a detached HEAD (externally managed workspace).
1. Push as new branch and create a Pull Request
2. Keep as-is (handle it later)
3. Discard this work
Which option?
Do not add explanation text to the menu — keep it concise.
# Resolve main repo root first (safe when running inside a worktree)
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
cd "$MAIN_ROOT"
git checkout <base-branch>
git pull
git merge <feature-branch>
Run the test suite again on the merged result. Only after tests pass on the merge: run Step 6 to clean up the worktree, then delete the branch:
git branch -d <feature-branch>
git push -u origin <feature-branch>
gh pr create --title "<descriptive title>" --body "$(cat <<'EOF'
## Summary
- <what changed, 2-3 bullets>
## Test Plan
- [ ] <verification steps>
EOF
)"
Do not clean up the worktree — the user needs it alive to iterate on PR feedback.
Report: "Keeping branch <name>. Worktree preserved at <path>."
Do not clean up the worktree.
Require typed confirmation before destroying anything:
This will permanently delete:
- Branch <name>
- All commits: <commit list>
- Worktree at <path> (if applicable)
Type 'discard' to confirm.
Wait for the exact word. If confirmed:
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
cd "$MAIN_ROOT"
Run Step 6 to clean up the worktree, then force-delete the branch:
git branch -D <feature-branch>
This step runs only for Options 1 and 4. Options 2 and 3 always preserve the worktree.
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)
WORKTREE_PATH=$(git rev-parse --show-toplevel)
If GIT_DIR == GIT_COMMON: This is a normal repo checkout. No worktree to
clean up. Done.
If the worktree path is under .worktrees/ or worktrees/ relative to the
main repo root: The current workflow created this worktree — it is safe to
remove it.
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
cd "$MAIN_ROOT"
git worktree remove "$WORKTREE_PATH"
git worktree prune # clean up any stale registrations
Otherwise: The host environment owns this workspace. Do not remove it. Leave the workspace in place and report the path to the user.
| Option | Merge | Push | Keep Worktree | Delete Branch |
|--------|-------|------|---------------|---------------|
| 1. Merge locally | yes | — | — | yes (safe -d) |
| 2. Create PR | — | yes | yes | — |
| 3. Keep as-is | — | — | yes | — |
| 4. Discard | — | — | — | yes (force -D) |
Skipping test verification
Open-ended questions instead of the menu
Cleaning up the worktree for Option 2
Deleting the branch before removing the worktree
git branch -d fails because the worktree still references it.Running git worktree remove from inside the worktree
cd to the main repo root before calling git worktree remove.Cleaning up externally-managed worktrees
.worktrees/ or worktrees/ paths that
the current workflow owns. If provenance is unclear, leave it.No confirmation for discard
discard typed by the user before proceeding.Never:
git worktree remove from inside the worktree being removed.Always:
discard confirmation for Option 4.cd to the main repo root before any worktree removal.git worktree prune after removal.development
Create an isolated git worktree from the correct base branch and check it out into a clean, gitignored directory. Use when the user asks to make a worktree, spin up a parallel/isolated workspace, work on something without disturbing the current checkout, branch off the current work, or run multiple agents on the same repo at once. Picks the base branch smartly — the current feature branch when you are on one, otherwise the develop integration branch — so worktrees continue your in-progress work by default instead of forking from the wrong place.
development
Verify a release was fully promoted through develop, staging, and master/main, then prune merged local and remote branches and stale git worktrees. Squash-merge aware — uses GitHub PR merge state as the merge oracle, not commit ancestry. Use when the user asks to clean up branches after a deploy, prune worktrees, remove merged branches, tidy up after promoting develop to staging to master, or confirm nothing stale was left behind before pruning.
tools
Capture a client or stakeholder feature request, turn it into a planner-ready PRD epic with scoped sub-issues, check for duplicate work, and place approved issues on a GitHub Projects kanban. Use when a user invokes feature intake, asks to turn a rough client requirement into GitHub issues, or wants an idea written as a PRD and pushed to a board.
tools
Provides Tailwind CSS v4 performance optimization and best practices guidelines. Triggers when writing, reviewing, or refactoring Tailwind CSS v4 code; when working with Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.