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.1.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.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_ai_pr_review-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b75318fbaa9ee0dc2d98ae3d54a480057f3e95ce6151d506ebbc865b64736dd3
MD5 7daa6860958d912f48d75ab28d4d0ccd
BLAKE2b-256 dbef008941d1c0d57af2ad8a12f60fc9a50f1039b9a927b623c4e18bd3ace17e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for git_ai_pr_review-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 608e174adf821a17b620ac306fb41b7b314eed982e27d18e4b6ae2d31578df36
MD5 53fe52f3a2dd33834552fe1bb86a3929
BLAKE2b-256 c09aaca66031cc02d50aaeb1daffa96c945fd40977b0739a634fe58dfbb89f21

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