commit-creator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Committing

代码提交

Format

格式

Language Requirement

语言要求

Always write in English only
text
<type>(<scope>): summary
  • Summary: ≤50 chars, imperative mood, no period
  • Scope: Module/package name (monorepo: exact package name or
    all
    )
  • Body (optional): Bullet list
    - {emoji} {text}
    (≤100 chars/line). One bullet = one logical change. Do not group multiple items on a single line.
  • Breaking: Add
    !
    after type and
    BREAKING CHANGE:
    footer
  • Issues: End the body with a bullet like
    - Fixes #123
    or
    - Fixes PROJ-456
  • No co-authorship: Never add
    Co-authored-by:
    ,
    Co-Authored-By:
    , or any attribution to Copilot, AI assistants, or automated tools at the end of commit messages
Types: feat ✨, fix 🐛, docs 📚, style 💄, refactor ♻️, perf ⚡, test ✅, build 🔧, ci 👷, chore 🔨, revert ⏪
始终仅使用英文编写
text
<type>(<scope>): summary
  • 摘要:≤50个字符,使用祈使语气,末尾不加句号
  • 范围:模块/包名称(单仓库monorepo:精确包名或
    all
  • 正文(可选):使用项目符号列表
    - {emoji} {text}
    (每行≤100字符)。一个项目符号对应一个逻辑变更,不要将多个项合并到同一行。
  • 破坏性变更:在类型后添加
    !
    ,并在页脚添加
    BREAKING CHANGE:
  • 关联问题:在正文末尾添加项目符号,如
    - Fixes #123
    - Fixes PROJ-456
  • 不添加共同作者:永远不要在提交信息末尾添加
    Co-authored-by:
    Co-Authored-By:
    或任何关于Copilot、AI助手或自动化工具的署名
类型:feat ✨(新功能)、fix 🐛(问题修复)、docs 📚(文档更新)、style 💄(代码格式)、refactor ♻️(代码重构)、perf ⚡(性能优化)、test ✅(测试相关)、build 🔧(构建配置)、ci 👷(持续集成)、chore 🔨(杂项任务)、revert ⏪(提交回滚)

Workflow

工作流程

Branch check

分支检查

Before committing, check the current branch:
bash
git branch --show-current
git remote show origin | grep "HEAD branch"
If the current branch is the default branch (e.g.
master
,
main
) and the user has not explicitly indicated they want to commit to it, ask the user:
  • Create a new branch and commit there
  • Commit directly to the current (default) branch
Wait for user's answer before proceeding.
If the user explicitly stated the target branch in their request (e.g. "commit to master", "commit here"), skip the question and proceed.
提交前,检查当前分支:
bash
git branch --show-current
git remote show origin | grep "HEAD branch"
如果当前分支是默认分支(如
master
main
且用户未明确表示要提交到该分支,请询问用户:
  • 创建新分支并在该分支提交
  • 直接提交到当前(默认)分支
等待用户回复后再继续操作。
如果用户在请求中明确指定了目标分支(如“提交到master”、“在此处提交”),则跳过询问直接执行。

Staging behavior

暂存行为

When both staged and unstaged changes exist in the working directory, and interaction is available:
  • Ask the user whether to:
    • Stage all files before committing
    • Commit only the currently staged changes
当工作目录中同时存在已暂存和未暂存的变更,且支持交互时:
  • 询问用户选择:
    • 提交前暂存所有文件
    • 仅提交当前已暂存的变更

Running git commit

执行Git提交

After executing
git commit
, wait for the process to exit on its own — do not interrupt or kill it. Pre-commit hooks (linters, type checkers, test runners) can run for a long time without producing any output. Killing the process mid-run causes an exit code 130 (SIGINT) and leaves the working tree in a dirty state.
执行
git commit
后,等待进程自行退出——不要中断或终止它。提交前钩子(linters代码检查、类型检查、测试运行器)可能会长时间运行且无输出。中途终止进程会导致退出码130(SIGINT),并使工作树处于脏状态。

Commit error handling

提交错误处理

Exit code 130 (interrupted):
The commit process was interrupted — this is not a validation failure. Do not auto-retry. Report that the commit was interrupted and ask the user whether to:
  • Try again
  • Cancel
Any other non-zero exit code (validation failure):
If the commit fails (e.g., due to pre-commit hooks, linting failures, or other validation errors):
  • Report the exact error message and reasons for the failure
  • Ask the user whether to:
    • Commit with
      --no-verify
      flag to bypass hooks
    • Attempt to fix the issues automatically
    • Let the user fix the issues manually
退出码130(已中断):
提交进程被中断——这不是验证失败。请勿自动重试。告知用户提交已中断,并询问用户选择:
  • 重试
  • 取消
其他非零退出码(验证失败):
如果提交失败(例如,由于提交前钩子、代码检查失败或其他验证错误):
  • 报告确切的错误信息和失败原因
  • 询问用户选择:
    • 使用
      --no-verify
      标志绕过钩子提交
    • 尝试自动修复问题
    • 让用户手动修复问题

Examples

示例

Simple feature:
text
feat(button): add loading state

- ✨ Add spinner icon during async operations
- 📦 @ui/icons: v1.0.0 → v1.1.0
- Fixes #42
Breaking change:
text
feat(theme)!: redesign color tokens

- ✨ Replace RGB values with HSL format
- 💄 Update all component styles to use new tokens
- 📦 @ui/theme: v2.1.0 → v3.0.0

BREAKING CHANGE: Color token values changed from RGB to HSL format
For more examples, see references/examples.md
简单功能提交:
text
feat(button): add loading state

- ✨ Add spinner icon during async operations
- 📦 @ui/icons: v1.0.0 → v1.1.0
- Fixes #42
破坏性变更提交:
text
feat(theme)!: redesign color tokens

- ✨ Replace RGB values with HSL format
- 💄 Update all component styles to use new tokens
- 📦 @ui/theme: v2.1.0 → v3.0.0

BREAKING CHANGE: Color token values changed from RGB to HSL format
更多示例,请查看references/examples.md