Skip to content

Commit a25a9bc

Browse files
CodeCasterXclaude
andcommitted
docs(opencode): 优化提交命令的规范说明
增强 commit 命令的执行规范: - 添加版权头年份检查和更新的详细流程 - 规范多行提交消息格式(标题+正文+签名) - 详细说明使用 HEREDOC 格式执行 git commit - 强调提交消息应说明"为什么"而不仅是"改了什么" Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 14e7b2c commit a25a9bc

File tree

1 file changed

+59
-8
lines changed

1 file changed

+59
-8
lines changed

.opencode/commands/commit.md

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,78 @@ subtask: false
3434
!`git diff`
3535
!`git log --oneline -5`
3636

37-
2. 分析变更:
38-
- 确定变更类型(新功能/增强/Bug修复/重构/测试/文档等)
39-
- 生成符合规范的提交消息(参考最近的 commit 格式)
40-
- 提交消息格式: `<type>(<scope>): <subject>`,subject 使用中文且约 20 字以内
41-
- scope 为模块名(如 fit、waterflow、fel),可省略
37+
2. 分析变更并生成**详细的**提交消息:
38+
39+
**提交消息结构(CRITICAL)**:
40+
```
41+
<type>(<scope>): <subject>
42+
43+
<body>
44+
45+
Co-Authored-By: <你的模型名称> <noreply@anthropic.com>
46+
```
47+
48+
**各部分要求**:
49+
- **标题行**: `<type>(<scope>): <subject>`
50+
* type: feat/fix/refactor/docs/build/test/chore 等
51+
* scope: 模块名(如 fit、waterflow、fel),可省略
52+
* subject: 中文,约 20 字以内,概括变更
53+
54+
- **正文(body)**: 详细说明变更内容
55+
* 用 2-4 个要点说明具体做了什么
56+
* 每个要点用 `-` 开头
57+
* 解释"为什么"这样改,而不仅仅是"改了什么"
58+
59+
- **签名**: 始终添加 Co-Authored-By,模型名称由你自己声明(如 Claude Sonnet 4.5、GPT-5.2、Gemini-3 等)
60+
61+
**示例**(仅供参考格式,不要直接复制内容):
62+
```
63+
docs(opencode): 规范命令编写标准并添加风格指南
64+
65+
优化所有自定义命令的执行方式:
66+
- 统一使用 `!` 标记可执行命令
67+
- 添加错误处理和状态检查
68+
- 改进时间戳获取方式(先获取再引用)
69+
- 新增 COMMAND_STYLE_GUIDE.md 编写规范文档
70+
71+
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
72+
```
73+
4274
- 不要提交敏感文件(.env, credentials.json等)
4375

4476
**步骤 3: 提交代码**
4577

4678
1. 添加文件到暂存区:
4779
!`git add .`
48-
80+
4981
或指定特定文件:
5082
!`git add <file1> <file2>`
5183

5284
2. 创建提交:
53-
!`git commit -m "<提交消息>"`
85+
86+
使用 HEREDOC 格式执行 git commit,支持多行提交消息。
87+
88+
**命令格式**(仅供参考,实际执行时替换占位符):
89+
```bash
90+
git commit -m "$(cat <<'EOF'
91+
<type>(<scope>): <subject>
92+
93+
<body 详细说明>
94+
95+
Co-Authored-By: <你的模型名称> <noreply@anthropic.com>
96+
EOF
97+
)"
98+
```
99+
100+
**执行要求**:
101+
- 根据步骤 2 分析的变更内容,生成实际的提交消息
102+
- 将上述格式中的占位符替换为实际内容
103+
- Co-Authored-By 中的模型名称由你自己声明(你是什么模型就写什么)
104+
- 使用 Bash 工具执行完整的 git commit 命令
54105
55106
3. 验证提交成功:
56107
!`git status`
57-
!`git log -1 --oneline`
108+
!`git log -1`
58109
59110
**步骤 4: 更新任务状态(如果是任务相关的提交)**
60111

0 commit comments

Comments
 (0)