finishing-a-development-branch

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

完成开发分支

Finish Development Branch

概述

Overview

通过提供清晰的选项并执行所选工作流来引导开发工作的收尾。
核心原则: 验证测试 → 展示选项 → 执行选择 → 清理。
开始时宣布: "我正在使用 finishing-a-development-branch 技能来完成这项工作。"
Guide the conclusion of development work by providing clear options and executing the selected workflow.
Core Principles: Verify Tests → Present Options → Execute Selection → Cleanup.
Announce at start: "I'm using the finishing-a-development-branch skill to wrap up this work."

流程

Process

步骤 1:验证测试

Step 1: Verify Tests

在展示选项之前,验证测试通过:
bash
undefined
Before presenting options, verify that tests pass:
bash
undefined

运行项目的测试套件

运行项目的测试套件

npm test / cargo test / pytest / go test ./...

**如果测试失败:**
测试失败(<N> 个失败)。必须先修复才能继续:
[显示失败信息]
在测试通过之前无法进行合并/PR。

停止。不要继续到步骤 2。

**如果测试通过:** 继续步骤 2。
npm test / cargo test / pytest / go test ./...

**If tests fail:**
Tests failed (<N> failures). Must fix before proceeding:
[Show failure details]
Cannot merge/PR until tests pass.

Stop. Do not proceed to Step 2.

**If tests pass:** Proceed to Step 2.

步骤 2:确定基础分支

Step 2: Identify Base Branch

bash
undefined
bash
undefined

尝试常见的基础分支

尝试常见的基础分支

git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null

或者询问:"这个分支是从 main 分出来的——对吗?"
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null

Or ask: "This branch was created from main — is that correct?"

步骤 3:展示选项

Step 3: Present Options

展示以下 4 个选项:
实现已完成。你想怎么做?

1. 在本地合并回 <base-branch>
2. 推送并创建 Pull Request
3. 保持分支现状(我稍后处理)
4. 丢弃这项工作

选哪个?
不要添加解释 - 保持选项简洁。
Present the following 4 options:
Implementation is 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?
Do not add explanations - keep options concise.

步骤 4:执行选择

Step 4: Execute Selection

选项 1:本地合并

Option 1: Local Merge

bash
undefined
bash
undefined

切换到基础分支

切换到基础分支

git checkout <base-branch>
git checkout <base-branch>

拉取最新代码

拉取最新代码

git pull
git pull

合并功能分支

合并功能分支

git merge <feature-branch>
git merge <feature-branch>

在合并结果上验证测试

在合并结果上验证测试

<test command>
<test command>

如果测试通过

如果测试通过

git branch -d <feature-branch>

然后:清理工作树(步骤 5)
git branch -d <feature-branch>

Then: Clean up worktree (Step 5)

选项 2:推送并创建 PR

Option 2: Push and Create PR

bash
undefined
bash
undefined

推送分支

推送分支

git push -u origin <feature-branch>
git push -u origin <feature-branch>

创建 PR

创建 PR

gh pr create --title "<title>" --body "$(cat <<'EOF'
gh pr create --title "<title>" --body "$(cat <<'EOF'

摘要

Summary

<2-3 条变更要点>
<2-3 key change points>

测试计划

Test Plan

  • <验证步骤> EOF )"

然后:清理工作树(步骤 5)
  • <Verification steps> EOF )"

Then: Clean up worktree (Step 5)

选项 3:保持现状

Option 3: Keep As-Is

报告:"保留分支 <name>。工作树保留在 <path>。"
不要清理工作树。
Report: "Branch <name> is retained. Worktree remains at <path>."
Do not clean up the worktree.

选项 4:丢弃

Option 4: Discard

先确认:
这将永久删除:
- 分支 <name>
- 所有提交:<commit-list>
- 工作树 <path>

输入 'discard' 确认。
等待精确的确认。
确认后:
bash
git checkout <base-branch>
git branch -D <feature-branch>
然后:清理工作树(步骤 5)
Confirm first:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree <path>

Enter 'discard' to confirm.
Wait for exact confirmation.
After confirmation:
bash
git checkout <base-branch>
git branch -D <feature-branch>
Then: Clean up worktree (Step 5)

步骤 5:清理工作树

Step 5: Clean Up Worktree

对于选项 1、2、4:
检查是否在工作树中:
bash
git worktree list | grep $(git branch --show-current)
如果是:
bash
git worktree remove <worktree-path>
对于选项 3: 保留工作树。
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 the worktree.

快速参考

Quick Reference

选项合并推送保留工作树清理分支
1. 本地合并--
2. 创建 PR--
3. 保持现状---
4. 丢弃---✓(强制)
OptionMergePushKeep WorktreeClean Up Branch
1. Local Merge--
2. Create PR--
3. Keep As-Is---
4. Discard---✓ (forced)

常见错误

Common Mistakes

跳过测试验证
  • 问题: 合并损坏的代码、创建失败的 PR
  • 修复: 在提供选项前始终验证测试
开放式问题
  • 问题: "接下来该做什么?" → 含糊不清
  • 修复: 准确展示 4 个结构化选项
自动清理工作树
  • 问题: 在可能还需要工作树时就删除了(选项 2、3)
  • 修复: 只在选项 1 和 4 时清理
丢弃时不确认
  • 问题: 意外删除工作成果
  • 修复: 要求输入 "discard" 确认
Skip Test Verification
  • Problem: Merge broken code, create failing PRs
  • Fix: Always verify tests before presenting options
Open-Ended Questions
  • Problem: "What to do next?" → Ambiguity
  • Fix: Precisely present the 4 structured options
Auto-Clean Worktree
  • Problem: Delete worktree when it might still be needed (Options 2, 3)
  • Fix: Only clean for Options 1 and 4
Discard Without Confirmation
  • Problem: Accidentally delete work results
  • Fix: Require input of "discard" for confirmation
Red Lines
Never:
  • Proceed when tests fail
  • Merge without verifying test results
  • Delete work results without confirmation
  • Force push without explicit request
Always:
  • Verify tests before presenting options
  • Precisely present the 4 options
  • Require confirmation input for Option 4
  • Only clean worktree for Options 1 and 4

红线

Integration

绝不:
  • 在测试失败时继续
  • 合并前不验证测试结果
  • 不确认就删除工作成果
  • 未经明确请求就强制推送
始终:
  • 在提供选项前验证测试
  • 准确展示 4 个选项
  • 选项 4 要求输入确认
  • 只在选项 1 和 4 时清理工作树
Called by the following skills:
  • subagent-driven-development (Step 7) - After all tasks are completed
  • executing-plans (Step 5) - After all batches are completed
Used with:
  • using-git-worktrees - Clean up worktrees created by this skill

集成

被以下技能调用:
  • subagent-driven-development(步骤 7)- 所有任务完成后
  • executing-plans(步骤 5)- 所有批次完成后
配合使用:
  • using-git-worktrees - 清理由该技能创建的工作树