mcpField
G
gemini-review

gemini-review

github.com/alinaqiテスト・品質711274 回インストール2 週間前に更新
リポジトリ

gemini-review について

Google Gemini CLI でコードレビューを行うスキルで、対話型、ヘッドレス、リポジトリ連携の各ワークフローを扱います。ブランチの変更確認や、CI・プルリクエストでのレビュー自動化に対応します。

主な機能

  1. 01code-review 拡張による対話型レビュー
  2. 02JSON 出力対応のヘッドレス CLI レビュー
  3. 03GitHub アプリと Action のワークフロー
  4. 04GitLab CI のレビュー設定
  5. 05GEMINI.md によるプロジェクトコンテキスト

活用シーン

  1. 01ブランチ変更のバグやセキュリティ問題の確認
  2. 02プルリクエストレビューの自動化
  3. 03CI パイプラインでのコードレビュー実行

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/alinaqi/maggy --skill gemini-review

インストール後、Claude Code で/gemini-reviewを入力して読み込まれたか確認します。

詳細

Google Gemini コードレビュースキル

Google の Gemini CLI と Gemini 2.5 Pro を使ってコードをレビューします。Gemini 2.5 Pro は、リポジトリ全体を一度に分析できる、圧倒的な 100 万トークンのコンテキストウィンドウを備えています。

ソース: Gemini CLI | コードレビュー拡張機能 | Gemini Code Assist | GitHub Action


コードレビューに Gemini を使う理由

機能メリット
Gemini 2.5 Proコードに対する最先端の推論能力
100 万トークンのコンテキストリポジトリ全体を扱えるため、分割は不要
無料枠Google アカウントで 1 日 1,000 件のリクエスト
一貫した出力すっきりとした書式で、予測可能な構成
GitHub とのネイティブ連携PR を自動レビューする Gemini Code Assist アプリ
ベンチマーク性能
ベンチマークスコア備考
SWE-Bench Verified63.8%エージェント型コーディングのベンチマーク
Qodo PR Benchmark56.3%PR レビューの品質
LiveCodeBench v570.4%コード生成
WebDev Arena#1ウェブ開発

インストール

前提条件
# Check Node.js version (requires 20+)
node --version

# Install Node.js 20 if needed
# macOS
brew install node@20

# Or via nvm
nvm install 20
nvm use 20
Gemini CLI をインストールする
# Via npm (recommended)
npm install -g @google/gemini-cli

# Via Homebrew (macOS)
brew install gemini-cli

# Or run without installing
npx @google/gemini-cli

# Verify installation
gemini --version
コードレビュー拡張機能をインストールする
# Requires Gemini CLI v0.4.0+
gemini extensions install https://github.com/gemini-cli-extensions/code-review

# Verify extension
gemini extensions list

認証

オプション 1:Google アカウント(推奨)

無料枠:1 日あたり 1,000 件、1 分あたり 60 件のリクエスト

# Run gemini and follow browser login
gemini

# Select: "Login with Google Account"
# Opens browser for OAuth

これにより、100 万トークンのコンテキストウィンドウを最大限に活用して Gemini 2.5 Pro にアクセスできます。

オプション 2:Gemini API キー

無料枠:1 日あたり 100 件のリクエスト

# Get API key from https://aistudio.google.com/apikey

# Set environment variable
export GEMINI_API_KEY="your-api-key"

# Or add to shell profile
echo 'export GEMINI_API_KEY="your-api-key"' >> ~/.zshrc

# Run Gemini
gemini
オプション 3:Vertex AI(エンタープライズ)
# For Google Cloud projects
export GOOGLE_API_KEY="your-api-key"
export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT="your-project-id"

gemini

インタラクティブなコードレビュー

コードレビュー拡張機能を使う
# Start Gemini CLI
gemini

# Run code review on current branch
/code-review

拡張機能は次の内容を分析します:

  • 現在のブランチのコード変更
  • 品質上の問題の特定
  • 修正案の提案
手動レビュー用プロンプト
# In interactive mode
gemini

# Then ask:
> Review the changes in this branch for bugs and security issues
> Analyze src/api/users.ts for potential vulnerabilities
> What are the code quality issues in the last 3 commits?

ヘッドレスモード(自動化)

基本的な使い方
# Simple prompt execution
gemini -p "Review the code changes for bugs and security issues"

# With JSON output (for parsing)
gemini -p "Review the changes" --output-format json

# Stream JSON events (real-time)
gemini -p "Review and fix issues" --output-format stream-json

# Specify model
gemini -m gemini-2.5-pro -p "Deep code review of this PR"
CI/CD の完全な例
# Get diff and review
git diff origin/main...HEAD > diff.txt

gemini -p "Review this code diff for:
1. Security vulnerabilities
2. Performance issues
3. Code quality problems
4. Missing error handling

Diff:
$(cat diff.txt)
" --output-format json > review.json
セッション追跡
# Track token usage and costs
gemini -p "Review changes" --session-summary metrics.json

# View metrics
cat metrics.json

GitHub 連携

オプション 1:Gemini Code Assist アプリ(最も簡単)

GitHub Marketplace からインストールします:

  1. GitHub Marketplace → Gemini Code Assist に移動します
  2. 「Install」をクリックし、リポジトリを選択します
  3. PR を開くと、自動的にレビューされます

PR コメントで使えるコマンド:

/gemini review     # Request code review
/gemini summary    # Get PR summary
/gemini help       # Show available commands

利用上限:

  • 無料:1 日あたり 33 件の PR
  • エンタープライズ:1 日あたり 100 件以上の PR
オプション 2:GitHub Action
# .github/workflows/gemini-review.yml
name: Gemini Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install Gemini CLI
        run: npm install -g @google/gemini-cli

      - name: Run Review
        env:
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
        run: |
          # Get diff
          git diff origin/${{ github.base_ref }}...HEAD > diff.txt

          # Run Gemini review
          gemini -p "Review this pull request diff for bugs, security issues, and code quality problems. Be specific about file names and line numbers.

          $(cat diff.txt)" > review.md

      - name: Post Review Comment
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const review = fs.readFileSync('review.md', 'utf8');
            github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: `## 🤖 Gemini Code Review\n\n${review}`
            });
オプション 3:公式 GitHub Action
# .github/workflows/gemini-review.yml
name: Gemini Code Review

on:
  pull_request:
    types: [opened, synchronize]
  issue_comment:
    types: [created]

jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
      issues: write

    steps:
      - uses: actions/checkout@v4

      - name: Run Gemini CLI
        uses: google-github-actions/run-gemini-cli@v1
        with:
          gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
          prompt: "Review this pull request for code quality, security issues, and potential bugs."

コメントで使えるオンデマンドコマンド:

@gemini-cli /review
@gemini-cli explain this code change
@gemini-cli write unit tests for this component

GitLab CI/CD

# .gitlab-ci.yml
gemini-review:
  image: node:20
  stage: review
  script:
    - npm install -g @google/gemini-cli
    - |
      gemini -p "Review the merge request changes for bugs, security issues, and code quality" > review.md
    - cat review.md
  artifacts:
    paths:
      - review.md
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  variables:
    GEMINI_API_KEY: $GEMINI_API_KEY

設定

グローバル設定
# ~/.gemini/settings.json
{
  "model": "gemini-2.5-pro",
  "theme": "dark",
  "sandbox": true
}
プロジェクト設定(GEMINI.md)

プロジェクト固有のコンテキストを設定するには、プロジェクトのルートに GEMINI.md ファイルを作成します:

# Project Context for Gemini

## Tech Stack
- TypeScript with strict mode
- React 18 with hooks
- FastAPI backend
- PostgreSQL database

## Code Review Focus Areas
1. Type safety - ensure proper TypeScript types
2. React hooks rules - check for dependency array issues
3. SQL injection - verify parameterized queries
4. Authentication - check all endpoints have proper auth

## Conventions
- Use camelCase for variables
- Use PascalCase for components
- All API errors should use AppError class

CLI クイックリファレンス

# Interactive
gemini                          # Start interactive mode
/code-review                    # Run code review extension

# Headless
gemini -p "prompt"              # Single prompt, exit
gemini -p "prompt" --output-format json   # JSON output
gemini -m gemini-2.5-flash -p "prompt"    # Use faster model

# Extensions
gemini extensions list          # List installed
gemini extensions install URL   # Install extension
gemini extensions update        # Update all

# Key Flags
--output-format json            # Structured output
--output-format stream-json     # Real-time events
--session-summary FILE          # Track metrics
-m MODEL                        # Select model

比較:Claude、Codex、Gemini

項目ClaudeCodex CLIGemini CLI
セットアップなし(組み込み)npm + OpenAI APInpm + Google アカウント
モデルClaudeGPT-5.2-CodexGemini 2.5 Pro
コンテキスト会話レビューごとに新規100 万トークン(大容量!)
無料枠該当なし制限あり1 日あたり 1,000 件
最適な用途すばやいレビュー高精度大規模なコードベース
GitHub とのネイティブ連携なし@codexGemini Code Assist
用途に応じた選び方
シナリオ推奨エンジン
ワークフロー内ですばやくレビューClaude
重要なセキュリティレビューCodex(検出率 88%)
大規模なコードベース(100 ファイル以上)Gemini(100 万トークンのコンテキスト)
無料の自動レビューGemini
複数の視点からレビュー3 つすべて(2 種類/3 種類のエンジン)

トラブルシューティング

問題解決策
gemini: command not foundnpm install -g @google/gemini-cli
Node.js version errorNode.js 20+ にアップグレードします
Authentication failedgemini を再実行して、もう一度ログインします
Extension not foundgemini extensions install https://github.com/gemini-cli-extensions/code-review
Rate limited待つか、Vertex AI にアップグレードします
Hangs in CIDEBUG 環境変数が設定されていないことを確認します

アンチパターン

  • 認証設定を省略する - CI/CD の前に必ず設定します
  • ログに API キーを記録する - シークレット管理を使用します
  • コンテキストの上限を無視する - 1M トークンでも、大規模なモノレポでは上限に達します
  • すべてのコミットで実行する - クォータを節約するため、PR のみで使用します
  • プロジェクトのコンテキストを設定しない - レビューの質を高めるため、GEMINI.md を追加します

コメント