- GPTComet: AI-Powered Git Commit Message Generator And Reviewer
GPTComet is an AI-powered developer tool that streamlines your Git workflow and enhances code quality through automated commit message generation and intelligent code review.
This project leverages the power of large language models to automate repetitive tasks and improve the overall development process. The core features include:
- Automatic Commit Message Generation: GPTComet can generate commit messages based on the changes made in the code.
- Git Hook Integration: Install a
prepare-commit-msghook once and letgit commitfill the message automatically. - Intelligent Code Review: Get AI-powered code reviews with actionable feedback and suggestions.
- Progress Indicators: Optional verbose mode shows real-time progress for long-running operations.
- Support for Multiple Languages: GPTComet supports multiple languages, including English, Chinese and so on.
- Customizable Configuration: GPTComet allows users to customize the configuration to suit their needs, such llm model and prompt.
- Support for Rich Commit Messages: GPTComet supports rich commit messages, which include a title, summary, and detailed description.
- Support for Multiple Providers: GPTComet supports multiple providers, including OpenAI, Gemini, Claude/Anthropic, Vertex, Azure, AWS Bedrock, Ollama, and others.
- Support SVN and Git: GPTComet supports both SVN and Git repositories.
To use GPTComet, you can install it with Homebrew:
brew install belingud/tap/gptcometTo upgrade a Homebrew-managed installation, use:
brew upgrade gptcometYou can also download from Github release, or by install scripts:
curl -sSL https://cdn.jsdelivr.net/gh/belingud/gptcomet@master/install.sh | bashWindows:
irm https://cdn.jsdelivr.net/gh/belingud/gptcomet@master/install.ps1 | iexIf you want to install specific version, you can use the following script:
curl -sSL https://cdn.jsdelivr.net/gh/belingud/gptcomet@master/install.sh | bash -s -- -v 0.4.2irm https://cdn.jsdelivr.net/gh/belingud/gptcomet@master/install.ps1 | iex -CommandArgs @("-v", "0.4.2")If you prefer to run in python, you can install by pip directly, it packaged the binary files corresponding to the platform already.
pip install gptcomet
# Using pipx
pipx install gptcomet
# Using uv
uv tool install gptcomet
Resolved 1 package in 1.33s
Installed 1 package in 8ms
+ gptcomet==0.1.6
Installed 2 executables: gmsg, gptcometTo use gptcomet, follow these steps:
- Install GPTComet: Install GPTComet through pypi.
- Configure GPTComet: See Setup. Configure GPTComet with your api_key and other required keys like:
provider: The provider of the language model (defaultopenai).api_base: The base URL of the API (defaulthttps://api.openai.com/v1).api_key: The API key for the provider.model: The model used for generating commit messages (defaultgpt-6.1-sol).
- Run GPTComet: Run GPTComet using the following command:
gmsg commit.
If you are using openai provider, and finished set api_key, you can run gmsg commit directly.
-
Direct Configuration
- Configure directly in
~/.config/gptcomet/gptcomet.yaml.
- Configure directly in
-
Interactive Setup
- Use the
gmsg newprovidercommand for guided setup.
- Use the
-
Environment Variables
- If
api_keyis not set in the configuration file, GPTComet falls back to the provider's conventional environment variable, such asOPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY,AZURE_API_KEY, or<PROVIDER>_API_KEYfor other providers. - The configuration file takes precedence when both are set.
- If
gmsg newprovider
Select Provider
> 1. azure
2. chatglm
3. claude
4. cohere
5. deepseek
6. gemini
7. groq
8. kimi
9. mistral
10. ollama
11. openai
12. openrouter
13. sambanova
14. silicon
15. tongyi
16. vertex
17. xai
18. Input Manually
↑/k up • ↓/j down • ? moreOpenAI api key page: https://platform.openai.com/api-keys
gmsg newprovider
Selected provider: openai
Configure provider:
Previous inputs:
Enter OpenAI API base: https://api.openai.com/v1
Enter API key: sk-abc*********************************************
Enter max tokens: 1024
Enter Enter model name (default: gpt-6.1-sol):
> gpt-6.1-sol
Provider openai configured successfully!Gemini api key page: https://aistudio.google.com/u/1/apikey
gmsg newprovider
Selected provider: gemini
Configure provider:
Previous inputs:
Enter Gemini API base: https://generativelanguage.googleapis.com/v1beta/models
Enter API key: AIz************************************
Enter max tokens: 1024
Enter Enter model name (default: gemini-3.8-flash):
> gemini-3.8-flash
Provider gemini already has a configuration. Do you want to overwrite it? (y/N): y
Provider gemini configured successfully!I don't have an anthropic account yet, please see Anthropic console
Vertex console page: https://console.cloud.google.com
gmsg newprovider
Selected provider: vertex
Configure provider:
Previous inputs:
Enter Vertex AI API Base URL: https://us-central1-aiplatform.googleapis.com/v1
Enter API key: sk-awz*********************************************
Enter location (e.g., us-central1): us-central1
Enter max tokens: 1024
Enter model name: gemini-3.8-flash
Enter Enter Google Cloud project ID:
> test-project
Provider vertex configured successfully!gmsg newprovider
Selected provider: azure
Configure provider:
Previous inputs:
Enter Azure OpenAI endpoint: https://gptcomet.openai.azure.com
Enter API key: ********************************
Enter API version: 2024-02-15-preview
Enter Azure OpenAI deployment name: gpt-6.1-sol
Enter max tokens: 1024
Enter Enter deployment name (default: gpt-6.1-sol):
> gpt-6.1-sol
Provider azure configured successfully!gmsg newprovider
Selected provider: ollama
Configure provider:
Previous inputs:
Enter Ollama API Base URL: http://localhost:11434/api
Enter max tokens: 1024
Enter Enter model name (default: qwen3.8:27b):
> qwen3.8:27b
Provider ollama configured successfully!- AI21
- AWS Bedrock
- Baidu Qianfan (ERNIE)
- ByteDance Doubao
- Cloudflare Workers AI
- Groq
- Mistral
- Tongyi/Qwen
- XAI
- Sambanova
- Silicon
- Deepseek
- ChatGLM
- KIMI
- LM Studio
- LongCat
- Cohere
- OpenRouter
- Hunyuan
- ModelScope
- MiniMax
Default models are refreshed periodically; see docs/provider-models.md for the current defaults and the last verification date.
AWS Bedrock uses the OpenAI-compatible Bedrock runtime endpoint with a Bedrock API key (set
bedrock.api_keyorAWS_BEARER_TOKEN_BEDROCK). IAM access-key/SigV4 authentication is not supported yet.
Or you can enter the provider name manually, and setup config manually.
gmsg newprovider
You can either select one from the list or enter a custom provider name.
...
vertex
> Input manually
Enter provider name: test
Enter OpenAI API Base URL [https://api.openai.com/v1]:
Enter model name [gpt-6.1-sol]:
Enter API key: ************************************
Enter max tokens [1024]:
[GPTComet] Provider test configured successfully.This is also the escape hatch for any OpenAI-compatible service that GPTComet
does not ship a preset for: enter a custom provider name, then set its
api_base, model, and api_key. Advanced users can also set
completion_path, answer_path, stream_answer_path, extra_headers, and
extra_body for non-standard APIs.
Cloudflare Workers AI is a built-in provider now. Select cloudflare in
gmsg newprovider and enter your account ID, API token, and Workers AI model
(for example @cf/openai/gpt-oss-120b); GPTComet builds the OpenAI-compatible
endpoint for you. The old /ai/run + result.response manual workaround is no
longer needed.
$ gmsg newprovider
Selected provider: cloudflare
Configure provider:
Enter Cloudflare account ID: <account_id>
Enter Cloudflare API token: *************************************
Enter Workers AI model ID [@cf/openai/gpt-oss-120b]:
Enter max tokens [1024]:
Provider cloudflare configured successfully!The following are the available commands for GPTComet:
gmsg config: Config manage commands group.get <key>: Get the value of a configuration key.list: List the entire configuration content.reset: Reset the configuration to default values (optionally reset only the prompt section with--prompt).set <key> <value>: Set a configuration value.path: Get the configuration file path.remove <key> [value]: Remove a configuration key or a value from a list. (List value only, likefileignore)append <key> <value>: Append a value to a list configuration.(List value only, likefileignore)keys: List all supported configuration keys.validate: Validate the current configuration and report issues.
gmsg commit: Generate commit message by changes/diff.--svn: Generate commit message for svn.--dry-run: Dry run the command without actually generating the commit message.-y/--yes: Skip the confirmation prompt.--no-verify: Skip git hooks verification, akin to usinggit commit --no-verify--repo: Path to the repository (default ".").--answer-path: Override answer path--api-base: Override API base URL--api-key: Override API key--completion-path: Override completion path--frequency-penalty: Override frequency penalty--max-tokens: Override maximum tokens--model: Override model name--provider: Override AI provider (openai/deepseek)--proxy: Override proxy URL--retries: Override retry count--timeout: Override request timeout in seconds--temperature: Override temperature--top-p: Override top_p value
gmsg generate: Generate a commit message from the staged diff and print only the message to stdout.--repo: Path to the repository (default ".").--rich: Generate a rich commit message with details.- API override flags:
--model,--api-base,--api-key,--timeout, and the other advanced flags.
gmsg hook: Manage the Gitprepare-commit-msghook.install [--repo] [--force]: Install the hook;--forcebacks up an existing hook first.uninstall [--repo]: Remove a gptcomet-managed hook and restore a backup.status [--repo]: Show the hooks directory, state, and backup.
gmsg newprovider: Add a new provider.gmsg review: Review staged diff or pipe togmsg review.--svn: Get diff from svn.--stream: Stream output as it arrives from the LLM.--repo: Path to the repository (default ".").--answer-path: Override answer path--api-base: Override API base URL--api-key: Override API key--completion-path: Override completion path--frequency-penalty: Override frequency penalty--max-tokens: Override maximum tokens--model: Override model name--provider: Override AI provider (openai/deepseek)--proxy: Override proxy URL--retries: Override retry count--timeout: Override request timeout in seconds--temperature: Override temperature--top-p: Override top_p value
Global flags:
-c, --config string Config file path
-d, --debug Enable debug modeInstall the hook once per repository:
gmsg hook install
gmsg hook statusThe managed prepare-commit-msg hook generates a message from the staged diff before the editor
opens. It fails open: if gptcomet is missing, the configuration is invalid, there is no staged
diff, or the API call fails or times out, the commit message file is left unchanged and the commit
continues.
gmsg hook uninstall # remove the managed hook
gmsg hook install --force # back up and replace an existing hookBehavior:
- Skips
git commit -m/-F, merges, squash commits, andgit commit --amend. - Skips when the message file already has non-comment content. The all-comment template used by the first commit is still filled; a custom template with real content is left untouched.
GMSG_SKIP=1skips the hook entirely.GMSG_FORCE=1overrides the explicit-message and existing-content skips.GMSG_BIN=/path/to/gmsgselects the binary;GMSG_CONFIG=/path/to/config.yamlselects the configuration file.gmsg hook install -c <config>embeds that config path in the hook.gmsg hook install --forcebacks up an existing hook toprepare-commit-msg.gptcomet-backup;gmsg hook uninstallrestores it.- The hooks directory is resolved with
git rev-parse, socore.hooksPathand linked worktrees are respected. - Generation is synchronous, so the editor opens after the model responds; the configured
<provider>.timeoutbounds the wait. git commit --no-verifydoes not skipprepare-commit-msg; useGMSG_SKIP=1instead.
To preview the exact message without committing:
gmsg generate
gmsg generate --richgenerate writes only the message to stdout; status and token-usage output goes to stderr, so it is
safe to use in scripts.
Here's a summary of the main configuration keys:
| Key | Description | Default Value |
|---|---|---|
provider |
The name of the LLM provider to use. | openai |
file_ignore |
A list of file patterns to ignore in the diff. | (See file_ignore) |
output.lang |
The language for commit message generation. | en |
output.rich_template |
The template to use for rich commit messages. | <title>:<summary>\n\n<detail> |
output.translate_title |
Translate the title of the commit message. | false |
output.review_lang |
The language to generate the review message. | en |
output.markdown_theme |
The theme to display markdown_theme content. | auto |
console.verbose |
Enable verbose output with progress indicators and detailed error messages. | true |
<provider>.api_base |
The API base URL for the provider. | (Provider-specific) |
<provider>.api_key |
The API key for the provider. | |
<provider>.model |
The model name to use. | (Provider-specific) |
<provider>.retries |
The number of retry attempts for API requests. | 2 |
<provider>.timeout |
Request timeout in seconds. Non-streaming calls use it as a total deadline; streaming calls use it as an idle timeout that resets whenever content arrives. | 60 |
<provider>.proxy |
The proxy URL to use (if needed). | |
<provider>.max_tokens |
The maximum number of tokens to generate. | 2048 |
<provider>.top_p |
The top-p value for nucleus sampling. | 0.7 |
<provider>.temperature |
The temperature value for controlling randomness. | 0.7 |
<provider>.frequency_penalty |
The frequency penalty value. | 0 |
<provider>.extra_headers |
Extra headers to include in API requests (JSON string). | {} |
<provider>.extra_body |
Extra body to include in API requests (JSON string). | {} |
<provider>.completion_path |
The API path for completion requests. | (Provider-specific) |
<provider>.answer_path |
The JSON path to extract the answer from the API response. | (Provider-specific) |
prompt.brief_commit_message |
The prompt template for generating brief commit messages. | (See defaults/defaults.go) |
prompt.rich_commit_message |
The prompt template for generating rich commit messages. | (See defaults/defaults.go) |
prompt.translation |
The prompt template for translating commit messages. | (See defaults/defaults.go) |
prompt.review |
The prompt template for reviewing code changes. | (See defaults/defaults.go) |
Note: <provider> should be replaced with the actual provider name (e.g., openai, gemini, claude).
Some providers require specific keys, such as Vertex needing project ID, location, etc.
The configuration file for GPTComet is gptcomet.yaml. The file should contain the following keys:
output.translate_title is used to determine whether to translate the title of the commit message.
For example in output.lang: zh-cn, the title of the commit message is feat: Add new feature
If output.translate_title is set to true, the commit message will be translated to 功能:新增功能.
Otherwise, the commit message will be translated to feat: 新增功能.
In some case you can set complation_path to empty string, like <provider>.completion_path: "", to use api_base endpoint directly.
The file to ignore when generating a commit. The default value is
- bun.lockb
- Cargo.lock
- composer.lock
- Gemfile.lock
- package-lock.json
- pnpm-lock.yaml
- poetry.lock
- yarn.lock
- pdm.lock
- Pipfile.lock
- "*.py[cod]"
- go.sum
- uv.lockYou can add more file_ignore by using the gmsg config append file_ignore <xxx> command.
<xxx> uses gitignore-style patterns:
*.lockmatchesa.lockandvendor/a.lock(a pattern without/matches at any depth).vendor/**matches everything undervendor/, anddocs/*.mdmatches only direct children ofdocs/./go.summatches only the repository-rootgo.sum;go.summatches it at any depth.build/matches a directory namedbuildand everything below it.!important.lockre-includes a file matched by an earlier pattern.
Example:
gmsg config append file_ignore "vendor/**"
gmsg config append file_ignore "!vendor/keep.go"The provider configuration of the language model.
The default provider is openai.
Provider config just like:
provider: openai
openai:
api_base: https://api.openai.com/v1
api_key: YOUR_API_KEY
model: gpt-6.1-sol
retries: 2
max_tokens: 1024
temperature: 0.7
top_p: 0.7
frequency_penalty: 0
extra_headers: {}
answer_path: choices.0.message.content
completion_path: /chat/completionsIf you are using openai, just leave the api_base as default. Set your api_key in the config section.
If you are using an openai class provider, or a provider compatible interface, you can set the provider to openai.
And set your custom api_base, api_key and model.
For example:
Openrouter providers api interface compatible with openai,
you can set provider to openai and set api_base to https://openrouter.ai/api/v1,
api_key to your api key from keys page
and model to openai/gpt-6.1-sol or some other you prefer.
gmsg config set openai.api_base https://openrouter.ai/api/v1
gmsg config set openai.api_key YOUR_API_KEY
gmsg config set openai.model openai/gpt-6.1-sol
gmsg config set openai.max_tokens 1024Silicon providers the similar interface with openrouter, so you can set provider to openai
and set api_base to https://api.siliconflow.cn/v1.
Note that max tokens may vary, and will return an error if it is too large.
The output configuration of the commit message.
The default output is
output:
lang: en
rich_template: "<title>:<summary>\n\n<detail>"
translate_title: false
review_lang: "en"
markdown_theme: "auto"You can set rich_template to change the template of the rich commit message,
and set lang to change the language of the commit message.
Supported markdown theme:
auto: Auto detect markdown theme (default).ascii: ASCII style.dark: Dark theme.dracula: Dracula theme.light: Light theme.tokyo-night: Tokyo Night theme.notty: Notty style, no render.pink: Pink theme.
If you not set markdown_theme, the markdown theme will be auto detected.
If you are using light terminal, the markdown theme will be dark, if you are using dark terminal, the markdown theme will be light.
GPTComet is using glamour to render markdown, you can preview the markdown theme in glamour preview.
output.lang and output.review_lang support the following languages:
en: Englishzh-cn: Simplified Chinesezh-tw: Traditional Chinesefr: Frenchvi: Vietnameseja: Japaneseko: Koreanru: Russiantr: Turkishid: Indonesianth: Thaide: Germanes: Spanishpt: Portugueseit: Italianar: Arabichi: Hindiel: Greekpl: Polishnl: Dutchsv: Swedishfi: Finnishhu: Hungariancs: Czechro: Romanianbg: Bulgarianuk: Ukrainianhe: Hebrewlt: Lithuanianla: Latinca: Catalansr: Serbiansl: Slovenianmk: Macedonianlv: Latvian
The console output config.
The default console is
console:
verbose: trueWhen verbose is enabled (true), GPTComet provides enhanced user experience:
-
Progress Indicators: Shows real-time progress for commit message generation and code review
[1/2] Fetching git diff... ✓ Fetching git diff (0.07s) Discovered provider: mistral, model: codestral-latest [2/2] Generating message... ✓ Generating message (13.24s) -
Detailed Operation Information: Displays which provider and model are being used
-
Enhanced Error Messages: All errors include:
- Clear problem description
- Specific suggestions for resolution
- Relevant documentation links
- Appropriate emoji indicators for quick identification
When verbose is disabled (false), GPTComet runs in silent mode with minimal output, suitable for scripting and automated workflows.
You can use gmsg config keys to check supported keys.
Here is an example of how to use GPTComet:
- When you first set your OpenAI KEY by
gmsg config set openai.api_key YOUR_API_KEY, it will generate config file at~/.local/gptcomet/gptcomet.yaml, includes:
provider: "openai"
openai:
api_base: "https://api.openai.com/v1"
api_key: "YOUR_API_KEY"
model: "gpt-6.1-sol"
retries: 2
output:
lang: "en"
- Run the following command to generate a commit message:
gmsg commit - GPTComet will generate a commit message based on the changes made in the code and display it in the console.
GPTComet provides helpful error messages with actionable suggestions:
$ gmsg commit
❌ API Key Not Configured
Provider 'openai' requires an API key, but none was found.
What to do:
• Set API key: gmsg config set openai.api_key <your-key>
• Or set env var: export OPENAI_API_KEY=<your-key>
• Check provider: gmsg config get openai
Docs: https://github.com/belingud/gptcomet#configurationWhen console.verbose is enabled (default), you'll see real-time progress:
$ gmsg commit
[1/2] Fetching git diff...(0.07s)
Discovered provider: mistral, model: codestral-latest
[2/2] Generating message...
📤 Sending request to mistral...
Token usage> prompt: 1341, completion: 10, total: 1,351
✓ Generating message (13.24s)
feat: add user authentication featureTo disable progress indicators and run in silent mode:
gmsg config set console.verbose falseNote: Replace YOUR_API_KEY with your actual API key for the provider.
- Go 1.25+
- Python 3.9+
- just command runner
- pytest (for Python tests)
If you'd like to contribute to GPTComet, feel free to fork this project and submit a pull request.
First, fork the project and clone your repo.
git clone https://github.com/<yourname>/gptcometSecond, make sure you have uv, you can install by pip, brew or other way in their installation docs
Use just command to install dependencies:
just install# Run all Go tests
go test ./...
# Run specific package tests
go test ./internal/llm/
# Run with coverage
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# Using just
just test # Run tests with coverage
just test-coverage # Generate coverage report
just test-cover-func # Show coverage by function# Run Python wrapper tests
just test-py
# Run with coverage
just test-py-cov
# Or manually with uv
uv run pytest tests/py_tests/ -v
uv run pytest tests/py_tests/ --cov=py/gptcomet --cov-report=html# Static analysis
go vet ./...
staticcheck ./...
# Using just
just check # Run go vet and staticcheck
just format # Format Go code# Code linting
ruff check py/
# Formatting
ruff format py/# Build Go binary
just build
# Build all platforms
just build-all
# Build Python wheel
just build-pyIf you have any questions or suggestions, feel free to contact.
If you like GPTComet, you can buy me a coffee to support me. Any support can help the project go further.
GPTComet is licensed under the MIT License.

