使用 AI 自動生成 Git commit message 的 CLI 工具。支援 OpenAI 和 Anthropic API。
- 自動生成 Conventional Commits 格式的 commit message
- 支援 OpenAI 和 Anthropic 兩種 AI 提供者
- 支援多國語言 commit message(中文、日文、韓文等)
- 簡單的命令列介面
- 安全的設定檔儲存
複製以下指令到終端機執行,自動下載預編譯的執行檔並安裝:
macOS (Apple Silicon M1/M2/M3):
curl -sSL https://github.com/meowalien/aicommit/releases/latest/download/aicommit-darwin-arm64 -o /usr/local/bin/aicommit && \
chmod +x /usr/local/bin/aicommit && \
echo "✅ 安裝完成!" && \
aicommit --helpmacOS (Intel):
curl -sSL https://github.com/meowalien/aicommit/releases/latest/download/aicommit-darwin-amd64 -o /usr/local/bin/aicommit && \
chmod +x /usr/local/bin/aicommit && \
echo "✅ 安裝完成!" && \
aicommit --helpLinux (x86_64):
curl -sSL https://github.com/meowalien/aicommit/releases/latest/download/aicommit-linux-amd64 -o /usr/local/bin/aicommit && \
chmod +x /usr/local/bin/aicommit && \
echo "✅ 安裝完成!" && \
aicommit --helpLinux (ARM64):
curl -sSL https://github.com/meowalien/aicommit/releases/latest/download/aicommit-linux-arm64 -o /usr/local/bin/aicommit && \
chmod +x /usr/local/bin/aicommit && \
echo "✅ 安裝完成!" && \
aicommit --help如果
/usr/local/bin需要權限,請在指令前加上sudo
- 前往 Releases 頁面
- 下載對應你系統的執行檔:
aicommit-darwin-arm64- macOS Apple Siliconaicommit-darwin-amd64- macOS Intelaicommit-linux-amd64- Linux x86_64aicommit-linux-arm64- Linux ARM64
- 重新命名為
aicommit並移動到 PATH 目錄中 - 賦予執行權限:
chmod +x aicommit
如果你想從原始碼編譯,需要先安裝 Go 1.21 或更高版本。
# 1. Clone 專案
git clone https://github.com/meowalien/aicommit.git
cd aicommit
# 2. 編譯並安裝到 GOPATH/bin
go install ./cmd/aicommit/
# 3. 設定 PATH(加入 ~/.zshrc)
grep -q 'export PATH="$PATH:$HOME/go/bin"' ~/.zshrc || echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.zshrc
source ~/.zshrc
# 4. 驗證安裝
aicommit --help在使用之前,需要先設定 AI 提供者的 API Key:
aicommit set anthropic_key=你的_ANTHROPIC_API_KEY
aicommit set provider=anthropicaicommit set openai_key=你的_OPENAI_API_KEY
aicommit set provider=openai# Anthropic 模型
aicommit set anthropic_model=claude-sonnet-4-20250514
# OpenAI 模型
aicommit set openai_model=gpt-4o預設為英文 (en),可設定為其他語言:
# 繁體中文
aicommit set language=zh-TW
# 簡體中文
aicommit set language=zh-CN
# 日文
aicommit set language=ja
# 韓文
aicommit set language=ko
# 英文(預設)
aicommit set language=en也可以使用簡寫 lang:
aicommit set lang=zh-TW設定檔儲存於 ~/.aicommit/config.yaml
# 1. 先 stage 你的修改
git add .
# 2. 執行 aicommit 自動生成 commit message 並 commit
aicommit# 預覽模式:只顯示生成的 message,不執行 commit
aicommit --dry-run
aicommit -d
# 詳細輸出模式
aicommit --verbose
aicommit -v
# 顯示說明
aicommit --help| 指令 | 說明 |
|---|---|
aicommit |
自動生成 commit message 並 commit |
aicommit set KEY=VALUE |
設定 API key 或其他選項 |
aicommit --dry-run |
預覽模式,不執行 commit |
aicommit --verbose |
詳細輸出模式 |
aicommit --help |
顯示說明 |
| Key | 說明 | 預設值 |
|---|---|---|
provider |
AI 提供者 (openai 或 anthropic) |
anthropic |
language / lang |
Commit message 語言 | en |
anthropic_key |
Anthropic API Key | - |
anthropic_model |
Anthropic 模型 | claude-sonnet-4-20250514 |
openai_key |
OpenAI API Key | - |
openai_model |
OpenAI 模型 | gpt-4o |
$ git add .
$ aicommit
Generating commit message using anthropic...
Generated commit message:
feat(auth): add user login validation
Commit successful!$ aicommit --dry-run
Generating commit message using anthropic...
Generated commit message:
fix(api): resolve null pointer exception in user service
(dry-run mode - not committing)$ aicommit set language=zh-TW
$ aicommit --dry-run
Generating commit message using anthropic...
Generated commit message:
feat(auth): 新增使用者登入驗證功能
(dry-run mode - not committing)工具會自動生成符合 Conventional Commits 規範的 commit message:
feat: 新功能fix: 修復 bugdocs: 文件修改style: 程式碼格式修改(不影響功能)refactor: 重構perf: 效能優化test: 測試相關build: 建置系統或外部依賴修改ci: CI 設定修改chore: 其他雜項修改
確保 $HOME/go/bin 在你的 PATH 中:
echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.zshrc
source ~/.zshrc確認你的 API Key 設定正確:
cat ~/.aicommit/config.yaml在執行 aicommit 之前,需要先 stage 檔案:
git add .
# 或
git add <specific-files># 刪除執行檔
rm $(which aicommit)
# 刪除設定檔
rm -rf ~/.aicommitMIT