git-auto-commit

A cross-platform CLI tool that automatically generates meaningful commit messages from your staged changes using AI.
Features
- 🤖 Multiple AI Providers: Supports OpenAI (native & Azure), Anthropic Claude, and GitHub Models
- 🌍 Cross-Platform: Works on Windows, Linux, and macOS
- 📝 Conventional Commits: Generates commit messages following the conventional commit format
- 🔒 Secure: API keys stored in local config file with restricted permissions
- 🎯 Simple to Use: Interactive configuration wizard and straightforward CLI
- ⚡ Fast: Written in Go for optimal performance
Installation
From Source
go install github.com/algernon-coop/git-auto-commit@latest
Using Go Get
git clone https://github.com/algernon-coop/git-auto-commit.git
cd git-auto-commit
go build -o git-auto-commit .
Pre-built Binaries
Download pre-built binaries from the releases page.
Quick Start
Run the interactive configuration wizard:
git-auto-commit configure
This will prompt you to select an AI provider and enter your credentials:
- OpenAI (native): Requires an OpenAI API key
- OpenAI (Azure): Requires Azure OpenAI endpoint, API key, and deployment name
- Anthropic Claude: Requires an Anthropic API key
- GitHub Models: Requires a GitHub token
2. Stage Your Changes
git add .
3. Generate and Commit
git-auto-commit
The tool will:
- Analyze your staged changes
- Generate a meaningful commit message using AI
- Display the message for review
- Commit the changes
Dry Run Mode
To preview the commit message without committing:
git-auto-commit --dry-run
Configuration
The configuration is stored in ~/.git-auto-commit.yaml by default. You can specify a custom config file:
git-auto-commit --config /path/to/config.yaml
provider: openai
openai:
api_key: your-api-key-here
model: gpt-4
Supported AI Providers
OpenAI (Native)
provider: openai
openai:
api_key: sk-...
model: gpt-4 # or gpt-3.5-turbo, gpt-4-turbo, etc.
Azure OpenAI
provider: azure
azure:
endpoint: https://your-resource.openai.azure.com
api_key: your-azure-api-key
deployment: your-deployment-name
Anthropic Claude
provider: claude
claude:
api_key: sk-ant-...
model: claude-3-5-sonnet-20241022 # or other Claude models
GitHub Models
provider: github
github:
token: ghp_...
model: gpt-4o # or other available models
Development
Prerequisites
Building from Source
git clone https://github.com/algernon-coop/git-auto-commit.git
cd git-auto-commit
go mod download
go build -o git-auto-commit .
Running Tests
go test ./... -v
Using Dev Container
This project includes a dev container configuration for VS Code:
- Install the Dev Containers extension
- Open the project in VS Code
- Click "Reopen in Container" when prompted
Linting
golangci-lint run
CI/CD
The project uses GitHub Actions for continuous integration:
- Test: Runs tests on Linux, Windows, and macOS with multiple Go versions
- Lint: Runs golangci-lint to ensure code quality
- Build: Creates binaries for all supported platforms
Dependencies
Dependencies are managed with Go modules and automatically updated weekly via Dependabot.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'feat: add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Inspired by the need for better commit messages
- Built with Cobra for CLI functionality
- Uses various AI providers for intelligent commit message generation