Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AutoReview

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.


πŸ”‘ Key Features

  • πŸ” 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 .env file 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

⚑ Quick Start

# 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

Run your first review

# 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 42

πŸ”§ Configuration

AutoReview loads configuration from three sources β€” in priority order:

1. CLI flags (highest priority)

python autoreview.py --pr https://github.com/owner/repo/pull/123 \
  --token ghp_xxxxxxxxxxxxxxxxxxxx \
  --llm-api-key sk-xxxxxxxxxxxxxxxxxxxx \
  --model deepseek

2. Environment variables (.env file)

# 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 URL

3. .env file setup

cp .env.example .env
# Edit .env with your tokens

πŸ—οΈ Architecture

autoreview/
β”œβ”€β”€ 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

πŸ€– Multi-LLM Support

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

Ollama example (no API key)

# 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:11434

DeepSeek example (cheap & fast)

export LLM_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx
python autoreview.py --pr https://github.com//pull/123 --model deepseek

🎯 Focus Areas

Use --focus to narrow the review to specific concerns:

python autoreview.py --pr https://github.com/owner/repo/pull/123 \
  --focus security \
  --focus bugs \
  --focus performance

Available focus areas: security, performance, readability, bugs

Without --focus, the LLM gives a full-spectrum review.


πŸ“‹ All CLI Options

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

πŸ›‘οΈ Security Notes

  • 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 repo scope only; read-only access is sufficient
  • No third-party logging β€” no analytics, telemetry, or external calls beyond GitHub + LLM API

πŸ“‹ Example Output

============================================================
πŸ”  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
============================================================

πŸš€ CI/CD Integration

# .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

πŸ“‹ Roadmap

  • 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)

🎯 Why This Project

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! 🌟


License

MIT β€” Kiell Tampubolon

About

AI-powered code review for GitHub pull requests in your terminal. Multi-LLM support (OpenAI, DeepSeek, Claude, Ollama).

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages