
Finishing A Development Branch
Close out a finished feature branch after tests pass by detecting the correct base branch and choosing merge, PR, or cleanup without skipping verification.
Install
npx skills add https://github.com/izyanrajwani/agent-skills-library --skill finishing-a-development-branchWhat is this skill?
- Step 1 runs the project-appropriate test command and stops with ⊘ BLOCKED:TESTS if anything fails
- Step 2 detects base branch via merge-base against main, master, or develop and asks when ambiguous
- Step 3 presents exactly four integration options after verification
- Supports npm/yarn, Cargo, pytest, go test, and Makefile test targets from repo layout
Adoption & trust: 1 installs on skills.sh; 4 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
Ship is where integrated, tested work lands in mainline; this skill explicitly runs after implementation is complete and tests pass. review matches the merge/PR decision gate and branch integration choices rather than writing new product code.
Common Questions / FAQ
Is Finishing A Development Branch safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Finishing A Development Branch
# Finishing a Development Branch ## The Process ### Step 1: Verify Tests Determine test runner from project structure: - `package.json` → `npm test` or `yarn test` - `Cargo.toml` → `cargo test` - `pyproject.toml` / `setup.py` → `pytest` - `go.mod` → `go test ./...` - `Makefile` with `test` target → `make test` Run tests. If any fail, report `⊘ BLOCKED:TESTS` with failure count and stop. Do not proceed to Step 2. ### Step 2: Determine Base Branch Find the branch this feature diverged from: ```bash # Check which branch has the closest merge-base for candidate in main master develop; do if git rev-parse --verify "$candidate" >/dev/null 2>&1; then MERGE_BASE=$(git merge-base HEAD "$candidate" 2>/dev/null) if [ -n "$MERGE_BASE" ]; then echo "Candidate: $candidate (merge-base: $MERGE_BASE)" fi fi done ``` Select the candidate with the most recent merge-base (closest ancestor). If multiple branches share the same merge-base or detection is ambiguous, ask: "This branch could target `main` or `develop`. Which should it merge into?" **Store the result** - subsequent steps reference `<base-branch>` meaning this determined value. ### Step 3: Present Options Present exactly these 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 (I'll handle it later) 4. Discard this work Which option? ``` ### Step 4: Execute Choice #### Option 1: Merge Locally ```bash git checkout <base-branch> git pull git merge <feature-branch> ``` **If merge conflicts:** ``` ⊘ BLOCKED:CONFLICTS Merge conflicts in: - <conflicted files> Cannot auto-resolve. User must: 1. Resolve conflicts manually 2. Run tests 3. Re-run this workflow ``` Stop. Do not proceed. **If merge succeeds:** ```bash # Verify tests on merged result <test command> # If tests pass, delete feature branch git branch -d <feature-branch> ``` Then: Cleanup worktree (Step 5). Report `✓ MERGED`. #### Option 2: Push and Create PR **Verify `gh` CLI is available:** ```bash if ! command -v gh &>/dev/null; then echo "gh CLI not installed. Install from https://cli.github.com/ or push manually and create PR via web." exit 1 fi gh auth status || echo "gh not authenticated. Run: gh auth login" ``` Extract title from first commit on branch (original intent): ```bash MERGE_BASE=$(git merge-base HEAD <base-branch>) TITLE=$(git log --reverse --format=%s "$MERGE_BASE"..HEAD | head -1) git push -u origin <feature-branch> gh pr create --title "$TITLE" --body "$(cat <<'EOF' ## Summary <2-3 bullets of what changed> ## Test Plan - [ ] <verification steps> EOF )" ``` Report `✓ PR_CREATED` with PR URL. **Keep worktree intact** for continued work during review. #### Option 3: Keep As-Is Report `✓ PRESERVED` with branch name and worktree path. **Do not cleanup worktree.** #### Option 4: Discard **Confirm first:** ``` This will permanently delete: - Branch <name> - All commits: <commit-list> - Worktree at <path> Type 'discard' to confirm. ``` Wait for exact confirmation. If not received, abort. If confirmed: ```bash git checkout <base-branch> git branch -D <feature-branch> ``` Then: Cleanup worktree (Step 5). Report `✓ DISCARDED`. ### Step 5: Cleanup Worktree **For Options 1 and 4 only:** ```bash # Check if currently in a worktree (not main repo) if [ "$(git rev-parse --git-common-dir)" != "$(git rev-parse --git-dir)" ]; then # Get worktree root (handles invocation from subdirectory) WORKTREE_ROOT=$(git rev-parse --show-toplevel) cd "$(git rev-parse --git-common-dir)/.." git worktree remove "$WORKTREE_ROOT" fi ``` **For Options 2 and 3:** Keep worktree intact. ## Quick Reference | Option | Merge | Push | Keep Worktree | Clea