
Finishing A Development Branch
Handles the endgame when you've finished coding and tests pass. Detects whether you're in a regular repo or worktree, verifies tests actually pass, then gives you four structured options: merge locally, push and create a PR, leave it alone, or discard the work. The thoughtful part is how it manages worktree cleanup based on who created it, only removing worktrees it knows came from Superpowers tooling while leaving harness-managed ones intact. It also refuses to continue if tests fail and requires explicit confirmation before discarding work. Gets called automatically by subagent-driven-development and executing-plans when all tasks complete, but you can invoke it directly when you're ready to finish a branch.
- skills.sh installs
- 993
- GitHub stars
- 8.5K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add jnmetacode/superpowers-zh --skill finishing-a-development-branch --agent claude-codeInstalls into .claude/skills of the current project.
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(由外部管理的工作区)。
Sponsors
Details
- Repository
- github.com/jnmetacode/superpowers-zh
- Category
- Git & Pull Requests
- First seen
- Jun 3, 2026
More from jnmetacode/superpowers-zh
All 20- Using Git Worktrees987
- Chinese Git Workflow979
- Dispatching Parallel Agents970
- Writing Skills967
- Mcp Builder963
- Workflow Runner952
- Using Superpowers1.2K
- Chinese Documentation1.2K
- Brainstorming1.2K
- Systematic Debugging1.2K
- Receiving Code Review1.1K
- Verification Before Completion1.1K
- Writing Plans1.1K
- Test Driven Development1.1K
- Chinese Code Review1.1K
- Chinese Commit Conventions1K
- Subagent Driven Development1K
- Executing Plans1K
- Requesting Code Review1K