commit-msg

commit-msg is a command-line tool that generates commit messages using LLM (Large Language Models). It is designed to help developers create clear and concise commit messages for their Git repositories automatically by analyzing your staged changes.
Screenshot
Below is a sample execution of commit-msg:

Before running the application, ensure you have set the system environment variables. and add commit.exe to path variables (same for linux macOS)
π Hacktoberfest 2025
This project is participating in Hacktoberfest 2025! We welcome contributions from developers of all skill levels.
Looking to contribute? Check out:
Features
β¨ AI-Powered Commit Messages - Automatically generate meaningful commit messages
π Multiple LLM Support - Choose between Google Gemini, Grok, Claude or ChatGPT
π Context-Aware - Analyzes staged and unstaged changes
π Auto-Copy to Clipboard - Generated messages are automatically copied for instant use
π File Statistics Display - Visual preview of changed files and line counts
π Easy to Use - Simple CLI interface with beautiful terminal UI
β‘ Fast - Quick generation of commit messages
Supported LLM Providers
You can use Google Gemini, Grok, Claude, or ChatGPT as the LLM to generate commit messages:
Environment Variables
| Variable |
Values |
Description |
COMMIT_LLM |
gemini, grok, claude, or chatgpt |
Choose your LLM provider |
GEMINI_API_KEY |
Your API key |
Required if using Gemini |
GROK_API_KEY |
Your API key |
Required if using Grok |
CLAUDE_API_KEY |
Your API key |
Required if using Claude |
OPENAI_API_KEY |
Your API key |
Required if using ChatGPT |
π¦ Installation
Option 1: Download Pre-built Binary (Recommended)
-
Download the latest release from the GitHub Releases page
-
Extract the executable to a directory
-
Add the directory to your system PATH:
Windows:
setx PATH "%PATH%;C:\path\to\commit-msg"
Linux/macOS:
export PATH=$PATH:/path/to/commit-msg
echo 'export PATH=$PATH:/path/to/commit-msg' >> ~/.bashrc # or ~/.zshrc
-
Set up environment variables:
Windows:
setx COMMIT_LLM "gemini"
setx GEMINI_API_KEY "your-api-key-here"
Linux/macOS:
export COMMIT_LLM=gemini
export GEMINI_API_KEY=your-api-key-here
# Add to ~/.bashrc or ~/.zshrc to persist
Option 2: Build from Source
Requirements: Go 1.23.4 or higher
# Clone the repository
git clone https://github.com/dfanso/commit-msg.git
cd commit-msg
# Install dependencies
go mod download
# Build the executable
go build -o commit cmd/commit-msg/main.go
# (Optional) Install to GOPATH
go install
π Usage
Basic Usage
Navigate to any Git repository and run:
commit .
Or if running from source:
go run cmd/commit-msg/main.go .
Example Workflow
# Make changes to your code
echo "console.log('Hello World')" > app.js
# Stage your changes
git add .
# Generate commit message
commit .
# The tool will display:
# - File statistics (staged, unstaged, untracked)
# - Generated commit message in a styled box
# - Automatically copy to clipboard
# Output: "feat: add hello world console log to app.js"
# You can now paste it with Ctrl+V (or Cmd+V on macOS)
Use Cases
- π Generate commit messages for staged changes
- π Analyze both staged and unstaged changes
- π Get context from recent commits and file statistics
- β
Create conventional commit messages
- π Auto-copy to clipboard for immediate use
- π¨ Beautiful terminal UI with file statistics and previews
π§ Configuration
Getting API Keys
Google Gemini:
- Visit Google AI Studio
- Create a new API key
- Set the
GEMINI_API_KEY environment variable
Grok (X.AI):
- Visit X.AI Console
- Generate an API key
- Set the
GROK_API_KEY environment variable
Claude (Anthropic):
- Visit the Anthropic Console
- Create a new API key
- Set the
CLAUDE_API_KEY environment variable
OpenAI (ChatGPT):
- Visit OpenAI Platform
- Create a new API key
- Set the
OPENAI_API_KEY environment variable
π€ Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Quick Start for Contributors
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Commit your changes:
git commit -m 'feat: add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
Areas Where We Need Help
- π Bug fixes
- β¨ New LLM provider integrations (OpenAI, Claude, etc.)
- π Documentation improvements
- π§ͺ Test coverage
- π Internationalization
- β‘ Performance optimizations
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Thanks to all contributors
- Google Gemini and X.AI Grok for providing LLM APIs
- The open-source community
π Support
Made with β€οΈ for Hacktoberfest 2025