An intelligent, AI-powered git commit and push tool that automatically generates meaningful commit messages from your staged changes. Works with multiple AI providers including OpenAI, Anthropic, Google, Mistral, and Cohere.
🚀 Quick Start: New to AI Auto Commit? See docs/QUICKSTART.md for a 2-minute setup guide. 🔧 Contributing: Want to contribute? See CONTRIBUTING.md for developer setup.
- 🤖 AI-Powered Commit Messages: Automatically generates conventional commit messages from your code changes
- 🔄 Multi-Provider Support: Works with OpenAI, Anthropic (Claude), Google (Gemini), Mistral, and Cohere
- 💰 Token Budget Management: Configurable token limits to control API costs
- 🎯 Smart Diff Analysis: Uses hierarchical analysis to understand complex changes
- 🛡️ Safety Features: Creates backups and verifies changes before committing
- ⚙️ Flexible Configuration: Easy-to-use config system for models and settings
- 📦 Works Anywhere: Install once, use from any git repository on your system
Use this if you develop or clone this repo and want autocommit available everywhere, always running this repo’s latest code:
cd /path/to/ai_tools/auto_commit
./install-global.shOr without the script (requires pipx):
cd /path/to/ai_tools/auto_commit
pipx install -e .Then run autocommit from any directory. After you pull changes, no reinstall is needed—the command uses this repo’s source.
Choose the method for your platform:
curl -fsSL https://raw.githubusercontent.com/yourusername/ai_auto_commit/main/install.sh | bashirm https://raw.githubusercontent.com/yourusername/ai_auto_commit/main/install.ps1 | iexflatpak install flathub com.github.yourusername.AIAutoCommityay -S ai-auto-commitsudo apt install ai-auto-commitbrew tap yourusername/tap
brew install ai-auto-commitwinget install YourPublisher.AIAutoCommitchoco install ai-auto-commitscoop bucket add extras
scoop install ai-auto-commitpip install ai-auto-commitpipx install ai-auto-commitAfter installing via any method above, run the interactive setup wizard:
autocommit initThe wizard will guide you through configuring your AI provider API keys, default model, and token budget. All settings are stored securely in ~/.config/ai_auto_commit/config.json.
- Clone or navigate to the project directory:
cd /path/to/ai_auto_commit- Install the package (recommended: use editable mode for development):
pip install -e .Or for a regular installation:
pip install .- Verify installation:
autocommit --helpThe autocommit command should now be available globally from any directory.
- Run the interactive setup wizard:
autocommit initAfter installation, run the interactive setup wizard to configure your API keys and preferences:
autocommit initThe wizard will guide you through:
- API Key Configuration: Add API keys for one or more AI providers (OpenAI, Anthropic, Google, Mistral, Cohere)
- Default Model Selection: Choose your preferred AI model
- Token Budget: Set a token limit to control API costs
All configuration is stored in ~/.config/ai_auto_commit/config.json. Your API keys are stored locally and never transmitted anywhere except to your chosen AI provider.
If you prefer not to use the interactive wizard, you can configure settings manually:
# Set default model
autocommit config set model gpt-4o
# Set token budget (default: 250,000)
autocommit config set token-budget 500000
# Set custom commit prompt template
autocommit config set commit-prompt "Generate concise conventional commits focused on impact."
# View current configuration
autocommit config get
# Edit config file directly
autocommit config editThe tool stores configuration in ~/.config/ai_auto_commit/config.json. You can manage it in three ways:
autocommit config getThis displays:
- Config file location
- Default model
- Token budget
- All other settings
# Using a predefined model
autocommit config set model gpt-4o
# Using a custom model name
autocommit config set model my-custom-modelAvailable Models by Provider:
- OpenAI:
gpt-5.2,gpt-5.1,gpt-4o,gpt-4o-mini,gpt-4-turbo,gpt-4,gpt-3.5-turbo,o3,o3-mini - Anthropic:
claude-opus-4.5,claude-sonnet-4.5,claude-haiku-4.5,claude-3-5-sonnet-20241022 - Google:
gemini-3-pro-preview-high,gemini-3-flash-preview,gemini-1.5-pro,gemini-1.5-flash - Mistral:
devstral-2,mistral-large-latest,mistral-medium-latest,mistral-small-latest - Cohere:
command-r-plus,command-r
The token budget limits how many tokens can be used per commit operation. This helps control API costs.
# Set to 500,000 tokens
autocommit config set token-budget 500000
# Set to 100,000 tokens (more conservative)
autocommit config set token-budget 100000Default: 250,000 tokens
Use this to personalize the prompt template sent to the AI when generating commit messages:
autocommit config set commit-prompt "Generate concise conventional commits, emphasize why, and keep bullets under 12 words."This stores your custom template under commit_prompt_template in the config file.
Open the config file in your default editor:
autocommit config editThis will:
- Create the config file if it doesn't exist
- Open it in your default editor (respects
$EDITORor$VISUAL) - Fall back to common editors (
nano,vim,vi,code,subl) if no editor is set
The config file format is JSON:
{
"default_model": "gpt-4o",
"token_budget": 250000,
"commit_prompt_template": "Generate concise conventional commits and focus on impact."
}- Stage your changes:
git add file1.py file2.py
# or stage all changes
git add .- Run autocommit:
autocommitThe tool will:
- Analyze your staged changes
- Generate an AI-powered commit message
- Show you the message for review
- Ask for confirmation before committing and pushing
# Use a specific model for this commit
autocommit --model gpt-4o
# Use a different provider
autocommit --provider anthropic --model claude-sonnet-4.5
# Adjust temperature (0.0-1.0, default: 0.2)
autocommit --temperature 0.5
# Push to a different remote
autocommit --remote upstream
# Provide API key inline
autocommit --api-key "sk-..." --provider openaiWhen you run autocommit, you'll see:
- Repository Status: Shows what changes will be committed
- Generated Commit Message: AI-generated message based on your changes
- Comment Prompt: Option to add a comment to the top of the commit message
- Confirmation: Final confirmation before committing and pushing
Example Interaction:
🚀 AI Auto Commit Tool
============================================================
Operating on repository: /path/to/repo
Checking repository status...
📝 Generated Commit Message
============================================================
feat: add user authentication system
- Add login endpoint with JWT tokens
- Implement password hashing with bcrypt
- Add user registration flow
- Update API documentation
============================================================
You can add a comment to the top of this commit message.
Press Enter to proceed with the message as-is, or type a comment.
Enter comment (or press Enter to skip):
Repository path: /path/to/repo
Commit message: feat: add user authentication system...
Is this git commit and path correct? (Y/n/c for manual comment): y
The tool commits only staged files. It will:
- ✅ Commit all staged changes
- ✅ Generate a commit message from the staged diff
- ✅ Push to the configured remote (default:
origin) - ✅ Push to the current branch
Important: Files must be staged first using git add before running autocommit.
The tool uses a token budget system to control API costs:
- Reservation System: Tokens are reserved before API calls
- Automatic Refunds: Unused tokens are refunded
- Budget Tracking: See token usage in the output
- Configurable Limits: Set your budget via config
Example output:
Final token usage: 15,234/250,000 tokens
- Backup Creation: Creates a backup before making changes
- Working Directory Verification: Checks repository state
- File Deletion Detection: Warns if files might be affected
- Confirmation Prompts: Multiple checkpoints before committing
The tool uses two strategies:
- Heuristic Approach (Token-Light): For simple changes, uses file statistics without sending full diffs
- Hierarchical Approach: For complex changes, analyzes diffs in stages
This balances quality with cost efficiency.
You can switch between providers easily:
# Use OpenAI
autocommit --provider openai --model gpt-4o
# Use Anthropic
autocommit --provider anthropic --model claude-sonnet-4.5
# Use Google
autocommit --provider google --model gemini-1.5-proYou can configure multiple API keys in the setup wizard to easily switch between providers.
Problem: The tool can't find any staged changes.
Solution: Stage your files first:
git add <files>
# or
git add .Problem: The tool can't find your API key.
Solutions:
-
Run the interactive setup wizard:
autocommit init
-
Or provide it via command line:
autocommit --api-key "sk-..." --provider openai
Problem: You're not in a git repository.
Solution: Navigate to a git repository directory:
cd /path/to/your/git/repo
autocommitThe tool automatically detects the git repository root from any subdirectory.
Problem: Your changes are too large for the current token budget.
Solutions:
-
Increase the token budget:
autocommit config set token-budget 500000 -
Commit changes in smaller chunks:
git add file1.py file2.py autocommit git add file3.py file4.py autocommit
Problem: autocommit config edit can't find an editor.
Solutions:
-
Set the
EDITORenvironment variable:export EDITOR="nano" # or vim, code, etc.
-
Or manually edit the config file:
nano ~/.config/ai_auto_commit/config.json
Problem: Generated commit messages aren't accurate.
Solutions:
-
Use a more capable model:
autocommit config set model gpt-4o # or autocommit --model claude-opus-4.5
-
Add a comment when prompted to provide context
-
Stage related changes together for better context
All configuration is stored in:
~/.config/ai_auto_commit/config.json
You can view, edit, or manually modify this file. The tool will automatically create it with defaults on first use.
Your API keys are stored locally in the config file (~/.config/ai_auto_commit/config.json) with standard file permissions (readable only by your user account). The keys are stored in plain text in the config file, so ensure your home directory has appropriate permissions.
Best Practices:
- Never commit your config file to version control
- Ensure your home directory and config file have restrictive permissions
- Regularly rotate your API keys
- On shared systems, ensure proper file permissions on the config directory
The tool:
- Only stores keys locally (never transmitted to any third party)
- Only sends API requests to your chosen AI provider
- Never collects telemetry or analytics
- Is completely open source for your review
# Install (Arch Linux)
yay -S ai-auto-commit
# Run interactive setup
autocommit init
# Navigate to your git repo and use it
cd ~/my-project
git add .
autocommit# Make some changes
vim src/main.py
# Stage and commit
git add src/main.py
autocommitgit add .
autocommit --model gpt-4o --temperature 0.3# Set up defaults
autocommit config set model claude-sonnet-4.5
autocommit config set token-budget 300000
# Use with defaults
git add .
autocommit# Run setup wizard again to change API keys
autocommit init
# Or edit config file directly
autocommit config edit- Review Before Committing: Always review the generated commit message
- Stage Related Changes: Group related changes together for better context
- Use Appropriate Models: Use faster/cheaper models for simple changes, more capable models for complex changes
- Monitor Token Usage: Keep an eye on token usage to control costs
- Set Sensible Budgets: Configure token budgets based on your typical change sizes
- Use Comments: Add comments when you need to provide additional context
- Python 3.8+
- Git
- One or more AI provider API keys:
- OpenAI API key
- Anthropic API key
- Google API key
- Mistral API key
- Cohere API key
MIT
For issues, questions, or contributions, please open an issue on the project repository.
Happy Committing! 🚀