跳到正文
DEV Community· Mohit·· 3 小時前AI 評分42

SlowCommit:本機優先的 AI Git 提交訊息生成器

I Built SlowCommit: A Local-First AI Git Commit Message Generator 🦥

AI 導讀

SlowCommit 是以 Python 和 Ollama 建構的本機優先 AI Git 提交訊息生成器,會根據已暫存的 Git 變更草擬 Conventional Commit 訊息。它在本機處理變更,並以盡力而為的方式遮蓋常見機密模式;開發者須檢視建議,工具不會自動提交。作者以 qwen2.5-coder:7b 測試,六項自動化測試全部通過。

正文

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady

What I Built

I built SlowCommit 🦥, a local-first AI-powered Git commit message generator using Python and Ollama.

Writing clear commit messages is a repetitive task. SlowCommit helps developers save some effort by generating a concise Conventional Commit message from their staged Git changes.

It reads only the staged diff, applies best-effort redaction for certain common secret patterns, limits the prompt size, and asks a locally running AI model to suggest a message.

The developer reviews the suggestion and decides whether to use it. SlowCommit never commits automatically.

Demo

I tested SlowCommit locally on Windows using qwen2.5-coder:7b.

For a staged README update, it suggested:

docs: add local demo section to README

This is a local command-line application rather than a deployed web app.

Code

GitHub repository: https://github.com/mohit-saini-dev/slowcommit

The project includes a Python CLI, Git staged-diff handling, an Ollama API integration, basic secret-pattern redaction, bounded prompt construction, and automated tests.

How I Built It

I built SlowCommit in Python and integrated it with Git and Ollama.

The tool retrieves staged changes using git diff --cached, processes the diff with safeguards such as best-effort secret redaction and prompt-size limits, and sends it to the local Ollama API.

I tested it with the open-weight qwen2.5-coder:7b model. The project also includes tests for redaction, diff truncation, untrusted prompt framing, and commit-message cleanup. All six tests pass.

Why Does Open Innovation Matter?

Open innovation makes it possible to build useful AI tools without requiring a hosted inference API.

With Ollama, users can run a supported model on their own computer and choose which model suits their hardware and needs. This gives developers more control over their workflow and can reduce dependence on paid cloud inference services.

SlowCommit is designed around that idea: local inference by default, a small and inspectable codebase, and human review before any commit is made.

Local processing does not guarantee that every secret will be detected, so users should still review staged changes and avoid staging sensitive information.

The Lazy Payoff

SlowCommit automates the first draft of a commit message, reducing repetitive writing effort while leaving the final decision to the developer.

I tested it on a real staged README change and received a usable suggestion. I haven't measured a reliable time saving yet, so I won't claim a specific number.

來源:DEV Community · dev.to