关于 exit-strategy
exit-strategy 是用于收尾分支开发工作的技能,会先验证测试,再提供四种处置选项,并按选择执行分支与工作树清理。
主要功能
- 01退出前验证测试
- 02提供四种结构化选项
- 03本地合并或创建拉取请求
- 04丢弃工作前要求确认
- 05工作树清理规则
适用场景
- 01测试通过后收尾功能分支
- 02准备分支并创建拉取请求
- 03保留或丢弃已完成的分支工作
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ kucherenko/ gangsta --skill exit-strategy安装后在 Claude Code 中输入/exit-strategy确认已加载。
详细介绍
退出策略:完成开发分支
概述
每项操作都需要妥善收尾。通过验证、展示选项、执行操作并清理,指导开发工作完成。
核心原则: 验证测试 → 展示选项 → 执行选择 → 清理。
开始时宣布:“正在启动此分支的退出策略。”
流程
步骤 1:验证测试
展示选项前,先验证测试通过:
# Run project's test suite
npm test / cargo test / pytest / go test ./...
如果测试失败:
Tests failing (<N> failures). Must fix before exiting:
[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
或者询问 Don:“此分支是从 main 拆分出来的——这样对吗?”
步骤 3:展示选项
只展示以下 4 个选项:
Implementation complete. What's the exit strategy?
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>
然后:清理 safehouse(步骤 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
)"
然后:向 Don 报告 PR URL。保留 safehouse。
选项 3:保持原样
报告:“保留分支 。safehouse 保留在 。”
不要清理 safehouse。
选项 4:丢弃
先确认:
This will permanently delete:
- Branch <name>
- All commits: <commit-list>
- Safehouse at <path>
Type 'discard' to confirm.
等待 Don 给出准确的确认。
如果已确认:
git checkout <base-branch>
git branch -D <feature-branch>
然后:清理 safehouse(步骤 5)
步骤 5:清理 Safehouse
针对选项 1、2、4:
检查当前是否处于 safehouse(工作树)中:
git worktree list | grep $(git branch --show-current)
如果是:
git worktree remove <worktree-path>
**针对选项 3:**保留 safehouse。
快速参考
| 选项 | 合并 | 推送 | 保留 Safehouse | 清理分支 |
|---|---|---|---|---|
| 1. 在本地合并 | ✓ | - | - | ✓ |
| 2. 创建 PR | - | ✓ | ✓ | - |
| 3. 保持原样 | - | - | ✓ | - |
| 4. 丢弃 | - | - | - | ✓(强制) |
常见错误
跳过测试验证
- **问题:**合并有问题的代码,创建未通过检查的 PR
- **修复:**提供选项前务必验证测试
开放式问题
- 问题:“接下来我该做什么?”→含糊不清
- **修复:**只展示 4 个结构化选项
自动清理 safehouse
- **问题:**safehouse 可能仍有用途,却将其移除(选项 2、3)
- **修复:**仅在选项 1 和 4 中清理
丢弃前未确认
- **问题:**意外删除工作成果
- **修复:**要求 Don 输入“discard”以确认
危险信号
绝不:
- 在测试未通过时继续操作
- 未验证结果中的测试就进行合并
- 未经 Don 确认就删除工作成果
- 未收到明确请求就强制推送
务必:
- 提供选项前验证测试
- 只展示 4 个选项
- 选项 4 必须获得输入确认
- 仅针对选项 1 和 4 清理 safehouse
集成
由以下内容调用:
- Laundering——最终验证后
- 任何完成基于分支的工作的技能
搭配使用:
- gangsta:safehouse-worktrees——清理该技能创建的 safehouse
Omerta 合规性
- 真实守则:提供选项前验证测试
- 可用性守则:向 Don 报告最终状态
评论
支持 Markdown