finishing-a-development-branch
Featured当实现完成、所有测试通过、需要决定如何集成工作时使用——通过提供合并、PR 或清理等结构化选项来引导开发工作的收尾
AI & Automation 7,264 stars
705 forks Updated 4 days ago MIT
Install
Quality Score: 99/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# 完成开发分支
## 概述
通过提供清晰的选项并执行所选工作流来引导开发工作的收尾。
**核心原则:** 验证测试 → 检测环境 → 展示选项 → 执行选择 → 清理。
**开始时宣布:** "我正在使用 finishing-a-development-branch 技能来完成这项工作。"
## 流程
### 步骤 1:验证测试
**在展示选项之前,验证测试通过:**
```bash
# 运行项目的测试套件
npm test / cargo test / pytest / go test ./...
```
**如果测试失败:**
```
测试失败(<N> 个失败)。必须先修复才能继续:
[显示失败信息]
在测试通过之前无法进行合并/PR。
```
停止。不要继续到步骤 2。
**如果测试通过:** 继续步骤 2。
### 步骤 2:检测环境
**在展示选项之前,先确定工作区状态:**
```bash
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)
```
这决定了展示哪种菜单、以及清理方式:
| 状态 | 菜单 | 清理 |
|------|------|------|
| `GIT_DIR == GIT_COMMON`(普通仓库) | 标准 4 个选项 | 无 worktree 可清理 |
| `GIT_DIR != GIT_COMMON`,命名分支 | 标准 4 个选项 | 按来源判断(见步骤 6) |
| `GIT_DIR != GIT_COMMON`,分离 HEAD | 收敛 3 个选项(无合并) | 无清理(由外部管理) |
### 步骤 3:确定基础分支
```bash
# 尝试常见的基础分支
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
```
或者询问:"这个分支是从 main 分出来的——对吗?"
### 步骤 4:展示选项
**普通仓库和命名分支 worktree —— 准确展示以下 4 个选项:**
```
实现已完成。你想怎么做?
1. 在本地合并回 <base-branch>
2. 推送并创建 Pull Request
3. 保持分支现状(我稍后处理)
4. 丢弃这项工作
选哪个?
```
**分离 HEAD —— 准确展示以下 3 个选项:**
```
实现已完成。你在分离 HEAD 上(由外部管理的工作区)。
1. 作为新分支推送并创建 Pull Request
2. 保持现状(我稍后处理)
3. 丢弃这项工作
选哪个?
```
**不要添加解释** —— 保持选项简洁。
### 步骤 5:执行选择
#### 选项 1:本地合并
```bash
# 切到主仓库根目录,保证 CWD 安全
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
cd "$MAIN_ROOT"
# 先合并 —— 在删除任何东西之前先验证合并成功
git checkout <base-branch>
git pull...
Details
- Author
- jnMetaCode
- Repository
- jnMetaCode/superpowers-zh
- Created
- 4 months ago
- Last Updated
- 4 days ago
- Language
- JavaScript
- License
- MIT
Integrates with
Bundled in these plugins
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Listed
finishing-a-development-branch
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
1 Updated 3 days ago
NafisRayan AI & Automation Listed
finishing-a-development-branch
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
3 Updated today
Ralph-Workflow AI & Automation Solid
finishing-a-development-branch
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup
0 Updated 5 days ago
lhbsaa