Finishing a Development Branch
Complete development work by presenting clear options and executing the chosen workflow.
WHAT This Skill Does
After implementation is complete, guides you through verifying tests, presenting integration options, and executing the chosen path (merge, PR, keep, or discard).
WHEN To Use
- - Implementation is complete
- All tests pass
- Ready to integrate work into the main branch
KEYWORDS: finish branch, complete branch, merge, PR, done with feature
The Process
Step 1: Verify Tests
CODEBLOCK0
If tests fail: Stop. Cannot proceed until tests pass.
CODEBLOCK1
If tests pass: Continue to Step 2.
Step 2: Determine Base Branch
CODEBLOCK2
Or confirm: "This branch split from main - is that correct?"
Step 3: Present Options
Present exactly these 4 options:
CODEBLOCK3
Step 4: Execute Choice
Option 1: Merge Locally
CODEBLOCK4
Then: Cleanup worktree (Step 5)
Option 2: Push and Create PR
CODEBLOCK5
Then: Cleanup worktree (Step 5)
Option 3: Keep As-Is
Report: "Keeping branch <name>. Worktree preserved at <path>."
Do NOT cleanup worktree.
Option 4: Discard
Confirm first:
CODEBLOCK6
Wait for exact confirmation. If confirmed:
CODEBLOCK7
Then: Cleanup worktree (Step 5)
Step 5: Cleanup Worktree
For Options 1, 2, 4 only:
CODEBLOCK8
For Option 3: Keep worktree.
Quick Reference
| Option | Merge | Push | Keep Worktree | Cleanup Branch |
|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR |
- | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
NEVER
- - Proceed with failing tests
- Merge without verifying tests on the result
- Delete work without typed confirmation ("discard")
- Force-push without explicit request
- Skip presenting all 4 options
- Automatically cleanup worktree for Options 2 or 3
- Ask open-ended "What should I do next?" (use structured options)
Integration
Called by:
- -
subagent-development (after all tasks complete) - INLINECODE3 (after all batches complete)
Pairs with:
- -
git-worktrees - Cleans up worktree created by that skill
技能名称: finishing-branch
详细描述:
完成开发分支
通过呈现清晰的选项并执行所选工作流程来完成开发工作。
该技能的作用
实现完成后,指导你验证测试、呈现集成选项,并执行所选路径(合并、拉取请求、保留或丢弃)。
何时使用
关键词:完成分支、结束分支、合并、拉取请求、功能完成
流程
第1步:验证测试
bash
npm test / cargo test / pytest / go test ./...
如果测试失败: 停止。在测试通过之前无法继续。
测试失败(N个失败)。必须在完成前修复:
[显示失败信息]
如果测试通过: 继续执行第2步。
第2步:确定基础分支
bash
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
或确认:此分支从 main 分支分出 - 是否正确?
第3步:呈现选项
精确呈现以下4个选项:
实现已完成。您想做什么?
- 1. 合并回 <基础分支>(本地)
- 推送并创建拉取请求
- 保持分支不变(稍后处理)
- 丢弃此工作
选择哪个选项?
第4步:执行选择
选项1:本地合并
bash
git checkout <基础分支>
git pull
git merge <功能分支>
<再次运行测试>
git branch -d <功能分支>
然后:清理工作树(第5步)
选项2:推送并创建拉取请求
bash
git push -u origin <功能分支>
gh pr create --title <标题> --body $(cat <
摘要
<2-3条更改要点>
测试计划
EOF
)
然后:清理工作树(第5步)
选项3:保持原样
报告:保留分支 <名称>。工作树保留在 <路径>。
不要清理工作树。
选项4:丢弃
先确认:
这将永久删除:
- - 分支 <名称>
- 所有提交:<提交列表>
- 位于 <路径> 的工作树
输入 discard 确认。
等待精确确认。如果确认:
bash
git checkout <基础分支>
git branch -D <功能分支>
然后:清理工作树(第5步)
第5步:清理工作树
仅适用于选项1、2、4:
bash
检查是否在工作树中
git worktree list | grep $(git branch --show-current)
如果是:
git worktree remove <工作树路径>
对于选项3: 保留工作树。
快速参考
| 选项 | 合并 | 推送 | 保留工作树 | 清理分支 |
|---|
| 1. 本地合并 | ✓ | - | - | ✓ |
| 2. 创建拉取请求 |
- | ✓ | ✓ | - |
| 3. 保持原样 | - | - | ✓ | - |
| 4. 丢弃 | - | - | - | ✓(强制) |
禁止事项
- - 在测试失败时继续
- 未验证结果测试就进行合并
- 未经输入确认(discard)就删除工作
- 未经明确请求就强制推送
- 跳过呈现所有4个选项
- 自动清理选项2或3的工作树
- 提出开放式问题接下来我该做什么?(使用结构化选项)
集成
被调用者:
- - subagent-development(所有任务完成后)
- executing-plans(所有批次完成后)
配对使用:
- - git-worktrees - 清理该技能创建的工作树