💡 摘要
一个使用ChatGPT AI生成git提交信息和代码审查摘要的CLI工具。
🎯 适合人群
🤖 AI 吐槽: “看起来很能打,但别让配置把人劝退。”
风险:High。建议检查:是否执行 shell/命令行指令;是否发起外网请求(SSRF/数据外发);API Key/Token 的获取、存储与泄露风险;文件读写范围与路径穿越风险。以最小权限运行,并在生产环境启用前审计代码与依赖。
CodeGPT
A CLI tool written in Go that generates git commit messages or provides code review summaries using ChatGPT AI (gpt-5, gpt-4o, gpt-4 model). It also automatically installs a git prepare-commit-msg hook.

Table of Contents
- CodeGPT
- Table of Contents
- Features
- Installation
- Configuration
- Using API Key Helper for Dynamic Credentials
- How to Customize the Default Prompt Folder
- How to Change to Azure OpenAI Service
- Support for Gemini API Service
- Support for Anthropic API Service
- How to Change to Groq API Service
- How to Change to Ollama API Service
- How to Change to OpenRouter API Service
- Usage
- Change Commit Message Template
- Testing
- Star History
- Reference
Features
- Supports Azure OpenAI Service, OpenAI API, [Gemini][60], [Anthropic][100], [Ollama][41], [Groq][30], and [OpenRouter][50].
- Adheres to the conventional commits specification.
- Integrates with Git prepare-commit-msg Hook, see the Git Hooks documentation.
- Allows customization of generated diffs by specifying the number of context lines (default: 3).
- Enables file exclusion patterns for git diff operations.
- Translates commit messages into other languages (supports
en,zh-tw, orzh-cn). - Supports SOCKS proxy or custom network HTTP proxy.
- Generates brief code reviews.
- Allows customization of prompt templates and variables.

Installation
macOS
Install via Homebrew:
brew tap appleboy/tap brew install codegpt
Windows
Install via Chocolatey:
choco install codegpt
Install via Script or Binary
For most systems, you can use an install script or manually download a pre-compiled binary.
A. Automated Install (Recommended)
Run the install script to automatically download and set up the latest release:
bash < <(curl -sSL https://raw.githubusercontent.com/appleboy/CodeGPT/main/install.sh)
Or download and run manually:
curl -LO https://raw.githubusercontent.com/appleboy/CodeGPT/main/install.sh chmod +x install.sh ./install.sh
B. Manual Install (Advanced)
-
Download the latest pre-compiled binary from the release page.
-
Change permissions:
chmod 755 codegpt -
Move the binary to your system bin directory:
mv codegpt /usr/local/bin/ -
Confirm installation:
codegpt version
Configurable Environment Variables
| Variable Name | Default Value | Description | | ------------- | ------------------ | ----------------------------------------------------------------------------- | | VERSION | latest | The CodeGPT version to install (defaults to latest release) | | INSTALL_DIR | $HOME/.codegpt/bin | Installation directory | | INSECURE | unset (disabled) | If set to any value, skips SSL verification. Enabled when variable is present |
Example usage:
# Install with insecure mode enabled (ignoring curl SSL verification): INSECURE=1 ./install.sh # Install a specific version to a custom directory: VERSION=1.1.0 INSTALL_DIR=/opt/codegpt ./install.sh
The script will:
- Detect your OS and architecture
- Download the latest binary
- Add the binary to your PATH
From Source
Install from source code:
go install github.com/appleboy/CodeGPT/cmd/codegpt@latest
Using VSCode Devcontainer
Add the feature to your devcontainer.json:
"features": { "ghcr.io/kvokka/features/codegpt:1": {} }
Configuration
First, create your OpenAI API Key. The OpenAI Platform allows you to generate a new API Key.

Set the environment variable OPENAI_API_KEY:
export OPENAI_API_KEY=sk-xxxxxxx
Alternatively, store your API key in a custom config file:
codegpt config set openai.api_key sk-xxxxxxx
This will create a .codegpt.yaml file in your home directory ($HOME/.config/codegpt/.codegpt.yaml). The following options are available:
| Option | Description |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| openai.base_url | Replace the default base URL (https://api.openai.com/v1). |
| openai.api_key | Generate API key from openai platform page. |
| openai.api_key_helper | Shell command to dynamically generate API key (e.g., from password manager or secret service). |
| openai.api_key_helper_refresh_interval | Interval in seconds to refresh credentials from api_key_helper (default: 900 seconds / 15 minutes). Set to 0 to disable caching. |
| openai.org_id | Identifier for this organization sometimes used in API requests. See organization settings. Only for openai service. |
| openai.model | Default model is gpt-4o, you can change to other custom model (Groq or OpenRouter provider). |
| openai.proxy | HTTP/HTTPS client proxy. |
| openai.socks | SOCKS client proxy. |
| openai.timeout | Default HTTP timeout is 10s (ten seconds). |
| openai.skip_verify | Default skip_verify is false, You can change it to true to ignore SSL verification. |
| openai.max_tokens | Default max tokens is 300. See reference [max_tokens](https://platform.o
优点
- 自动生成提交信息。
- 支持多种AI服务。
- 可自定义模板和设置。
缺点
- 需要设置API密钥。
- 高级功能可能需要额外配置。
- 依赖外部AI服务。
相关技能
免责声明:本内容来源于 GitHub 开源项目,仅供展示和评分分析使用。
版权归原作者所有 appleboy.
