conventional-commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Commit Authoring

提交编写指南

Create git commits following Conventional Commits v1.0.0.
When invoked with arguments, commit staged changes with a message for: $ARGUMENTS
This skill applies only to git commit messages. Do not apply these conventions to PR titles, branch names, changelog entries, or release notes unless explicitly requested.
遵循 Conventional Commits v1.0.0 规范创建 Git 提交。
当传入参数时,为以下内容提交暂存的变更并附带消息:$ARGUMENTS
本技能仅适用于 Git 提交消息。除非明确要求,请勿将这些规范应用于 PR 标题、分支名称、变更日志条目或发布说明。

Workflow

工作流程

  1. Run
    git diff --cached
    to inspect staged changes
  2. If no staged changes exist, report this and stop
  3. Analyze the diff to determine the appropriate type, scope, and description
  4. Compose the commit message following the rules below
  5. Run
    git commit -m "<message>"
    (use a HEREDOC for multi-line messages)
  6. Do not stage files. Only commit what is already staged.
  1. 运行
    git diff --cached
    检查暂存的变更
  2. 如果没有暂存的变更,报告此情况并停止操作
  3. 分析差异以确定合适的类型、范围和描述
  4. 按照以下规则编写提交消息
  5. 运行
    git commit -m "<message>"
    (多行消息使用 HEREDOC)
  6. 请勿暂存文件。仅提交已暂存的内容。

Message Structure

消息结构

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

[optional body]

[optional footer(s)]
text
<type>[可选范围]: <描述>

[可选正文]

[可选页脚]

Types

类型

TypePurpose
feat
New feature
fix
Bug fix
docs
Documentation only
style
Formatting, whitespace
refactor
Neither fix nor feature
perf
Performance improvement
test
Adding or updating tests
build
Build system or dependencies
ci
CI configuration
chore
Maintenance tasks
类型用途
feat
新功能
fix
Bug 修复
docs
仅文档变更
style
格式调整、空白字符处理
refactor
既非修复也非新功能的代码重构
perf
性能优化
test
添加或更新测试
build
构建系统或依赖项变更
ci
CI 配置变更
chore
维护任务

Scopes

范围

Scope is optional. When used, set it to the module, component, or area of the codebase affected.
Derive scopes from the project structure. Use directory names or module names, not file names.
Examples:
feat(auth):
,
fix(api):
,
docs(readme):
,
refactor(db):
Omit scope when the change is cross-cutting or affects the project root.
范围是可选的。使用时,将其设置为受影响的模块、组件或代码库区域。
从项目结构中提取范围。使用目录名或模块名,而非文件名。
示例:
feat(auth):
,
fix(api):
,
docs(readme):
,
refactor(db):
当变更为跨领域或影响项目根目录时,省略范围。

Description

描述

Use imperative mood: "add feature" not "added feature" or "adds feature". Lowercase the first letter after the type prefix. Omit trailing period. Limit to 50 characters.
使用祈使语气:例如用 "add feature" 而非 "added feature" 或 "adds feature"。 类型前缀后的第一个字母小写。 省略末尾的句号。 限制在 50 个字符以内。

Body

正文

Wrap at 72 characters. Explain what changed and why, not how.
Separate the body from the description with one blank line.
Use the body for context the diff alone does not convey: motivation, trade-offs, or constraints that influenced the approach.
每行最多 72 个字符。解释变更内容和原因,而非实现方式。
正文与描述之间用一个空行分隔。
正文用于提供差异本身无法传达的上下文:比如变更动机、权衡方案或影响实现方式的约束条件。

Prohibited Content

禁止内容

Do not include any of the following in commit messages:
  • AI attribution ("Generated with Claude Code", "Co-authored-by" lines for AI)
  • Emoji in type prefixes or descriptions
  • Time estimates or dates
  • TODO items or future work references
  • File lists (the diff already shows what changed)
  • Apologies or hedging ("try to fix", "hopefully resolves")
提交消息中请勿包含以下内容:
  • AI 归属信息(如 "Generated with Claude Code"、AI 相关的 "Co-authored-by" 行)
  • 类型前缀或描述中的表情符号
  • 时间预估或日期
  • TODO 项或未来工作的引用
  • 文件列表(差异中已显示变更内容)
  • 道歉或不确定的表述(如 "try to fix"、"hopefully resolves")

Examples

示例

Simple:
text
docs: correct spelling of CHANGELOG
With scope:
text
feat(lang): add Polish language
Breaking change:
text
feat!: send email to customer when product ships

BREAKING CHANGE: customers now receive emails by default.
With body:
text
fix: prevent duplicate form submissions

Disables submit button after first click and adds
debounce to the handler.
With footer:
text
fix: resolve race condition in auth flow

Refs: #123
Reviewed-by: Alice
简单示例:
text
docs: correct spelling of CHANGELOG
带范围的示例:
text
feat(lang): add Polish language
破坏性变更示例:
text
feat!: send email to customer when product ships

BREAKING CHANGE: customers now receive emails by default.
带正文的示例:
text
fix: prevent duplicate form submissions

Disables submit button after first click and adds
debounce to the handler.
带页脚的示例:
text
fix: resolve race condition in auth flow

Refs: #123
Reviewed-by: Alice