# LocalCommit: Offline Conventional Git Commits with Local LLMs

> Source: <https://dev.to/gaurav0s/localcommit-offline-conventional-git-commits-with-local-llms-opk>
> Published: 2026-10-04 21:20:48+00:00

*This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend ([https://dev.to/challenges/hacktoberfest-weekend-2026-10-01](https://dev.to/challenges/hacktoberfest-weekend-2026-10-01))*

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.

Here is how running LocalCommit looks in terminal:

``` bash
$ 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.
```

The source code and setup instructions are open source on GitHub:

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.

`model` file (default: `qwen2.5-coder:3b`)
If Ollama is not installed, follow the platform-specific instructions in
[INSTRUCTION.md](https://github.com/Gaurav5189/LocalCommit/INSTRUCTION.md).

```
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](https://github.com/Gaurav5189/LocalCommit/INSTRUCTION.md).

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/](https://ollama.com/)) running locally:

`/api/show` endpoints at runtime to discover the exact context window allocated by your environment.
Open-weights models and local runtimes like Ollama make use cases possible that cloud AI endpoints fundamentally cannot support:

The development session where I debugged the container connectivity issues and fixed the Ollama host resolution:

This project is open source and available under the MIT License.
