en un clic
finishing-a-development-branch
当实施完成,所有测试通过,你需要决定如何集成工作时使用 - 通过提供合并、PR 或清理的结构化选项来指导开发工作的完成
Menu
当实施完成,所有测试通过,你需要决定如何集成工作时使用 - 通过提供合并、PR 或清理的结构化选项来指导开发工作的完成
在进行任何创造性工作之前,你必须使用此功能——创造特性、构建组件、添加功能或修改行为。在实施之前探索用户意图、需求和设计。
当面临 2 个以上可以独立工作且没有共享状态或顺序依赖关系的任务时使用
当你有一份书面的实施 plan 要在单独的会话中执行,并带有审查检查点时使用
当完成任务、实施主要功能或在合并之前验证工作是否符合要求时使用
当在当前会话中执行具有独立任务的实施 plans 时使用
当遇到任何 bug、测试失败或意外行为时使用,在提出修复之前
| name | finishing-a-development-branch |
| description | 当实施完成,所有测试通过,你需要决定如何集成工作时使用 - 通过提供合并、PR 或清理的结构化选项来指导开发工作的完成 |
通过提供清晰的选项和处理所选的工作流来指导开发工作的完成。
核心原则: 验证测试 → 检测环境 → 展示选项 → 执行选择 → 清理。
开始时宣布: "I'm using the finishing-a-development-branch skill to complete this work."
在展示选项之前,验证测试通过:
# 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.
停止。不要继续到第二步。
如果测试通过: 继续到第二步。
在展示选项之前确定工作区状态:
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)
这决定了展示哪个菜单以及清理如何工作:
| 状态 | 菜单 | 清理 |
|---|---|---|
GIT_DIR == GIT_COMMON (普通 repo) | 标准 4 个选项 | 无 worktree 需要清理 |
GIT_DIR != GIT_COMMON, 命名分支 | 标准 4 个选项 | 基于来源的 (见第六步) |
GIT_DIR != GIT_COMMON, detached HEAD | 简化 3 个选项 (无 merge) | 无清理 (外部管理) |
# Try common base branches
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null
或者询问: "This branch split from main - is that correct?"
普通 repo 和命名分支 worktree — 确切地展示这 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?
Detached HEAD — 确切地展示这 3 个选项:
Implementation complete. You're on a detached HEAD (externally managed workspace).
1. Push as new branch and create a Pull Request
2. Keep as-is (I'll handle it later)
3. Discard this work
Which option?
不要添加解释 - 保持选项简洁。
# Get main repo root for CWD safety
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
cd "$MAIN_ROOT"
# Merge first — verify success before removing anything
git checkout <base-branch>
git pull
git merge <feature-branch>
# Verify tests on merged result
<test command>
# Only after merge succeeds: cleanup worktree (Step 6), then delete branch
然后: 清理 worktree (第六步),然后删除分支:
git branch -d <feature-branch>
# Push branch
git push -u origin <feature-branch>
# Create PR
gh pr create --title "<title>" --body "$(cat <<'EOF'
## Summary
<2-3 bullets of what changed>
## Test Plan
- [ ] <verification steps>
EOF
)"
不要清理 worktree — 用户需要它来迭代 PR 反馈。
报告: "Keeping branch . Worktree preserved at ."
不要 cleanup worktree。
首先确认:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>
Type 'discard' to confirm.
等待确切的确认。
如果已确认:
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
cd "$MAIN_ROOT"
然后: 清理 worktree (第六步),然后强制删除分支:
git branch -D <feature-branch>
仅在选项 1 和 4 时运行。 选项 2 和 3 总是保留 worktree。
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)
WORKTREE_PATH=$(git rev-parse --show-toplevel)
如果 GIT_DIR == GIT_COMMON: 普通 repo,无 worktree 需要清理。完成。
如果 worktree 路径在 .worktrees/、worktrees/ 或 ~/.config/superpowers/worktrees/ 下: Superpowers 创建了此 worktree — 我们负责清理。
MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
cd "$MAIN_ROOT"
git worktree remove "$WORKTREE_PATH"
git worktree prune # 自修复: 清理任何过时的注册
否则: 宿主环境 (harness) 拥有此工作区。不要移除它。如果你的平台提供了 workspace-exit 工具,使用它。否则,保留工作区不动。
| 选项 | Merge | Push | 保留 Worktree | 清理 Branch |
|---|---|---|---|---|
| 1. Merge locally | ✓ | - | - | ✓ |
| 2. Create PR | - | ✓ | ✓ | - |
| 3. Keep as-is | - | - | ✓ | - |
| 4. Discard | - | - | - | ✓ (force) |
跳过测试验证
开放式问题
为选项 2 清理 worktree
在移除 worktree 之前删除分支
git branch -d 失败,因为 worktree 仍然引用该分支从 worktree 内部运行 git worktree remove
git worktree remove 之前总是 cd 到主 repo root清理 harness 拥有的 worktrees
.worktrees/、worktrees/ 或 ~/.config/superpowers/worktrees/ 下的 worktrees丢弃无确认
绝不 (Never):
git worktree remove总是 (Always):
cd 到主 repo rootgit worktree prune必需的工作流 skills:
被调用方: