Agent skill

finishing-a-development-branch

Use when implementation is complete, tests pass, and you need to decide the integration path. Triggers: 'done with this branch', 'ready to merge', 'ship it', 'wrap this up', 'how should I integrate this', 'what next after implementation'. NOT for: PR creation mechanics (use creating-issues-and-pull-requests).

Stars 5
Forks 2

Install this agent skill to your Project

npx add-skill https://github.com/axiomantic/spellbook/tree/main/skills/finishing-a-development-branch

SKILL.md

Finishing a Development Branch

Announce: "Using finishing-a-development-branch skill to complete this work."

Invariant Principles

  1. Tests Gate Everything - Never present options until tests pass. Never merge without verifying tests on merged result.
  2. Structured Choice Over Open Questions - Present exactly 4 options, never "what should I do?"
  3. Destruction Requires Proof - Option 4 (Discard) demands typed "discard" confirmation. No shortcuts.
  4. Worktree Lifecycle Matches Work State - Cleanup only for Options 1 (merged) and 4 (discarded). Keep for Options 2 and 3.

Inputs

Input Required Description
Passing test suite Yes Tests must pass before this skill can proceed
Feature branch Yes Current branch with completed implementation
Base branch No Branch to merge into (auto-detected if unset)
post_impl setting No Autonomous mode directive (auto_pr, offer_options, stop)

Outputs

Output Type Description
Integration result Action Merge, PR, preserved branch, or discarded branch
PR URL Inline GitHub PR URL (Option 2 only)
Worktree state State Removed (Options 1, 4) or preserved (Options 2, 3)

Autonomous Mode

Check context for autonomous mode indicators: "Mode: AUTONOMOUS", "autonomous mode", or post_impl preference.

post_impl value Behavior
auto_pr Skip Step 3, execute Option 2 directly
offer_options Present options normally
stop Skip Step 3, report completion without action
(unset in autonomous) Default to Option 2. Log: "Autonomous mode: defaulting to PR creation"

Branch-Relative Documentation

Required behavior:

  • Derive all changelog/PR/commit content from the merge base diff at time of writing.
  • When HEAD changes (new commits, rebases, amends), re-evaluate and actively delete stale entries. Never accumulate entries session-by-session.
  • Code comments describe the present. Git describes the past. No "changed from X to Y", "previously did Z", "refactored from old approach", "CRITICAL FIX: now does X instead of Y".
  • Test: "Does this comment make sense to someone reading the code for the first time, with no knowledge of prior implementation?" If no, delete it.

The rare exception: A comment may reference external historical facts that explain non-obvious constraints (e.g., "SQLite < 3.35 doesn't support RETURNING"). Reframe as a present-tense constraint, not a change narrative.


The Process

Step 1: Verify Tests

bash
# 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 proceed to Step 2.

If tests pass: Continue to Step 2.

Step 2: Determine Base Branch

bash
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null

If the command fails or is ambiguous, ask: "This branch split from main - 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?

Don't add explanation - keep options concise.

Step 4: Execute Choice

Dispatch subagent with command: finish-branch-execute

Provide context: chosen option number, feature branch name, base branch name, worktree path (if applicable).

Step 5: Cleanup Worktree

Dispatch subagent with command: finish-branch-cleanup

Provide context: chosen option number, worktree path. Note: Option 3 skips cleanup entirely.


Quick Reference

Option Merge Push Keep Worktree Cleanup Branch
1. Merge locally Yes - - Yes
2. Create PR - Yes Yes -
3. Keep as-is - - Yes -
4. Discard - - - Yes (force)

Anti-Patterns


Self-Check

IF ANY unchecked: STOP and fix.


Integration

Called by:

  • executing-plans (Step 5) - After all batches complete
  • executing-plans --mode subagent (Step 7) - After all tasks complete in subagent mode

Pairs with:

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

<FINAL_EMPHASIS> You are a Release Engineer. Clean integrations that never break main and never lose work without confirmation are your entire reputation. A test-gated, confirmation-gated, option-structured handoff is the only acceptable delivery. Anything less is negligence. </FINAL_EMPHASIS>

Expand your agent's capabilities with these related and highly-rated skills.

axiomantic/spellbook

spellbook-auditing

Meta-audit skill for spellbook development. Spawns parallel subagents to factcheck docs, optimize instructions, find token savings, and identify MCP candidates. Produces actionable report.

5 2
Explore
axiomantic/spellbook

documentation-updates

Use after modifying library skills, library commands, or agents to ensure CHANGELOG, README, and docs are updated

5 2
Explore
axiomantic/spellbook

project-encyclopedia

[DEPRECATED] Use project-level AGENTS.md files instead. Previously used for first-session codebase onboarding and persistent glossary creation.

5 2
Explore
axiomantic/spellbook

reviewing-impl-plans

Use when reviewing implementation plans before execution. Triggers: 'is this plan solid', 'review the plan', 'check before I start building', 'anything missing from this plan', 'will this plan work', 'audit the implementation plan'. NOT for: reviewing design documents (use reviewing-design-docs) or creating plans (use writing-plans).

5 2
Explore
axiomantic/spellbook

session-resume

Session resume protocol and session repairs handling. Loaded when spellbook_session_init returns resume_available: true, or when session_init returns a repairs array. Triggers: 'resume', 'continue', 'where were we', session resume, session repairs.

5 2
Explore
axiomantic/spellbook

brainstorming

Use when exploring design approaches, generating ideas, or making architectural decisions. Triggers: 'explore options', 'what are the tradeoffs', 'how should I approach', 'let's think through', 'sketch out an approach', 'I need ideas for', 'how would you structure', 'what are my options'. Also invoked by develop when design decisions are needed.

5 2
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results