AI Commit — Auto-Generate Git Commits with AI
CLI tool that generates conventional commit messages from your staged changes using AI. Supports Claude, GPT-4, and local models. One command for perfect commit messages. 3,000+ stars.
这个资产会安全暂存
这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。
npx -y tokrepo@latest install 158cf02b-635a-4bae-ac9d-fc93f684eec2 --target codex先暂存文件;激活前需要读取暂存 README 和安装计划。
What it is
AI Commit is a CLI tool that generates conventional commit messages from your staged Git changes using AI. You stage your changes with git add, run the AI Commit command, and it analyzes the diff to produce a clear, descriptive commit message following conventional commit format. It supports Claude, GPT-4, and local models.
This tool targets developers who want consistently formatted commit messages without spending time writing them. It reads the actual code diff, understands what changed, and produces messages that describe the why rather than just listing file names.
Why it saves time or tokens
Writing good commit messages takes thought. Most developers default to lazy messages like 'fix bug' or 'update code' because proper messages feel like overhead. AI Commit removes this friction by generating descriptive messages automatically. The tool sends only the staged diff to the AI, keeping token usage proportional to the change size rather than the entire codebase.
How to use
- Install the CLI tool globally:
npm install -g aicommitor via your preferred package manager - Configure your preferred AI provider and API key
- Stage changes and run:
aicommitto generate and apply a commit message
Example
# Stage your changes
git add src/auth/login.ts src/auth/session.ts
# Generate commit message
aicommit
# Output:
# feat(auth): add session refresh on token expiry
#
# - Check token expiration before API calls
# - Refresh session automatically when within 5min of expiry
# - Add retry logic for failed refresh attempts
| Feature | Description |
|---|---|
| Conventional commits | type(scope): description format |
| Multi-model | Claude, GPT-4, Ollama, local models |
| Diff-based | Analyzes actual code changes |
| Interactive | Review and edit before committing |
| Configurable | Custom prompts and templates |
Related on TokRepo
- AI tools for coding — developer productivity tools on TokRepo
- Automation tools — Git workflow automation helpers
Common pitfalls
- Very large diffs exceed model context limits; commit smaller, focused changes for better message quality
- The generated message reflects what the AI infers, not your intent; always review before accepting
- API key configuration varies by tool version; check the documentation for the correct environment variable or config file format
常见问题
AI Commit supports multiple providers including OpenAI (GPT-4, GPT-4o), Anthropic (Claude), and local models through Ollama. You configure the provider and model in a config file or environment variable. Some versions also support Google Gemini and other providers.
Yes. AI Commit generates messages in conventional commit format: type(scope): description. Types include feat, fix, refactor, docs, test, chore, and others. The scope is inferred from the changed file paths. You can customize the prompt to match your team's commit conventions.
Cost depends on the AI provider and diff size. A typical commit with a few hundred lines of diff costs a fraction of a cent with cloud providers. Using local models through Ollama makes it completely free. The tool sends only the staged diff, not your entire codebase.
AI Commit is designed for interactive local development, not CI/CD. In CI, commits are already made. However, you could use it in a pre-commit hook or a squash-merge workflow where the final commit message needs generating. Run it in non-interactive mode for automated contexts.
Most AI Commit tools support custom prompts or templates. You can specify the commit types you use, require certain scopes, or add custom instructions like including ticket numbers. Check your specific tool's configuration for prompt customization options.
引用来源 (3)
- aicommits GitHub— AI-powered commit message generation from Git diffs
- Conventional Commits— Conventional commits specification for structured messages
- Git Docs— Git diff for analyzing staged changes
来源与感谢
讨论
相关资产
pre-commit — A Framework for Managing Git Hook Scripts
pre-commit manages and installs multi-language Git hooks from a YAML file. It runs linters, formatters, and checks before commits reach CI — catching issues early with zero manual setup per developer.
AI Git Narrator — Generate Commit & PR Text
Generate commit messages and PR descriptions from diffs with OpenAI/Gemini/Ollama options; verified 118★ and installs via Homebrew on macOS.
Cursor Rules MDC Generator — Auto-Generate from Docs
Auto-generate Cursor .mdc rule files for any library using Exa semantic search and LLM-powered documentation extraction.
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.