Skip to content
jnmetacode avatar

Finishing A Development Branch

Finish a development branch by verifying tests, choosing merge, PR, or keep, and guarding discards.

CCM score
75 of 100
skills.sh installs
1K
GitHub stars
8.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the closing workflow: test verification, environment detection, base-branch confirmation, option menu, execution, and worktree cleanup
  • Offers 3 options for normal repos and named-branch worktrees, or 2 for detached HEAD, and never merges or discards without explicit approval
  • Enforces an exact discard confirmation word and blocks --force removal when a worktree holds uncommitted files
  • Designed for agent-driven development sessions where a human partner decides how finished work gets integrated

Install

$ npx -y skills add jnmetacode/superpowers-zh --skill finishing-a-development-branch -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

收尾一个开发分支

概述

核心原则: 验证测试 → 检测环境 → 展示选项 → 执行选择 → 清理。

开始时宣告: "我正在使用 finishing-a-development-branch 技能来收尾这份工作。"

步骤 1:验证测试

运行项目的完整测试套件(npm test / cargo test / pytest / go test ./...)。

如果测试失败,报告失败并停下——菜单是在测试全绿之后才出现的:

测试失败(<N> 个)。完成之前必须先修:

[展示失败详情]

如果测试通过: 继续步骤 2。

步骤 2:检测环境

GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
# 现在就捕获 —— 此刻还在工作区里面。步骤 5 会切换目录,
# 而清理(步骤 6)需要这个值
WORKTREE_PATH=$(git rev-parse --show-toplevel)

这决定了展示哪种菜单、以及清理方式:

状态菜单清理
GIT_DIR == GIT_COMMON(普通仓库)标准 3 个选项无 worktree 可清理
GIT_DIR != GIT_COMMON,命名分支标准 3 个选项按来源判断(见步骤 6)
GIT_DIR != GIT_COMMON,分离 HEAD收敛为 2 个选项(不含合并)由外部管理——原地别动

步骤 3:确定基础分支

基础分支就是这份工作从哪儿分出来的那个——通常在计划里、对话里,或者分支的 upstream 里已经写明了。如果还不知道,就问:"这个分支是从 <你的最佳猜测> 分出来的,对吗?"合并之前先确认:合并到错误的基础分支,代价很高。

步骤 4:展示选项

普通仓库和命名分支 worktree——精确展示这 3 个选项:

实现已完成。你想怎么做?

1. 本地合并回 <base-branch>
2. 推送并创建 Pull Request
3. 保留分支不动(我稍后自己处理)

选哪个?

分离 HEAD——精确展示这 2 个选项:

实现已完成。你当前处于分离 HEAD(由外部管理的工作区)。

Details

Repository
github.com/jnmetacode/superpowers-zh
Category
Git & Releases
First seen
Jun 3, 2026

Questions

What does the finishing-a-development-branch skill do?

finishing-a-development-branch guides the wrap-up of a development branch once implementation is done and all tests pass. It runs the full test suite, detects the git environment, and presents structured options: merge locally, push and create a pull request, or keep the branch as it is. It then carries out the choice you make and cleans up the worktree when appropriate.

How do I install the finishing-a-development-branch skill?

Run npx -y skills add jnmetacode/superpowers-zh --skill finishing-a-development-branch -y in your project to install it. Once installed, finishing-a-development-branch lets your agent close out finished work with a tested merge, a pull request, or a deliberate hold on the branch.

When should I use finishing-a-development-branch instead of merging by hand?

Use finishing-a-development-branch when implementation is complete and the tests pass, and you need to decide how to integrate the work. The skill makes the agent stop and show the options rather than merging on its own, and it verifies tests on the merged result before any deletion. It also refuses to discard work unless you explicitly confirm by typing discard.

Does finishing-a-development-branch handle git worktrees?

Yes, finishing-a-development-branch detects whether you are in a normal repository, a named-branch worktree, or a detached HEAD, and adapts the menu to match. It removes worktrees only under .worktrees/ or worktrees/ and never force-deletes files that exist only in a worktree. Pull request worktrees are kept so feedback can be addressed there.

Which skills in the Git & Releases category are similar to finishing-a-development-branch?

finishing-a-development-branch sits in the Git & Releases category, alongside triage, git-guardrails-claude-code, setup-pre-commit, caveman-commit and pr. Where those cover commits and reviews, finishing-a-development-branch focuses on the final integration step of a feature branch.

More from jnmetacode/superpowers-zh

All 20

Similar to Finishing A Development Branch

More Git & Releases