ScriptsApr 1, 2026·1 min read

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.

TL;DR
CLI tool that auto-generates meaningful git commit messages using Claude, GPT, or Ollama from staged diffs.
§01

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.

§02

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.

§03

How to use

  1. Install OpenCommit globally via npm
  2. Configure your AI provider and API key
  3. Stage your changes and run oco instead of git commit
§04

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
§05

Related on TokRepo

§06

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

Which AI models does OpenCommit support?+

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.

Can I use OpenCommit with a git hook?+

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.

Does OpenCommit follow Conventional Commits?+

Yes. OpenCommit generates messages in Conventional Commits format by default (feat:, fix:, docs:, etc.). You can customize the format through configuration.

How much does each commit message cost?+

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.

Can I review the message before committing?+

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)
🙏

Source & Thanks

di-sukharev/opencommit — 7,200+ GitHub stars

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets