finishing-a-development-branch
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese完成開發分支
Complete Development Branch
概述
Overview
通過提供清晰的選項和處理選定的工作流程來指導開發工作的完成。
核心原則: 驗證測試→呈現選項→執行選擇→清理。
開始時宣佈:“我正在使用完成開發分支技能來完成這項工作。”
Guides the completion of development work by providing clear options and handling the selected workflow.
Core Principles: Verify Tests → Present Options → Execute Selection → Cleanup.
Announce at start: "I am using the Complete Development Branch skill to finish this work."
流程
Process
第 1 步:驗證測試
Step 1: Verify Tests
在提供選項之前,請先驗證測試是否通過:
bash
undefinedVerify tests pass before offering options:
bash
undefinedRun project's test suite
Run project's test suite
npm test / cargo test / pytest / go test ./...
**如果測試失敗:**Tests failing (<N> failures). Must fix before completing:
[Show failures]
Cannot proceed with merge/PR until tests pass.
停止。不要繼續執行步驟 2。
**如果測試通過:** 繼續執行步驟 2。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. Do not proceed to Step 2.
**If tests pass:** Proceed to Step 2.步驟2:確定基礎分支
Step 2: Identify Base Branch
bash
undefinedbash
undefinedTry common base branches
Try common base branches
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
或者問:“這個分支從主分支中分離出來 - 這是正確的嗎?”git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
Alternatively ask: "This branch was branched off <base-branch> - is that correct?"第 3 步:提出選項
Step 3: Present Options
準確呈現這 4 個選項:
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?不要加入解釋 - 保持選項簡潔。
Present these 4 options exactly:
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?Do NOT add explanations - keep options concise.
第四步:執行選擇
Step 4: Execute Selection
選項 1:本地合併
Option 1: Merge Locally
bash
undefinedbash
undefinedSwitch to base branch
Switch to base branch
git checkout <base-branch>
git checkout <base-branch>
Pull latest
Pull latest
git pull
git pull
Merge feature branch
Merge feature branch
git merge <feature-branch>
git merge <feature-branch>
Verify tests on merged result
Verify tests on merged result
<test command>
<test command>
If tests pass
If tests pass
git branch -d <feature-branch>
然後:清理工作樹(步驟 5)git branch -d <feature-branch>
Then: Clean up worktree (Step 5)選項2:全民並建立PR
Option 2: Push and Create Pull Request
bash
undefinedbash
undefinedPush branch
Push branch
git push -u origin <feature-branch>
git push -u origin <feature-branch>
Create PR
Create PR
gh pr create --title "<title>" --body "$(cat <<'EOF'
gh pr create --title "<title>" --body "$(cat <<'EOF'
Summary
Summary
<2-3 bullets of what changed>
<2-3 bullets of what changed>
Test Plan
Test Plan
- <verification steps> EOF )"
然後:清理工作樹(步驟 5)- <verification steps> EOF )"
Then: Clean up worktree (Step 5)選項 3:保持原樣
Option 3: Keep As-Is
報告:“保留分支 <名稱>。工作樹保留在 <路徑>。”
**不要清理工作樹。 **
Report: "Branch <name> retained. Worktree remains at <path>."
Do NOT clean up worktree.
選項 4:丟棄
Option 4: Discard
先確認:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.等待具體確認。
如果確認:
bash
git checkout <base-branch>
git branch -D <feature-branch>然後:清理工作樹(步驟 5)
First confirm:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.Wait for explicit confirmation.
If confirmed:
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 worktree.
快速參考
Quick Reference
| 選項 | 合併 | 推 | 保留工作樹 | 清理分行 |
|---|---|---|---|---|
| 1.本地合併 | ✓ | - | - | ✓ |
| 2.建立公關 | - | ✓ | ✓ | - |
| 3. 保持原樣 | - | - | ✓ | - |
| 4. 丟棄 | - | - | - | ✓(力) |
| Option | Merge | Push | Keep Worktree | Clean Up Branch |
|---|---|---|---|---|
| 1. Merge Locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep As-Is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
常見錯誤
Common Mistakes
跳過測試驗證
- **問題:**合併損壞的碼,建立失敗的PR
- 修復: 在提供選項之前始終驗證測試
開放式問題
- 問題:“接下來我應該做什麼?” → 模棱兩可
- 修復: 準確呈現 4 個結構化選項
自動工作樹清理
- 問題: 在可能需要時刪除工作樹(選項 2、3)
- 修復: 僅清理選項 1 和 4
沒有確認丟棄
- 問題: 意外刪除工作
- 修復: 需要輸入「丟棄」確認
Skipping Test Verification
- Problem: Merging broken code, creating failing PRs
- 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: Deleting worktree when it might be needed (Options 2, 3)
- Fix: Only clean up for Options 1 and 4
No Confirmation for Discard
- Problem: Accidentally deleting work
- Fix: Require 'discard' input confirmation
危險信號
Red Flags
絕不:
- 繼續失敗的測試
- 合併而不驗證結果測試
- 刪除作品而不確認
- 沒有明確請求的強制推送
總是:
- 在提供選項之前驗證測試
- 正好給出 4 個選項
- 取得選項 4 的鍵入確認訊息
- 僅清理選項 1 和 4 的工作樹
Never:
- Proceed with failing tests
- Merge without verifying post-merge tests
- Delete work without confirmation
- Force push without explicit request
Always:
- Verify tests before offering options
- Give exactly 4 options
- Get typed confirmation for Option 4
- Only clean up worktrees for Options 1 and 4
一體化
Integration
調用者:
- 子代理驅動開發(第 7 步)- 所有任務完成後
- 執行計劃(步驟 5)- 所有批次完成後
搭配:
- using-git-worktrees - 透過此技能創建工作樹進行清理
Callers:
- Sub-Agent Driven Development (Step 7) - After all tasks are complete
- Execute Plan (Step 5) - After all batches are complete
Works With:
- using-git-worktrees - Worktrees created via this skill are cleaned up