conventional-commits
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConventional 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:
- Start with a type, then optional scope, optional , then
!.: - Use for new features.
feat - Use for bug fixes.
fix - Put scope in parentheses when used, e.g. .
fix(parser): - Place the description immediately after .
: - Start body one blank line after the description.
- Start footer block one blank line after body (or after description if no body).
- Format each footer as or
<token>: <value>.<token> #<value> - Use in footer tokens instead of spaces, except
-.BREAKING CHANGE - Mark breaking changes with before
!and/or:footer.BREAKING CHANGE: <description> - Keep uppercase when used.
BREAKING CHANGE - Treat other structural units as case-insensitive when validating.
Apply these RECOMMENDED quality rules:
- Write the description in imperative mood (for example , not
fix auth timeout).fixed auth timeout - Keep the description concise so the header is easy to scan in .
git log - Wrap body/footer lines at about 72 characters for terminal readability.
- Use a body to explain why the change is needed when intent is not obvious from the diff.
- 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:
- : add behavior or capability
feat - : correct incorrect behavior
fix - : documentation-only change
docs - : formatting-only change
style - : internal change without behavior fix/feature
refactor - : performance improvement
perf - : add or change tests
test - : build/dependency/tooling change
build - : CI/CD pipeline change
ci - : maintenance that does not fit above
chore - : revert a previous change
revert
Use types outside and when appropriate; only , , and breaking markers imply SemVer meaning by default.
featfixfeatfix- 以类型开头,后跟可选的范围、可选的,再跟
!。: - 新增功能使用类型。
feat - 修复Bug使用类型。
fix - 使用范围时需放在括号内,例如 。
fix(parser): - 描述内容紧跟在之后。
: - 正文需在描述后空一行开始。
- 页脚块需在正文后空一行开始(若没有正文,则在描述后空一行)。
- 每个页脚格式为或
<标识>: <内容>。<标识> #<内容> - 页脚标识中使用代替空格,
-除外。BREAKING CHANGE - 破坏性变更需在前添加
:,和/或使用!页脚标记。BREAKING CHANGE: <描述> - 使用时需保持大写。
BREAKING CHANGE - 验证时,其他结构单元不区分大小写。
Drafting Workflow
推荐的质量规则
- Summarize what changed and why in one sentence.
- Decide if the change is a feature, fix, or other type.
- Choose a scope noun if it clarifies impact (,
api,auth,parser).deps - Detect breaking behavior:
- Add before
!, and/or: - Add footer.
BREAKING CHANGE: <description>
- Add
- Write a concise description line.
- Use imperative mood in the description and keep it standalone.
- Add body paragraphs only when extra context is needed; wrap around 72 columns.
- Add trailer footers for metadata (for example ,
Fixes: #123).Reviewed-by: Name - Re-check against the checklist below before finalizing.
- 描述使用祈使语气(例如,而非
fix auth timeout)。fixed auth timeout - 描述需简洁,使提交信息头在中易于浏览。
git log - 正文/页脚每行约72个字符换行,适配终端可读性。
- 当从代码差异中无法明确变更意图时,使用正文解释变更原因。
- 相关时使用明确的问题/操作标记(例如、
Fixes: #123、Resolves: #77)。Refs: #42
Validation Checklist
类型选择
Confirm all items before returning a commit message:
- Header matches .
<type>[scope][!]: <description> - Description exists and is not empty.
- Body and footer blocks are separated by exactly one blank line.
- Footer tokens are valid trailers.
- Breaking changes are explicitly marked (or
!).BREAKING CHANGE: - /
featare used correctly when applicable.fix - Description uses imperative wording and is concise.
- Body/footers are wrapped for readability when multi-line.
选择最符合变更意图的主类型:
- : 添加新行为或功能
feat - : 修正错误行为
fix - : 仅文档变更
docs - : 仅格式调整
style - : 内部代码重构,无功能修复或新增
refactor - : 性能优化
perf - : 添加或修改测试
test - : 构建/依赖/工具链变更
build - : CI/CD流水线变更
ci - : 不属于以上类型的维护操作
chore - : 回滚之前的变更
revert
适当时使用和之外的类型;默认情况下,只有、和破坏性变更标记会关联SemVer版本含义。
featfixfeatfixSemVer Mapping
撰写流程
- -> PATCH
fix - -> MINOR
feat - Any commit with breaking change marker -> MAJOR
- 用一句话总结变更内容及原因。
- 判断变更属于功能新增、Bug修复还是其他类型。
- 若能明确影响范围,选择范围名词(如、
api、auth、parser)。deps - 检测是否为破坏性变更:
- 在前添加
:,和/或! - 添加页脚。
BREAKING CHANGE: <描述>
- 在
- 撰写简洁的描述行。
- 描述使用祈使语气,且可独立理解。
- 仅当需要额外上下文时添加正文段落,每行约72个字符换行。
- 为元数据添加页脚标记(例如、
Fixes: #123)。Reviewed-by: Name - 最终确定前对照下方检查清单进行复核。
Examples
验证检查清单
text
feat(auth): add device-bound refresh tokenstext
fix(api): prevent duplicate invoice creation
Add idempotency key validation for create-invoice endpoint.
Refs: #482text
feat(storage)!: replace v1 blob schema
BREAKING CHANGE: remove support for legacy v1 blob readers.返回提交信息前请确认所有项:
- 信息头符合格式。
<type>[scope][!]: <描述> - 描述存在且不为空。
- 正文和页脚块之间恰好空一行。
- 页脚标识为有效的标记格式。
- 破坏性变更已明确标记(或
!)。BREAKING CHANGE: - 适当时正确使用/
feat类型。fix - 描述使用祈使语气且简洁。
- 多行的正文/页脚已换行以提升可读性。
—
SemVer版本映射
—
- -> PATCH版本
fix - -> MINOR版本
feat - 任何带有破坏性变更标记的提交 -> MAJOR版本
—
示例
—
text
feat(auth): add device-bound refresh tokenstext
fix(api): prevent duplicate invoice creation
Add idempotency key validation for create-invoice endpoint.
Refs: #482text
feat(storage)!: replace v1 blob schema
BREAKING CHANGE: remove support for legacy v1 blob readers.