commit-suggester
v1.1.0
Published
AI-powered git commit message suggester with multiple AI providers
Maintainers
Readme
Commit Suggester
A simple CLI tool that uses AI to generate conventional commit messages for your git changes.
Features
- 🤖 Multiple AI Providers - Groq, OpenAI, Anthropic, Google Gemini
- 🚀 Auto-staging - Automatically stages all changes before analysis
- 🔍 Dry Run Mode - Preview suggestions without committing
- 📦 Staged Only Mode - Analyze only pre-staged changes
- ⚡ Simple Setup - Just set environment variables
- 🎯 Smart Analysis - Analyzes your actual git diffs
- 📝 Conventional Commits - Follows standard format
- ✨ Interactive - Choose from 3 AI suggestions or write custom
Quick Setup
Installation
# Install globally with npm
npm install -g commit-suggester
# Or with Bun
bun install -g commit-suggesterSetup API Key (choose one):
# Recommended - Groq (fast & free)
export GROQ_API_KEY="your_groq_key_here"
# Or use others
export OPENAI_API_KEY="your_openai_key_here"
export ANTHROPIC_API_KEY="your_anthropic_key_here"
export GOOGLE_GENERATIVE_AI_API_KEY="your_google_key_here"
# Add to your shell profile
echo 'export GROQ_API_KEY="your_key"' >> ~/.zshrc
source ~/.zshrcReady to Use!
commit-suggester # Auto mode
commit-suggester -i # Interactive mode
commit-suggester -d # Dry run (preview only)
commit-suggester -s # Staged only (skip auto-staging)Get API Keys
- Groq (Recommended): console.groq.com/keys - Fast & Free
- OpenAI: platform.openai.com/api-keys
- Anthropic: console.anthropic.com
- Google: ai.google.dev/tutorials/setup
Usage
Auto Mode (Default)
# Make your changes
echo "console.log('hello')" > test.js
# Auto-commit with best suggestion
commit-suggesterOutput:
🚀 Commit Suggester - AI-powered Git Commits
📦 Staging all changes...
📊 Analyzing changes...
✅ Found 1 file(s): +1/-0
🤖 Using GROQ AI (llama-3.3-70b-versatile)
🤖 Generating commit suggestions...
🎯 Auto-selected: "feat: add hello world console log"
📝 Committing changes...
✅ Committed successfully!
🎉 Successfully committed: "feat: add hello world console log"Interactive Mode
# Choose from 3 options + custom
commit-suggester -iOutput:
🚀 Commit Suggester - AI-powered Git Commits
📦 Staging all changes...
📊 Analyzing changes...
✅ Found 1 file(s): +1/-0
🤖 Using GROQ AI (llama-3.3-70b-versatile)
🤖 Generating commit suggestions...
📋 Interactive Mode - Choose your commit message:
? Select a commit message:
❯ [1] feat: add hello world console log
[2] chore: create test javascript file
[3] feat(test): add basic console output
✏️ Write custom message
? Commit with: "feat: add hello world console log"? Yes
📝 Committing changes...
✅ Committed successfully!
🎉 Successfully committed: "feat: add hello world console log"Dry Run Mode
Preview AI suggestions without actually committing:
commit-suggester -d
# or
commit-suggester --dry-runOutput:
🚀 Commit Suggester - AI-powered Git Commits
🔍 Dry run mode - no commit will be made
📦 Staging all changes...
📊 Analyzing changes...
✅ Found 1 file(s): +1/-0
🤖 Using GROQ AI (llama-3.3-70b-versatile)
🎯 Auto-selected: "feat: add hello world console log"
🔍 Dry run - would commit: "feat: add hello world console log"
Run without --dry-run to actually commit.Staged Only Mode
Only analyze files you've already staged (respects your manual staging):
# Stage specific files manually
git add src/feature.ts
# Analyze only staged files
commit-suggester -s
# or
commit-suggester --stagedCombining Options
Options can be combined for more control:
commit-suggester -i -d # Interactive + dry run
commit-suggester -i -s # Interactive + staged only
commit-suggester -s -d # Staged only + dry runHelp
commit-suggester --helpOutput:
🚀 Commit Suggester - AI-powered Git Commits
Usage:
commit-suggester # Auto-select best commit message
commit-suggester -i # Interactive mode (3 options + custom)
commit-suggester -d, --dry-run # Preview suggestions without committing
commit-suggester -s, --staged # Only use already staged changes
commit-suggester --help # Show this help
Options can be combined:
commit-suggester -i -d # Interactive + dry run
commit-suggester -i -s # Interactive + staged only
Setup:
export GROQ_API_KEY="your_key" # Recommended - Fast & Free
export OPENAI_API_KEY="your_key" # Alternative
export ANTHROPIC_API_KEY="your_key" # AlternativeHow it Works
Auto Mode:
- Auto-stages all your changes (
git add .) - Analyzes git diffs to understand what changed
- Generates 3 AI suggestions (best one first)
- Auto-commits with the best suggestion
Interactive Mode (-i):
- Auto-stages all your changes (
git add .) - Analyzes git diffs to understand what changed
- Shows 3 AI suggestions + custom option
- Interactive selection with confirmation
- Commits with your chosen message
Dry Run Mode (-d):
- Stages changes (unless
-sflag used) - Analyzes git diffs
- Generates AI suggestions
- Displays what would be committed (no actual commit)
Staged Only Mode (-s):
- Skips auto-staging (uses your manually staged files)
- Analyzes only staged changes
- Generates AI suggestions
- Commits (unless
-dflag used)
CLI Options Reference
| Flag | Short | Description |
|------|-------|-------------|
| --interactive | -i | Choose from 3 suggestions + custom input |
| --dry-run | -d | Preview suggestions without committing |
| --staged | -s | Only analyze already-staged changes |
| --help | -h | Show help information |
Supported Commit Types
feat: New featuresfix: Bug fixesdocs: Documentationstyle: Code style changesrefactor: Code refactoringtest: Testschore: Maintenanceperf: Performance improvements
Project Structure
src/
├── cli.ts # Main CLI interface
├── CommitSuggester.ts # Core logic
├── services/
│ ├── AIService.ts # AI provider handling
│ └── GitService.ts # Git operations
└── types/
└── index.ts # TypeScript typesDevelopment
# Clone and setup
git clone https://github.com/rishinpoolat/commit-suggester.git
cd commit-suggester
bun install
# Run in development
bun run dev
# Build
bun run build
# Type check
bun run typecheck
# Test locally
bun link
commit-suggesterLicense
MIT - See LICENSE file for details.
