aif-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConventional Commit Generator
Conventional Commit 提交信息生成器
Generate commit messages following the Conventional Commits specification.
生成遵循Conventional Commits规范的提交信息。
Workflow
工作流程
-
Analyze Changes
- Run to see staged files
git status - Run to see staged changes
git diff --cached - If nothing staged, show warning and suggest staging
- Run
-
Determine Commit Type
- : New feature
feat - : Bug fix
fix - : Documentation only
docs - : Code style (formatting, semicolons)
style - : Code change that neither fixes a bug nor adds a feature
refactor - : Performance improvement
perf - : Adding or modifying tests
test - : Build system or dependencies
build - : CI configuration
ci - : Maintenance tasks
chore
-
Identify Scope
- From file paths (e.g., →
src/auth/)auth - From argument if provided
- Optional - omit if changes span multiple areas
- From file paths (e.g.,
-
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
-
分析变更
- 运行查看已暂存文件
git status - 运行查看暂存的变更内容
git diff --cached - 若没有暂存任何内容,显示警告并建议进行暂存操作
- 运行
-
确定提交类型
- : 新增功能
feat - : Bug修复
fix - : 仅修改文档
docs - : 代码样式调整(如格式化、分号修改)
style - : 代码重构(既不修复Bug也不添加新功能)
refactor - : 性能优化
perf - : 添加或修改测试
test - : 构建系统或依赖项变更
build - : CI配置变更
ci - : 维护任务
chore
-
确定提交范围
- 从文件路径提取(例如:→
src/auth/)auth - 若用户提供参数则使用该参数作为范围
- 可选:若变更涉及多个领域则省略范围
- 从文件路径提取(例如:
-
生成提交信息
- 主题行长度不超过72个字符
- 使用祈使语气(如用"add"而非"added")
- 类型后的第一个单词首字母无需大写
- 主题末尾不要加句号
Format
格式
<type>(<scope>): <subject>
<body>
<footer><type>(<scope>): <subject>
<body>
<footer>Examples
示例
Simple feature:
feat(auth): add password reset functionalityBug 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 #123Breaking 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 objectBehavior
行为逻辑
When invoked:
- Check for staged changes
- Analyze the diff content
- Propose a commit message
- Ask for confirmation or modifications
- Execute with the message
git commit - 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
- Show branch/ahead status:
If argument provided (e.g., ):
/aif-commit auth- Use it as the scope
- Or as context for the commit message
当被调用时:
- 检查是否有暂存的变更
- 分析差异内容
- 生成提交信息提案
- 请求用户确认或修改
- 使用该信息执行命令
git commit - 提交成功后,提供推送选项:
- 显示分支/超前状态:
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信息