V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
trio
V2EX  ›  分享创造

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

  •  
  •   trio · 2 天前 · 911 次点击

    标题: 用 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

    安装方法:

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

    5 条回复    2025-08-15 15:26:49 +08:00
    kkeep
        1
    kkeep  
       2 天前
    claude -p "/commit-code" 就行了,配置一个 command
    trio
        2
    trio  
    OP
       2 天前
    @kkeep 是的,一直都这么干。所以出发点之一是为了省点 token usage ,全力用 opus4 。
    zzerd
        3
    zzerd  
       2 天前
    #### 这玩意我一直用 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  
       2 天前
    我感觉搞个 subagent 更合适一点?
    trio
        5
    trio  
    OP
       2 天前
    @zzerd 这个不错。不过 catmit 还有提 pr ,压缩 commit 的功能,都是我日常用的比较多的。
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2637 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 09:26 · PVG 17:26 · LAX 02:26 · JFK 05:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.