branch-finalization
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFinishing 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 → Clean up.
Announce at start: "I'm using the finishing-a-development-branch skill to complete this work."
通过提供清晰的选项并处理所选工作流,指导完成开发工作。
核心原则: 验证测试 → 提供选项 → 执行选择 → 清理。
开始时告知: "我正在使用finishing-a-development-branch技能来完成这项工作。"
The Process
流程
Step 1: Verify Tests
步骤1:验证测试
Before presenting options, verify tests pass:
bash
undefined在提供选项之前,先验证测试是否通过:
bash
undefinedRun project's test suite
运行项目测试套件
npm test / cargo test / pytest / go test ./...
**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.npm test / cargo test / pytest / go test ./...
**如果测试失败:**测试失败(<N>个失败项)。完成前必须修复:
[显示失败内容]
在测试通过前无法继续合并/PR操作。
停止操作,不要进入步骤2。
**如果测试通过:** 继续步骤2。Step 2: Determine Base Branch
步骤2:确定基准分支
bash
undefinedbash
undefinedTry common base branches
尝试常见的基准分支
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
Or ask: "This branch split from main - is that correct?"git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
或者询问:"此分支从main分支拆分而来 - 是否正确?"Step 3: Present Options
步骤3:提供选项
Present exactly these 4 options:
Implementation complete. What would you like to do?
1. Merge back to <base-branch> locally
2. Push and create a 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.
精确提供以下4个选项:
开发完成。您想要执行什么操作?
1. 本地合并回<base-branch>
2. 推送并创建Pull Request
3. 保留分支现状(我稍后处理)
4. 丢弃此工作内容
请选择选项?不要添加解释 - 保持选项简洁。
Step 4: Execute Choice
步骤4:执行选择
Option 1: Merge Locally
选项1:本地合并
bash
undefinedbash
undefinedSwitch to base branch
切换到基准分支
git checkout <base-branch>
git checkout <base-branch>
Pull latest
拉取最新代码
git pull
git pull
Merge feature branch
合并功能分支
git merge <feature-branch>
git merge <feature-branch>
Verify tests on merged result
验证合并后的测试结果
<test command>
<test command>
If tests pass
如果测试通过
git branch -d <feature-branch>
Then: Cleanup worktree (Step 5)git branch -d <feature-branch>
然后:清理工作区(步骤5)Option 2: Push and Create PR
选项2:推送并创建PR
bash
undefinedbash
undefinedPush branch
推送分支
git push -u origin <feature-branch>
git push -u origin <feature-branch>
Create PR
创建PR
gh pr create --title "<title>" --body "$(cat <<'EOF'
gh pr create --title "<title>" --body "$(cat <<'EOF'
Summary
摘要
<2-3 bullets of what changed>
<2-3个要点说明变更内容>
Test Plan
测试计划
- <verification steps> EOF )"
Then: Cleanup worktree (Step 5)- <验证步骤> EOF )"
然后:清理工作区(步骤5)Option 3: Keep As-Is
选项3:保留现状
Report: "Keeping branch <name>. Worktree preserved at <path>."
Don't cleanup worktree.
告知:"保留分支<name>。工作区已保留在<path>路径下。"
不要清理工作区。
Option 4: Discard
选项4:丢弃
Confirm first:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.Wait for exact confirmation.
If confirmed:
bash
git checkout <base-branch>
git branch -D <feature-branch>Then: Cleanup worktree (Step 5)
先确认:
此操作将永久删除:
- 分支<name>
- 所有提交:<commit-list>
- <path>路径下的工作区
请输入'discard'确认。等待精确的确认指令。
如果确认:
bash
git checkout <base-branch>
git branch -D <feature-branch>然后:清理工作区(步骤5)
Step 5: Cleanup Worktree
步骤5:清理工作区
For Options 1, 2, 4:
Check if in worktree:
bash
git worktree list | grep $(git branch --show-current)If yes:
bash
git worktree remove <worktree-path>For Option 3: Keep worktree.
针对选项1、2、4:
检查是否在工作区中:
bash
git worktree list | grep $(git branch --show-current)如果存在:
bash
git worktree remove <worktree-path>针对选项3: 保留工作区。
Quick Reference
快速参考
| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
| 选项 | 合并 | 推送 | 保留工作区 | 清理分支 |
|---|---|---|---|---|
| 1. 本地合并 | ✓ | - | - | ✓ |
| 2. 创建PR | - | ✓ | ✓ | - |
| 3. 保留现状 | - | - | ✓ | - |
| 4. 丢弃 | - | - | - | ✓ (强制) |
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
Automatic worktree cleanup
- Problem: Remove worktree when might need it (Option 2, 3)
- Fix: Only cleanup for Options 1 and 4
No confirmation for discard
- Problem: Accidentally delete work
- Fix: Require typed "discard" confirmation
跳过测试验证
- 问题: 合并有问题的代码,创建失败的PR
- 解决方法: 在提供选项前始终验证测试
开放式问题
- 问题: "我接下来应该做什么?" → 表述模糊
- 解决方法: 精确提供4个结构化选项
自动清理工作区
- 问题: 在可能需要工作区时将其删除(选项2、3)
- 解决方法: 仅针对选项1和4进行清理
丢弃时未确认
- 问题: 意外删除工作内容
- 解决方法: 要求输入'discard'进行确认
Red Flags
注意事项
Never:
- Proceed with failing tests
- Merge without verifying tests on result
- Delete work without confirmation
- Force-push without explicit request
Always:
- Verify tests before offering options
- Present exactly 4 options
- Get typed confirmation for Option 4
- Clean up worktree for Options 1 & 4 only
绝对不要:
- 测试失败时继续操作
- 未验证合并结果的测试就进行合并
- 未确认就删除工作内容
- 未明确请求就强制推送
始终要:
- 在提供选项前验证测试
- 精确提供4个选项
- 针对选项4获取输入确认
- 仅针对选项1和4清理工作区
Integration
集成
Called by:
- subagent-driven-development (Step 7) - After all tasks complete
- executing-plans (Step 5) - After all batches complete
Pairs with:
- using-git-worktrees - Cleans up worktree created by that skill
调用者:
- subagent-driven-development(步骤7)- 所有任务完成后
- executing-plans(步骤5)- 所有批次完成后
搭配使用:
- using-git-worktrees - 清理由该技能创建的工作区