skills/finishing-a-development-branch/SKILL.md
开发工作完成后的收尾流程,提供合并/PR/丢弃三种上下文感知选项。触发:所有测试通过、需要决定如何集成工作成果。由 subagent-driven-development 或 executing-plans 在最后阶段自动调用。测试未通过时不得继续;分支名未知时暂停询问。
npx skillsauth add Chikage0o0/opencode finishing-a-development-branchInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
通过呈现清晰的选项并处理所选的工作流,指导完成开发工作。
核心原则: 验证测试 → 确定分支 → 提供上下文感知选项 → 执行选择。
开始时声明: "我正在使用 finishing-a-development-branch 技能来完成这项工作。"
在提供选项之前,验证测试是否通过:
# 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。
current_branch=$(git branch --show-current)
if [ -z "$current_branch" ]; then
# Detached HEAD or unknown current branch
# Stop and ask the user which branch should be treated as current
fi
if [ "$current_branch" = "main" ] || [ "$current_branch" = "master" ]; then
base_branch="$current_branch"
elif git show-ref --verify --quiet refs/heads/main; then
base_branch="main"
elif git show-ref --verify --quiet refs/heads/master; then
base_branch="master"
else
# Neither main nor master exists
# Stop and ask the user which branch should be treated as base
fi
规则:
current_branch 是 main 或 master,设置 base_branch="$current_branch"。refs/heads/main 存在,设置 base_branch="main"。refs/heads/master 存在,设置 base_branch="master"。如果 current_branch != base_branch,提供:
Implementation complete. What would you like to do?
1. Merge back to $base_branch locally
2. Push current branch and create a Pull Request
3. Keep the current branch as-is
4. Discard this work
Which option?
如果 current_branch == base_branch,不提供合并选项。提供:
Implementation complete on the base branch. No merge is needed.
1. Keep the current branch as-is
2. Discard this work
Which option?
仅在用户选择 Merge back to $base_branch locally 或 Push current branch and create a Pull Request 后运行此步骤。对于 Keep the current branch as-is 或 Discard this work 不要归档。
仅归档当前工作明确标识的文档:
active/ 目录中的所有文件docs/specs/active/ 移动到 docs/specs/completed/,将当前计划从 docs/plans/active/ 移动到 docs/plans/completed/,然后暂存这些路径变更,并使用 git-commit 在当前分支上创建归档提交,再继续# Example for explicitly identified files only
mkdir -p docs/specs/completed docs/plans/completed
mv "<current-spec-path>" "docs/specs/completed/<spec-filename>"
mv "<current-plan-path>" "docs/plans/completed/<plan-filename>"
git add "<current-spec-path>" "docs/specs/completed/<spec-filename>" "<current-plan-path>" "docs/plans/completed/<plan-filename>"
# Then create the archive commit with the git-commit skill before continuing
仅在 current_branch != base_branch 时可用。
在运行合并命令之前,按此顺序推导 merge_message:
在 current_branch 上完成步骤 3.5 后:
# Switch to base branch
git checkout "$base_branch"
# Pull latest
git pull
# Merge current branch with an explicit merge commit message
git merge --no-ff -m "$merge_message" "$current_branch"
# Verify tests on merged result
npm test / cargo test / pytest / go test ./...
# If tests pass
git branch -d "$current_branch"
如果合并后测试失败,停止并修复后再继续。
仅在 current_branch != base_branch 时可用。
在 current_branch 上完成步骤 3.5 后:
# Push branch
git push -u origin "$current_branch"
# Create PR
gh pr create --title "<title>" --base "$base_branch" --body "$(cat <<'EOF'
## Summary
<2-3 bullets of what changed>
## Test Plan
- [ ] <verification steps>
EOF
)"
报告:"保持分支 $current_branch 不变。"
先确认:
如果 current_branch != base_branch:
This will permanently delete:
- Branch $current_branch
- All commits: <commit-list>
Type 'discard' to confirm.
等待确切确认。
如果确认:
git checkout "$base_branch"
git branch -D "$current_branch"
如果 current_branch == base_branch,删除分支无效。在运行任何破坏性命令之前,停止并准确询问用户他们希望如何丢弃基础分支上的工作(例如,还原提交)。
| 上下文 | 可用选项 |
|---------|-------------------|
| current_branch != base_branch | 在本地合并回 $base_branch / 推送当前分支并创建 Pull Request / 保持当前分支不变 / 丢弃此工作 |
| current_branch == base_branch | 保持当前分支不变 / 丢弃此工作 |
跳过测试验证
未先检测分支上下文
current_branch 和 base_branch使用未命名的合并提交
merge_message,然后才是当前任务标题已在基础分支上时提供合并
丢弃时没有确认
discard 确认绝不:
current_branch 或 base_branch 未知时继续current_branch == base_branch 时提供合并选项merge_message始终:
git branch --show-current 和 git show-ref 确定分支被以下技能调用:
与以下技能配对:
data-ai
Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
development
Create new agent skills with proper structure, progressive disclosure, and bundled resources. Use when user wants to create, write, or build a new skill.
development
Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.
development
Simplifies code for clarity without changing behavior. Use for readability, maintainability, and complexity reduction after behavior is understood.