mcpField
F
Finishing a Development Branch

Finishing a Development Branch

github.com/obra开发755520 次安装55 周前更新
代码仓库

关于 Finishing a Development Branch

Finishing a Development Branch 是用于收尾开发分支的技能。它先验证测试,再提供四种指定的后续选项,并按所选方案执行合并、创建 Pull Request、保留或丢弃分支及相应的 worktree 清理。

主要功能

  1. 01提供选项前验证测试
  2. 02确定分支的基准分支
  3. 03提供四种指定的收尾选择
  4. 04执行所选分支工作流
  5. 05按规则清理 worktree

适用场景

  1. 01测试通过后收尾功能分支
  2. 02创建 Pull Request 或本地合并
  3. 03保留分支或经确认后丢弃

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/obra/superpowers-skills --skill finishing-a-development-branch

安装后在 Claude Code 中输入/finishing-a-development-branch确认已加载。

详细介绍

完成开发分支

概述

通过提供明确选项并执行所选工作流,引导完成开发工作。

核心原则: 验证测试 → 提供选项 → 执行选择 → 清理。

开始时宣布:“我正在使用「完成开发分支」技能来完成这项工作。”

流程

步骤 1:验证测试

提供选项之前,先验证测试是否通过:

# 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。

步骤 2:确定基础分支
# Try common base branches
git merge-base HEAD main 2>/dev/null || git merge-base HEAD master 2>/dev/null

或者询问:“此分支是从 main 分出的——这样对吗?”

步骤 3:提供选项

请严格提供以下 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?

不要添加说明——选项应简洁明了。

步骤 4:执行选择
选项 1:在本地合并
# Switch to base branch
git checkout <base-branch>

# Pull latest
git pull

# Merge feature branch
git merge <feature-branch>

# Verify tests on merged result
<test command>

# If tests pass
git branch -d <feature-branch>

然后:清理工作树(步骤 5)

选项 2:推送并创建 PR
# 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
)"

然后:清理工作树(步骤 5)

选项 3:保持原样

报告:“保留分支 。工作树保留在 。”

不要清理工作树。

选项 4:丢弃

先确认:

This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Worktree at <path>

Type 'discard' to confirm.

等待确切的确认内容。

如果已确认:

git checkout <base-branch>
git branch -D <feature-branch>

然后:清理工作树(步骤 5)

步骤 5:清理工作树

对于选项 1、2、4:

检查当前是否位于工作树中:

git worktree list | grep $(git branch --show-current)

如果是:

git worktree remove <worktree-path>

**对于选项 3:**保留工作树。

快速参考

选项合并推送保留工作树清理分支
1. 在本地合并✓--✓
2. 创建 PR-✓✓-
3. 保持原样--✓-
4. 丢弃---✓(强制)

常见错误

跳过测试验证

  • **问题:**合并有问题的代码,创建无法通过的 PR
  • **修正:**提供选项前务必验证测试

提出开放式问题

  • 问题:“接下来我该怎么做?”→ 含义不明确
  • **修正:**严格提供 4 个结构化选项

自动清理工作树

  • **问题:**可能还需要工作树时将其移除(选项 2、3)
  • **修正:**仅对选项 1 和 4 进行清理

丢弃前不确认

  • **问题:**意外删除工作
  • **修正:**要求输入“discard”进行确认

危险信号

绝不:

  • 在测试失败时继续
  • 不验证结果上的测试就合并
  • 未经确认就删除工作
  • 未经明确请求就强制推送

务必:

  • 提供选项前验证测试
  • 严格提供 4 个选项
  • 对选项 4 要求输入确认
  • 仅对选项 1 和 4 清理工作树

集成

由以下流程调用:

  • skills/collaboration/subagent-driven-development(步骤 7)
  • skills/collaboration/executing-plans(步骤 5)

配合使用:

  • skills/collaboration/using-git-worktrees(创建工作树)

评论

支持 Markdown