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.
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
TypeScript refactoring and modernization guidelines from a principal specialist perspective. This skill should be used when refactoring, reviewing, or modernizing TypeScript code to ensure type safety, compiler performance, and idiomatic patterns. Triggers on tasks involving TypeScript type architecture, narrowing, generics, error handling, or migration to modern TypeScript features.
tools
Resolves TypeScript and JavaScript problems across type-level programming, performance, monorepo management, migration, and modern tooling. Invoke when diagnosing "type instantiation excessively deep" errors, migrating JS to TS, configuring strict tsconfig, debugging module resolution, or choosing between Biome/ESLint/Turborepo/Nx.
tools
Turborepo monorepo build system guidance. Triggers on: `turbo.json`, task pipelines, `dependsOn`, caching, remote cache, the `turbo` CLI, `--filter`, `--affected`, CI optimization, environment variables, internal packages, monorepo structure, and package boundaries. Use when the user configures tasks or workflows, creates packages, sets up a monorepo, shares code between apps, runs changed packages, debugs cache behavior, or works in an `apps/` plus `packages/` workspace.
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.