Stop Writing Bad Commit Messages: Let OpenCommit Generate Them With AI
You know the feeling. You've just fixed a nasty bug or added a feature, and now you stare at the terminal trying to come up with a commit message that's actually meaningful. Most of the time you type something like "fixed stuff" or "update" and move on, knowing full well that future you (or your teammates) will curse that vague message. OpenCommit is a CLI tool that solves this exact problem by auto-generating descriptive commit messages from your staged changes using AI. It's a simple, practical tool that won the GitHub 2023 hackathon, and all the commits in its own repository were written by the tool itself.
What It Does
OpenCommit is a Node.js CLI tool that you install globally with npm. When you run the oco command in a Git repository, it analyzes your staged changes and sends the diff to an AI provider (like OpenAI or local models via Ollama or llama.cpp) to generate a commit message. The tool then creates the commit with that message automatically.
The architecture is straightforward: you configure an API key once, and the tool handles the rest. It stores your API key locally in ~/.opencommit config file. You can run git add beforehand, but you don't have to -- OpenCommit will stage your changes for you. The generated commit messages include emojis and long descriptions by default, but these are configurable. The README mentions that "basically everything is" configurable, though it doesn't detail every option.
What makes this interesting is the flexibility in AI providers. You're not locked into OpenAI. The tool supports running locally with Ollama using models like Mistral or Llama 3, and it also works with llama.cpp for self-hosted GGUF models. If you have Ollama running on a different machine with GPUs, you can configure a custom endpoint URL.
Why It's Cool
-
It eliminates a tedious decision. The hardest part of committing isn't the code -- it's summarizing what you did in a way that's useful later. OpenCommit removes that friction entirely. You stage, you run
oco, and you get a coherent message that actually describes the changes. -
Local model support matters. Not everyone wants to send their code to OpenAI's servers, especially for proprietary work. The fact that OpenCommit works with Ollama and llama.cpp means you can keep everything local. The README even includes a troubleshooting note about IPv6/IPv4 connection issues with Ollama, which shows the developer has thought about real-world deployment problems.
-
It's self-documenting in a clever way. The project's own commit history serves as a living demonstration. You can browse the commits and see exactly what OpenCommit generates for real changes. This is more honest than curated examples -- you see the tool's output in its natural habitat, including any quirks or patterns.
-
Configuration is straightforward. Setting up is just two commands: install globally, set your API key (or configure a local provider), and you're done. The
oco config setpattern is clean and familiar to anyone who's used similar CLI tools. -
Multiple provider support without complexity. Rather than building separate integrations for each AI service, OpenCommit uses a simple configuration approach. Switching from OpenAI to Ollama is just a matter of setting a few config variables -- no reinstalling or reconfiguring the tool itself.
How to Try It
Getting started takes about two minutes. First, install the tool globally:
npm install -g opencommit
Then get an API key from OpenAI (or another supported provider) and configure it:
oco config set OCO_API_KEY=<your_api_key>
Now you can use it in any Git repository. Just stage your changes and run:
git add <files...>
oco
Or let OpenCommit handle staging for you -- just run oco directly.
If you prefer to run locally with Ollama, start Ollama, pull a model like Mistral, then configure:
oco config set OCO_AI_PROVIDER='ollama' OCO_MODEL='llama3:8b'
For llama.cpp, start the server with your GGUF model and configure the endpoint URL accordingly.
The full documentation and source code are available on GitHub at github.com/di-sukharev/opencommit.
Final Thoughts
OpenCommit is exactly the kind of tool that makes you wonder why you didn't build it yourself. It solves a small, specific pain point that every developer experiences, and it does so without overcomplicating things. The local model support is a smart addition that makes it viable for teams who can't or won't send code to third-party APIs. Is it essential? No. But if you've ever looked back at your commit history and cringed at "fixed bug" or "updated stuff," it's worth trying. You might find that letting AI write your commit messages frees up just enough mental energy to focus on what actually matters -- the code itself.
Follow @githubprojects for more developer tools and open source projects.
Repository: https://github.com/di-sukharev/opencommit