关于 conventional-commits
conventional-commits 是用于按 Conventional Commits 格式编写 Git 提交信息的技能,涵盖类型、范围、描述、正文和不兼容变更标记,便于整理提交历史与自动生成发布信息。
主要功能
- 01Conventional Commits 格式规范
- 02提交类型与范围指南
- 03描述和正文规则
- 04不兼容变更标记
- 05语义化版本指南
适用场景
- 01编写 Git 提交信息
- 02生成提交信息
- 03准备拉取请求合并提交
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ jackjin1997/ clawforge --skill conventional-commits安装后在 Claude Code 中输入/conventional-commits确认已加载。
附带文件_meta.json
详细介绍
Conventional Commits
所有提交消息都应遵循 Conventional Commits 规范。这样可以自动生成变更日志、进行语义化版本管理,并改善提交历史。
格式结构
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
提交类型
必需类型
feat:- 新功能(对应语义化版本中的 MINOR)fix:- 错误修复(对应语义化版本中的 PATCH)
常见的其他类型
docs:- 仅涉及文档的更改style:- 代码风格更改(格式调整、缺少分号等)refactor:- 代码重构,不涉及错误修复或新功能perf:- 性能改进test:- 添加或更新测试build:- 构建系统或外部依赖项的更改ci:- CI/CD 配置更改chore:- 其他不修改 src 或 test 文件的更改revert:- 撤销之前的提交
作用范围
可选的作用范围可提供有关代码库相关部分的更多上下文:
feat(parser): add ability to parse arrays
fix(auth): resolve token expiration issue
docs(readme): update installation instructions
描述
- 必须紧跟在类型/作用范围后的冒号和空格之后
- 使用祈使语气(使用“add feature”,而不是“added feature”或“adds feature”)
- 首字母不要大写
- 末尾不要加句号
- 保持简洁(通常为 50-72 个字符)
正文
- 可选的较长描述,用于提供更多上下文
- 必须与描述之间空一行
- 可以包含多个段落
- 说明更改的“内容”和“原因”,而不是“方式”
破坏性更改
可通过两种方式标明破坏性更改:
1. 在类型/作用范围中使用 !
feat!: send an email to the customer when a product is shipped
feat(api)!: send an email to the customer when a product is shipped
2. 使用 BREAKING CHANGE 页脚
feat: allow provided config object to extend other configs
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
3. 同时使用两种方式
chore!: drop support for Node 6
BREAKING CHANGE: use JavaScript features not available in Node 6.
示例
简单功能
feat: add user authentication
带作用范围的功能
feat(auth): add OAuth2 support
带正文的错误修复
fix: prevent racing of requests
Introduce a request id and a reference to latest request. Dismiss
incoming responses other than from latest request.
Remove timeouts which were used to mitigate the racing issue but are
obsolete now.
破坏性更改
feat!: migrate to new API client
BREAKING CHANGE: The API client interface has changed. All methods now
return Promises instead of using callbacks.
文档更新
docs: correct spelling of CHANGELOG
带多个段落和页脚的正文
fix: prevent racing of requests
Introduce a request id and a reference to latest request. Dismiss
incoming responses other than from latest request.
Remove timeouts which were used to mitigate the racing issue but are
obsolete now.
Reviewed-by: Z
Refs: #123
指南
- 始终使用类型 - 每条提交都必须以类型、冒号和空格开头
- 使用祈使语气 - 写得仿佛是在补全句子“If applied, this commit will...”
- 具体明确 - 描述应清楚说明更改内容
- 聚焦单一事项 - 每条提交只包含一项逻辑上的更改
- 适当使用作用范围 - 作用范围有助于对代码库中的更改进行分类
- 记录破坏性更改 - 始终清楚标明破坏性更改
与语义化版本的对应关系
fix:→ PATCH 版本递增(1.0.0 → 1.0.1)feat:→ MINOR 版本递增(1.0.0 → 1.1.0)- BREAKING CHANGE → MAJOR 版本递增(1.0.0 → 2.0.0)
适用场景
在以下场景中使用此格式:
- 所有 git 提交
- 生成提交消息
- 拉取请求合并提交
- 用户询问提交消息或 git 提交时
应避免的常见错误
❌ Added new feature(过去时,首字母大写)
✅ feat: add new feature(祈使语气,小写)
❌ fix: bug(过于笼统)
✅ fix: resolve null pointer exception in user service
❌ feat: add feature(内容重复)
✅ feat: add user profile page
❌ feat: Added OAuth support.(过去时,末尾带句号)
✅ feat: add OAuth support
评论
支持 Markdown