用 Claude Code 写了个自动生成 commit message 的工具 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
trio
V2EX    分享创造

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

  •  
  •   trio 59 天前 1595 次点击
    这是一个创建于 59 天前的主题,其中的信息可能已经有所发展或是发生改变。

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


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

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

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

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

    对比示例:

    • 传统写法:"修复认证 bug"

    • catmit 生成:

      fix(auth): 解决 token 验证的竞态条件问题 - 添加互斥锁防止并发刷新 token - 更新过期 token 的错误处理逻辑 

    核心特性:

    • 使用 Go 开发,性能优秀,提供友好的终端界面
    • 支持智能合并多个提交
    • 中英文双语支持
    • 集成 PR 创建功能,自动生成描述
    • 大型代码库优化,智能分析重要文件
    • 支持 OpenAI 、Azure 、Ollama 等多种 AI 服务

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

    安装方法:

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

    7 条回复    2025-09-21 23:18:28 +08:00
    kkeep
        1
    kkeep  
       58 天前
    claude -p "/commit-code" 就行了,配置一个 command
    trio
        2
    trio  
    OP
       58 天前
    @kkeep 是的,一直都这么干。所以出发点之一是为了省点 token usage ,全力用 opus4 。
    zzerd
        3
    zzerd  
       58 天前
    #### 这玩意我一直用 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
        4
    maximdx  
       58 天前
    我感觉搞个 subagent 更合适一点?
    trio
        5
    trio  
    OP
       58 天前
    @zzerd 这个不错。不过 catmit 还有提 pr ,压缩 commit 的功能,都是我日常用的比较多的。
    yyzq007
        6
    yyzq007  
       23 天前
    感谢, 已经用起来了~
    trio
        7
    trio  
    OP
       20 天前
    @yyzq007 多谢支持
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2699 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 23ms UTC 12:07 PVG 20:07 LAX 05:07 JFK 08:07
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86