name: skill-git-workflow description: 为任务操作创建范围化的Git提交。在任务状态更改或工件创建后调用。 allowed-tools: Bash(git:*)
上下文按需加载通过@引用(参见上下文加载部分)
Git工作流技能
为任务操作创建适当范围的Git提交。
上下文加载
在需要时按需加载上下文:
@.opencode/context/core/standards/git-safety.md- Git安全规则和最佳实践@.opencode/context/index.md- 完整上下文发现索引
触发条件
此技能在以下情况激活:
- 任务状态更改(研究、计划、实施完成)
- 工件创建
- 任务生命周期操作发生
提交消息格式
任务操作
| 操作 | 格式 | CI触发 |
|---|---|---|
| 创建任务 | task {N}: create {title} |
否 |
| 完成研究 | task {N}: complete research |
否 |
| 创建计划 | task {N}: create implementation plan |
否 |
| 完成阶段 | task {N} phase {P}: {phase_name} |
否 |
| 完成任务 | task {N}: complete implementation |
否 |
| 完成任务(带CI) | task {N}: complete implementation [ci] |
是 |
| 修订计划 | task {N}: revise plan (v{V}) |
否 |
系统操作
| 操作 | 格式 |
|---|---|
| 归档任务 | todo: archive {N} completed tasks |
| 错误修复 | errors: create fix plan for {N} errors |
| 代码审查 | review: {scope} code review |
| 状态同步 | sync: reconcile TODO.md and state.json |
执行流程
1. 接收提交请求:
- operation_type
- task_number(如适用)
- scope(要包含的文件)
- message_template
2. 暂存适当文件:
- git add {scope}
3. 创建提交:
- 格式化消息
- 添加共同作者
- 执行提交
4. 验证成功:
- 检查退出码
- 记录结果
5. 返回结果
提交范围规则
任务特定提交
仅包含任务相关文件:
specs/TODO.md
specs/state.json
specs/{NNN}_{SLUG}/**
实施提交
包含修改的源文件:
Logos/**/*.lean (用于Lean任务)
src/**/* (用于通用任务)
阶段提交
范围仅限于阶段更改:
该阶段修改的文件
更新带有阶段状态的计划
安全检查
提交前
1. git status - 验证暂存文件
2. 检查无敏感文件暂存(.env, 凭据)
3. 验证提交消息格式
从不运行
git push --forcegit reset --hard(无显式请求)git rebase -i
消息模板
{scope}: {action} {description}
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CI触发
概述
在推送事件上,CI 默认跳过。要触发CI,在提交消息中添加 [ci] 标记。
trigger_ci 参数
创建提交时,trigger_ci 参数控制CI是否运行:
| 值 | 行为 | 使用场景 |
|---|---|---|
false(默认) |
不添加CI标记 | 常规提交、研究、规划 |
true |
在消息后附加 [ci] |
Lean更改、实施完成 |
CI决策标准
触发CI(trigger_ci: true)当:
- Lean文件修改(.lean)- 确保构建通过
- 实施完成 - 合并前最终验证
- CI配置更改(.github/workflows/)- 验证工作流更改
- Mathlib依赖更新(lakefile.lean, lake-manifest.json)- 确保兼容性
- 关键错误修复 - 验证修复工作
跳过CI(默认)当:
- 仅文档更改(.md文件)
- 研究/规划工件
- 配置更改(非CI)
- 常规任务管理操作
带CI标记的提交消息
task {N}: complete implementation [ci]
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CI始终运行时
CI运行无论标记与否,当:
- 拉取请求事件(所有PR运行CI)
- 手动 workflow_dispatch 触发
- 提交带有
[ci]标记
执行命令
标准提交
git add {files}
git commit -m "$(cat <<'EOF'
{message}
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)"
任务提交
git add specs/
git commit -m "$(cat <<'EOF'
task {N}: {action}
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)"
返回格式
{
"status": "completed|failed",
"summary": "Created commit: {short_message}",
"commit_hash": "abc123",
"files_committed": [
"path/to/file1",
"path/to/file2"
],
"message": "Full commit message",
"ci_triggered": true|false
}
错误处理
无需提交
{
"status": "committed",
"summary": "No changes to commit",
"commit_hash": null
}
提交前钩子失败
{
"status": "failed",
"error": "Pre-commit hook failed",
"recovery": "Fix issues and retry (do not use --no-verify)"
}
Git错误
{
"status": "failed",
"error": "Git command failed: {error}",
"recovery": "Check git status and resolve manually"
}
非阻塞行为
Git失败不应阻塞任务操作:
- 记录失败
- 继续任务
- 向用户报告提交失败
- 任务状态无论如何都保持