git-commit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit Commit Message Skill
Git 提交信息技能
Generate conventional, informative commit messages for Java projects.
为Java项目生成符合Conventional Commits规范、信息详实的提交信息。
When to Use
使用场景
- After making code changes
- User says "commit this" / "commit changes" / "create commit"
- Before creating PRs
- 完成代码变更后
- 用户说出“commit this”/“commit changes”/“create commit”时
- 创建PR之前
Format Standard
格式规范
Use Conventional Commits format:
<type>(<scope>): <subject>
<body>
<footer>使用Conventional Commits格式:
<type>(<scope>): <subject>
<body>
<footer>Types (Java context)
提交类型(Java场景)
- feat: New feature (new API, new functionality)
- fix: Bug fix
- refactor: Code refactoring (no functional change)
- test: Add/update tests
- docs: Documentation only
- perf: Performance improvement
- build: Maven/Gradle changes
- chore: Maintenance (dependency updates, etc)
- feat:新功能(新增API、新功能)
- fix:Bug修复
- refactor:代码重构(无功能变更)
- test:新增/更新测试
- docs:仅文档变更
- perf:性能优化
- build:Maven/Gradle相关变更
- chore:维护性工作(依赖更新等)
Scope Examples (Java specific)
作用域示例(Java专属)
- Module name: ,
core,apiplugin-loader - Component: ,
PluginManagerExtensionFactory - Area: ,
lifecycle,dependenciessecurity
- 模块名:、
core、apiplugin-loader - 组件:、
PluginManagerExtensionFactory - 领域:、
lifecycle、dependenciessecurity
Subject Rules
主题规则
- Imperative mood: "Add support" not "Added support"
- No period at end
- Max 50 chars
- Lowercase after type
- 使用祈使语气:用“Add support”而非“Added support”
- 末尾不加句号
- 最长50个字符
- 类型后首字母小写
Body (optional but recommended)
正文(可选但推荐)
- Explain WHAT and WHY, not HOW
- Wrap at 72 chars
- Reference issues: "Fixes #123" / "Relates to #456"
- 解释“是什么”和“为什么”,而非“怎么做”
- 每行不超过72个字符
- 关联Issue:用“Fixes #123”/“Relates to #456”
Examples
示例
Simple fix
简单修复
fix(plugin-loader): prevent NPE when plugin directory is missing
Check for null before accessing plugin directory to avoid
NullPointerException during initialization.
Fixes #234fix(plugin-loader): prevent NPE when plugin directory is missing
Check for null before accessing plugin directory to avoid
NullPointerException during initialization.
Fixes #234Feature with breaking change
带破坏性变更的功能
feat(api): add support for plugin dependencies versioning
BREAKING CHANGE: PluginDescriptor now requires semantic versioning
format (x.y.z) instead of free-form version strings.
Closes #567feat(api): add support for plugin dependencies versioning
BREAKING CHANGE: PluginDescriptor now requires semantic versioning
format (x.y.z) instead of free-form version strings.
Closes #567Refactoring
重构
refactor(core): extract plugin validation logic
Move validation logic from PluginManager to separate
PluginValidator class for better testability and separation
of concerns.refactor(core): extract plugin validation logic
Move validation logic from PluginManager to separate
PluginValidator class for better testability and separation
of concerns.Test addition
新增测试
test(plugin-loader): add integration tests for plugin loading
Add comprehensive integration tests covering:
- Loading from directory
- Loading from JAR
- Error handling for invalid pluginstest(plugin-loader): add integration tests for plugin loading
Add comprehensive integration tests covering:
- Loading from directory
- Loading from JAR
- Error handling for invalid pluginsBuild/dependency update
构建/依赖更新
build(deps): upgrade Spring Boot to 3.2.1
Update Spring Boot from 3.1.0 to 3.2.1 for security patches
and performance improvements.build(deps): upgrade Spring Boot to 3.2.1
Update Spring Boot from 3.1.0 to 3.2.1 for security patches
and performance improvements.Workflow
工作流程
- Analyze changes using
git diff --staged - Identify scope from modified files
- Determine type based on change nature
- Generate message following format
- Execute commit:
git commit -m "message"
- 分析变更:使用 命令
git diff --staged - 确定作用域:根据修改的文件判断
- 确定提交类型:根据变更性质判断
- 生成提交信息:遵循上述格式
- 执行提交:运行
git commit -m "message"
Token Optimization
Token 优化
- Read staged changes ONCE: + targeted file diffs
git diff --staged --stat - Don't read entire files unless necessary
- Use concise body - aim for 2-3 lines max
- Batch multiple small changes into logical commits
- 仅读取一次暂存区变更:使用 + 目标文件diff
git diff --staged --stat - 除非必要,否则不读取完整文件
- 正文保持简洁,最多2-3行
- 将多个小变更合并为有逻辑的提交
Anti-patterns
反模式
❌ Avoid:
- "fix stuff" / "update code" / "changes"
- "WIP" commits (unless explicitly requested)
- Mixing unrelated changes (use separate commits)
- Over-detailed technical implementation in message
✅ Good commits:
- Single logical change
- Clear, searchable subject
- References issues when applicable
- Explains business value
❌ 应避免:
- “fix stuff”/“update code”/“changes”这类模糊表述
- “WIP”类提交(除非用户明确要求)
- 混合不相关的变更(应拆分提交)
- 提交信息中包含过多技术实现细节
✅ 优秀提交的特点:
- 单一逻辑变更
- 主题清晰、可检索
- 必要时关联Issue
- 说明业务价值
Integration with GitHub
与GitHub集成
After commit, suggest next steps:
- "Push changes?"
- "Create PR for issue #X?"
- "Continue with next task?"
提交完成后,建议后续操作:
- “是否推送变更?”
- “是否为Issue #X创建PR?”
- “是否继续下一个任务?”
Common Patterns for Java Projects
Java项目常见模式
Adding new functionality
新增功能
feat(extension): add support for prioritized extensions
Allow extensions to specify priority order for execution.
Extensions with higher priority run first.
Closes #123feat(extension): add support for prioritized extensions
Allow extensions to specify priority order for execution.
Extensions with higher priority run first.
Closes #123Fixing bugs
修复Bug
fix(classloader): resolve resource lookup in nested JARs
ClassLoader.getResource() was failing for resources in
JARs loaded from plugin JARs (nested JARs). Fixed by
implementing proper resource resolution chain.
Fixes #456fix(classloader): resolve resource lookup in nested JARs
ClassLoader.getResource() was failing for resources in
JARs loaded from plugin JARs (nested JARs). Fixed by
implementing proper resource resolution chain.
Fixes #456Dependency updates
依赖更新
build(deps): bump slf4j from 1.7.30 to 2.0.9
Updates SLF4J to latest stable version. No API changes
required as we use only stable APIs.build(deps): bump slf4j from 1.7.30 to 2.0.9
Updates SLF4J to latest stable version. No API changes
required as we use only stable APIs.Documentation improvements
文档优化
docs(readme): add plugin development quickstart guide
Add step-by-step guide for creating first plugin:
- Project setup
- Implementing Plugin interface
- Building and testingdocs(readme): add plugin development quickstart guide
Add step-by-step guide for creating first plugin:
- Project setup
- Implementing Plugin interface
- Building and testingPerformance optimizations
性能优化
perf(plugin-loader): cache plugin descriptors
Cache parsed plugin descriptors to avoid repeated I/O
and parsing. Reduces plugin loading time by ~40%.
Related to #789perf(plugin-loader): cache plugin descriptors
Cache parsed plugin descriptors to avoid repeated I/O
and parsing. Reduces plugin loading time by ~40%.
Related to #789Multi-file Changes
多文件变更
When changes span multiple components:
refactor(core): reorganize plugin lifecycle management
- Extract lifecycle state machine to separate class
- Move validation logic to validators package
- Update tests to reflect new structure
This refactoring improves testability and separation
of concerns without changing external APIs.
Related to #111, #222当变更涉及多个组件时:
refactor(core): reorganize plugin lifecycle management
- Extract lifecycle state machine to separate class
- Move validation logic to validators package
- Update tests to reflect new structure
This refactoring improves testability and separation
of concerns without changing external APIs.
Related to #111, #222Breaking Changes
破坏性变更
Always use BREAKING CHANGE footer:
feat(api)!: replace Plugin.start() with Plugin.initialize()
BREAKING CHANGE: The Plugin.start() method has been renamed
to Plugin.initialize() for better semantic clarity. All
plugin implementations must update their code.
Migration guide: Replace @Override start() with @Override
initialize() in all Plugin implementations.
Closes #999始终使用BREAKING CHANGE页脚:
feat(api)!: replace Plugin.start() with Plugin.initialize()
BREAKING CHANGE: The Plugin.start() method has been renamed
to Plugin.initialize() for better semantic clarity. All
plugin implementations must update their code.
Migration guide: Replace @Override start() with @Override
initialize() in all Plugin implementations.
Closes #999Quick Reference Card
快速参考卡
| Change Type | Type | Example Scope |
|---|---|---|
| New feature | feat | api, core, loader |
| Bug fix | fix | plugin-loader, lifecycle |
| Refactoring | refactor | core, utils |
| Tests | test | integration, unit |
| Docs | docs | readme, javadoc |
| Build | build | maven, deps |
| Performance | perf | classloader, cache |
| Maintenance | chore | ci, tooling |
| 变更类型 | 类型标识 | 作用域示例 |
|---|---|---|
| 新功能 | feat | api, core, loader |
| Bug修复 | fix | plugin-loader, lifecycle |
| 重构 | refactor | core, utils |
| 测试 | test | integration, unit |
| 文档 | docs | readme, javadoc |
| 构建 | build | maven, deps |
| 性能 | perf | classloader, cache |
| 维护 | chore | ci, tooling |