From xpowers
Closes a bd epic, verifies tests pass, and presents four integration options (merge locally, create PR, keep branch, discard) then executes the chosen action.
How this skill is triggered — by the user, by Claude, or both
Slash command
/xpowers:finishing-a-development-branchThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
<skill_overview>
<skill_overview> Close bd epic, verify tests pass, present 4 integration options, execute choice, cleanup worktree appropriately. </skill_overview>
<rigidity_level> LOW FREEDOM - Follow the 6-step process exactly. Present exactly 4 options. Never skip test verification. Must confirm before discarding. </rigidity_level>
<quick_reference>
| Step | Action | If Blocked |
|---|---|---|
| 1 | Close bd epic | Tasks still open → STOP |
| 2 | Verify tests pass (test-runner agent) | Tests fail → STOP |
| 3 | Determine base branch | Ask if needed |
| 4 | Present exactly 4 options | Wait for choice |
| 5 | Execute choice | Follow option workflow |
| 6 | Cleanup worktree (options 1,2,4 only) | Option 3 keeps worktree |
Options: 1=Merge locally, 2=PR, 3=Keep as-is, 4=Discard (confirm) </quick_reference>
<when_to_use>
Don't use for:
<the_process>
Announce: "I'm using xpowers:finishing-a-development-branch to complete this work."
Verify all tasks closed:
tm dep tree bd-1 # Show task tree
tm list --status open --parent bd-1 # Check for open tasks
If any tasks still open:
Cannot close epic bd-1: N tasks still open:
- bd-3: Task Name (status: in_progress)
- bd-5: Task Name (status: open)
Complete all tasks before finishing.
STOP. Do not proceed.
If all tasks closed:
tm close bd-1
IMPORTANT: Use xpowers:test-runner agent to avoid context pollution.
Dispatch xpowers:test-runner agent:
Run: cargo test
(or: npm test / pytest / go test ./...)
Agent returns summary + failures only.
If tests fail:
Tests failing (N failures). Must fix before completing:
[Show failures]
Cannot proceed until tests pass.
STOP. Do not proceed.
If tests pass: Continue to Step 3.
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
Or ask: "This branch split from main - is that correct?"
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?
Don't add explanation. Keep concise.
git checkout <base-branch>
git pull
git merge <feature-branch>
# Verify tests on merged result
Dispatch xpowers:test-runner: "Run: <test command>"
# If tests pass
git branch -d <feature-branch>
Then: Step 6 (cleanup worktree)
Get epic info:
tm show bd-1
tm dep tree bd-1
Create PR:
git push -u origin <feature-branch>
gh pr create --title "feat: <epic-name>" --body "$(cat <<'EOF'
## Epic
Closes bd-<N>: <Epic Title>
## Summary
<2-3 bullets from epic implementation>
## Tasks Completed
- bd-2: <Task Name>
- bd-3: <Task Name>
## Test Plan
- [ ] All tests passing
- [ ] <verification steps from epic>
EOF
)"
Then: Step 6 (cleanup worktree)
Report: "Keeping branch . Worktree preserved at ."
Don't cleanup worktree.
Confirm first:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.
Wait for exact "discard" confirmation.
If confirmed:
git checkout <base-branch>
git branch -D <feature-branch>
Then: Step 6 (cleanup worktree)
For Options 1, 2, 4 only:
# Check if in worktree
git worktree list | grep $(git branch --show-current)
# If yes
git worktree remove <worktree-path>
For Option 3: Keep worktree (don't cleanup). </the_process>
Developer skips test verification before presenting options
# Step 1: Epic closed ✓
tm close bd-1
Step 2: SKIPPED test verification
Jump directly to presenting options
"Implementation complete. What would you like to do?
- Merge back to main locally
- Push and create PR
..."
User selects Option 1
git checkout main
git merge feature-branch
Tests fail! Broken code now on main
<why_it_fails>
# After closing epic
tm close bd-1 ✓
# MANDATORY: Verify tests BEFORE presenting options
Dispatch xpowers:test-runner agent: "Run: cargo test"
# Agent reports
"Test suite passed (127 tests, 0 failures, 2.3s)"
# NOW present options
"Implementation complete. What would you like to do?
1. Merge back to main locally
..."
What you gain:
# User selects Option 2: Create PR
git push -u origin feature-auth
gh pr create --title "feat: Add OAuth" --body "..."
Developer immediately cleans up worktree
git worktree remove ../feature-auth-worktree
PR gets feedback: "Please add rate limiting"
User: "Can you address the PR feedback?"
Worktree is gone! Have to recreate it
git worktree add ../feature-auth-worktree feature-auth
Lost local state, uncommitted experiments, etc.
<why_it_fails>
git push -u origin feature-auth
gh pr create --title "feat: Add OAuth" --body "..."
# Report PR created
"Pull request created: https://github.com/user/repo/pull/42
Keeping worktree at ../feature-auth-worktree for PR updates."
# NO worktree cleanup
# User can address PR feedback in same worktree
Cleanup happens later when:
What you gain:
# User says: "Actually, discard this work"
Developer immediately executes
git checkout main
git branch -D feature-experimental
git worktree remove ../feature-experimental-worktree
50 commits deleted
User: "Wait, I meant discard the LAST commit, not the whole branch!"
Too late - work is gone
<why_it_fails>
User: "Discard this work"
"This will permanently delete:
- Branch feature-experimental
- All commits:
* a1b2c3d Add OAuth integration
* d4e5f6g Add rate limiting
* g7h8i9j Update tests
... (47 more commits)
- Worktree at ../feature-experimental-worktree
Type 'discard' to confirm."
# WAIT for exact confirmation
User types: "discard"
# NOW execute
git checkout main
git branch -D feature-experimental
git worktree remove ../feature-experimental-worktree
"Branch feature-experimental deleted."
What you gain:
<option_matrix>
| Option | Merge | Push | Keep Worktree | Cleanup Branch | Cleanup Worktree |
|---|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ | ✓ |
| 2. Create PR | - | ✓ | ✓ | - | - |
| 3. Keep as-is | - | - | ✓ | - | - |
| 4. Discard | - | - | - | ✓ (force) | ✓ |
| </option_matrix> |
<critical_rules>
All of these mean: STOP. Follow the process.
<verification_checklist> Before completing:
Can't check all boxes? Return to process and complete missing steps. </verification_checklist>
**This skill is called by:** - xpowers:review-implementation (final step after approval)Call chain:
xpowers:executing-plans → xpowers:review-implementation → xpowers:finishing-a-development-branch
↓
(if gaps found: STOP)
This skill calls:
CRITICAL: Never read .beads/issues.jsonl directly. Always use bd CLI commands.
When stuck:
npx claudepluginhub dpolishuk/xpowersGuides completion of development work by verifying tests, detecting git context, and presenting structured options for merge, PR, or cleanup. Use when implementation is done and tests pass.
Guides completing a development branch by verifying tests, presenting structured options (merge, PR, keep, discard), and executing the chosen workflow.
Guides completion of development work by verifying tests, presenting structured options (merge locally, push/PR, keep as-is, discard), and executing the chosen workflow.