关于 git-commit
为 Java 项目编写 Conventional Commits 提交信息的 Skill。它分析暂存区变更以选择类型和范围,并生成简洁主题及可选正文。
主要功能
- 01分析暂存区变更
- 02选择提交类型和范围
- 03编写规范提交主题
- 04添加可选正文和问题引用
- 05处理破坏性变更页脚
适用场景
- 01代码修改后编写提交信息
- 02创建 PR 前准备提交
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ decebals/ claude-code-java --skill git-commit安装后在 Claude Code 中输入/git-commit确认已加载。
附带文件README.md
详细介绍
Git 提交消息技能
为 Java 项目生成符合规范且信息明确的提交消息。
适用场景
- 完成代码更改后
- 用户说“提交此更改”/“提交更改”/“创建提交”
- 创建 PR 之前
格式规范
使用 Conventional Commits 格式:
<type>(<scope>): <subject>
<body>
<footer>
类型(Java 上下文)
- feat:新功能(新 API、新功能)
- fix:修复错误
- refactor:重构代码(不改变功能)
- test:添加/更新测试
- docs:仅修改文档
- perf:性能改进
- build:Maven/Gradle 更改
- chore:维护(更新依赖等)
范围示例(Java 专用)
- 模块名称:
core、api、plugin-loader - 组件:
PluginManager、ExtensionFactory - 领域:
lifecycle、dependencies、security
主题规则
- 使用祈使语气:“Add support”,而不是“Added support”
- 末尾不加句号
- 最多 50 个字符
- 类型后使用小写字母
正文(可选,但建议填写)
- 说明是什么以及为什么,而不是如何实现
- 每行不超过 72 个字符
- 引用问题:“Fixes #123”/“Relates to #456”
示例
简单修复
fix(plugin-loader): prevent NPE when plugin directory is missing
Check for null before accessing plugin directory to avoid
NullPointerException during initialization.
Fixes #234
包含破坏性更改的功能
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
重构
refactor(core): extract plugin validation logic
Move validation logic from PluginManager to separate
PluginValidator class for better testability and separation
of concerns.
添加测试
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(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.
工作流
- 使用
git diff --staged分析更改 - 根据修改的文件确定范围
- 根据更改性质确定类型
- 按照格式生成消息
- 执行提交:
git commit -m "message"
令牌优化
- 只读取一次暂存的更改:
git diff --staged --stat和针对性文件差异 - 除非必要,否则不要读取整个文件
- 正文保持简洁,最多 2~3 行
- 将多个小更改合并为逻辑清晰的提交
反模式
❌ 避免:
- “fix stuff”/“update code”/“changes”
- “WIP” 提交(除非用户明确要求)
- 混合无关更改(使用单独的提交)
- 在消息中详细描述技术实现
✅ 优质提交:
- 只包含一项逻辑清晰的更改
- 主题明确且便于搜索
- 适用时引用问题
- 说明业务价值
与 GitHub 集成
提交后,建议下一步操作:
- “推送更改?”
- “为问题 #X 创建 PR?”
- “继续下一个任务?”
Java 项目的常见模式
添加新功能
feat(extension): add support for prioritized extensions
Allow extensions to specify priority order for execution.
Extensions with higher priority run first.
Closes #123
修复错误
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
更新依赖
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.
改进文档
docs(readme): add plugin development quickstart guide
Add step-by-step guide for creating first plugin:
- Project setup
- Implementing Plugin interface
- Building and testing
优化性能
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
多文件更改
当更改涉及多个组件时:
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 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
快速参考卡
| 更改类型 | 类型 | 范围示例 |
|---|---|---|
| 新功能 | feat | api、core、loader |
| 错误修复 | fix | plugin-loader、lifecycle |
| 重构 | refactor | core、utils |
| 测试 | test | integration、unit |
| 文档 | docs | readme、javadoc |
| 构建 | build | maven、deps |
| 性能 | perf | classloader、cache |
| 维护 | chore | ci、tooling |
参考资料
评论
支持 Markdown