OpenCommit — AI-Powered Git Commit Messages
OpenCommit auto-generates meaningful git commit messages using AI. 7.2K+ stars. Claude, GPT, Ollama, git hook integration. Open source.
What it is
OpenCommit is a CLI tool that analyzes your staged git changes and generates meaningful commit messages using AI. It reads the diff, sends it to an LLM (Claude, GPT, or local models via Ollama), and proposes a conventional commit message. It supports git hook integration so commit messages are generated automatically on every commit.
Developers who want consistent, descriptive commit messages without spending time writing them benefit from OpenCommit. Teams enforcing conventional commit standards find it especially useful.
How it saves time or tokens
Writing good commit messages takes 30-60 seconds per commit. OpenCommit generates one in about 1 second. Over a day with dozens of commits, this saves meaningful time. The AI reads the full diff context, producing messages that are often more descriptive than hastily written manual ones. The token_estimate per commit is approximately 389 tokens.
How to use
- Install OpenCommit globally via npm
- Configure your AI provider and API key
- Stage your changes and run
ocoinstead ofgit commit
Example
# Install
npm install -g opencommit
# Configure provider
oco config set OCO_API_KEY=sk-ant-your-key
oco config set OCO_MODEL=claude-sonnet-4-20250514
# Use: stage changes and run
git add .
oco
# Output: feat(auth): add JWT token refresh logic with expiry check
# Or install as git hook (auto-generate on every commit)
oco hook set
git add . && git commit # Message generated automatically
Related on TokRepo
- AI tools for coding — Browse AI development tools
- Featured workflows — Discover top-rated tools and workflows
Common pitfalls
- Large diffs (many files changed) produce longer context and higher token costs; commit frequently in small batches
- The git hook runs on every commit including rebases and merges; disable it for non-standard commits
- Generated messages may not match your team's exact commit convention; customize the prompt template in config
Frequently Asked Questions
OpenCommit supports OpenAI (GPT-4, GPT-4o), Anthropic (Claude), local models via Ollama, and any OpenAI-compatible endpoint. You configure the provider and model in the oco config.
Yes. Run `oco hook set` to install a prepare-commit-msg hook. Every `git commit` will automatically generate an AI commit message. Run `oco hook unset` to remove it.
Yes. OpenCommit generates messages in Conventional Commits format by default (feat:, fix:, docs:, etc.). You can customize the format through configuration.
Cost depends on diff size and model. A typical commit with Claude costs fractions of a cent. Large diffs with GPT-4 may cost a few cents. Using Ollama with local models is free.
Yes. By default, OpenCommit shows the generated message and asks for confirmation. You can edit it, regenerate, or cancel. Auto-approve mode is available but not recommended.
Citations (3)
- OpenCommit GitHub— AI-powered git commit message generator
- OpenCommit README— Supports Claude, GPT, and Ollama providers
- Conventional Commits— Conventional Commits specification
Related on TokRepo
Source & Thanks
di-sukharev/opencommit — 7,200+ GitHub stars
Discussion
Related Assets
Moodle — Open-Source Learning Management System
The most widely used open-source learning platform, providing course management, assessments, and collaboration tools for educators and organizations worldwide.
Sylius — Headless E-Commerce Framework on Symfony
An open-source headless e-commerce platform built on Symfony and API Platform, designed for developers who need a customizable and API-first commerce solution.
Akaunting — Free Self-Hosted Accounting Software
A free, open-source online accounting application built on Laravel for small businesses and freelancers to manage invoices, expenses, and financial reports.