Skip to content

AI Code Review is a lightweight, simple GitHub Action that supports various AI models to analyze and provide feedback on your code. This GitHub Action helps improve code quality by automatically reviewing pull requests, focusing on specified file extensions, and excluding specific paths.

License

Notifications You must be signed in to change notification settings

AleksandrFurmenkovOfficial/ai-code-review

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Code Review

*is a GitHub Action that is 90% generated by AIs.

Description

Perform code review using various AI models from OpenAI, Anthropic, Google, X, Deepseek or Perplexity to analyze and provide feedback on your code. This GitHub Action helps improve the code quality by automatically reviewing pull requests, focusing on specified file extensions, and excluding specific paths.

Inputs

token - Required. This GitHub token is used for authentication and to access your GitHub repository.

owner - Required. The username of the repository owner.

repo - Required. The name of the repository.

pr_number - Required. The number of the pull request that needs to be reviewed.

ai_provider - Required. The AI provider to use { openai, anthropic, google, x, deepseek}. Default is 'openai'.

openai_api_key - Required if using OpenAI provider. This key is necessary to access OpenAI's API for code review purposes.

openai_model - Optional. The OpenAI model name (e.g., gpt-4.1, gpt-4o or o3(super slow)). Default is 'gpt-4.1'.

anthropic_api_key - Required if using Anthropic provider. This key is necessary to access Anthropic's API for code review purposes.

anthropic_model - Optional. The Anthropic model name (e.g., claude-sonnet-4-20250514 or claude-opus-4-20250514). Default is 'claude-sonnet-4-20250514'.

google_api_key - Required if using Google provider. This key is necessary to access Google's API for code review purposes.

google_model - Optional. The Google model name (e.g., gemini-2.5-pro or gemini-2.5-flash). Default is 'gemini-2.5-flash'.

deepseek_api_key - Required if using Deepseek provider. This key is necessary to access Deepseek's API for code review purposes.

deepseek_model - Optional. The Deepseek model name (e.g., deepseek-chat). Default is 'deepseek-chat'.

x_api_key - Required if using X provider. This key is necessary to access X's API for code review purposes.

x_model - Optional. The Deepseek model name (e.g., grok-3 or grok-4). Default is 'grok-3'.

perplexity_api_key - Required if using Perplexity provider. This key is necessary to access Perplexity's API for code review purposes.

perplexity_model - Optional. The Perplexity model name (e.g., sonar, sonar-pro, r1-1776, sonar-reasoning-pro). Default is 'sonar-reasoning-pro'.

include_extensions - Optional. A comma-separated list of file extensions to include in the review (e.g., ".py,.js,.html"). If not specified, the action will consider all file types.

exclude_extensions - Optional. A comma-separated list of file extensions to exclude from the review.

include_paths - Optional. A comma-separated list of directory paths to include in the review.

exclude_paths - Optional. A comma-separated list of directory paths to exclude from the review (e.g., "test/,docs/"). If not specified, the action will consider all paths.

fail_action_if_review_failed - Optional. If set to true, the action fails when the review process fails. Default is 'false'.

review_rules_file - Optional. Path to a file in the repository containing custom review rules to be added to the AI system prompt.

Usage Examples

Create a new .github/workflows/ai-code-review.yml file in your GitHub repository. Below are examples for different AI providers:

OpenAI Example

name: AI Code Review with OpenAI

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

jobs:
  ai_code_review:
    runs-on: ubuntu-latest
    steps:
    - name: AI Code Review
      uses: AleksandrFurmenkovOfficial/ai-code-review@v0.9
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        owner: ${{ github.repository_owner }}
        repo: ${{ github.event.repository.name }}
        pr_number: ${{ github.event.number }}
        
        ai_provider: 'openai'
        openai_api_key: ${{ secrets.OPENAI_API_KEY }}
        openai_model: 'gpt-4.1'

Anthropic Example

name: AI Code Review with Anthropic

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

jobs:
  ai_code_review:
    runs-on: ubuntu-latest
    steps:
    - name: AI Code Review
      uses: AleksandrFurmenkovOfficial/ai-code-review@v0.9
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        owner: ${{ github.repository_owner }}
        repo: ${{ github.event.repository.name }}
        pr_number: ${{ github.event.number }}
        
        ai_provider: 'anthropic'
        anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
        anthropic_model: 'claude-sonnet-4-20250514'

Google Example

name: AI Code Review with Google

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

jobs:
  ai_code_review:
    runs-on: ubuntu-latest
    steps:
    - name: AI Code Review
      uses: AleksandrFurmenkovOfficial/ai-code-review@v0.9
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        owner: ${{ github.repository_owner }}
        repo: ${{ github.event.repository.name }}
        pr_number: ${{ github.event.number }}
        
        ai_provider: 'google'
        google_api_key: ${{ secrets.GOOGLE_API_KEY }}
        google_model: 'gemini-2.5-flash'

Deepseek Example

name: AI Code Review with Deepseek

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

jobs:
  ai_code_review:
    runs-on: ubuntu-latest
    steps:
    - name: AI Code Review
      uses: AleksandrFurmenkovOfficial/ai-code-review@v0.9
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        owner: ${{ github.repository_owner }}
        repo: ${{ github.event.repository.name }}
        pr_number: ${{ github.event.number }}
        
        ai_provider: 'deepseek'
        deepseek_api_key: ${{ secrets.DEEPSEEK_API_KEY }}
        deepseek_model: 'deepseek-chat'

X Example

name: AI Code Review with X

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

jobs:
  ai_code_review:
    runs-on: ubuntu-latest
    steps:
    - name: AI Code Review
      uses: AleksandrFurmenkovOfficial/ai-code-review@v0.9
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        owner: ${{ github.repository_owner }}
        repo: ${{ github.event.repository.name }}
        pr_number: ${{ github.event.number }}
        
        ai_provider: 'x'
        x_api_key: ${{ secrets.X_API_KEY }}
        x_model: 'grok-3'

Perplexity Example

name: AI Code Review with Perplexity

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

jobs:
  ai_code_review:
    runs-on: ubuntu-latest
    steps:
    - name: AI Code Review
      uses: AleksandrFurmenkovOfficial/ai-code-review@v0.9
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        owner: ${{ github.repository_owner }}
        repo: ${{ github.event.repository.name }}
        pr_number: ${{ github.event.number }}
        
        ai_provider: 'perplexity'
        perplexity_api_key: ${{ secrets.PERPLEXITY_API_KEY }}
        perplexity_model: 'sonar-reasoning-pro'

Advanced Configuration Example

name: AI Code Review with Advanced Settings

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

jobs:
  ai_code_review:
    runs-on: ubuntu-latest
    steps:
    - name: AI Code Review
      uses: AleksandrFurmenkovOfficial/ai-code-review@v0.9
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        owner: ${{ github.repository_owner }}
        repo: ${{ github.event.repository.name }}
        pr_number: ${{ github.event.number }}

        ai_provider: 'openai'
        openai_api_key: ${{ secrets.OPENAI_API_KEY }}
        
        include_extensions: '.py,.js,.tsx'
        exclude_extensions: '.test.js'
        include_paths: 'src/,app/'
        exclude_paths: 'test/,docs/'
        fail_action_if_review_failed: 'true'

Troubleshooting

Common Issues

API Key Issues

  • Problem: Error message about invalid API keys
  • Solution: Ensure your API keys are correctly set as GitHub secrets and properly passed to the workflow.

Action Failing with Timeout

  • Problem: The action fails with a timeout error
  • Solution:
    1. Try using a simpler or faster model
    2. Split large PRs into smaller ones
    3. Use include/exclude paths to limit the scope of the review

Error: "This model's maximum context length is exceeded"

  • Problem: The AI model can't process all the provided code due to token limitations
  • Solution:
    1. Use exclude_paths to skip large files
    2. Use include_extensions to focus only on critical file types
    3. Make smaller PRs with fewer changed files

About

AI Code Review is a lightweight, simple GitHub Action that supports various AI models to analyze and provide feedback on your code. This GitHub Action helps improve code quality by automatically reviewing pull requests, focusing on specified file extensions, and excluding specific paths.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5