An intelligent CLI tool that uses AI to review your code, analyze pull requests, and suggest improvements.
- Code Analysis: Review individual files or entire directories
- Git Diff Review: Analyze staged changes before committing
- GitHub PR Integration: Review pull requests directly from the command line
- Multi-Language Support: Works with Python, JavaScript, TypeScript, Go, Rust, and more
- Configurable Focus: Choose between security, performance, style, or bug detection
- Rich Output: Beautiful terminal output with syntax highlighting
pip install coderevWith OpenAI support:
pip install coderev[openai]With all optional dependencies:
pip install coderev[all]git clone https://github.com/limem01/coderev.git
cd coderev
pip install -e ".[dev]"# Review a single file
coderev review app.py
# Review a directory
coderev review src/ --recursive
# Review staged git changes
coderev diff
# Review a GitHub PR
coderev pr https://github.com/owner/repo/pull/123
# Focus on security issues
coderev review app.py --focus security
# Output as JSON
coderev review app.py --format jsonCreate a .coderev.toml in your project root or home directory:
[coderev]
api_key = "your-api-key" # Or use CODEREV_API_KEY env var
model = "claude-3-sonnet"
focus = ["bugs", "security", "performance"]
ignore_patterns = ["*.test.py", "migrations/*"]
max_file_size = 100000 # bytes
language_hints = true
[github]
token = "ghp_xxx" # Or use GITHUB_TOKEN env var# Basic review
coderev review main.py
# Review with specific focus areas
coderev review main.py --focus security --focus performance
# Review multiple files
coderev review src/api.py src/models.py src/utils.py
# Recursive directory review
coderev review ./src --recursive --exclude "*.test.py"# Review staged changes
coderev diff
# Review changes between branches
coderev diff main..feature-branch
# Review last N commits
coderev diff HEAD~3# Review a PR by URL
coderev pr https://github.com/owner/repo/pull/42
# Review a PR by number (requires GitHub remote)
coderev pr 42
# Post review comments directly to PR
coderev pr 42 --post-comments# Rich terminal output (default)
coderev review app.py
# JSON output for CI/CD pipelines
coderev review app.py --format json
# Markdown output
coderev review app.py --format markdown
# SARIF output for GitHub Security
coderev review app.py --format sarif| Focus | Description |
|---|---|
bugs |
Logic errors, null references, off-by-one errors |
security |
SQL injection, XSS, hardcoded secrets, unsafe deserialization |
performance |
N+1 queries, unnecessary loops, memory leaks |
style |
Code style, naming conventions, documentation |
architecture |
Design patterns, SOLID principles, coupling |
testing |
Test coverage suggestions, edge cases |
The easiest way to use CodeRev in your CI/CD pipeline is via our official GitHub Action:
name: AI Code Review
on: [pull_request]
permissions:
contents: read
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run CodeRev
uses: limem01/coderev@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
model: 'claude-3-sonnet-20240229'
focus: 'bugs,security,performance'
fail_on: 'critical'
post_review: 'true'| Input | Description | Required | Default |
|---|---|---|---|
anthropic_api_key |
Anthropic API key for Claude models | No* | - |
openai_api_key |
OpenAI API key for GPT models | No* | - |
github_token |
GitHub token for posting reviews | Yes | ${{ github.token }} |
model |
Model to use | No | claude-3-sonnet-20240229 |
focus |
Focus areas (comma-separated) | No | bugs,security,performance |
fail_on |
Fail on severity level | No | - |
post_review |
Post review to PR | No | true |
max_files |
Max files to review | No | 20 |
ignore_patterns |
Patterns to ignore | No | *.test.*,*.spec.* |
*Either anthropic_api_key or openai_api_key is required.
| Output | Description |
|---|---|
score |
Code quality score (0-100) |
issues_count |
Total issues found |
critical_count |
Critical issues |
high_count |
High severity issues |
medium_count |
Medium severity issues |
low_count |
Low severity issues |
review_url |
URL to posted review |
name: AI Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
jobs:
coderev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run CodeRev
id: review
uses: limem01/coderev@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
focus: 'bugs,security,performance,architecture'
fail_on: 'high'
max_files: '30'
ignore_patterns: '*.test.*,*.spec.*,*.min.js,package-lock.json'
- name: Quality Gate
if: always()
run: |
if [ "${{ steps.review.outputs.score }}" -lt 70 ]; then
echo "::error::Code quality score is below 70"
exit 1
fiIf you prefer more control, you can install CodeRev directly:
name: Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install coderev
- run: coderev diff origin/main...HEAD --format sarif > results.sarif
env:
CODEREV_API_KEY: ${{ secrets.CODEREV_API_KEY }}
- uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: coderev
name: AI Code Review
entry: coderev diff --staged --fail-on high
language: system
pass_filenames: falseCodeRev can also be used as a Python library:
from coderev import CodeReviewer
reviewer = CodeReviewer(api_key="your-key")
# Review code string
result = reviewer.review_code("""
def get_user(id):
query = f"SELECT * FROM users WHERE id = {id}"
return db.execute(query)
""", language="python", focus=["security"])
for issue in result.issues:
print(f"[{issue.severity}] Line {issue.line}: {issue.message}")The examples/ directory contains practical code samples:
- basic_review.py — Review code strings and files, handle results
- async_parallel.py — Concurrent multi-file reviews
- custom_rules.py — Define rules in Python or YAML
- cost_estimation.py — Estimate API costs before reviewing
- review_history.py — Track and analyze quality trends
- ci_integration.py — Quality gates for CI/CD pipelines
# Clone and install dev dependencies
git clone https://github.com/limem01/coderev.git
cd coderev
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
ruff check .
# Run type checking
mypy src/CodeRev is automatically published to PyPI when a new GitHub release is created:
- Update the version in
pyproject.toml - Commit and push to main
- Create a new release on GitHub
- The CI will automatically build and publish to PyPI
For this to work, you need to configure trusted publishing on PyPI:
- Go to PyPI → Your projects → coderev → Publishing
- Add a new trusted publisher with:
- Owner:
limem01 - Repository:
coderev - Workflow name:
publish.yml - Environment name:
pypi(andtestpypifor TestPyPI)
- Owner:
Not sure if CodeRev is right for you? Check our detailed comparison with other AI code review tools including:
- Codium PR-Agent - Open source PR-focused tool
- CodeRabbit - Commercial SaaS solution
- Amazon CodeGuru - AWS ML-powered reviews
- Sourcery - Python-focused AI assistant
TL;DR: Choose CodeRev for CLI-first workflows, self-hosting, custom rules, and transparent pricing.
MIT License - see LICENSE for details.
Contributions are welcome! Please read our Contributing Guide for details.
