SuperAPI AI Directory

finishing-a-development-branch

Coding & development

View repository

Updated 10-16 08:46

About this skill

Complete Development Branch

Overview

Guide the completion of development work by offering clear options and handling the selected workflow.

Core principle: Verify tests → Present options → Execute choice → Clean up.

Announce at the start:"I am using the Complete Development Branch skill to complete this work."

Process

Step 1: Verify Tests

Before offering options, first verify that tests pass:

# Run project's test suite
npm 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.

If tests pass: Continue to step 2.

Step 2: Determine Base Branch

# Try common base branches
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null

Or ask: "This branch was split off from the main branch - is that correct?"

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?

Do not add explanations - keep options concise.

Step 4: Execute Choice

Option 1: Local Merge

# Switch to base branch
git checkout <base-branch>

# Pull latest
git pull

# Merge feature branch
git merge <feature-branch>

# Verify tests on merged result
<test command>

# If tests pass
git branch -d <feature-branch>

Then: clean up worktree (step 5)

Option 2: Push and Create PR

# Push branch
git push -u origin <feature-branch>

# Create PR
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
<2-3 bullets of what changed>

## Test Plan
- [ ] <verification steps>
EOF
)"

Then: clean up worktree (step 5)

Option 3: Keep As Is

Report: "Keeping branch <name>. Worktree kept at <path>."

**Do not clean up the worktree.**

Option 4: Discard

First confirm:

This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>

Type 'discard' to confirm.

Wait for explicit confirmation.

If confirmed:

git checkout <base-branch>
git branch -D <feature-branch>

Then: clean up worktree (step 5)

Step 5: Clean Up Worktree

For options 1, 2, 4:

Check whether in the worktree:

git worktree list | grep $(git branch --show-current)

If yes:

git worktree remove <worktree-path>

For option 3: Keep the worktree.

Quick Reference

Option Merge Push Keep Worktree Clean Up Branch
1. Local Merge ✓ - - ✓
2. Create PR - ✓ ✓ -
3. Keep As Is - - ✓ -
4. Discard - - - ✓ (force)

Common Mistakes

Skipping Test Verification

  • **Problem:** merging broken code, creating a failing PR
  • Fix: always verify tests before offering options

Open-Ended Questions

  • Problem:"What should I do next?" → ambiguous
  • Fix: present exactly 4 structured options

Automatic Worktree Cleanup

  • Problem: deleting the worktree when it may still be needed (options 2, 3)
  • Fix: only clean up options 1 and 4

Discarding Without Confirmation

  • Problem: accidentally deleting work
  • Fix: require entering "discard" confirmation

Red Flags

Never:

  • Continue with failing tests
  • Merge without verifying result tests
  • Delete work without confirmation
  • Force push without explicit request

Always:

  • Verify tests before offering options
  • Give exactly 4 options
  • Get typed confirmation message for option 4
  • Clean up worktree for options 1 and 4 only

All-in-one

Caller:

  • Subagent-driven development(Step 7) - After all tasks complete
  • Execute plan(Step 5) - After all batches complete

Pair with:

  • using-git-worktrees - Cleanup via worktree created by this skill