AI-powered code review for GitHub pull requests β directly in your terminal.
Give AutoReview a PR URL or owner/repo/pr-number, and it fetches the diff, sends it to your favourite LLM, and prints a structured code review β in seconds.
- π Full PR diff analysis β fetches all changed files, additions, deletions, and patches via GitHub REST API
- π€ Multi-LLM support β OpenAI GPT-4o mini, DeepSeek Chat, Anthropic Claude, or any Ollama local model
- π― Focus areas β pin the review to security, performance, readability, or bugs
- π¦ Zero config to start β reads tokens from env vars; drop-in
.envfile supported - πͺΆ Lightweight β pure Python, no framework, < 300 lines of core code
- π Markdown output β review is formatted with headers, code blocks, and file paths β copy straight into your PR comment
# Clone the repo
git clone https://github.com/glatinone/autoreview.git
cd autoreview
# Install dependencies
pip install -r requirements.txt
# Copy and edit config
cp .env.example .env
# β Add your GITHUB_TOKEN and LLM_API_KEY to .env# From a PR URL
python autoreview.py --pr https://github.com/owner/repo/pull/123
# From owner / repo / pr-number
python autoreview.py --owner myorg --repo myrepo --pr-number 42AutoReview loads configuration from three sources β in priority order:
python autoreview.py --pr https://github.com/owner/repo/pull/123 \
--token ghp_xxxxxxxxxxxxxxxxxxxx \
--llm-api-key sk-xxxxxxxxxxxxxxxxxxxx \
--model deepseek# Required
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
# LLM API keys (pick one based on your provider)
LLM_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx # DeepSeek (default provider)
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx # OpenAI
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxx # Anthropic
# Optional
LLM_MODEL=openai # Default model (overridden by --model)
OLLAMA_URL=http://localhost:11434 # Ollama base URLcp .env.example .env
# Edit .env with your tokensautoreview/
βββ autoreview.py # CLI entry point + orchestration
βββ requirements.txt
βββ README.md
βββ .env.example # Environment variable template
βββ src/
βββ __init__.py
βββ config.py # Config loader (CLI args + env vars)
βββ github_client.py # GitHub REST API client
βββ llm_client.py # Multi-LLM adapter
βββ reviewer.py # Orchestration layer
Data flow:
PR URL/args
β config.py (resolve token, model, focus)
β github_client.py (fetch PR diff + metadata)
β llm_client.py (send diff to LLM with focus prompt)
β reviewer.py (structure the response)
β print formatted review
AutoReview is provider-agnostic. Set up one or more:
| Provider | Model | Environment Variable | Flag |
|---|---|---|---|
| DeepSeek (default) | deepseek-chat | LLM_API_KEY |
--model deepseek |
| OpenAI | GPT-4o mini | OPENAI_API_KEY |
--model openai |
| Anthropic | Claude Sonnet | ANTHROPIC_API_KEY |
--model anthropic |
| Ollama (local) | any installed model | (no key needed) | --model ollama |
# Terminal 1: start Ollama
ollama serve
ollama pull llama3.2
# Terminal 2: run AutoReview
python autoreview.py --pr https://github.com/owner/repo/pull/123 \
--model ollama \
--ollama-url http://localhost:11434export LLM_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx
python autoreview.py --pr https://github.com//pull/123 --model deepseekUse --focus to narrow the review to specific concerns:
python autoreview.py --pr https://github.com/owner/repo/pull/123 \
--focus security \
--focus bugs \
--focus performanceAvailable focus areas: security, performance, readability, bugs
Without --focus, the LLM gives a full-spectrum review.
usage: autoreview.py [-h] [--pr PR] [--owner OWNER] [--repo REPO]
[--pr-number PR_NUMBER] [--token TOKEN]
[--model {openai,deepseek,anthropic,ollama}]
[--llm-api-key KEY] [--ollama-url URL]
[--focus FOCUS] [-v] [-V]
AI-powered code review for GitHub pull requests.
options:
--pr PR Full PR URL
--owner OWNER Repository owner
--repo REPO Repository name
--pr-number PR_NUMBER PR number
--token TOKEN GitHub token (or set GITHUB_TOKEN)
--model {openai,deepseek,anthropic,ollama}
LLM provider (default: openai)
--llm-api-key KEY LLM API key (or set LLM_API_KEY)
--ollama-url URL Ollama base URL (default: http://localhost:11434)
--focus FOCUS Focus areas (repeatable)
-v, --verbose Verbose output
-V, --version Show version
- Tokens stay local β never sent anywhere except GitHub and your chosen LLM provider
- Read-only β AutoReview only reads PR data, never modifies anything
- GitHub token scope β requires
reposcope only; read-only access is sufficient - No third-party logging β no analytics, telemetry, or external calls beyond GitHub + LLM API
============================================================
π AUTOREVIEW β AI-Powered Code Review
============================================================
π¦ Repository : owner/repo
π’ PR : #42 β "Add user authentication"
π€ Author : contributor
π Files changed: 3
π€ Model : deepseek-chat
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π― REVIEW SUMMARY
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
Logic : 2 suggestions
π Security : 1 critical finding
π Bugs : None found
π Readability : Minor improvements
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π SECURITY
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β οΈ src/auth.py:45 β SQL injection risk in raw query.
`cursor.execute(f"SELECT * FROM users WHERE
id={user_id}")` allows injection. Use parameterized
query:
`cursor.execute("SELECT * FROM users WHERE id=%s",
(user_id,))`
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
LOGIC
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π‘ src/auth.py:67 β Consider caching the token validation
result. This is called on every protected route. A TTL
cache (e.g. 5 min) could cut latency by ~80%.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Generated by AutoReview | MIT License
============================================================
# .github/workflows/review.yml
name: AutoReview
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run AutoReview
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
run: |
python autoreview.py \
--pr ${{ github.event.pull_request.html_url }} \
--model deepseek \
--focus security \
--focus bugs \
--verbose- Post review directly as a GitHub PR comment (
--post-comment) - Review specific files only (
--files src/) - Team config file (
~/.autoreview.yaml) - Streaming output (
--stream) - Batch review multiple PRs
- Diff summary mode (files + lines changed, no AI review)
Built as a portfolio project demonstrating:
- API integration (GitHub REST, multiple LLM APIs)
- Clean architecture (thin client β orchestrator β LLM)
- CLI design (argparse, env vars, help text)
- Error handling (auth errors, network failures, missing fields)
- Extensibility (swap LLMs, add new providers without touching core logic)
Pull requests and stars welcome! π
MIT β Kiell Tampubolon