One of the most common problems developers face is writing good Git commit messages.
After a long coding session, many of us end up writing commit messages like:
fix stuff
update code
changes
final fix
These messages work, but they don't really explain what changed or why the change was made. Over time, this makes project history harder to understand.
So I decided to build a small developer tool to solve this problem.
Introducing AI Commit — a CLI tool that automatically generates meaningful Git commit messages using local AI models.
The Idea
The idea behind AI Commit is simple:
- Detect staged Git changes
- Send the diff to a local AI model
- Generate a structured commit message
- Let the developer review and commit
The interesting part is that everything runs locally using Ollama, which means:
- No API keys required
- No cloud dependency
- Works completely offline
- Privacy-first workflow
How It Works
The tool analyzes your staged Git changes and sends them to a local language model.
Git diff
↓
AI Commit CLI
↓
Local Ollama Model
↓
Generated Commit Message
The generated commit message can follow different formats such as:
- Conventional commits
- Semantic commit messages
- Detailed commit descriptions
Installation
The tool is available on PyPI and can be installed with pip.
pip install ollama-git-commit
Requirements
Before using the tool, make sure you have:
- Python 3.8+
- Git installed
- Ollama installed and running
Start Ollama:
ollama serve
Pull a model (example):
ollama pull llama3
Usage
Navigate to any Git repository and stage your changes.
git add .
Then run:
ai-commit
The tool will:
- Analyze your staged changes
- Generate a commit message
- Allow you to review or modify it
This makes writing good commit messages fast and consistent.
Why Local AI?
Many AI developer tools rely on cloud APIs.
While this works well, it has a few drawbacks:
- API costs
- Internet dependency
- Privacy concerns
By using local LLMs with Ollama, AI Commit keeps everything on your machine.
This makes it ideal for developers who prefer offline and private AI workflows.
Tech Stack
The project is built with:
- Python
- Ollama
- Git CLI
- Local LLM models
- Open source tooling
Open Source Project
AI Commit is fully open source and available on GitHub.
GitHub Repository:
https://github.com/himanshu231204/ai-commit
PyPI Package:
https://pypi.org/project/ollama-git-commit/
If you find the project useful, consider giving it a ⭐ on GitHub.
What I Learned Building This
While building this project, I learned several things:
- How to build CLI tools with Python
- Integrating local LLMs using Ollama
- Packaging and publishing Python libraries to PyPI
- Designing developer productivity tools
Open source projects like this are a great way to learn by building real tools.
Future Improvements
Some features I'm planning to add:
- Git hook support
- Better commit style detection
- Configuration file support
- VS Code integration
Final Thoughts
Good commit messages are an important part of maintaining clean and understandable project history.
AI Commit is a small step toward making that process easier with the help of local AI.
If you're interested in experimenting with AI-powered developer tools, feel free to try it out.
Feedback and contributions are always welcome.
Top comments (0)