git-commit
Scannednpx machina-cli add skill JackyST0/awesome-agent-skills/git-commit --openclawFiles (1)
SKILL.md
2.4 KB
Git Commit
Git 提交信息生成技能,根据代码变更自动生成规范的 commit message。
Git commit message generator that creates conventional commit messages based on code changes.
When to Use
当用户请求以下操作时使用此 skill:
- 生成 commit message / Generate commit message
- 写提交信息 / Write commit message
- 提交代码 / Commit code
- 描述代码变更 / Describe code changes
Instructions
提交信息格式 / Commit Message Format
遵循 Conventional Commits 规范:
<type>(<scope>): <subject>
<body>
<footer>
类型 / Types
| Type | 说明 / Description |
|---|---|
| feat | 新功能 / New feature |
| fix | 修复 bug / Bug fix |
| docs | 文档变更 / Documentation |
| style | 格式调整 / Formatting |
| refactor | 重构 / Refactoring |
| perf | 性能优化 / Performance |
| test | 测试相关 / Tests |
| chore | 构建/工具 / Build/tools |
生成步骤 / Generation Steps
- 分析变更 - 查看
git diff或git status - 确定类型 - 根据变更内容选择合适的 type
- 提取范围 - 确定影响的模块或组件
- 撰写主题 - 用简洁的语言描述变更(50 字符内)
- 添加正文 - 如需要,详细说明变更原因和影响
规则 / Rules
- 主题行不超过 50 个字符
- 使用祈使句(如 "add" 而非 "added")
- 主题行首字母小写
- 主题行结尾不加句号
- 正文每行不超过 72 个字符
Examples
示例 1:新功能
feat(auth): add OAuth2 login support
- Add Google OAuth2 provider
- Add GitHub OAuth2 provider
- Update login page with social login buttons
示例 2:修复 Bug
fix(api): resolve null pointer in user service
The getUserById method was not handling the case when
user doesn't exist, causing a NullPointerException.
Closes #123
示例 3:文档更新
docs(readme): update installation instructions
Add Docker setup guide and clarify environment variables.
示例 4:重构
refactor(database): migrate from callbacks to async/await
Convert all database operations to use async/await pattern
for better readability and error handling.
Source
git clone https://github.com/JackyST0/awesome-agent-skills/blob/main/examples/git-commit/SKILL.mdView on GitHub Overview
This skill generates conventional commit messages from code changes. It analyzes diffs to pick a type (feat, fix, docs, etc.), infers a scope, and crafts a concise subject with optional body, aligning with Conventional Commits for a cleaner project history.
How This Skill Works
It analyzes your working tree with git diff/git status to determine the change type. Then it extracts the scope, crafts a concise subject (<=50 chars) in imperative form, and appends an optional body or footer per Conventional Commits rules.
When to Use It
- 生成 commit message / Generate commit message
- 写提交信息 / Write commit message
- 提交代码 / Commit code
- 描述代码变更 / Describe code changes
- 准备发布说明 / Prepare changelog entries
Quick Start
- Step 1: Analyze changes with git diff or git status
- Step 2: Determine type and extract scope from the changes
- Step 3: Write a subject <= 50 chars in lowercase imperative mood and add optional body/footers
Best Practices
- 遵循 Conventional Commits 规范,使用 type(scope): subject 格式
- 主题行 <= 50 字符,首字母小写,使用祈使句,末尾不加句号
- 尽量给出准确的 scope,指向受影响的模块或组件
- 正文每行不超过 72 字符,必要时解释原因和影响
- 可选类型包括 feat, fix, docs, style, refactor, perf, test, chore
Example Use Cases
- feat(auth): add OAuth2 login support\n\n- Add Google OAuth2 provider\n- Add GitHub OAuth2 provider\n- Update login page with social login buttons
- fix(api): resolve null pointer in user service\n\nThe getUserById method was not handling the case when\nuser doesn't exist, causing a NullPointerException.\n\nCloses #123
- docs(readme): update installation instructions\n\nAdd Docker setup guide and clarify environment variables.
- refactor(database): migrate from callbacks to async/await\n\nConvert all database operations to use async/await pattern\nfor better readability and error handling.
- style(ui): fix formatting of modal layout\n\nAdjust spacing and alignments to improve accessibility and readability.
Frequently Asked Questions
Add this skill to your agents