An AI-powered code review tool that works as a CLI, npm module, GitHub Action, and standalone bot. Similar to Greptile, but open and flexible.
- Context-Aware Reviews: Analyzes full codebase, not just diffs
- Multi-Provider AI: OpenAI, Anthropic (Claude), Qwen (via CLI subprocess)
- Custom Rules: Configure team standards in
.aicodereview/rules.md - AI PR Summaries: Auto-generates PR descriptions with Mermaid diagrams
- Multiple Interfaces: CLI, GitHub Action, standalone bot, and importable module
# Install globally
npm install -g @aicodereviewer/cli
# Or run from the repo
node packages/cli/dist/cli.js --help
# Initialize rules
aicodereview init
# Review a diff file
aicodereview review --diff my-changes.diff --provider openai
# Read diff from stdin
git diff main | aicodereview review --stdin --provider anthropic
# Generate only a summary
aicodereview summarize --diff my-changes.diff --jsonname: AI Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: AI Code Review
uses: aicodereviewer/action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
ai-provider: openai
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
rules-path: '.aicodereview/rules.md'The bot runs as a service and responds to /review commands on PRs.
cd packages/bot
cp .env.example .env
# Edit .env with your credentials
npm startThen configure your GitHub App's webhook URL to point to your server (e.g., https://your-server.com/).
Users can then comment on any PR:
/review— triggers a full code review/ai-review— same as above- The bot posts a summary comment + inline comments on the diff
import { CodeReviewer, ReviewConfig } from '@aicodereviewer/core';
const config: ReviewConfig = {
ai: {
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY,
model: 'gpt-4-turbo-preview',
},
rules: [],
includeDependencies: true,
};
const reviewer = new CodeReviewer(config, '/path/to/repo');
const result = await reviewer.reviewDiff(diffContent, files, fileDiffs);
console.log(result.summary);
console.log(result.comments);| Provider | Env Variable | Notes |
|---|---|---|
| OpenAI | OPENAI_API_KEY |
Default: gpt-4-turbo-preview |
| Anthropic | ANTHROPIC_API_KEY |
Default: claude-3-sonnet-20240229 |
| Qwen CLI | (none) | Requires qwen installed |
If you have Qwen CLI installed, you can use it as a provider:
aicodereview review --diff changes.diff --provider qwen-cliThe tool spawns a subprocess of qwen --no-interactive and pipes the prompt via stdin.
Create .aicodereview/rules.md in your repo:
# AI Code Review Rules
## Rule: NO_CONSOLE_LOG
- Description: Do not use console.log in production code. Use proper logging libraries.
- Scope: src/**/*.ts
- Severity: warning
## Rule: ERROR_HANDLING
- Description: All async functions must have proper error handling with try/catch.
- Scope: src/**/*.ts
- Severity: criticalRules are written in plain English and scoped to specific file patterns using glob syntax.
| Command | Description |
|---|---|
aicodereview review |
Full code review with inline comments |
aicodereview summarize |
Generate PR summary only |
aicodereview init |
Create default rules file |
| Flag | Description |
|---|---|
--diff <path> |
Path to diff file |
--stdin |
Read diff from stdin |
--root <path> |
Root directory of the codebase |
--provider <name> |
AI provider (openai, anthropic, qwen-cli) |
--model <name> |
Override default model |
--rules <path> |
Path to rules markdown file |
--no-context |
Disable full codebase context |
--json |
Output as JSON |
| Input | Required | Default | Description |
|---|---|---|---|
github-token |
Yes | ${{ github.token }} |
GitHub token |
ai-provider |
No | openai |
AI provider |
openai-api-key |
No | $OPENAI_API_KEY |
OpenAI API key |
anthropic-api-key |
No | $ANTHROPIC_API_KEY |
Anthropic API key |
model |
No | provider default | AI model |
rules-path |
No | .aicodereview/rules.md |
Rules file path |
review-mode |
No | pr |
pr, summary, or comments |
ignore-paths |
No | `` | Comma-separated paths to ignore |
max-files |
No | 50 |
Max files to analyze |
aicodereviewer/
├── packages/
│ ├── core/ # Shared analysis engine, AI providers
│ │ ├── src/
│ │ │ ├── providers/ # OpenAI, Anthropic, Qwen CLI
│ │ │ ├── code-reviewer.ts # Main review orchestrator
│ │ │ ├── codebase-analyzer.ts # File analysis & dependency graph
│ │ │ ├── rules-engine.ts # Custom rules parser
│ │ │ └── summary-generator.ts # PR summaries & Mermaid diagrams
│ │ └── dist/
│ ├── cli/ # Command-line interface
│ │ └── src/cli.ts
│ ├── action/ # GitHub Action (CI/CD)
│ │ └── src/index.ts
│ └── bot/ # Standalone GitHub bot (webhook service)
│ └── src/bot.ts
├── package.json # Root workspace config
└── README.md
# Install dependencies
npm install
# Build all packages
npm run build
# Run CLI in dev mode
npm run dev:cliMIT