| name | finishing-a-development-branch |
| description | Use when implementation is complete, all tests pass, and you need to decide how to integrate the work |
| zh_description | 用于finishing、development、branch,支持任务规划、执行、评审和验证。 |
| version | 1.0.3 |
| author | seaworld008 |
| source | in-house |
| source_url | |
| tags | ["git", "workflow", "delivery"] |
| created_at | 2026-04-13 |
| updated_at | 2026-07-27 |
| quality | 4 |
| complexity | intermediate |
Finishing a Development Branch
Overview
Core principle: Verify tests → Detect environment → Present options → Execute choice → Clean up.
Announce at start: "I'm using the finishing-a-development-branch skill to complete this work."
Step 1: Verify Tests
Run the project's full test suite (npm test / cargo test / pytest / go test ./...).
If tests fail, report the failures and stop — the menu comes after a green suite:
Tests failing (<N> failures). Must fix before completing:
[Show failures]
If tests pass: continue to Step 2.
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)
WORKTREE_PATH=$(git rev-parse --show-toplevel)
This determines which menu to show and how cleanup works:
| State | Menu | Cleanup |
|---|
GIT_DIR == GIT_COMMON (normal repo) | Standard 3 options | No worktree to clean up |
GIT_DIR != GIT_COMMON, named branch | Standard 3 options | Provenance-based (see Step 6) |
GIT_DIR != GIT_COMMON, detached HEAD | Reduced 2 options (no merge) | Externally managed — leave in place |
Step 3: Determine Base Branch
The base branch is whatever this work forked from — usually named in the
plan, the conversation, or the branch's upstream. If it is not already
known, ask: "This branch split from - is that correct?"
Confirm before merging: merging into the wrong base is expensive to undo.
Step 4: Present Options
Normal repo and named-branch worktree — present exactly these 3 options: