https://github.com/yashraj-n/gcmg
A command-line tool that uses AI to automatically generate meaningful and well-formatted Git commit messages based on your code changes. It supports multiple AI providers including OpenAI, Anthropic, Google, Groq, and Perplexity.
https://github.com/yashraj-n/gcmg
ai cli commit git github npm package typescript
Last synced: about 1 year ago
JSON representation
A command-line tool that uses AI to automatically generate meaningful and well-formatted Git commit messages based on your code changes. It supports multiple AI providers including OpenAI, Anthropic, Google, Groq, and Perplexity.
- Host: GitHub
- URL: https://github.com/yashraj-n/gcmg
- Owner: yashraj-n
- License: mit
- Created: 2024-12-21T17:07:00.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-14T16:04:22.000Z (about 1 year ago)
- Last Synced: 2025-06-14T16:04:59.877Z (about 1 year ago)
- Topics: ai, cli, commit, git, github, npm, package, typescript
- Language: TypeScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ GCMG - Git Commit Message Generator
[](https://badge.fury.io/js/gcmg)
[](https://opensource.org/licenses/MIT)
[](https://nodejs.org/)
**๐ค Intelligent AI-powered commit message generation for developers who value quality and consistency**
*Transform your git workflow with smart, standardized commit messages generated from your actual code changes*

---
## โจ Features
๐ฏ **Smart Commit Generation** - Analyzes your `git diff` to create meaningful, descriptive commit messages
๐ค **Multi-AI Provider Support** - Choose from OpenAI, Anthropic, Google, Groq, and more
โก **Lightning Fast** - Built with esbuild for optimal performance
๐ง **Interactive Setup** - Guided configuration with beautiful CLI prompts
๐ **Standardized Format** - Consistent commit message structure across your projects
๐ **Cross-Platform** - Works seamlessly on Windows, macOS, and Linux
๐ **Auto Git Operations** - Optional automatic add, commit, and push workflow
๐ฌ **AI Query Mode** - Ask questions about git commands and get instant help
## ๐จ What Makes GCMG Special?
### ๐ง **Intelligent Analysis**
- Reads your actual code changes via `git diff`
- Understands context and generates relevant commit messages
- Handles large diffs intelligently (with smart 10k character limit)
### ๐ญ **Multiple AI Personalities**
Choose from the industry's best AI models:
| Provider | Models Available | Strengths |
|----------|-----------------|-----------|
| **OpenAI** | GPT-4, GPT-4o, o1, o3-mini | Most versatile, excellent reasoning |
| **Anthropic** | Claude-4, Claude-3.5 Sonnet/Haiku | Superior code understanding |
| **Google** | Gemini 2.0, Gemini 1.5 Pro/Flash | Fast and efficient |
| **Groq** | Llama 3.3, Mixtral, Qwen | Lightning-fast inference |
| **Google Vertex** | Enterprise Gemini models | Enterprise-grade reliability |
### ๐ฏ **Perfect Commit Format**
Every generated message follows this proven structure:
```
[feat] Add user authentication system
- Implement JWT token-based authentication
- Add login and logout endpoints
- Create user session management
- Add password encryption with bcrypt
... Enhances application security and user management
```
## ๐ Quick Start
### Installation
```bash
npm install -g gcmg
```
### Setup (One-time)
```bash
gcmg config
```
Follow the interactive prompts to:
1. ๐ฏ Select your preferred AI provider
2. ๐ค Choose an AI model
3. ๐ Enter your API key
### Usage
```bash
# Make your changes
git add .
# Generate and commit
gcmg
# Or ask for help
gcmg "how do I remove sensitive data from git history?"
```
## ๐ช Command Showcase
GCMG provides multiple command aliases for maximum convenience:
```bash
gcmg # ๐ Primary command
git-cmg # ๐ง Git-style alias
git-commit-msg-generate # ๐ Descriptive alias
```
### ๐จ Available Commands
| Command | Description | Example |
|---------|-------------|---------|
| `gcmg` | ๐ฏ Generate commit message from changes | `gcmg` |
| `gcmg config` | โ๏ธ Interactive configuration setup | `gcmg config` |
| `gcmg edit` | โ๏ธ Edit configuration file | `gcmg edit` |
| `gcmg help` | ๐ Show beautiful help message | `gcmg help` |
| `gcmg ` | ๐ฌ Ask git-related questions | `gcmg "revert last commit"` |
## ๐ ๏ธ Configuration
Configuration is stored securely in platform-appropriate locations:
- **Windows:** `%APPDATA%\gcmg\.gcmg-config`
- **macOS:** `~/Library/Application Support/gcmg/.gcmg-config`
- **Linux:** `~/.config/gcmg/.gcmg-config`
### ๐ง Configuration Structure
```json
{
"name": "OpenAI",
"provider": "@ai-sdk/openai",
"model": "gpt-4o",
"apiKey": "your-api-key",
"prompts": {
"commit": "Your custom commit prompt...",
"help": "Your custom help prompt..."
}
}
```
## ๐ญ Advanced Features
### ๐ค **AI Query Mode**
Get instant help with git commands:
```bash
gcmg "how to merge branches safely"
gcmg "undo last commit but keep changes"
gcmg "remove file from git history"
```
### โก **Smart Diff Handling**
- Automatically detects when no changes exist
- Warns about large diffs (>10k characters)
- Handles binary files and complex changes intelligently
### ๐ **Streamlined Workflow**
1. **Analyze** - Reads your git diff
2. **Generate** - Creates intelligent commit message
3. **Review** - Shows you the proposed message
4. **Commit** - Optionally commits with `git add . && git commit`
5. **Push** - Optionally pushes to remote repository
## ๐๏ธ Architecture
GCMG is built with modern development practices:
- **TypeScript** - Type-safe development
- **ESBuild** - Lightning-fast compilation
- **Vercel AI SDK** - Unified AI provider interface
- **Enquirer** - Beautiful interactive prompts
- **Zod** - Runtime type validation
- **Cross-platform** - Works everywhere Node.js runs
### ๐ Project Structure
```
gcmg/
โโโ src/
โ โโโ commands/ # ๐ฏ CLI command implementations
โ โโโ lib/ # ๐ง Core libraries (config, LLM, models)
โ โโโ scripts/ # ๐ ๏ธ Build and utility scripts
โ โโโ prompts.ts # ๐ฌ AI prompt templates
โโโ assets/ # ๐จ Visual assets
โโโ dist/ # ๐ฆ Built output
```
## ๐จ Commit Types
GCMG automatically categorizes your changes:
| Type | Description | Example |
|------|-------------|---------|
| `feat` | โจ New features | `[feat] Add dark mode toggle` |
| `fix` | ๐ Bug fixes | `[fix] Resolve login validation error` |
| `docs` | ๐ Documentation | `[docs] Update API documentation` |
| `style` | ๐ Code formatting | `[style] Fix indentation and spacing` |
| `refactor` | โป๏ธ Code refactoring | `[refactor] Simplify user service logic` |
| `test` | ๐งช Testing | `[test] Add unit tests for auth module` |
| `chore` | ๐ง Maintenance | `[chore] Update dependencies` |
## ๐ค Contributing
We love contributions! Here's how to get started:
1. **Fork** the repository
2. **Create** your feature branch (`git checkout -b feature/amazing-feature`)
3. **Commit** your changes using GCMG itself! (`gcmg`)
4. **Push** to the branch (`git push origin feature/amazing-feature`)
5. **Open** a Pull Request
### ๐ ๏ธ Development Setup
```bash
git clone https://github.com/yashraj-n/gcmg.git
cd gcmg
npm install
npm run build
```
## ๐ Why Choose GCMG?
### ๐ฏ **Before GCMG**
```
git commit -m "fix stuff"
git commit -m "update"
git commit -m "asdfgh"
```
### โจ **After GCMG**
```
[fix] Resolve authentication middleware validation error
- Fix JWT token verification logic
- Add proper error handling for expired tokens
- Update middleware to handle edge cases
- Add comprehensive logging for debugging
... Improves application security and user experience
```
## ๐ Real-World Example
```bash
$ gcmg
โ Getting Changes...
โ Generating Commit Message...
[feat] Implement user profile management system
- Add user profile CRUD operations
- Create profile update validation
- Implement avatar upload functionality
- Add email verification for profile changes
- Create comprehensive user settings page
... Enhances user experience with complete profile control
? Do you want to add and commit these changes? โบ Yes
โ Changes committed successfully
? Do you want to push the changes? โบ Yes
โ Changes pushed successfully
๐ Goodbye!
```
## ๐ License
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
**โญ Star this repo if GCMG helps improve your git workflow! โญ**
[๐ Report Bug](https://github.com/yashraj-n/gcmg/issues) ยท [โจ Request Feature](https://github.com/yashraj-n/gcmg/issues) ยท [๐ฌ Discussions](https://github.com/yashraj-n/gcmg/discussions)
Made with ๐ป and โ for developers who care about quality commits