conventional-commits

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Conventional Commits

Conventional Commits

Use this skill to produce commit messages that follow the Conventional Commits 1.0.0 specification. Use the official spec as the source of truth: https://www.conventionalcommits.org/en/v1.0.0/#specification
使用本技能生成符合Conventional Commits 1.0.0规范的提交信息。 请以官方规范为权威参考:https://www.conventionalcommits.org/en/v1.0.0/#specification

Output Format

输出格式

Write commit messages in this structure:
text
<type>[optional scope][optional !]: <description>

[optional body]

[optional footer(s)]
Apply these REQUIRED rules:
  1. Start with a type, then optional scope, optional
    !
    , then
    : 
    .
  2. Use
    feat
    for new features.
  3. Use
    fix
    for bug fixes.
  4. Put scope in parentheses when used, e.g.
    fix(parser):
    .
  5. Place the description immediately after
    : 
    .
  6. Start body one blank line after the description.
  7. Start footer block one blank line after body (or after description if no body).
  8. Format each footer as
    <token>: <value>
    or
    <token> #<value>
    .
  9. Use
    -
    in footer tokens instead of spaces, except
    BREAKING CHANGE
    .
  10. Mark breaking changes with
    !
    before
    :
    and/or
    BREAKING CHANGE: <description>
    footer.
  11. Keep
    BREAKING CHANGE
    uppercase when used.
  12. Treat other structural units as case-insensitive when validating.
Apply these RECOMMENDED quality rules:
  1. Write the description in imperative mood (for example
    fix auth timeout
    , not
    fixed auth timeout
    ).
  2. Keep the description concise so the header is easy to scan in
    git log
    .
  3. Wrap body/footer lines at about 72 characters for terminal readability.
  4. Use a body to explain why the change is needed when intent is not obvious from the diff.
  5. Use explicit issue/action trailers when relevant (for example
    Fixes: #123
    ,
    Resolves: #77
    ,
    Refs: #42
    ).
请按照以下结构撰写提交信息:
text
<type>[可选 scope][可选 !]: <描述>

[可选 正文]

[可选 页脚]

Type Selection

强制规则

Choose one primary type that best matches intent:
  • feat
    : add behavior or capability
  • fix
    : correct incorrect behavior
  • docs
    : documentation-only change
  • style
    : formatting-only change
  • refactor
    : internal change without behavior fix/feature
  • perf
    : performance improvement
  • test
    : add or change tests
  • build
    : build/dependency/tooling change
  • ci
    : CI/CD pipeline change
  • chore
    : maintenance that does not fit above
  • revert
    : revert a previous change
Use types outside
feat
and
fix
when appropriate; only
feat
,
fix
, and breaking markers imply SemVer meaning by default.
  1. 以类型开头,后跟可选的范围、可选的
    !
    ,再跟
    : 
  2. 新增功能使用
    feat
    类型。
  3. 修复Bug使用
    fix
    类型。
  4. 使用范围时需放在括号内,例如
    fix(parser):
  5. 描述内容紧跟在
    : 
    之后。
  6. 正文需在描述后空一行开始。
  7. 页脚块需在正文后空一行开始(若没有正文,则在描述后空一行)。
  8. 每个页脚格式为
    <标识>: <内容>
    <标识> #<内容>
  9. 页脚标识中使用
    -
    代替空格,
    BREAKING CHANGE
    除外。
  10. 破坏性变更需在
    : 
    前添加
    !
    ,和/或使用
    BREAKING CHANGE: <描述>
    页脚标记。
  11. 使用
    BREAKING CHANGE
    时需保持大写。
  12. 验证时,其他结构单元不区分大小写。

Drafting Workflow

推荐的质量规则

  1. Summarize what changed and why in one sentence.
  2. Decide if the change is a feature, fix, or other type.
  3. Choose a scope noun if it clarifies impact (
    api
    ,
    auth
    ,
    parser
    ,
    deps
    ).
  4. Detect breaking behavior:
    • Add
      !
      before
      :
      , and/or
    • Add
      BREAKING CHANGE: <description>
      footer.
  5. Write a concise description line.
  6. Use imperative mood in the description and keep it standalone.
  7. Add body paragraphs only when extra context is needed; wrap around 72 columns.
  8. Add trailer footers for metadata (for example
    Fixes: #123
    ,
    Reviewed-by: Name
    ).
  9. Re-check against the checklist below before finalizing.
  1. 描述使用祈使语气(例如
    fix auth timeout
    ,而非
    fixed auth timeout
    )。
  2. 描述需简洁,使提交信息头在
    git log
    中易于浏览。
  3. 正文/页脚每行约72个字符换行,适配终端可读性。
  4. 当从代码差异中无法明确变更意图时,使用正文解释变更原因。
  5. 相关时使用明确的问题/操作标记(例如
    Fixes: #123
    Resolves: #77
    Refs: #42
    )。

Validation Checklist

类型选择

Confirm all items before returning a commit message:
  1. Header matches
    <type>[scope][!]: <description>
    .
  2. Description exists and is not empty.
  3. Body and footer blocks are separated by exactly one blank line.
  4. Footer tokens are valid trailers.
  5. Breaking changes are explicitly marked (
    !
    or
    BREAKING CHANGE:
    ).
  6. feat
    /
    fix
    are used correctly when applicable.
  7. Description uses imperative wording and is concise.
  8. Body/footers are wrapped for readability when multi-line.
选择最符合变更意图的主类型:
  • feat
    : 添加新行为或功能
  • fix
    : 修正错误行为
  • docs
    : 仅文档变更
  • style
    : 仅格式调整
  • refactor
    : 内部代码重构,无功能修复或新增
  • perf
    : 性能优化
  • test
    : 添加或修改测试
  • build
    : 构建/依赖/工具链变更
  • ci
    : CI/CD流水线变更
  • chore
    : 不属于以上类型的维护操作
  • revert
    : 回滚之前的变更
适当时使用
feat
fix
之外的类型;默认情况下,只有
feat
fix
和破坏性变更标记会关联SemVer版本含义。

SemVer Mapping

撰写流程

  • fix
    -> PATCH
  • feat
    -> MINOR
  • Any commit with breaking change marker -> MAJOR
  1. 用一句话总结变更内容及原因。
  2. 判断变更属于功能新增、Bug修复还是其他类型。
  3. 若能明确影响范围,选择范围名词(如
    api
    auth
    parser
    deps
    )。
  4. 检测是否为破坏性变更:
    • : 
      前添加
      !
      ,和/或
    • 添加
      BREAKING CHANGE: <描述>
      页脚。
  5. 撰写简洁的描述行。
  6. 描述使用祈使语气,且可独立理解。
  7. 仅当需要额外上下文时添加正文段落,每行约72个字符换行。
  8. 为元数据添加页脚标记(例如
    Fixes: #123
    Reviewed-by: Name
    )。
  9. 最终确定前对照下方检查清单进行复核。

Examples

验证检查清单

text
feat(auth): add device-bound refresh tokens
text
fix(api): prevent duplicate invoice creation

Add idempotency key validation for create-invoice endpoint.

Refs: #482
text
feat(storage)!: replace v1 blob schema

BREAKING CHANGE: remove support for legacy v1 blob readers.
返回提交信息前请确认所有项:
  1. 信息头符合
    <type>[scope][!]: <描述>
    格式。
  2. 描述存在且不为空。
  3. 正文和页脚块之间恰好空一行。
  4. 页脚标识为有效的标记格式。
  5. 破坏性变更已明确标记(
    !
    BREAKING CHANGE:
    )。
  6. 适当时正确使用
    feat
    /
    fix
    类型。
  7. 描述使用祈使语气且简洁。
  8. 多行的正文/页脚已换行以提升可读性。

SemVer版本映射

  • fix
    -> PATCH版本
  • feat
    -> MINOR版本
  • 任何带有破坏性变更标记的提交 -> MAJOR版本

示例

text
feat(auth): add device-bound refresh tokens
text
fix(api): prevent duplicate invoice creation

Add idempotency key validation for create-invoice endpoint.

Refs: #482
text
feat(storage)!: replace v1 blob schema

BREAKING CHANGE: remove support for legacy v1 blob readers.