AI Code Reviewer is a GitHub Action that leverages multiple AI providers (OpenAI, Anthropic, Google) to provide intelligent feedback and suggestions on your pull requests. This powerful tool helps improve code quality and saves developers time by automating the code review process.
- Supports multiple AI providers:
- OpenAI (ChatGPT)
- Anthropic (Claude)
- Google (Gemini)
- Custom (any OpenAI/Anthropic-compatible API - Ollama, Llama.cpp, MiniMax, GLM, LM Studio, vLLM, etc.)
- Provides intelligent comments and suggestions for improving your code
- Reviews only new changes in PR updates
- Filters out files that match specified exclude patterns
- Easy to set up and integrate into your GitHub workflow
-
Choose your preferred AI provider and get an API key:
-
Add the API key as a GitHub Secret in your repository:
OPENAI_API_KEYfor OpenAIANTHROPIC_API_KEYfor ClaudeGOOGLE_AI_KEYfor Google GeminiAI_API_KEYfor Custom AI(Ollama, Llama.cpp, MiniMax, GLM, LM Studio, vLLM, etc.) - This parameter can be empty
-
Create
.github/workflows/code-review.yml:
name: AI Code Review
on:
pull_request:
types: [opened, synchronize]
permissions: write-all
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: AI Code Review
uses: your-username/ai-code-reviewer@main # Example: ramonpaolo/ai-code-reviewer@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needs the permission to write comment, read code and approve PR
# Choose your AI provider and key
AI_PROVIDER: "openai" # or "anthropic" or "google" or "custom"
AI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AI_MODEL: "gpt-4o-mini" # or "minimax-m2.1" or "Qwen3-Coder-480B-A35B-Instruct"
AI_TEMPERATURE: 0.3 # 0 to 1 - higher values = more creativity and variance; Obs: not affect some models and providers
# Optional configurations
APPROVE_REVIEWS: true
MAX_COMMENTS: 10 # 0 to disable
PROJECT_CONTEXT: "This is a Node.js TypeScript project"
CONTEXT_FILES: "package.json,README.md"
EXCLUDE_PATTERNS: "**/*.lock,**/*.json,**/*.md"| Input | Description | Default |
|---|---|---|
AI_PROVIDER |
AI provider to use (openai, anthropic, google, custom) |
openai |
AI_API_KEY |
API key for chosen provider (optional for local/custom providers) | Required |
AI_BASE_URL |
Custom API base URL (required for custom providers - must include the full endpoint path like /v1 or /v1/text/chatcompletion_v2) |
"" |
AI_MODEL |
Model to use (see supported models below) | Provider's default |
AI_TEMPERATURE |
Temperature for AI model | 0 |
APPROVE_REVIEWS |
Whether to approve PRs automatically | true |
MAX_COMMENTS |
Maximum number of review comments | 0 |
PROJECT_CONTEXT |
Project context for better reviews | "" |
CONTEXT_FILES |
Files to include in review (comma-separated) | "package.json,README.md" |
EXCLUDE_PATTERNS |
Files to exclude (glob patterns, comma-separated) | "**/*.lock,**/*.json,**/*.md" |
All models supported by the provider should be supported.
When using the custom provider, you must provide the complete URL to the API endpoint, including the full path (e.g., /api/chat, /v1/text/chatcompletion_v2, etc.):
# Example with Ollama (local)
- name: AI Code Review (Ollama)
uses: your-username/ai-code-reviewer@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AI_PROVIDER: "custom"
AI_BASE_URL: "http://some-ollama-url:11434/api/chat"
AI_MODEL: "llama3.2"
AI_API_KEY: "" # Not needed for Ollama
# Example with MiniMax
- name: AI Code Review (MiniMax)
uses: your-username/ai-code-reviewer@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AI_PROVIDER: "custom"
AI_BASE_URL: "https://api.minimax.io/v1/text/chatcompletion_v2"
AI_MODEL: "minimax-m2.1"
AI_API_KEY: "your-minimax-api-key"Important: For custom providers, AI_BASE_URL must include the complete endpoint path, not just the base domain.
Create a .env file with your credentials:
GITHUB_TOKEN=your_github_token
AI_PROVIDER=openai # or anthropic, google, custom
AI_API_KEY=your_api_key
AI_MODEL=your_preferred_model
AI_BASE_URL=url_api# Install dependencies
yarn install
# Build TypeScript files
yarn build
# Run unit tests
yarn test
# Package for distribution
yarn package
# Generate test PR payload (for e2e testing)
yarn generate-pr-payload <owner> <repo> <pr_number>
# Run end-to-end tests
yarn test:e2e <owner> <repo> <pr_number>To test the action locally:
- Create a
.envfile with your credentials:
GITHUB_TOKEN=your_github_token
AI_PROVIDER=openai # or anthropic, google, custom
AI_API_KEY=your_api_key
AI_MODEL=your_preferred_model
AI_BASE_URL=url_api- Generate a test PR payload:
yarn generate-pr-payload <owner> <repo> 123- Run the e2e test:
yarn test:e2e <owner> <repo> 123Note: Make sure you have write access to the repository you're testing with.
Contributions are welcome! Please feel free to submit issues or pull requests.
MIT License - see LICENSE for details.