🎯

finishing-a-development-branch

🎯Skill

from izyanrajwani/agent-skills-library

VibeIndex|
What it does

Streamlines Git branch completion by running tests, determining merge target, and guiding developers through merging or creating pull requests.

πŸ“¦

Part of

izyanrajwani/agent-skills-library(10 items)

finishing-a-development-branch

Installation

πŸ“‹ No install commands found in docs. Showing default command. Check GitHub for actual instructions.
Quick InstallInstall with npx
npx skills add izyanrajwani/agent-skills-library --skill finishing-a-development-branch
3Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

Git branch completion workflow. Use when implementation is complete, tests pass, and a feature branch needs to be integrated via merge, pull request, or cleanup.

Overview

# 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 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 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

git pull

git merge

```

If merge conflicts:

```

⊘ BLOCKED:CONFLICTS

Merge conflicts in:

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

# If tests pass, delete feature branch

git branch -d

```

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 )

TITLE=$(git log --reverse --format=%s "$MERGE_BASE"..HEAD | head -1)

git push -u origin

gh pr create --title "$TITLE" --body "$(cat <<'EOF'

Summary

<2-3 bullets of what changed>

Test Plan

  • [ ]

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
  • All commits:
  • Worktree at

Type 'discard' to confirm.

```

Wait for exact confirmation. If not received, abort.

If confirmed:

```bash

git checkout

git branch -D

```

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 | Cleanup Branch |

|--------|-------|------|---------------|----------------|

| 1. Merge locally | βœ“ | - | - | βœ“ |

| 2. Create PR | - | βœ“ | βœ“ | - |

| 3. Keep as-is | - | - | βœ“ | - |

| 4. Discard | - | - | - | βœ“ (force) |

Terminal States

On completion, report exactly one:

| State | Output | Meaning |

|-------|--------|---------|

| βœ“ MERGED | Branch merged to , worktree cleaned | Option 1 success |

| βœ“ PR_CREATED | PR #N at URL | Option 2 success |

| βœ“ PRESERVED | Branch kept at path | Option 3 success |

| βœ“ DISCARDED | Branch deleted, worktree cleaned | Option 4 success |

| ⊘ BLOCKED:TESTS | N test failures | Cannot proceed |

| ⊘ BLOCKED:CONFLICTS | Merge conflict in files | Cannot proceed |

Guardrails

Blocking conditions (stop immediately):

  • Tests failing β†’ ⊘ BLOCKED:TESTS
  • Merge conflicts β†’ ⊘ BLOCKED:CONFLICTS

Mandatory confirmations:

  • Option 4 (Discard): Require typed "discard" confirmation

Cleanup rules:

  • Options 1, 4: Clean up worktree and branch
  • Options 2, 3: Preserve worktree

Never:

  • Proceed with failing tests
  • Merge without verifying tests on result
  • Delete work without typed confirmation
  • Force-push without explicit request

Integration

Called by:

  • subagent-driven-development (Step 7) - After all tasks complete
  • executing-plans (Step 5) - After all batches complete

Pairs with:

  • using-git-worktrees - Cleans up worktree created by that skill

More from this repository9

🎯
systematic-debugging🎯Skill

Systematically investigates root causes of bugs by tracing data flow, analyzing system components, and forming precise hypotheses before attempting fixes.

🎯
verification-before-completion🎯Skill

Enforces evidence-first verification by requiring concrete proof via specific commands before claiming task completion or success.

🎯
using-git-worktrees🎯Skill

Creates isolated Git workspaces for parallel development without disrupting the current working tree.

🎯
executing-plans🎯Skill

Systematically executes implementation plans by loading, critically reviewing, executing tasks in batches, and reporting progress for architect feedback.

🎯
test-driven-development🎯Skill

Guides developers through writing tests first, implementing minimal code to pass, and refactoring while ensuring verified test coverage for behavior changes.

🎯
requesting-code-review🎯Skill

Requests a comprehensive code review by dispatching a subagent to analyze code changes, identify potential issues, and provide structured feedback before merge.

🎯
brainstorming🎯Skill

Collaboratively explores and refines ideas into validated design specifications through iterative, focused questioning and incremental validation.

🎯
dispatching-parallel-agents🎯Skill

Dispatches independent test failures or bug domains to specialized subagents for concurrent, focused investigation and resolution.

🎯
writing-plans🎯Skill

Generates comprehensive, test-driven implementation plans with precise file paths, code snippets, and verification steps for multi-step development tasks.