jnmetacode avatar

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-code

Installs 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
1jnmetacode avatarusing-git-worktreesjnmetacode/superpowers-zh当需要开始与当前工作区隔离的功能开发,或在执行实现计划之前使用——通过原生工具或 git worktree 回退机制确保隔离工作区存在987skills.sh installs
2github avatarpython-pypi-package-buildergithub/awesome-copilotEnd-to-end skill for building, testing, linting, versioning, and publishing a production-grade Python library to PyPI. Covers all four build backends (setuptool950skills.sh installs
3mindrally avatargit-workflowmindrally/skillsGit conventions and workflow guidelines using Conventional Commits, branching strategies, and best practices for version control850skills.sh installs
4code-yeongyu avatarpre-publish-reviewcode-yeongyu/oh-my-openagentNuclear-grade 16-agent pre-publish release gate. Runs /get-unpublished-changes to detect all changes since last npm release, spawns up to 10 ultrabrain agents f771skills.sh installs
5lingfengqaq avatarwebnovel-reviewlingfengqaq/webnovel-writer使用审查 Agent 评估章节质量,生成报告并写回审查指标。766skills.sh installs
6boshu2 avatarpr-implementboshu2/agentopsImplement a scoped OSS PR.743skills.sh installs