commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Conventional Commit

Conventional Commit

Enforces Conventional Commits format for all git commit messages. This skill applies to both AI agents and human users.
为所有Git提交信息强制遵循Conventional Commits格式。此技能适用于AI Agent和人类用户。

Commit Message Format

提交信息格式

<type>[optional scope][optional !]: <description>

[optional body]

[optional footer(s)]
<type>[可选 scope][可选 !]: <描述>

[可选 正文]

[可选 页脚]

Types (Required)

类型(必填)

TypeDescription
feat
A new feature
fix
A bug fix
docs
Documentation only changes
style
Changes that do not affect the meaning of the code (white-space, formatting, etc.)
refactor
A code change that neither fixes a bug nor adds a feature
perf
A code change that improves performance
test
Adding missing tests or correcting existing tests
build
Changes that affect the build system or external dependencies
ci
Changes to CI configuration files and scripts
chore
Other changes that don't modify src or test files
revert
Reverts a previous commit
类型描述
feat
新增功能
fix
修复Bug
docs
仅修改文档
style
不影响代码含义的修改(如空白、格式调整等)
refactor
既不是修复Bug也不是新增功能的代码变更
perf
提升性能的代码变更
test
添加缺失测试或修正现有测试
build
影响构建系统或外部依赖的变更
ci
修改CI配置文件或脚本
chore
其他不修改源码或测试文件的变更
revert
回滚之前的提交

Scope (Optional)

范围(可选)

Scope provides additional context. Determine scope by checking recent commits:
bash
git log --oneline -10
Common scope patterns:
  • Feature/module name:
    feat(auth):
    ,
    fix(api):
  • File/directory:
    docs(readme):
    ,
    refactor(utils):
  • Component:
    style(button):
    ,
    test(login):
范围用于提供额外上下文。可通过查看最近提交确定范围:
bash
git log --oneline -10
常见范围模式:
  • 功能/模块名称:
    feat(auth):
    ,
    fix(api):
  • 文件/目录:
    docs(readme):
    ,
    refactor(utils):
  • 组件:
    style(button):
    ,
    test(login):

Breaking Changes

破坏性变更

Add
!
before the colon for breaking changes:
feat(api)!: change authentication endpoint
Or add
BREAKING CHANGE:
in the footer.
在冒号前添加
!
表示破坏性变更:
feat(api)!: change authentication endpoint
或者在页脚中添加
BREAKING CHANGE:

Examples

示例

Basic (No Scope)

基础示例(无范围)

feat: add user registration form
fix: resolve memory leak in event handler
docs: update installation instructions
feat: add user registration form
fix: resolve memory leak in event handler
docs: update installation instructions

With Scope

带范围示例

feat(auth): implement OAuth2 login
fix(api): handle null response from server
refactor(utils): simplify date formatting logic
feat(auth): implement OAuth2 login
fix(api): handle null response from server
refactor(utils): simplify date formatting logic

With Body (Japanese)

包含正文(日文示例)

feat(検索): 全文検索機能を追加

Elasticsearchを使用した全文検索機能を実装。
日本語形態素解析にはkuromojiを使用。
feat(検索): 全文検索機能を追加

Elasticsearchを使用した全文検索機能を実装。
日本語形態素解析にはkuromojiを使用。

Breaking Change

破坏性变更示例

feat(api)!: change response format to JSON:API

BREAKING CHANGE: API responses now follow JSON:API specification.
Clients need to update their response parsers.
feat(api)!: change response format to JSON:API

BREAKING CHANGE: API responses now follow JSON:API specification.
Clients need to update their response parsers.

Validation

验证

To validate a commit message before committing:
bash
bash /mnt/skills/user/conventional-commit/scripts/validate-commit.sh "feat: add new feature"
提交前验证提交信息:
bash
bash /mnt/skills/user/conventional-commit/scripts/validate-commit.sh "feat: add new feature"

For AI Agents

针对AI Agent的要求

When creating commits:
  1. Always use Conventional Commits format
  2. Check recent commits for scope patterns:
    git log --oneline -10
  3. Use the appropriate type based on the change
  4. Do NOT use emojis in commit messages
  5. Write clear, concise descriptions
  6. Add body for complex changes
  7. Mark breaking changes with
    !
    or
    BREAKING CHANGE:
创建提交时:
  1. 必须使用Conventional Commits格式
  2. 检查最近提交的范围模式:
    git log --oneline -10
  3. 选择与变更对应的合适类型
  4. 禁止在提交信息中使用表情符号
  5. 编写清晰、简洁的描述
  6. 复杂变更需添加正文说明
  7. 使用
    !
    BREAKING CHANGE:
    标记破坏性变更

Language

语言要求

  • Use the same language as the codebase or user's preference
  • Japanese descriptions are fully supported
  • Keep type prefixes in English (feat, fix, etc.)
  • 使用与代码库或用户偏好一致的语言
  • 完全支持日文描述
  • 类型前缀需保持英文(feat、fix等)

Git Hooks (Optional)

Git Hooks(可选)

To enforce validation via git hooks, add to
.git/hooks/commit-msg
:
bash
#!/bin/bash
bash /mnt/skills/user/conventional-commit/scripts/validate-commit.sh "$(cat $1)" || exit 1
如需通过Git Hooks强制验证,将以下内容添加到
.git/hooks/commit-msg
bash
#!/bin/bash
bash /mnt/skills/user/conventional-commit/scripts/validate-commit.sh "$(cat $1)" || exit 1