| name | finishing-a-development-branch |
| description | Use when implementation is complete, all tests pass, and you need to decide how to integrate the work |
Finishing a Development Branch
Overview
Guide completion of development work by presenting clear options and handling chosen workflow.
Core principle: Verify tests → Detect environment → Present options → Execute choice → Clean up.
The Process
Step 1: Verify Tests
Run test suite. If tests fail, stop. If pass, continue.
Step 2: Detect Environment
Determine workspace state (normal repo vs worktree vs detached HEAD).
Step 3: Determine Base Branch
git merge-base HEAD main or ask.
Step 4: Present Options
- Merge back to base branch locally
- Push and create a Pull Request
- Keep the branch as-is
- Discard this work
Step 5: Execute Choice
Merge locally: Checkout base, merge, verify tests, cleanup.
Create PR: Push branch, create PR with gh CLI.
Keep as-is: Report branch name and location.
Discard: Confirm first, then cleanup.
Step 6: Cleanup Workspace
Only for Options 1 and 4. Remove worktree and prune.
Red Flags
Never: Proceed with failing tests, delete work without confirmation, force-push without explicit request.