finishing-a-development-branchlisted
Install: claude install-skill shumingyang-opencode/superpowers-zh-tw
# 完成開發分支
## 總覽
**核心原則:** 驗證測試 → 偵測環境 → 呈現選項 → 執行選擇 → 清理。
**開始時宣告:** 「我正使用 finishing-a-development-branch 技能來完成這份工作。」
## 第 1 步:驗證測試
執行專案的完整測試套件(`npm test` / `cargo test` / `pytest` / `go test ./...`)。
**如果測試失敗**,回報失敗並停止 —— 選單要在測試全綠之後才會出現:
```
Tests failing (<N> failures). Must fix before completing:
[Show failures]
```
**如果測試通過:** 繼續到第 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)
# Capture now, while still inside the workspace — Step 5 changes directory
# before cleanup (Step 6) needs this value
WORKTREE_PATH=$(git rev-parse --show-toplevel)
```
這決定要顯示哪個選單以及如何清理:
| 狀態 | 選單 | 清理 |
|-------|------|---------|
| `GIT_DIR == GIT_COMMON`(一般 repo) | 標準 3 個選項 | 沒有 worktree 需要清理 |
| `GIT_DIR != GIT_COMMON`,具名分支 | 標準 3 個選項 | 依來源決定(見第 6 步) |
| `GIT_DIR != GIT_COMMON`,detached HEAD | 縮減為 2 個選項(無合併) | 由外部管理 —— 保留原位 |
## 第 3 步:決定基礎分支
基礎分支是這份工作從中分支出來的來源 —— 通常在計畫、對話或分支的上游中提及。如果尚未得知,請詢問:「這個分支是從 <你的最佳猜測> 分出來的 - 正確嗎?」合併前先確認:合併到錯誤的基礎分支要復原的成本很高。
## 第 4 步:呈現選項
**一般 repo 與具名分支 worktree —— 呈現恰好這 3 個選項:**
```
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)
Which option?
```
**Detached HEAD —— 呈現恰好這 2 個選項:**
```
Implementation complete. You're on a detached HEAD (externally managed workspace).
1. Push as new branch and create a Pull Requ