gmc is a CLI tool that accelerates the efficiency of Git add and commit by using LLM to generate high-quality commit messages, thereby reducing the cognitive load on developers when submitting code.
- One Command Commit:Complete git add and commit operations with a single command
- Smart Message Generation:Automatically generate commit messages based on git diff
- LLM Models Support:Support OpenAI API Style
- Role Customization:Generate commit messages tailored to different engineering roles
- Conventional Commits:The generated message follows the Conventional Commits specification
- Branch Creation:Automatically create feature branches with generated names based on description
- Commit History Analysis:Analyze commit quality and get AI-powered improvement suggestions
- Auto Version Tagging:Recommend the next semantic version and create annotated git tags on demand
First use gmc to set the OpenAI API serivce:
gmc config set apibase https://your-proxy-domain.com/v1
gmc config set apikey YOUR_OPENAI_API_KEY
gmc config set model gpt-4.1-miniAnd Configure other parameters.
# Set role
(base) ➜ ~ gmc config set [Key]
apibase -- Set OpenAI API Base URL
apikey -- Set OpenAI API Key
model -- Set up the LLM model
prompt_template -- Set Prompt Template
prompts_dir -- Set Prompt Template Directory
role -- Set Current RoleUse the following command.
# It's will Automatically read git diff from staging area.
gmc
# Automatically add all changes to the staging area
gmc -a
# Associate issue number
gmc --issue 123
# Create feature branch with generated name
gmc --branch "implement user authentication"
# Verbose output for debugging
gmc --verbose
# Set Template directory
gmc config set prompts_dir /path/to/templates
# Use Template (only filename in prompts_dir)
gmc config set prompt_template my_template
# Analyze commit history quality (personal)
gmc analyze
# Analyze team commit history quality
gmc analyze --team
# Suggest next semantic version and create a tag
gmc tag
# Auto-confirm the suggested tag without prompting
gmc tag --yesgmc supports prompt templates, allowing you to adjust the style of the generated commit message.
| Template Name | Description |
|---|---|
| default | Standard prompt template, generate commit messages that conform to the specification |
You can create a prompt template, the method is as follows:
- Create a YAML format template file in the
~/.gmc/promptsdirectory, for examplemy_template.yaml:
name: "My Template"
description: "My commit message format"
template: |
As a {{.Role}}, please generate a commit message that follows the Conventional Commits specification for the following Git changes:
Changed Files:
{{.Files}}
Changed Content:
{{.Diff}}
Commit message format requirements:
- Use the "type(scope): description" format
- The type must be one of: feat, fix, docs, style, refactor, perf, test, chore
- The scope should be specific, and the description should be concise
- Do not include issue numbersYou can use the following variables in the template:
{{.Role}}: The user configured role{{.Files}}: The list of changed files{{.Diff}}: Git difference content
This project is licensed under the MIT License - see the LICENSE file for details