aif-commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Conventional Commit Generator

Conventional Commit 提交信息生成器

Generate commit messages following the Conventional Commits specification.
生成遵循Conventional Commits规范的提交信息。

Workflow

工作流程

  1. Analyze Changes
    • Run
      git status
      to see staged files
    • Run
      git diff --cached
      to see staged changes
    • If nothing staged, show warning and suggest staging
  2. Determine Commit Type
    • feat
      : New feature
    • fix
      : Bug fix
    • docs
      : Documentation only
    • style
      : Code style (formatting, semicolons)
    • refactor
      : Code change that neither fixes a bug nor adds a feature
    • perf
      : Performance improvement
    • test
      : Adding or modifying tests
    • build
      : Build system or dependencies
    • ci
      : CI configuration
    • chore
      : Maintenance tasks
  3. Identify Scope
    • From file paths (e.g.,
      src/auth/
      auth
      )
    • From argument if provided
    • Optional - omit if changes span multiple areas
  4. Generate Message
    • Keep subject line under 72 characters
    • Use imperative mood ("add" not "added")
    • Don't capitalize first letter after type
    • No period at end of subject
  1. 分析变更
    • 运行
      git status
      查看已暂存文件
    • 运行
      git diff --cached
      查看暂存的变更内容
    • 若没有暂存任何内容,显示警告并建议进行暂存操作
  2. 确定提交类型
    • feat
      : 新增功能
    • fix
      : Bug修复
    • docs
      : 仅修改文档
    • style
      : 代码样式调整(如格式化、分号修改)
    • refactor
      : 代码重构(既不修复Bug也不添加新功能)
    • perf
      : 性能优化
    • test
      : 添加或修改测试
    • build
      : 构建系统或依赖项变更
    • ci
      : CI配置变更
    • chore
      : 维护任务
  3. 确定提交范围
    • 从文件路径提取(例如:
      src/auth/
      auth
    • 若用户提供参数则使用该参数作为范围
    • 可选:若变更涉及多个领域则省略范围
  4. 生成提交信息
    • 主题行长度不超过72个字符
    • 使用祈使语气(如用"add"而非"added")
    • 类型后的第一个单词首字母无需大写
    • 主题末尾不要加句号

Format

格式

<type>(<scope>): <subject>

<body>

<footer>
<type>(<scope>): <subject>

<body>

<footer>

Examples

示例

Simple feature:
feat(auth): add password reset functionality
Bug fix with body:
fix(api): handle null response from payment gateway

The payment API can return null when the gateway times out.
Added null check and retry logic.

Fixes #123
Breaking change:
feat(api)!: change response format for user endpoint

BREAKING CHANGE: user endpoint now returns nested profile object
简单功能提交:
feat(auth): add password reset functionality
带正文的Bug修复提交:
fix(api): handle null response from payment gateway

The payment API can return null when the gateway times out.
Added null check and retry logic.

Fixes #123
破坏性变更提交:
feat(api)!: change response format for user endpoint

BREAKING CHANGE: user endpoint now returns nested profile object

Behavior

行为逻辑

When invoked:
  1. Check for staged changes
  2. Analyze the diff content
  3. Propose a commit message
  4. Ask for confirmation or modifications
  5. Execute
    git commit
    with the message
  6. After a successful commit, offer to push:
    • Show branch/ahead status:
      git status -sb
    • If the branch has no upstream, use:
      git push -u origin <branch>
    • Otherwise:
      git push
    • User choice:
      • Push now
      • Skip push
If argument provided (e.g.,
/aif-commit auth
):
  • Use it as the scope
  • Or as context for the commit message
当被调用时:
  1. 检查是否有暂存的变更
  2. 分析差异内容
  3. 生成提交信息提案
  4. 请求用户确认或修改
  5. 使用该信息执行
    git commit
    命令
  6. 提交成功后,提供推送选项:
    • 显示分支/超前状态:
      git status -sb
    • 若分支没有上游分支,使用命令:
      git push -u origin <branch>
    • 否则使用:
      git push
    • 用户可选择:
      • 立即推送
      • 跳过推送
若提供参数(例如:
/aif-commit auth
):
  • 将其作为提交范围
  • 或作为提交信息的上下文

Important

注意事项

  • Never commit secrets or credentials
  • Review large diffs carefully before committing
  • Suggest splitting if changes are unrelated
  • Add Co-Authored-By for pair programming if mentioned
  • 切勿提交密钥或凭证
  • 提交前仔细检查大的差异内容
  • 若变更内容不相关,建议拆分提交
  • 若涉及结对编程,添加Co-Authored-By信息