Skip to main content

AI-powered PR review CLI using OpenAI

Project description

PR Review CLI

An AI-powered code review tool that analyzes your git diff and routes it through the right level of LLM scrutiny.

How it works

git diff → LLM classifies change size
              │
              ├── Small change ──→ Focused review (old vs new code)
              │
              └── Big change  ──→ AST analysis finds all callers
                                   └──→ Deep review (diff + impacted files)

Install

# Install the OpenAI client
pip install openai python-dotenv

# Run directly
python reviewer.py

# Or install as a CLI command
pip install -e .
pr-review

Usage

# Set your API key
export OPENAI_API_KEY=sk-...    # macOS / Linux
setx OPENAI_API_KEY "sk-..."   # Windows (PowerShell)

# Review changes vs HEAD (default — unstaged/staged changes)
pr-review

# Review feature branch against main
pr-review --base main

# Review against remote main
pr-review --base origin/main

# Review against a specific commit
pr-review --base abc1234

Output

  • Prints the review to stdout
  • Saves a pr_review_output.md file in the current directory

What the LLM looks for

Small change review:

  • Summary of what changed
  • Bugs & edge cases
  • Code quality & naming
  • Concrete improvement suggestions
  • Final verdict (approve / approve with suggestions / request changes)

Big change review (+ AST impact analysis):

  • Everything above, plus:
  • Breaking change detection (are callers still compatible?)
  • Per-file impact analysis of all call sites found via AST
  • Migration notes — what else needs updating

Notes

  • AST analysis is Python-only (uses the ast stdlib module)
  • Skips .venv and node_modules directories
  • The diff-size LLM call uses OpenAI (model example: gpt-4o-mini)
  • The codebase was refactored: core modules now include llm/openai.py, ast_analyzer.py, diff_parser.py, git.py, and cli.py with reviewer.py acting as the orchestrator
  • Reviews are also saved to pr_review_output.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_ai_pr_review-0.1.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_ai_pr_review-0.1.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file git_ai_pr_review-0.1.2.tar.gz.

File metadata

  • Download URL: git_ai_pr_review-0.1.2.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for git_ai_pr_review-0.1.2.tar.gz
Algorithm Hash digest
SHA256 64304568f1cc4a1d7797d2947da67b7fb14a446fe31a2246796dfd3c99a711fc
MD5 e234700c5180495e006864034ed9ad7a
BLAKE2b-256 214fe83d1590c3f50c0bfcb6f394585a6bef31996e346202e763b7dcd92bd0d2

See more details on using hashes here.

File details

Details for the file git_ai_pr_review-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for git_ai_pr_review-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 289c3a5f4c518a0c870d5fca50e352760662dd2c21313f43a7d40d07bdfbb33a
MD5 0623744073035b5b5ecb090d6e835ca5
BLAKE2b-256 0da4e36d0b1c7efa5d5d5d89f4c2f2353b3f9a83bcae7d9b6c4fe8792d15730a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page