关于 commit-helper
commit-helper 是面向 Git 提交操作的技能,帮助编写符合 Conventional Commits 的提交信息,涵盖类型、范围、主题、正文和页脚格式。
主要功能
- 01遵循 Conventional Commits 结构
- 02选择变更类型与范围
- 03编写简洁的祈使句主题
- 04添加说明正文和问题页脚
- 05用脚本校验提交信息
适用场景
- 01规范功能或缺陷修复的提交信息
- 02记录破坏性变更及问题引用
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ zhaono1/ agent-playbook --skill commit-helper安装后在 Claude Code 中输入/commit-helper确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
README.mdreferences/conventional-commits.mdexamples.mdscopes.mdscripts/validate_commit.py详细介绍
提交消息助手
用于创建格式规范的 Git 提交消息,并遵循 Conventional Commits 规范。
此技能的触发条件
在以下情况下,此技能会触发:
- 请求提交更改
- 提及提交消息
- 请求设置 git commit 格式
- 说“commit”或“git commit”
提交消息格式
<type>(<scope>): <subject>
<body>
<footer>
类型
| 类型 | 描述 |
|---|---|
feat | 新功能 |
fix | 修复错误 |
docs | 仅更改文档 |
style | 不影响代码含义的更改(格式调整等) |
refactor | 既不修复错误也不添加功能的代码更改 |
perf | 提升性能的代码更改 |
test | 添加缺失的测试或修正现有测试 |
chore | 更改构建流程或辅助工具 |
ci | 更改 CI 配置文件和脚本 |
build | 影响构建系统或外部依赖项的更改 |
范围
范围应指明受影响的代码库区域:
- 前端:
components、hooks、store、styles、utils - 后端:
api、models、services、database、auth - DevOps:
ci、deploy、docker - 也可以使用项目特定的范围
指南
主题行
- 使用祈使语气(使用“add feature”,而非“added feature”或“adds feature”)
- 末尾不加句号
- 最多 50 个字符
- 具体、简洁
正文
- 在主题与正文之间空一行
- 正文说明是什么以及为什么,而非如何做
- 每行最多 72 个字符
- 提及任何不兼容更改
页脚
- 引用问题:
Closes #123、Fixes #456、Refs #789 - 多个问题:
Closes #123, #456, #789 - 不兼容更改:以
BREAKING CHANGE:开头,后接说明
示例
好的示例
feat(auth): add OAuth2 login support
Implement OAuth2 authentication flow to allow users to log in
with their Google or GitHub accounts.
This change adds:
- New OAuth2 middleware for handling callbacks
- Updated login UI with social login buttons
- User profile synchronization
Closes #123
fix(api): resolve race condition in user creation
The concurrent user creation requests could result in duplicate
email entries. Added unique constraint and proper error handling.
Fixes #456
refactor(user): simplify profile update logic
Extracted common validation logic into a reusable function
to reduce code duplication across profile update endpoints.
docs: update API documentation with new endpoints
Added documentation for the v2 user management endpoints
including request/response examples and error codes.
不好的示例
updated stuff # Too vague, no type/scope
fixed bug # No context about which bug
feat: added feature # Redundant ("feat" means new feature)
Feat(User): Add Login # Incorrect capitalization
feat: A really really really long subject line that exceeds the recommended limit # Too long
不兼容更改
引入不兼容更改时,在页脚中添加 BREAKING CHANGE::
feat(api): migrate to REST v2
The API endpoints have been restructured for better consistency.
Old endpoints are deprecated and will be removed in v3.0.
BREAKING CHANGE: `/api/v1/users` is now `/api/v2/users`.
All consumers must update their integration by 2025-03-01.
工作流
编写提交消息时:
- 查看更改 - 运行
git diff以了解更改内容 - 确定类型 - 确定更改类型
- 确定范围 - 确定受影响的区域
- 编写主题 - 编写清晰、简洁的主题行
- 编写正文 - 说明是什么以及为什么(如有需要)
- 添加页脚 - 引用问题或注明不兼容更改
验证
使用验证脚本检查提交消息格式:
python3 scripts/validate_commit.py "feat(scope): add behavior"
参考文档
- 查看
references/conventional-commits.md,了解完整规范 - 查看
references/examples.md,查看更多示例 - 查看
references/scopes.md,了解推荐的范围命名方式
评论
支持 Markdown