conventional-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConventional Commit
Conventional Commit
Follow the Conventional Commits specification for all commits.
所有提交均需遵循Conventional Commits 规范。
Preconditions
前置条件
Validate branch
验证分支
Run .
git rev-parse --abbrev-ref HEADIf on or , stop and ask the user to create a feature branch.
mainmasterBranch names should follow: (e.g., ). If invalid, ask the user to rename the branch.
<TICKET_PREFIX>-<number>-<kebab-case-description>ENG-1333-migrate-review-flow执行 。
git rev-parse --abbrev-ref HEAD若当前处于或分支,请停止操作并要求用户创建功能分支。
mainmaster分支名称应遵循:(例如:)。若命名无效,请要求用户重命名分支。
<TICKET_PREFIX>-<number>-<kebab-case-description>ENG-1333-migrate-review-flowConventional Commits Spec
Conventional Commits 规范
The commit message format:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]提交信息格式:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]Types (required)
类型(必填)
| Type | Purpose |
|---|---|
| A new feature (correlates with MINOR in SemVer) |
| A bug fix (correlates with PATCH in SemVer) |
| Documentation only changes |
| Changes that do not affect meaning (whitespace, formatting) |
| Code change that neither fixes a bug nor adds a feature |
| Code change that improves performance |
| Adding or correcting tests |
| Changes to build system or external dependencies |
| Changes to CI configuration files and scripts |
| Other changes that don't modify src or test files |
| 类型 | 用途 |
|---|---|
| 新增功能(对应SemVer中的MINOR版本) |
| 修复Bug(对应SemVer中的PATCH版本) |
| 仅修改文档 |
| 不影响代码含义的更改(空白字符、格式调整等) |
| 既不修复Bug也不新增功能的代码变更 |
| 提升性能的代码变更 |
| 添加或修正测试 |
| 修改构建系统或外部依赖 |
| 修改CI配置文件和脚本 |
| 其他不修改源码或测试文件的变更 |
Scope (optional)
范围(可选)
A noun describing the section of codebase affected, in parentheses:
feat(parser): add ability to parse arraysfix(auth): resolve token expiration bug
用于描述受影响代码库部分的名词,放在括号中:
feat(parser): add ability to parse arraysfix(auth): resolve token expiration bug
Breaking Changes
破坏性变更
Append after type/scope OR add footer:
!BREAKING CHANGE:feat(api)!: remove deprecated endpoints
BREAKING CHANGE: The /v1/users endpoint has been removed. Use /v2/users instead.Breaking changes correlate with MAJOR in SemVer.
在类型/范围后追加 或添加 页脚:
!BREAKING CHANGE:feat(api)!: remove deprecated endpoints
BREAKING CHANGE: The /v1/users endpoint has been removed. Use /v2/users instead.破坏性变更对应SemVer中的MAJOR版本。
Steps
步骤
-
Review current statebash
git status git diff git log -1 --oneline -
Group changes logically - prefer multiple small commits over one large commit
-
Create commitsFor each logical group:
- Stage relevant files or hunks
- Commit using Conventional Commit format
Option A: Use git commit directly (recommended for agents):bashgit commit -m "feat(auth): add OAuth2 support"Multi-line with body:bashgit commit -m "feat(api): add pagination to list endpoints" \ -m "Implements cursor-based pagination for all list endpoints." \ -m "BREAKING CHANGE: Response format changed from array to object with data/meta keys."Option B: Usenon-interactive mode (streamich/git-cz, not standard cz):git-czbashnpx git-cz --non-interactive --type=feat --scope=auth --subject="add OAuth2 support"With body/breaking changes:bashnpx git-cz --non-interactive \ --type=feat \ --scope=api \ --subject="add pagination to list endpoints" \ --body="Implements cursor-based pagination for all list endpoints" \ --breaking="Response format changed from array to object with data/meta keys"Note: The standard(commitizen/cz-cli) is interactive-only and cannot be used by agents. Usenpx czorgit commitinstead.npx git-cz --non-interactive -
Push the branchbash
git push -u origin HEAD # if no upstream git push # otherwise
-
查看当前状态bash
git status git diff git log -1 --oneline -
按逻辑分组变更——优先选择多个小型提交而非一个大型提交
-
创建提交针对每个逻辑分组:
- 暂存相关文件或代码块
- 使用Conventional Commit格式提交
选项A:直接使用git commit(推荐Agent使用):bashgit commit -m "feat(auth): add OAuth2 support"带正文的多行提交:bashgit commit -m "feat(api): add pagination to list endpoints" \ -m "Implements cursor-based pagination for all list endpoints." \ -m "BREAKING CHANGE: Response format changed from array to object with data/meta keys."选项B:使用非交互模式(streamich/git-cz,非标准cz):git-czbashnpx git-cz --non-interactive --type=feat --scope=auth --subject="add OAuth2 support"带正文/破坏性变更的提交:bashnpx git-cz --non-interactive \ --type=feat \ --scope=api \ --subject="add pagination to list endpoints" \ --body="Implements cursor-based pagination for all list endpoints" \ --breaking="Response format changed from array to object with data/meta keys"注意:标准的(commitizen/cz-cli)仅支持交互式操作,无法被Agent使用。请使用npx cz或git commit替代。npx git-cz --non-interactive -
推送分支bash
git push -u origin HEAD # 若无上游分支 git push # 若已有上游分支
Commit Message Guidelines
提交信息指南
- Description: Use imperative mood ("add" not "added" or "adds")
- Description: Lowercase, no period at end
- Body: Explain what and why, not how
- Footer: Reference issues (,
Fixes #123)Closes #456
- 描述:使用祈使语气(用“add”而非“added”或“adds”)
- 描述:首字母小写,结尾不加句号
- 正文:说明做了什么以及原因,而非实现方式
- 页脚:关联问题(、
Fixes #123)Closes #456
Notes
注意事项
- Do not commit secrets, credentials, or environment files
- Describe intent and impact, not implementation detail
- When in doubt, split commits
- This skill does not perform rebases, squashes, or force pushes
- 请勿提交密钥、凭证或环境文件
- 描述意图和影响,而非实现细节
- 若有疑问,拆分提交
- 本Skill不执行变基、压缩或强制推送操作