AIAI Smart Summary (TL;DR)
Collapse

Current Project Version: v1.0.6
Project URL: https://github.com/unclesam-ly/git-air

git-air is a command-line tool that uses Large Language Models (LLMs) to review Git code changes. It is ideal for checking bugs, security issues, concurrency problems, resource leaks, and code quality issues before committing.

I. Installation

Install via Go

bash 复制代码
go install github.com/unclesam-ly/git-air@latest
git-air version

Build from Source

bash 复制代码
git clone https://github.com/unclesam-ly/git-air.git
cd git-air
go build -o git-air .
sudo mv git-air /usr/local/bin/

II. Command Overview

Command Purpose
git air Review current Git changes
git air [diff args] Review specified commits, branch diffs, or files
git air config set Set global configuration
git air config get View current configuration
git air msg Generate Conventional Commit Message
git air hook install Install pre-commit Hook
git air hook uninstall Uninstall pre-commit Hook
git air version View version information
git air update Upgrade to the latest version
git air upgrade Alias for update

III. Code Review Commands

bash 复制代码
# Review current staged area
git add .
git air

# Explicitly review staged area
git air --cached
git air --staged

# Review the last commit
git air HEAD~1

# Review a specified commit
git air abc1234

# Review diff between two branches
git air main..feature-branch

# Review a specified file
git air internal/service/user.go

Temporarily Override Model Configuration

bash 复制代码
git air --provider deepseek --model deepseek-chat
git air --key "YOUR_API_KEY"
git air --prompt "Focus on concurrency safety, error handling, and resource release issues"

Blocking Options

bash 复制代码
# Strict mode: WARNINGs will also block the process
git air --strict

# Non-blocking mode: Output report only, do not return non-zero status on issues
git air --no-block

In normal mode, the process is blocked when [BLOCKER], [CRITICAL], or [REJECT] is found; in strict mode, [WARNING] and [WARN] also block the process.

Code Review Parameters

Parameter Shorthand Description
--key -k Temporarily specify API Key
--model -m Temporarily specify model name
--provider -p Temporarily specify model provider
--prompt None Temporarily specify System Prompt
--cached None Review staged changes
--staged None Alternative spelling for --cached
--strict None WARNINGs also block the process
--no-block None Do not block the process

IV. Configuration Commands

Set and View Configuration

bash 复制代码
git air config set --provider gemini --key "YOUR_API_KEY"
git air config set --provider deepseek --key "YOUR_KEY" --model deepseek-chat
git air config get

Supported Providers

gemini, claude, grok, deepseek, qwen, zhipu, moonshot, siliconflow, doubao, minimax, yi, groq, openrouter, ollama, openai, custom.

Common Configuration Examples

bash 复制代码
# Gemini
git air config set --provider gemini --key "YOUR_KEY" --model gemini-3.7-flash

# Claude
git air config set --provider claude --key "YOUR_KEY" --model anthropic/claude-3.7-sonnet

# DeepSeek
git air config set --provider deepseek --key "YOUR_KEY" --model deepseek-chat

# Qwen
git air config set --provider qwen --key "YOUR_KEY" --model qwen-plus

# OpenAI
git air config set --provider openai --key "YOUR_KEY" --model gpt-4o-mini

# OpenRouter
git air config set --provider openrouter --key "YOUR_KEY"

Using Ollama Local Models

bash 复制代码
ollama pull qwen2.5-coder
git air config set --provider ollama --model qwen2.5-coder
git air

Custom OpenAI-compatible API

bash 复制代码
git air config set \
  --provider custom \
  --base-url "https://your-api.example.com/v1" \
  --key "YOUR_API_KEY" \
  --model "your-model"

Custom Token Pricing

Unit is in USD / 1M tokens:

bash 复制代码
git air config set --price-input 0.75 --price-output 3.75

Set Commit Message Language

bash 复制代码
git air config set --commit-lang en
git air config set --commit-lang zh
git air config set --commit-lang ja
git air config set --commit-lang ko
git air config set --commit-lang auto

config set Parameters

Parameter Shorthand Description
--provider -p Model provider
--key -k API Key
--model -m Model name
--base-url -u Custom API base URL
--prompt None Custom base System Prompt
--price-input None Input Token price
--price-output None Output Token price
--commit-lang None Commit Message language

V. AI Commit Message

bash 复制代码
# Generate commit message based on current changes
git air msg

# Specify language
git air msg -l en
git air msg -l zh
git air msg -l ja
git air msg -l ko

# Automatically stage all modifications (equivalent to git add -A)
git air msg -a

# Execute git commit directly after generation
git air msg -c

# Automatically stage, generate, and commit directly
git air msg -a -c

git air msg supports the following aliases:

bash 复制代码
git air commit-msg
git air commit

msg Parameters

Parameter Shorthand Description
--lang -l auto, zh, en, ja, ko
--all -a Automatically execute git add -A
--commit -c Execute git commit directly after generation
--key -k Temporarily specify API Key
--model -m Temporarily specify model
--provider -p Temporarily specify Provider

VI. Git Pre-commit Hook

bash 复制代码
# Install in the current repository
git air hook install

# Uninstall
git air hook uninstall

Once installed, every git commit execution will automatically review the staged code.

Emergency bypass:

bash 复制代码
git commit --no-verify

VII. Version and Upgrade

bash 复制代码
# View version
git air version

# Check for new version
git air version --check
git air version -c

# Upgrade
git air update
git air upgrade

The upgrade command uses go install github.com/unclesam-ly/git-air@latest under the hood, which requires Go to be installed locally.

VIII. Project Rules: .airules

Create .airules in the project root directory to add team guidelines for AI Review:

markdown 复制代码
# Team Coding Guidelines

1. All SQL operations must be located in the DAO or Repository layer;
2. Shared variables must use sync.RWMutex or sync/atomic;
3. Opened files, database connections, and HTTP Bodies must be closed promptly;
4. Silently ignoring errors is not allowed.

IX. Ignored Files: .airignore

Create .airignore in the project root directory to exclude files you do not want to submit to the model:

gitignore 复制代码
docs/
*.md
testdata/
tests/mock/
*.env
secrets.yaml

The project will also automatically filter out some lock files, generated files, and binary files to reduce meaningless token consumption.

X. Configuration Precedence

From lowest to highest roughly as follows:

  1. Default configuration;
  2. Global configuration: ~/.git-air/config.yaml;
  3. Project configuration: .git-air.yaml, .git-air.yml, or git-air.yaml;
  4. Environment variables;
  5. Command-line arguments.

Common environment variables:

bash 复制代码
export GIT_AIR_API_KEY="YOUR_API_KEY"
export GIT_AIR_PROVIDER="deepseek"
export GIT_AIR_MODEL="deepseek-chat"
export GIT_AIR_BASE_URL="https://api.example.com/v1"
export GIT_AIR_COMMIT_LANG="en"

View the final active configuration:

bash 复制代码
git air config get
bash 复制代码
# Stage changes after modifying code
git add .

# Review before committing
git air

# Re-stage after fixing issues
git add .

# Generate descriptive commit message and commit
git air msg -c

If you want to review automatically on every commit:

bash 复制代码
git air hook install

XII. Frequently Asked Questions

API Key Not Configured

bash 复制代码
git air config set --provider deepseek --key "YOUR_API_KEY"

Cloud API Key is not required when using Ollama:

bash 复制代码
git air config set --provider ollama --model qwen2.5-coder

No Code Changes Detected

bash 复制代码
git status
git diff
git diff --cached
git add <file_name>
git air --cached

Temporarily Switching Models

bash 复制代码
git air --provider ollama --model qwen2.5-coder

This method does not modify the global configuration.

XIII. License

The project is licensed under the MIT License. Issues, Pull Requests, and improvement suggestions are welcome.

Comments & Discussions

Write a comment...
0 / 500
Comments & Discussions (0)
暂无评论,快来抢占第一条沙发吧~
1
1
AIAI