Skip to main content

aireview

一款基於 Gemini API 的 AI 程式碼審查 CLI 工具。它能在你 commit 前分析已暫存(staged)的 git 變更,並直接在終端機中以繁體中文指出安全漏洞、Bug 以及改進建議。同時無縫整合了 ruff(針對 Python)與 actionlint(針對 GitHub Actions),為你提供全方位的程式碼品質檢查。

Demo

╔══════════════════════════════════════════════════════════╗
║                      AI Code Review                      ║
╠══════════════════════════════════════════════════════════╣
║  Score: 85/100  [Python, YAML]                           ║
║  1 critical  1 warning  0 suggestion                     ║
╚══════════════════════════════════════════════════════════╝

  Summary: 發現潛在的路徑遍歷風險與靜態分析工具回報的格式問題,請在提交前修正。

  ✖ CRITICAL  存在路徑遍歷(Path Traversal)安全漏洞  🔒 security
  └─ src/utils.py:12

     在讀取檔案時直接使用了外部傳入的 `filepath`,惡意使用者可以構造包含 `../../` 的路徑來讀取系統上的任意檔案。
     
    Fix:
     在開啟檔案前,應使用 `os.path.abspath` 驗證檔案路徑是否位於當前工作目錄內。
     ```python
     import os
     base_dir = os.path.abspath(".")
     abs_path = os.path.abspath(filepath)
     if abs_path.startswith(base_dir):
         with open(abs_path, "r") as f:
             # ...
     ```

  ──────────────────────────────────────────────────────

  ▲ WARNING  Ruff 靜態分析警告  ♻ code_quality
  └─ src/app.py:5

     Ruff 分析回報: `F401 [*] os imported but unused`。引入了未使用的模組會增加不必要的開銷並降低程式碼可讀性。
     
    Fix:
     請移除未使用的 `import os`。

  ──────────────────────────────────────────────────────

  ⚠  Critical issues found — review before committing.

Features

  • Gemini AI Code Review:使用 gemini-3.1-flash-lite 模型,以繁體中文提供精準、簡潔(不超過 300 字)的程式碼審查。
  • Ruff 靜態分析整合:自動針對變更的 Python 檔案執行 ruff,並將檢查結果提供給 AI 一併分析。
  • Actionlint 整合:自動針對 GitHub Actions 的 YAML 變更執行 actionlint 檢查(若未安裝則使用基本 YAML 語法驗證)。
  • 支援 .env 環境變數:自動從本地 .env 檔案載入 API Key(支援 export 前綴與行內註解)。
  • 靈活的使用方式:支援審查已暫存(staged)的變更、特定檔案,或是整個工作區的所有變更。

Installation

PyPI / pipx (recommended)

pipx installs the CLI in an isolated environment, making it available globally.

Homebrew (macOS)

brew install pipx
# 從 PyPI 全域安裝 (推薦)
pipx install aireview-joy

From source

git clone https://github.com/Joy0130/aireview.git
cd aireview
pipx install .

Setup

Set your Gemini API key as an environment variable:

export GEMINI_API_KEY="your-key-here"

Or add it to a .env file in your repository root:

GEMINI_API_KEY=your-key-here

Get a free API key at Google AI Studio.

Usage

aireview                    # 審查已暫存的變更 (需先執行 git add)
aireview --full             # 審查工作區內的所有變更
aireview --file src/app.py  # 審查特定檔案的變更 (基於 git diff)
aireview --scan src/app.py  # 直接掃描檔案的完整內容 (不依賴 git diff)
aireview -s a.py b.py       # 支援一次掃描多個檔案的完整內容
aireview --fix              # 強調修正建議
aireview --strict           # 嚴格模式 (會抓出更多細節問題)
aireview --output json      # 輸出機器可讀的 JSON 格式
aireview --output compact   # 輸出精簡格式 (適合用於腳本)
aireview --no-fail          # 永遠以 exit 0 退出 (避免阻擋 CI 流程)

Integrate with aicommit

# 審查已暫存的變更,如果沒有問題則進行 commit
aireview && aicommit

# 或者將精簡版的審查摘要傳遞給 aicommit
aireview --output compact | aicommit

Configuration

Create .aireview.yml in your repo root or ~/.aireview.yml:

language: auto
strict_level: standard      # relaxed | standard | strict
focus:
  - security
  - bugs
  - code_quality
  - performance
ignore_paths:
  - "*.lock"
  - "dist/"
  - "node_modules/"
max_diff_lines: 3000
gemini_model: gemini-3.1-flash-lite
show_fix_suggestions: true
fail_on_critical: true

Exit codes

Code Meaning
0 Review passed (no critical issues, or --no-fail)
1 Critical issues found
1 Configuration error or API failure

License

MIT

Metadata

Release files for aireview-joy 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aireview-joy 0.1.2
File Size Uploaded Provenance
aireview_joy-0.1.2.tar.gz 18.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aireview-joy 0.1.2
File Interpreter ABI Platform
aireview_joy-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 35.5 kB

Release files / aireview_joy-0.1.2.tar.gz

Download URL aireview_joy-0.1.2.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
bd1b9382c96b7b1c6dc2bb40dd0f44898fd568af374ca9872debf473188cca2c
BLAKE2b-256 checksum
How to use checksums
23c67b191c498327d93663b19598cac3e42f5782c2f55d93a9071ae22d6954e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

Release files / aireview_joy-0.1.2-py3-none-any.whl

Download URL aireview_joy-0.1.2-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
040849c25221d1e05c9411bd1e93f43850917f79bfce1729b962565a9715207a
BLAKE2b-256 checksum
How to use checksums
ef905eb580715cbc078f6a7e98ed45cfbb621afa2dd8514e04063b03cd350d88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

Security for aireview-joy 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aireview_joy-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page