用 Claude Code 写了个自动生成 commit message 的工具

35 天前
 trio

标题: 用 Claude Code 开发了一个自动生成 Git commit message 的工具 catmit


各位好,最近一直在使用 Claude Code ,用它完成了一个新工具 catmit 的开发。

这个工具解决的是一个常见痛点:编写高质量的 commit message 。

为什么不用 aicommit 或者 Cursor 或者 Claude Code 本身,因为 aicommit 只支持 OpenAI 、Cursor 已经累觉不爱,Claude Code 需要省点 token 用来干真正的活儿。

catmit 的工作流程: 分析代码差异 → 理解变更上下文 → 生成符合 conventional commit 规范的提交信息 → 预览确认 → 提交

对比示例:

核心特性:

项目地址: https://github.com/penwyp/catmit

安装方法:

欢迎大家试用并提供反馈。

1526 次点击
所在节点    分享创造
5 条回复
kkeep
34 天前
claude -p "/commit-code" 就行了,配置一个 command
trio
34 天前
@kkeep 是的,一直都这么干。所以出发点之一是为了省点 token usage ,全力用 opus4 。
zzerd
34 天前
#### 这玩意我一直用 aichat 命令行工具,配置一个 role 一个 git alias 就行了。用的时候就是 git ai-commit


##### role Library/Application Support/aichat/roles/creage-git-message.md
```markdown
---
model: gemini:gemini-2.5-flash
temperature: 0
---
You are an expert software engineer.
Review the provided context and diffs which are about to be committed to a git repo.
Review the diffs carefully.
Generate a commit message for those changes.
The commit message MUST use the imperative tense.
The commit message should be structured as follows: <type>: <description>
Use these for <type>: fix, feat, build, chore, ci, docs, style, refactor, perf, test
Reply with JUST the commit message, without quotes, comments, questions, etc!

````

##### git alias
```shell
[alias]
ai-commit = "!f() { git commit -m \"$(git diff | aichat -r create-git-message)\"; }; f"
}
```
maximdx
34 天前
我感觉搞个 subagent 更合适一点?
trio
34 天前
@zzerd 这个不错。不过 catmit 还有提 pr ,压缩 commit 的功能,都是我日常用的比较多的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1152419

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX