AI coding assistant-powered commit message generator
We all know we should write better commit messages. But we don't.
commitment analyzes your git diffs using your favorite AI coding assistant and generates professional, conventional commit messages automatically.
- No API Keys: Uses your local AI CLI (Claude, Codex, or Gemini) to generate commit messages
- Consistency: Every commit follows Conventional Commits format
- Context-aware: AI understands your changes and adds helpful context
- Frictionless: Just add the hook and stop committing
wip2andformatting
- π€ AI-powered generation using your local AI CLI (Claude, Codex, or Gemini) for accurate, context-aware messages - no extra API keys required!
- π Code analysis detects functions, tests, types, and patterns in your changes
- β¨ Conventional Commits for a standard format (feat:, fix:, docs:, etc.)
- π One-command setup with
commitment initfor automatic hook installation - πͺ Hook integration with husky, simple-git-hooks, or plain git hooks
- π Cross-platform support for macOS, Linux, and Windows
- π¦ Zero config works out of the box with sensible defaults
# 1. Install
npm install -D @arittr/commitment
# 2. Set up git hooks (automatic)
npx commitment init
# Or configure with a specific AI agent
npx commitment init --agent gemini
# 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.
# Using npm
npm install -D @arittr/commitment
# Using yarn
yarn add -D @arittr/commitment
# Using pnpm
pnpm add -D @arittr/commitment
# Using bun
bun add -D @arittr/commitment- Node.js >= 18
- 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 requires an AI CLI to function.
After running npx 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 .
npx commitmentGenerate message only (preview without committing):
npx commitment --dry-runUse a specific AI agent:
npx commitment --agent codex
# or
npx commitment --agent gemini- Analyze: Reads your staged changes with
git diff --cached - 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/
$ npx commitmentGenerated:
test: update test naming conventions and mock patterns
- Rename runner tests to reflect unit vs integration scope
- Update base-agent tests to use `command -v` instead of `which`
- Fix mock expectations to require non-empty stdout for availability checks
- Reorganize markdown reporter tests to use timestamped directories
- Add responseTimeMs validation to eval runner tests
- Update CLI invocation mocks to use shell wrapper pattern
π€ Generated with Claude via commitment
| 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 |
--cwd <path> |
Working directory | current directory |
See docs/CLI.md for complete CLI reference.
commitment supports multiple hook managers:
| Manager | Command | Best For |
|---|---|---|
| Auto-detect | npx commitment init |
Most projects |
| Husky | npx commitment init --hook-manager husky |
Teams with existing husky setup |
| simple-git-hooks | npx commitment init --hook-manager simple-git-hooks |
Lightweight alternative to husky |
| Plain Git Hooks | npx commitment init --hook-manager plain |
No dependencies |
Configure default agent:
npx commitment init --agent gemini # Use Gemini by default
npx commitment init --agent codex # Use Codex by defaultSee docs/HOOKS.md for detailed hook integration guide.
Check installation:
# For husky
ls -la .husky/prepare-commit-msg
# For plain git hooks
ls -la .git/hooks/prepare-commit-msgReinstall:
npx commitment initCheck permissions (Unix-like systems):
chmod +x .husky/prepare-commit-msg
# or
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.
Symptoms:
- Hooks don't run
- Line ending errors (
\rin scripts)
Solutions:
- Use Git Bash or WSL instead of CMD/PowerShell
- Verify line endings -
commitment inithandles this automatically - Check git config:
git config core.autocrlf false
| 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:
- Bun 1.1.0+ (development, bundling, testing)
Development:
# Install dependencies
bun install
# Run tests
bun test
# Run linting
bun run lint
# Build
bun run build
# Run evaluation system
bun run evalAdding a New AI Agent:
See CLAUDE.md for detailed instructions.
Architecture:
This project follows a strict layered architecture with schema-first type safety. See docs/constitutions/current/ for:
- Architecture guidelines
- Testing patterns
- Type safety rules
- Code style requirements
commitment includes a comprehensive evaluation framework that compares AI agents using multi-attempt testing:
# Run full evaluation
bun run eval
# Test specific fixture
bun run eval:fixture simple
# Test with live git changes
bun run eval:liveResults are saved to .eval-results/ with:
- Per-attempt scores and metrics
- Meta-evaluation across attempts
- Success rates and consistency analysis
- Response time measurements
This is not part of the test suite - it's a standalone tool for evaluating agent quality.
ISC
- Follows Conventional Commits specification
- Built with Claude CLI, Zod, and Bun
- Developed using Spectacular and Superpowers for Claude Code
- Inspired by years of bad commit messages