AI-powered commit message generator using your local CLI tools - no API keys required
A Rust port of commitment - generates conventional commit messages from git diffs using Claude, Codex, or Gemini CLI tools.
We all know we should write better commit messages. But we don't.
commitment-rs uses your local AI CLI (Claude Code, Codex, or Gemini) to analyze git diffs and generate professional, conventional commit messages automatically. No API keys or additional services required - it works with the AI tools you already have installed.
- No API keys required - Uses Claude Code, Codex, or Gemini CLI tools you already have installed
- Context-aware - Agentic coding CLIs understand your codebase context beyond just the diff
- Conventional Commits - Every commit follows Conventional Commits format
- Frictionless setup - One command (
commitment init) and stop committingwip2andformatting - Hook integration - Works with lefthook, husky, simple-git-hooks, or plain git hooks
- Fast startup - Native Rust binary, instant startup
- Smart diff handling - Automatic truncation, change summaries, optimized for AI analysis
# 1. Install (cargo install coming soon)
cargo install --path .
# 2. Set up git hooks (automatic)
commitment init
# 3. Make changes and commit
git add .
git commit # Message generated automatically!That's it! Every commit now gets an AI-generated, pretty good commit message.
git clone https://github.com/arittr/commitment-rs
cd commitment-rs
cargo build --release
# Binary is at target/release/commitment-rscargo install commitment-rs- Git repository
- AI CLI (one of):
- Claude CLI (recommended) - Install with
npm install -g @anthropic-ai/claude-code - Codex CLI - Install with
npm install -g @openai/codex - Gemini CLI - Install with
npm install -g @google/gemini-cli
- Claude CLI (recommended) - Install with
Important
commitment-rs uses your local AI CLI tools (not the OpenAI API or other cloud services). You need one of the CLIs above installed and configured.
After running commitment init, commit messages are generated automatically:
git add src/components/Button.tsx
git commit # Opens editor with AI-generated messageGenerate a message and commit in one step:
git add .
commitmentGenerate message only (preview without committing):
commitment --dry-runUse a specific AI agent:
commitment --agent codex
# or
commitment --agent gemini- Analyze: Reads your staged changes with
git diff --cached - Optimize: Truncates large diffs (8000 char limit), adds change summary
- Generate: Sends diff to AI CLI with a detailed prompt
- Validate: Ensures response follows Conventional Commits format
- Commit: Creates commit with generated message
git add src/api/ src/types/
commitmentGenerated:
refactor(agents): extract shared infrastructure to parent module
- Add check_command_exists() and run_command_with_stdin() utilities
- Define AGENT_TIMEOUT constant (120s) shared across all agents
- Reduce individual agent files to ~20 lines each
- Add display_name() and install_url() methods to AgentName
π€ Generated with Claude via commitment-rs
| Option | Description | Default |
|---|---|---|
--agent <name> |
AI agent to use (claude, codex, or gemini) |
claude |
--dry-run |
Generate message without creating commit | false |
--message-only |
Output only the commit message | false |
--quiet |
Suppress progress messages | false |
--cwd <path> |
Working directory | current directory |
Examples:
# Use Gemini agent
commitment --agent gemini
# Preview message without committing
commitment --dry-run
# Suppress progress messages (for scripts)
commitment --quietcommitment-rs supports multiple hook managers:
| Manager | Command | Best For |
|---|---|---|
| Auto-detect | commitment init |
Most projects |
| Lefthook | commitment init --hook-manager lefthook |
Fast, parallel execution, YAML config (recommended) |
| Husky | commitment init --hook-manager husky |
Teams with existing husky setup |
| simple-git-hooks | commitment init --hook-manager simple-git-hooks |
Lightweight alternative |
| Plain Git Hooks | commitment init --hook-manager plain |
No dependencies |
Configure default agent:
commitment init --agent gemini # Use Gemini by default
commitment init --agent codex # Use Codex by defaultWhen using lefthook, commitment-rs detects existing hook configurations before installation to prevent accidentally overwriting custom hooks or removing AI signature requirements.
Check installation:
# For lefthook
cat lefthook.yml
# For husky
ls -la .husky/prepare-commit-msg
# For plain git hooks
ls -la .git/hooks/prepare-commit-msgReinstall:
commitment initCheck permissions (Unix-like systems):
# For lefthook, run:
lefthook install
# For husky
chmod +x .husky/prepare-commit-msg
# For plain git hooks
chmod +x .git/hooks/prepare-commit-msgThis should not happen. Hooks check if you've specified a message:
git commit -m "my message" # Uses your message β
git commit # Generates message β
If hooks override your messages, please file an issue.
| Platform | CLI Usage | Hooks | AI Agents |
|---|---|---|---|
| macOS | β | β | β Claude, Codex, Gemini |
| Linux | β | β | β Claude, Codex, Gemini |
| Windows | β | β Claude, Codex, Gemini |
Note: Windows users should use Git Bash or WSL for best hook compatibility.
Contributions welcome!
Requirements:
- Rust (stable)
Commands:
# Build
cargo build
# Run tests
cargo test
# Run linting
cargo clippy -- -D warnings
# Format code
cargo fmt
# Run integration tests
cargo test --test integration_testsArchitecture:
This project follows a strict layered architecture. See CLAUDE.md for detailed development guidelines and docs/constitutions/current/ for:
- Architecture guidelines
- Patterns (enum dispatch, newtypes, shared infrastructure)
- Testing patterns
- Code style requirements
ISC
- Follows Conventional Commits specification
- Port of commitment
- Built with Rust, Tokio, and clap
- Developed using Claude Code
- Inspired by years of bad commit messages