I built LocalCommit, a lightweight CLI tool that inspects your staged git diffs and drafts concise Conventional Commit messages (feat(auth): add refresh token rotation) running entirely on your local machine using Ollama.
I built this for my friend Manish, a software engineer working under strict client non-disclosure agreements. Manish's team requires strict Conventional Commits for automated changelogs and semantic releases, but company policy strictly forbids piping source code or git diffs to proprietary cloud LLM APIs (like OpenAI or Anthropic). Whenever Manish makes multi-file changes across large codebases, writing detailed conventional commit messages by hand slows down their workflow.
LocalCommit solves this by reading git diff --staged and running inference on an open-weights model locally. Zero tokens leave the machine, no API keys are required, and the tool works even when working offline on a train or during an internet outage.
Demo
Here is how running LocalCommit looks in terminal:
$ git add src/auth/token.ts src/middleware/jwt.ts
$ npx localcommit
[localcommit] Checking staged changes...
[localcommit] Sending diff to qwen2.5-coder:3b...
Proposed commit message:
feat(auth): implement refresh token rotation and validation
Commit with this message? [y/N/e (edit)/r (regenerate)]: y
[main 7f2a1b9] feat(auth): implement refresh token rotation and validation
2 files changed, 48 insertions(+), 6 deletions(-)
You can confirm with [y] to commit immediately, hit [e] to edit in place, [r] to regenerate with a slightly different phrasing, or [n] to cancel without touching git state.
Code
The source code and setup instructions are open source on GitHub:
Local-first CLI for generating conventional commit messages via Ollama.
LocalCommit
Local-first CLI for generating conventional commit messages with Ollama.
LocalCommit reads your staged Git diff, generates a Conventional Commit message
with the configured local model, and asks for confirmation before committing.
Requirements
Node.js 18+
Git CLI
Ollama
A model configured in the root model file (default: qwen2.5-coder:3b)
If Ollama is not installed, follow the platform-specific instructions in
INSTRUCTION.md.
Setup
npm run setup
The setup command verifies Node.js and Git, checks that Ollama is running,
downloads qwen2.5-coder:3b if it is missing, installs dependencies, and
builds the project.
If setup reports that Ollama is unavailable, install it and start the Ollama
service by following INSTRUCTION.md.
Usage
Start Ollama in a separate terminal if it is not already running:
ollama serve
Stage your changes in a Git repository, then run:
npx localcommit
Inside a checkout of this project, npx localcommit resolves the local package
binary. To use it from…
LocalCommit is written in TypeScript and connects to Ollama (https://ollama.com/) running locally:
Default Model: By default, it targets qwen2.5-coder:3b—a fast, open-weights code model capable of running with low latency on modest CPU or laptop GPU hardware without draining battery.
Context Auto-Detection: Instead of assuming a static token limit, LocalCommit queries Ollama's /api/ps and /api/show endpoints at runtime to discover the exact context window allocated by your environment.
Two-Stage Summarization for Large Diffs:
Small diffs fit in a single prompt and produce an immediate message.
For larger, multi-file changes exceeding the context window, it switches to a hierarchical strategy: it prioritizes source code files (src/, tests/), generates concise per-file summaries bounded by a strict 60-second budget, and feeds that synthesized context into a final commit prompt.
Deterministic Post-Processing: Small local models can occasionally output markdown fences or descriptive preambles. LocalCommit passes the raw output through a deterministic formatting engine that enforces standard type(scope): subject syntax, cleans generic scopes, and converts verbs into imperative mood (add, fix, refactor).
Cross-Platform Host Detection: Handles network boundary quirks across Linux, macOS, Windows, and containerized setups (like Docker) by probing OLLAMA_HOST, 127.0.0.1:11434, and localhost:11434.
Why Does Open Innovation Matter?
Open-weights models and local runtimes like Ollama make use cases possible that cloud AI endpoints fundamentally cannot support:
Complete Data Sovereignty & Privacy: Codebases under NDAs, proprietary IP, or internal air-gapped networks cannot send raw git diffs over external APIs. Open models let developers use AI assistance without ever leaking code.
Offline Reliability: You don't need active Wi-Fi, metered bandwidth, or cloud service uptime to commit your work.
Zero Ongoing Costs & No API Keys: Developers don't have to manage credit cards, rate limits, or monthly token bills.
Flexibility to Swap Models: You can drop in any local model (e.g. llama3.2, codellama, deepseek-coder) simply by editing the model file or setting the LOCALCOMMIT_MODEL environment variable.
My Agent Session
The development session where I debugged the container connectivity issues and fixed the Ollama host resolution:
LocalCommit: Fixing cross-platform Ollama connectivity for containers
You
The setup script and CLI are failing to connect to Ollama in GitHub Codespaces because localhost resolves to ::1 but Ollama binds to [REDACTED]. Need multi-host resolution and proper URL construction.
Agent
I'll create a shared Ollama client utility for host resolution and fix both the setup script and CLI.