A command-line tool that automatically generates conventional commit messages using AI, based on your staged git changes.
Your commit messages will look like this:
- 🤖 AI-powered commit message generation (using
google/gemini-flash-1.5-8b
- SUPER CHEAP!)- Around $0.00001/commit -> $1 per 100K commit messages!
- 📝 Follows Conventional Commits format
- 🔒 Secure local API key storage
- 🚀 Automatic git commit and push
- 🐛 Debug mode for troubleshooting
- 💻 Cross-platform support (Windows, Linux, macOS)
- Git installed and configured
- For Windows: Git Bash or WSL installed
- For Linux/macOS: Bash shell environment
- An OpenRouter API key
curl
installed
- Clone this repository:
git clone https://github.com/mrgoonie/cmai.git
cd cmai
- Run the installation script:
./install.sh
This will:
- Create necessary directories
- Install the script globally as
cmai
- Set up proper permissions
- Clone this repository:
git clone https://github.com/mrgoonie/cmai.git
cd cmai
- Run the installation script in Git Bash:
./install.sh
Or manually:
- Copy
git-commit.sh
to%USERPROFILE%\git-commit-ai\
- Add the directory to your PATH environment variable
- Rename
git-commit.sh
tocmai.sh
This will:
- Create necessary directories
- Install the script globally as
cmai
- Set up proper permissions
Set up your OpenRouter API key:
cmai <your_openrouter_api_key>
The API key will be securely stored in:
- Linux/macOS:
~/.config/git-commit-ai/config
- Windows:
%USERPROFILE%\.config\git-commit-ai\config
- Make your code changes
- Generate commit message and commit changes:
cmai
To also push changes to remote:
cmai --push
# or
cmai -p
To use a different AI model:
cmai --model qwen/qwen-2.5-coder-32b-instruct
List of available models: https://openrouter.ai/models
This will:
- Stage all changes
- Generate a commit message using AI
- Commit the changes
- Push to the remote repository (if --push flag is used)
To see detailed information about what's happening:
cmai --debug
You can combine flags:
cmai --debug --push
# First time setup with API key
cmai your_openrouter_api_key
# Normal usage
cmai
# Commit and push
cmai --push
# Debug mode
cmai --debug
# Debug mode with push
cmai --debug --push
# Use a different AI model
cmai --model qwen/qwen-2.5-coder-32b-instruct
# Combine multiple flags
cmai --debug --push --model qwen/qwen-2.5-coder-32b-instruct
Example generated commit messages:
feat(api): add user authentication system
fix(data): resolve memory leak in data processing
docs(api): update API documentation
style(ui): improve responsive layout for mobile devices
~
├── git-commit-ai/
│ └── git-commit.sh
├── .config/
│ └── git-commit-ai/
│ └── config
└── usr/
└── local/
└── bin/
└── cmai -> ~/git-commit-ai/git-commit.sh
%USERPROFILE%
├── git-commit-ai/
│ └── cmai.sh
└── .config/
└── git-commit-ai/
└── config
- API key is stored locally with restricted permissions (600)
- Configuration directory is protected (700)
- No data is stored or logged except the API key
- All communication is done via HTTPS
-
No API key found
- Run
cmai your_openrouter_api_key
to configure
- Run
-
Permission denied
- Check file permissions:
ls -la ~/.config/git-commit-ai
- Should show:
drwx------
for directory and-rw-------
for config file
- Check file permissions:
-
Debug mode
- Run with
--debug
flag to see detailed logs - Check API responses and git operations
- Run with
-
Windows-specific issues
- Make sure Git Bash is installed
- Check if curl is available in Git Bash
- Verify PATH environment variable includes the installation directory
bash
sudo rm /usr/local/bin/cmai
rm -rf ~/git-commit-ai
rm -rf ~/.config/git-commit-ai
rm -rf "$USERPROFILE/git-commit-ai"
rm -rf "$USERPROFILE/.config/git-commit-ai"
Then remove the directory from your PATH environment variable
- Fork the repository
- Create your feature branch
- Commit your changes (using
cmai
😉) - Push to the branch
- Create a Pull Request
MIT License - see LICENSE file for details
- OpenRouter for providing the AI API
- Conventional Commits for the commit message format
- DigiCord AI - The Most Useful AI Chatbot on Discord
- IndieBacklink.com - Indie Makers Unite: Feature, Support, Succeed
- TopRanking.ai - AI Directory, listing AI products
- ZII.ONE - Personalized Link Shortener
- VidCap.xyz - Extract Youtube caption, download videos, capture screenshot, summarize,…
- ReadTube.me - Write blog articles based on Youtube videos
- BoostTogether.com - The Power of WE in Advertising
- AIVN.Site - Face Swap, Remove BG, Photo Editor,…
- DxUp.dev - Developer-focused platform for app deployment & centralized cloud resource management.