finish-branch
Finalizes a development branch by verifying tests pass, then presenting four completion options (merge locally, draft PR, keep as-is, or discard). Use when implementation is done, a feature branch is ready to ship, work needs to be merged or a PR created, or the user says "finish", "wrap up", "ship it", or "done with this branch". DO NOT TRIGGER when tests are still being written or implementation is incomplete.
- License 许可
- MIT
- 最近更新
- 2026-10-27
- Stars
- ★ 5
- Forks
- 2
01 前言 Front Matter
- name
- finish-branch
- description
- Finalizes a development branch by verifying tests pass, then presenting four completion options (merge locally, draft PR, keep as-is, or discard). Use when implementation is done, a feature branch is ready to ship, work needs to be merged or a PR created, or the user says "finish", "wrap up", "ship it", or "done with this branch". DO NOT TRIGGER when tests are still being written or implementation is incomplete.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md359 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
Finishing a Development Branch
Overview
Guide completion of development work by presenting clear options and handling chosen workflow.
Core principle: Verify tests -> Present options -> Execute choice.
Announce at start: "I'm using the finish-branch skill to complete this work."
The Process
Step 1: Verify Tests
Skip the re-run when verification is already fresh. If build-flow's final Verify stage (or another full-suite run this session) passed AND nothing has changed since — check git status is clean relative to that run and no files were edited after it — do not re-run. Report: "Tests verified by build-flow's final verification; no changes since." and continue to Step 2. Your human partner can always ask for a re-run.
Otherwise, verify tests pass:
# Run project's test suite — read the summary, not the full output
npm test / cargo test / pytest / go test ./... 2>&1 | tail -30
Never read full passing test output into your context — the summary line is the evidence. On failure, extract only the failing cases.
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 to Step 2.
Step 2: Determine Base Branch
Identify the base branch (typically main or master). If uncertain, 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. Commit, push, and create a draft 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
Option 1: Merge Locally
Your human partner should run /commit first to commit their changes.
Staging guidance:
- Do NOT stage
docs/plans/*.md(design docs, implementation plans)
If in a worktree:
# Get the main working tree path
main_tree=$(git worktree list --porcelain | head -1 | sed 's/worktree //')
# Navigate to main working tree
cd "$main_tree"
# Pull latest and merge
git pull --autostash
git merge <feature-branch>
# Verify tests
<test command>
If on a regular branch:
git checkout <base-branch>
git pull --autostash
git merge <feature-branch>
<test command>
git branch -d <feature-branch>
Option 2: Commit, Push, and Create Draft PR
Staging guidance:
- Stage all implementation files (source, tests, configs)
- Do NOT stage
docs/plans/*.md(design docs, implementation plans) - If unclear what to stage, show
git statusand ask your human partner
The user may run /commit themselves to handle staging and committing. If they say "commit staged changes", trust their staging decisions.
If your human partner hasn't committed yet:
# Show what would be staged
git status
# Let user confirm staging, or user runs /commit
After committing:
# Push branch
git push -u origin <feature-branch>
# Create draft PR
# REQUIRED SUB-SKILL: Use kit:create-pr
Invoke kit:create-pr which creates a draft PR by default. If your human partner explicitly requests "ready for review", pass that intent to kit:create-pr.
Option 3: Keep As-Is
Report: "Keeping branch <name>. Worktree preserved at <path>."
Option 4: Discard
Confirm first:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
Type 'discard' to confirm.
Wait for exact confirmation.
If confirmed:
- In a worktree: Use kit:worktree-cleanup to remove the worktree and delete the branch
- On a regular branch:
git checkout <base-branch> git branch -D <feature-branch>
Worktree Cleanup
No automatic worktree cleanup for any option.
After completing the chosen option, note: "When you're ready to clean up the worktree, use kit:worktree-cleanup."
Quick Reference
| Option | Commit | Push | Draft PR | Cleanup Worktree |
|---|---|---|---|---|
| 1. Merge locally | user | - | - | manual (later) |
| 2. Draft PR | user | yes | yes | manual (later) |
| 3. Keep as-is | - | - | - | manual (later) |
| 4. Discard | - | - | - | manual (later) |
Common Mistakes
Skipping test verification
- Problem: Merge broken code, create 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
Staging planning documents
- Problem: Design docs and implementation plans enter git history
- Fix: Never stage
docs/plans/*.md
Auto-cleaning worktree
- Problem: Remove worktree when review feedback may require more work
- Fix: Never auto-cleanup. User triggers kit:worktree-cleanup when ready.
No confirmation for discard
- Problem: Accidentally delete work
- Fix: Require typed "discard" confirmation
Red Flags
Never:
- Proceed with failing tests
- Merge without verifying tests on result
- Delete work without confirmation
- Force-push without explicit request
- Automatically clean up worktrees
- Stage
docs/plans/*.mdfiles
Always:
- Verify tests before offering options (a fresh, unchanged build-flow verification counts — don't re-run for ritual's sake)
- Present exactly 4 options
- Get typed confirmation for Option 4
- Let user control staging and committing
- Create PRs as drafts by default
Integration
Called by:
- build-flow — After your human partner chooses "Finish the branch"
Invokes:
- kit:create-pr — For Option 2 (draft PR creation)
Pairs with:
- kit:worktree-cleanup — User-triggered cleanup after finishing
04 同仓库更多 Skills
writing-docs
Use when creating or editing documentation of any kind, including Markdown, RST, or HTML pages, READMEs, design docs, ADRs, changelogs, docstrings, and comment blocks. Covers document purpose, headings, paragraphs, lists, procedures, notices, cross-references, code samples, placeholders, example data, and word choice for technical writing.
work
Runs the story worker loop in a story-workflow project — claim ready stories, implement each in its own worktree, close through verification gates, repeat until the goal is met or the loop stalls. Use when asked to "work the board", "complete all stories", "work on epic st-XXXX", "pick up the next story", "start a worker", or to resume or continue a story run — and when a loop re-prompt names the next story in a session that started the loop. DO NOT TRIGGER without .agents/shousper-stories/config.json (use stories:setup first), for decomposing a spec into stories (stories:plan), or to stop a run (stories:cancel).
using-stories
Compressed story-workflow rulebook, injected automatically at session start (including after compaction) in projects with .agents/shousper-stories/config.json. Use when unsure of the workflow rules mid-session, when asked "how does the story workflow work here", or for a story CLI quick reference. DO NOT TRIGGER in projects without .agents/shousper-stories/config.json, to set up the workflow (stories:setup), to file stories (stories:plan), or to run the loop (stories:work).
setup
Interactive onboarding that turns a repo into a story-workflow project — merge-mode choice, verification gates with test-runner detection, gitignore wiring, optional project-specific reviewer personas. Use when asked to "set up the story workflow", "adopt stories", "story init", "install the story board", or when stories:plan / stories:work is wanted but .agents/shousper-stories/config.json does not exist yet. DO NOT TRIGGER when .agents/shousper-stories/config.json already exists (use stories:plan to file work, stories:work to execute it), for creating individual stories, or for project scaffolding unrelated to the story workflow.
plan
Decomposes a spec or approved design into epics and stories on the story board — sized, dependency-ordered, gated, human-approved, then filed via the story CLI. Use in a project with .agents/shousper-stories/config.json when there is a design doc (often from kit:brainstorming), spec, requirements file, or feature request to break down; it replaces kit:writing-plans in the workflow chain for story-based projects. Also use for "file stories", "break this into stories", "populate the board". DO NOT TRIGGER in projects without .agents/shousper-stories/config.json (use kit:writing-plans), for executing stories (stories:work), or for filing a single discovered-work story mid-loop (plain story create).
cancel
Stops an active story loop and reports where the board stands. Use when asked to "stop the loop", "cancel the story run", "halt autonomous story work", "kill the worker loop", or when a runaway run must be shut down. DO NOT TRIGGER for closing a single story (that is story done inside stories:work), for deleting or archiving stories, or for removing the story workflow from a project.