Agent skill
branch-completion
Use when implementation is complete and tests pass. Guides completion by presenting structured options for merge, PR, or cleanup.
Install this agent skill to your Project
npx add-skill https://github.com/jagreehal/jagreehal-claude-skills/tree/main/skills/branch-completion
SKILL.md
Branch Completion
Guide completion of development work by verifying, presenting options, and executing cleanup.
The Iron Law
NO COMPLETION WITHOUT TEST VERIFICATION FIRST
Verify tests pass before presenting completion options.
The Process
Step 1: Verify Tests
Before presenting options:
npm test # or 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. Don't proceed to Step 2.
If tests pass: Continue.
Step 2: 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 (handle later)
4. Discard this work
Which option?
Step 3: Execute Choice
Option 1: Merge Locally
git checkout <base-branch>
git pull
git merge <feature-branch>
# Verify tests on merged result
npm test
git branch -d <feature-branch>
Then cleanup worktree (Step 4).
Option 2: Push and Create PR
git push -u origin <feature-branch>
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
- [Changes]
## Test Plan
- [ ] [Verification steps]
EOF
)"
Keep worktree for PR iteration.
Option 3: Keep As-Is
Report: "Keeping branch . Worktree preserved at ."
Don't 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 confirmed:
git checkout <base-branch>
git branch -D <feature-branch>
Then cleanup worktree.
Step 4: Cleanup Worktree
For Options 1, 2, 4 only:
git worktree remove <worktree-path>
For Option 3: Keep worktree.
MUST/SHOULD/NEVER Rules
MUST
- MUST: Verify tests before presenting options
- MUST: Present exactly 4 structured options
- MUST: Get typed confirmation for discard
- MUST: Verify tests again after merge (Option 1)
SHOULD
- SHOULD: Determine base branch automatically
- SHOULD: Include commit summary in discard confirmation
- SHOULD: Report PR URL after creation
NEVER
- NEVER: Proceed with failing tests
- NEVER: Present vague "what should I do?" questions
- NEVER: Delete work without typed confirmation
- NEVER: Force-push without explicit request
Quick Reference
| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
Integration
| Skill | Relationship |
|---|---|
git-worktrees |
Cleans up worktree created there |
verification-before-completion |
Tests must pass first |
implementation-planning |
Completes planned work |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
skill-authoring
Use when creating, editing, or reviewing skills. Covers discovery optimization, structure patterns, testing approaches, and format decisions.
testing-strategy
Test pyramid approach with unit, integration, and load tests. DI enables testability. Use vitest-mock-extended for typed mocks.
api-design
Build production-ready HTTP APIs with clean handlers, consistent error envelopes, health checks, CORS, and operational excellence.
validation-boundary
Validate at the boundary with Zod schemas and branded types. Business functions trust validated input.
resilience
Add retry, timeout, and circuit breaker patterns at the workflow level. Business functions stay clean.
session-continuity
Persistent task workflow with state machine. Every message MUST announce state. Uses .claude/ files for multi-session continuity. Never use TodoWrite. Never auto-advance tasks.
Didn't find tool you were looking for?