An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# ๐Ÿš€ GCMG - Git Commit Message Generator

[![npm version](https://badge.fury.io/js/gcmg.svg)](https://badge.fury.io/js/gcmg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js Version](https://img.shields.io/badge/node-%3E%3D14.0.0-brightgreen)](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*

![Demo](./assets/demo.gif)

---

## โœจ 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