Back to directory
zxcloli666 avatar
zxcloli666 / AI-Code-Review

AI-Code-Review

AI-powered GitHub Action for automated code review. Supports GPT-5, Claude 4, Gemini 2.5 Pro. AST analysis, linter integration, dependency tracking. Get Principal-level feedback on every PR.

7

Stars

1

Forks

0

Watchers

MIT

License

๐Ÿค– AI Code Review - GitHub Action with Deep Static Analysis

GitHub stars GitHub forks GitHub issues License: MIT GitHub Action

Automated AI-powered code review for GitHub Pull Requests
GPT-5 โ€ข Claude Opus 4 โ€ข Gemini 2.5 Pro โ€ข O3 โ€ข Custom AI Models

๐Ÿš€ Quick Start โ€ข โœจ Features โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ’ก Examples โ€ข ๐Ÿค Contributing


๐ŸŽฏ What is AI Code Review?

AI Code Review is a next-generation GitHub Action that automates pull request reviews using advanced artificial intelligence and deep static code analysis. Get Principal/Staff engineer-level feedback on every PR with AST parsing, linter integration, dependency tracking, and beautiful visual statistics.

๐Ÿ† Why Choose AI Code Review?

โœ… Save 2-4 hours per day on code reviews
โœ… Catch bugs before production with deep analysis
โœ… Consistent quality standards across your team
โœ… Support for 10+ programming languages
โœ… Works with GPT-5, Claude 4, Gemini, O3, and custom AI models
โœ… AST parsing + Linter integration + Dependency analysis


โœจ Key Features

๐Ÿง  Senior-Level AI Reviews

  • AI analyzes code like a Principal engineer with 15+ years of experience
  • Deep understanding of architecture, performance, and security
  • Provides detailed "why" explanations, not just "what"
  • Recognizes good code and best practices

๐Ÿ” Deep Static Code Analysis

  • AST Parsing: Extract functions, classes, and dependencies from any language
  • Linter Integration: Auto-runs ESLint, Pylint, Rust Clippy, C# Analyzers
  • Dependency Tracking: Maps function calls and dependencies across codebase
  • Complexity Metrics: Cyclomatic complexity and maintainability index
  • Call Graph Analysis: Understand function relationships and breaking changes

๐ŸŽจ Beautiful Visual Reports

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Files Reviewed    โ”‚ 15                                      โ”‚
โ”‚ Quality Score     โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 85/100             โ”‚
โ”‚ Issues Found      โ”‚ Critical: 0 | Warnings: 2 | Info: 1     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  • ASCII charts and sparklines
  • Quality scores and visual statistics
  • Trend analysis over time

๐Ÿค– Multi-Model Support

  • OpenAI: GPT-5, GPT-5-High, O3, O3-Mini
  • Anthropic: Claude Opus 4, Claude Sonnet 4
  • Google: Gemini 2.5 Pro, Gemini 2.5 Flash
  • Custom Endpoints: Azure OpenAI, AWS Bedrock, local models, or any OpenAI-compatible API

๐Ÿ› ๏ธ AI Tool System (14 Tools)

AI actively investigates your code using specialized tools:

  • read_file, get_file_diff, analyze_file_ast - Deep file analysis
  • analyze_function_impact - ๐ŸŽฏ Breaking change detector! Shows full context around ALL function call sites
  • find_function_callers, find_function_dependencies - Code navigation
  • analyze_function_complexity - Complexity metrics
  • run_linter - Execute language-specific linters
  • get_commits_list, get_commit_diff, get_file_history - Git context
  • ...and more!

๐ŸŒ Multi-Language Support

  • Review Language: Comments in any language (English, Russian, Spanish, French, German, Chinese, etc.)
  • Code Languages: TypeScript, JavaScript, Python, Rust, C#, Go, Java, PHP, Ruby, and more

๐Ÿ“ฆ Smart PR Handling

  • Intelligent Chunking: Splits large PRs optimally by module boundaries
  • Handles massive PRs without hitting token limits
  • Silent Mode: Reduce notification spam for your team
  • Auto Labeling: Manages PR labels based on review results

๐Ÿš€ Quick Start

Step 1: Create Workflow File

Create .github/workflows/ai-code-review.yml:

name: AI Code Review

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  ai-review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Important for commit history analysis

      - name: Run AI Code Review
        uses: zxcloli666/AI-Code-Review@v1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Step 2: Add OpenAI API Key

  1. Get your API key from OpenAI Platform
  2. Go to your repository Settings โ†’ Secrets and variables โ†’ Actions
  3. Click New repository secret
  4. Name: OPENAI_API_KEY, Value: your-api-key-here

Step 3: Create a Pull Request

That's it! ๐ŸŽ‰ AI Code Review will automatically analyze every new PR.


๐Ÿ“– Configuration Options

Required Inputs

Input Description Default
GITHUB_TOKEN GitHub token (auto-provided by Actions) -
OPENAI_API_KEY OpenAI API key or compatible provider -

Optional Inputs

Input Description Default
OPENAI_API_MODEL AI model (gpt-5, claude-opus-4, o3, etc.) gpt-5
OPENAI_API_BASE_URL Custom endpoint (Azure, Bedrock, local) https://api.openai.com/v1
REVIEW_LANGUAGE Review language (en, ru, es, fr, de, zh, etc.) en
SILENT_MODE Minimize email notifications (true/false) false
MAX_CHUNK_SIZE Max tokens per chunk (adjust for your model) 6000
ENABLE_LINTERS Run language-specific linters true
ENABLE_AST AST analysis for deep code understanding true
ENABLE_DEPENDENCY_ANALYSIS Dependency tracking and call graphs true
SEVERITY_THRESHOLD Min severity to report (info, warning, error) warning

๐Ÿ’ก Example Reviews

๐Ÿ” Click to see example review output
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ                                                                   โ”ƒ
โ”ƒ      ๐Ÿค– ๐—”๐—œ ๐—–๐—ข๐——๐—˜ ๐—ฅ๐—˜๐—ฉ๐—œ๐—˜๐—ช - ๐—”๐—ก๐—”๐—Ÿ๐—ฌ๐—ฆ๐—œ๐—ฆ ๐—–๐—ข๐— ๐—ฃ๐—Ÿ๐—˜๐—ง๐—˜ ๐Ÿค–              โ”ƒ
โ”ƒ                                                                   โ”ƒ
โ”ƒ         โšก Powered by Advanced AI & Deep Code Analysis โšก           โ”ƒ
โ”ƒ                                                                   โ”ƒ
โ”—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”›

## ๐Ÿ“‹ Executive Summary

This PR implements a new caching layer to reduce database load and improve 
response times. The implementation is solid with good error handling and test 
coverage. Found 2 performance optimizations and 1 documentation suggestion.

**Verdict**: โœ… APPROVED with minor suggestions

## ๐Ÿ“Š Review Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Files Reviewed        โ”‚ 15                                  โ”‚
โ”‚ Total Lines Changed   โ”‚ 450 (+320/-130)                     โ”‚
โ”‚ Commits Analyzed      โ”‚ 8                                   โ”‚
โ”‚ Tools Used            โ”‚ 12                                  โ”‚
โ”‚ Review Time           โ”‚ 45s                                 โ”‚
โ”‚ Quality Score         โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘ 85/100         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

## ๐ŸŽฏ Issues Summary

Critical  โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘  0
Warnings  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘  2
Info      โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘  1

## ๐Ÿ† Highlights

โœ… Well-structured code with clear separation of concerns
โœ… Comprehensive error handling in API endpoints
โœ… Good use of TypeScript types for type safety

## โš ๏ธ Issues Found

### src/api/handler.ts:45
**Severity:** Warning | **Category:** Performance

The database query inside the loop creates N+1 queries. Consider using 
a single query with JOIN or batch loading.

**Current:**
\`\`\`typescript
for (const user of users) {
  const posts = await db.query('SELECT * FROM posts WHERE user_id = ?', [user.id]);
}
\`\`\`

**Suggested:**
\`\`\`typescript
const posts = await db.query(`
  SELECT p.*, u.id as user_id
  FROM posts p
  JOIN users u ON p.user_id = u.id
  WHERE u.id IN (?)
`, [users.map(u => u.id)]);
\`\`\`

๐ŸŽฏ Advanced Use Cases

Manual Trigger with /review Command

Add the ability to trigger reviews on-demand:

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

jobs:
  ai-review:
    if: |
      (github.event_name == 'pull_request') ||
      (github.event_name == 'issue_comment' &&
       github.event.issue.pull_request &&
       contains(github.event.comment.body, '/review'))
    # ... rest of the workflow

Now comment /review on any PR to trigger a review!

Use Claude Opus 4

- uses: zxcloli666/AI-Code-Review@v1
  with:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    OPENAI_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
    OPENAI_API_BASE_URL: 'https://api.anthropic.com/v1'
    OPENAI_API_MODEL: 'claude-opus-4'

Use Google Gemini 2.5 Pro

- uses: zxcloli666/AI-Code-Review@v1
  with:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    OPENAI_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
    OPENAI_API_BASE_URL: 'https://generativelanguage.googleapis.com/v1'
    OPENAI_API_MODEL: 'gemini-2.5-pro'
    MAX_CHUNK_SIZE: '12000'  # Gemini supports larger context

Use OpenAI O3 Reasoning Model

- uses: zxcloli666/AI-Code-Review@v1
  with:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
    OPENAI_API_MODEL: 'o3-mini'
    MAX_CHUNK_SIZE: '10000'

Reviews in Russian

- uses: zxcloli666/AI-Code-Review@v1
  with:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
    REVIEW_LANGUAGE: 'ru'  # Reviews in Russian

Silent Mode (Reduce Notifications)

- uses: zxcloli666/AI-Code-Review@v1
  with:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
    SILENT_MODE: 'true'  # Minimize email spam

๐Ÿ› ๏ธ How It Works

1๏ธโƒฃ Data Collection

  • Retrieves PR details, branch info, and linked issues
  • Analyzes file types and programming languages
  • Builds commit history timeline

2๏ธโƒฃ Smart Chunking

  • Splits large PRs intelligently by module boundaries
  • Groups related files together
  • Optimizes token usage for your chosen AI model

3๏ธโƒฃ Deep Analysis

AI actively investigates code using 14 specialized tools:

File Analysis:

  • read_file - Read complete file content
  • get_file_diff - View specific changes with context
  • analyze_file_ast - Deep AST (Abstract Syntax Tree) parsing

Code Understanding:

  • analyze_function_impact - ๐ŸŽฏ Breaking Change Detector! Shows full context around ALL function call sites
  • find_function_callers - List all places where a function is called
  • find_function_dependencies - Find what a function depends on
  • analyze_function_complexity - Cyclomatic complexity metrics

Quality Tools:

  • run_linter - Execute language-specific linters (ESLint, Pylint, Clippy, etc.)

Git & History:

  • get_commits_list, get_commit_diff, get_file_history - Analyze code evolution

4๏ธโƒฃ AI Review Process

  • Uses mandatory workflow requiring 4-6 tools minimum per review
  • Analyzes from multiple dimensions: Security, Performance, Architecture, Maintainability
  • Provides senior-level feedback with detailed explanations
  • Categorizes issues by severity (critical, warning, info)

5๏ธโƒฃ Executive Summary Generation

  • Sends full review to AI for concise summary
  • Creates brief but comprehensive executive summary (under 300 words)
  • Includes: main changes, critical findings, key recommendations, verdict

6๏ธโƒฃ Publishing Results

  • Posts comprehensive review comment
  • Adds inline comments on specific lines
  • Manages labels automatically
  • Supports silent mode to reduce notification spam

๐Ÿ”ฅ Breaking Change Detection Example

When refactoring a function used across multiple files, AI uses analyze_function_impact to show full context around ALL call sites.

Example: Changing calculatePrice(quantity, price) to calculatePrice(options)

// Before:
function calculatePrice(quantity: number, price: number): number {
  return quantity * price;
}

// After:
function calculatePrice(options: { quantity: number; price: number; discount?: number }): number {
  const { quantity, price, discount = 0 } = options;
  return quantity * price * (1 - discount);
}

What AI sees:

## Function Impact Analysis: calculatePrice

**Definition**: `src/utils/pricing.ts:42`
**Parameters**: quantity, price
**Exported**: Yes

### Call Sites

Found **8** call site(s) across **3** file(s)

---

#### `src/components/Cart.tsx` (3 calls)

**Call at line 67**:
โ†’ 67 | const total = calculatePrice(item.quantity, item.price);
  68 | setCartTotal(total);

**Call at line 89**:
  88 | items.forEach(item => {
โ†’ 89 |   subtotal += calculatePrice(item.qty, item.unitPrice);
  90 | });

---

Total Impact: 8 call site(s) would be affected

Recommendations:
โš ๏ธ Medium impact: 8 call sites - thorough testing recommended
- All callers pass 2 parameters - breaking change confirmed
- Consider backward compatibility or deprecation period

The AI can now intelligently warn that all 8 call sites need updating! ๐ŸŽฏ


๐ŸŒ Supported Languages

Review Languages (Comments)

English, Russian, Spanish, French, German, Chinese, Japanese, Korean, Portuguese, Italian, Dutch, Polish, Turkish, Arabic, Hindi, and more...

Code Analysis Languages

  • JavaScript/TypeScript - ESLint, AST parsing
  • Python - Pylint, AST parsing
  • Rust - Clippy, AST parsing
  • C# - dotnet format analyzers
  • Go - golangci-lint (custom integration)
  • Java, PHP, Ruby, C++ - Basic analysis
  • And more...

๐Ÿ—๏ธ Development

Prerequisites

  • Node.js 20+
  • pnpm 9+

Setup

git clone https://github.com/zxcloli666/AI-Code-Review.git
cd AI-Code-Review
pnpm install
pnpm build

Project Structure

src/
โ”œโ”€โ”€ index.ts              # Entry point
โ”œโ”€โ”€ types/                # TypeScript types
โ”œโ”€โ”€ ai/                   # AI client & prompts
โ”‚   โ”œโ”€โ”€ client.ts         # OpenAI/compatible client
โ”‚   โ”œโ”€โ”€ prompts.ts        # System & user prompts
โ”‚   โ””โ”€โ”€ tools-registry.ts # 14 AI tools registry
โ”œโ”€โ”€ analysis/             # Code analysis engines
โ”‚   โ”œโ”€โ”€ ast-parser.ts     # AST parsing (Babel, TS, Acorn)
โ”‚   โ”œโ”€โ”€ linter-runner.ts  # Multi-language linter runner
โ”‚   โ””โ”€โ”€ call-graph.ts     # Dependency & call graph analysis
โ”œโ”€โ”€ chunking/             # Smart chunking strategies
โ”œโ”€โ”€ github/               # GitHub API integration
โ”œโ”€โ”€ stats/                # Visualization & statistics
โ””โ”€โ”€ utils/                # Utilities

Testing

pnpm run build
pnpm run type-check

Create a test repository, set up the workflow, and verify the output.


๐Ÿค Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'feat: add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open Pull Request

๐Ÿ“ License

MIT License - see LICENSE for details.


๐Ÿ™ Acknowledgments


โญ Support This Project

If you find AI Code Review useful, please:


Made with โค๏ธ by zxcloli666

โฌ† Back to top


AI Code Review Star History Chart

Releases

Feb 12, 2026

Download .zip

๐Ÿค– AI Code Review - GitHub Action with Deep Static Analysis

Automated AI-powered code review for GitHub Pull Requests GPT-5 โ€ข Claude Opus 4 โ€ข Gemini 2.5 Pro โ€ข O3 โ€ข Custom AI Models ๐Ÿš€ Quick Star...

Nov 18, 2025

Release v1.2.0

Download .zip

Release v1.2.0 feat: add full PR context to chunk reviews to prevent false positives When reviewing large PRs in chunks, AI now receives:

Full list of all files in the PR for context Clear indication...

Nov 10, 2025

Download .zip

Release v1.1.0

[ Add support for pull_request_target ]

๐Ÿค– AI Code Review - GitHub Action with Deep Static Analysis

Automated AI-powered code review for GitHub Pull Requests GPT-5 โ€ข Claude Opu...

๐Ÿค– AI Code Review - GitHub Action with Deep Static Analysis

Automated AI-powered code review for GitHub Pull Requests GPT-5 โ€ข Claude Opus 4 โ€ข Gemini 2.5 Pro โ€ข O3 โ€ข Custom AI Models ๐Ÿš€ Quick Star...

Contributors

1 contributors by commits. Profile dekhne ke liye kisi bhi developer par click karein.