commit
Commit Message Generator
根据暂存的代码变更自动生成符合 Conventional Commits 规范的提交信息,并自动添加对应的 emoji 前缀。
使用场景
- 用户执行
/commit命令 - 用户请求生成提交信息
- 用户需要帮助编写符合规范的 commit message
工作流程
1. 检查暂存状态
执行 git status 查看当前暂存的文件变更。如果没有暂存的文件,提示用户先使用 git add 添加文件。
2. 分析代码变更
执行 git diff --cached 获取暂存的代码差异,分析变更内容:
- 识别变更的文件类型和位置
- 理解变更的目的(新功能、修复、重构等)
- 确定影响范围(scope)
3. 生成提交信息
根据分析结果生成符合规范的提交信息。
消息格式:
type(scope): subject
允许的类型和对应 emoji:
| 类型 | Emoji | 说明 | 示例 |
|---|---|---|---|
| feat | ✨ | 新功能 | ✨ feat: add user authentication |
| fix | 🐛 | Bug 修复 | 🐛 fix: resolve login timeout |
| docs | 📝 | 文档变更 | 📝 docs: update API documentation |
| style | 🎨 | 代码风格 | 🎨 style: format code with prettier |
| refactor | ♻️ | 代码重构 | ♻️ refactor: extract common utils |
| perf | ⚡️ | 性能优化 | ⚡️ perf: optimize database queries |
| test | ✅ | 测试相关 | ✅ test: add unit tests for auth |
| build | 🏗️ | 构建系统 | 🏗️ build: update webpack config |
| ci | 👷 | CI 配置 | 👷 ci: add GitHub Actions workflow |
| chore | 🔧 | 其他变更 | 🔧 chore: update dependencies |
4. 执行提交
使用 HEREDOC 格式执行 git commit:
git commit -m "$(cat <<'EOF'
✨ feat(auth): add user login feature
EOF
)"
提交信息编写规则
Header 规则
- 格式:
emoji type(scope): subject - Header 最大长度:250 字符
- type 必须是允许的类型之一
- scope 可选,表示影响范围
- subject 使用祈使句,首字母小写,不加句号
类型选择指南
- feat: 添加新功能或新特性
- fix: 修复 bug 或问题
- docs: 仅文档变更(README、注释等)
- style: 不影响代码含义的变更(格式化、空格等)
- refactor: 既不是新功能也不是修复的代码变更
- perf: 提升性能的代码变更
- test: 添加或修改测试
- build: 影响构建系统或外部依赖的变更
- ci: CI 配置文件和脚本的变更
- chore: 其他不修改 src 或 test 文件的变更
Scope 建议
根据项目结构选择合适的 scope:
- 按模块:
auth、api、ui、db - 按功能:
login、payment、search - 按目录:
components、hooks、utils
注意事项
- 不要提交包含敏感信息的文件(.env、credentials 等)
- 提交前确保代码通过 lint 和类型检查
- 一次提交只做一件事,保持提交的原子性
- 提交信息要准确反映变更内容,关注"为什么"而非"做了什么"
参考资源
详细的提交规范和项目配置,参考:
references/commit-convention.md- 完整的提交规范文档references/commit-examples.md- 提交信息示例
More from adonis0123/adonis-skills
staged-changes-review
Checklist-driven review of staged Git changes with deterministic rule scanning and semantic analysis. Use when the user wants to review staged changes, check for errors before commit, or validate code quality before committing.
25ruler-rules-init
Migrate and bootstrap Ruler-based AI rules across repositories with English-first templates, preset-based project detection, and safe, idempotent setup. Use when creating or standardizing `.ruler/*` files, generating `AGENTS.md`/`CLAUDE.md`, wiring `ruler:apply` into `package.json`, adding generated-file ignores in `.gitignore`, and designing `applyTo` scoping patterns such as `**` and `web/**`.
18discuss-before-plan
Enforces 'decide then plan' discipline - the pre-planning decision gate. Use when the user asks for a plan or starts a change while key decisions are unresolved: architecture tradeoffs, data flow, public interfaces, unclear requirements, multi-module scope, or roughly 5+ files affected. Also triggers when the user explicitly wants to discuss, compare options, or review architecture before committing. Core job: reduce incorrect-execution cost by confirming decisions before producing executable plans.
17claude-skills-sync-init
Bootstrap Claude skill-sync automation in any repository. Use when users ask to set up `.agents/skills` to `.claude/skills` syncing, generate `skills:sync:*` scripts, inject package.json scripts/postinstall hooks, or initialize this sync workflow in a new or existing project.
16staged-review-validator
Validate staged-changes-review findings with evidence-based verdicts and minimal-fix guidance. Use when you need to confirm whether each reported issue is valid and actionable.
14tailwindcss-next-init
Initialize Tailwind CSS v4 and Iconify for Next.js App Router projects with script-driven templates. Use when you need a fast setup or migration with consistent style-entry conventions.
12