git-commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Git 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
    ,
    api
    ,
    plugin-loader
  • Component:
    PluginManager
    ,
    ExtensionFactory
  • Area:
    lifecycle
    ,
    dependencies
    ,
    security
  • 模块名:
    core
    、
    api
    、
    plugin-loader
  • 组件:
    PluginManager
    、
    ExtensionFactory
  • 领域:
    lifecycle
    、
    dependencies
    、
    security

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 #234
fix(plugin-loader): prevent NPE when plugin directory is missing

Check for null before accessing plugin directory to avoid
NullPointerException during initialization.

Fixes #234

Feature 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 #567
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 #567

Refactoring

重构

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 plugins
test(plugin-loader): add integration tests for plugin loading

Add comprehensive integration tests covering:
- Loading from directory
- Loading from JAR
- Error handling for invalid plugins

Build/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

工作流程

  1. Analyze changes using
    git diff --staged
  2. Identify scope from modified files
  3. Determine type based on change nature
  4. Generate message following format
  5. Execute commit:
    git commit -m "message"
  1. 分析变更:使用
    git diff --staged
    命令
  2. 确定作用域:根据修改的文件判断
  3. 确定提交类型:根据变更性质判断
  4. 生成提交信息:遵循上述格式
  5. 执行提交:运行
    git commit -m "message"

Token Optimization

Token 优化

  • Read staged changes ONCE:
    git diff --staged --stat
    + targeted file diffs
  • Don't read entire files unless necessary
  • Use concise body - aim for 2-3 lines max
  • Batch multiple small changes into logical commits
  • 仅读取一次暂存区变更:使用
    git diff --staged --stat
    + 目标文件diff
  • 除非必要,否则不读取完整文件
  • 正文保持简洁,最多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 #123
feat(extension): add support for prioritized extensions

Allow extensions to specify priority order for execution.
Extensions with higher priority run first.

Closes #123

Fixing 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 #456
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 #456

Dependency 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 testing
docs(readme): add plugin development quickstart guide

Add step-by-step guide for creating first plugin:
- Project setup
- Implementing Plugin interface
- Building and testing

Performance 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 #789
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 #789

Multi-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, #222

Breaking 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 #999

Quick Reference Card

快速参考卡

Change TypeTypeExample Scope
New featurefeatapi, core, loader
Bug fixfixplugin-loader, lifecycle
Refactoringrefactorcore, utils
Teststestintegration, unit
Docsdocsreadme, javadoc
Buildbuildmaven, deps
Performanceperfclassloader, cache
Maintenancechoreci, tooling
变更类型类型标识作用域示例
新功能featapi, core, loader
Bug修复fixplugin-loader, lifecycle
重构refactorcore, utils
测试testintegration, unit
文档docsreadme, javadoc
构建buildmaven, deps
性能perfclassloader, cache
维护choreci, tooling

References

参考资料