A CLI tool that reviews code diffs using LLMs.
Project description
PRRev
A CLI tool that reviews code diffs using LLMs. Point it at a local repo or a GitHub PR URL. It sends the diff to Claude or GPT-4o and outputs a structured review with severity ratings, file references, and line numbers.
Install
pip install prrev
Requires Python 3.10+.
Usage
# review uncommitted changes
prrev .
# review only staged changes
prrev . --staged
# review a specific commit
prrev . --commit abc123
# review a commit range
prrev . --range abc123..def456
# review a GitHub PR
prrev https://github.com/user/repo/pull/42
# post review as inline PR comments
prrev https://github.com/user/repo/pull/42 --post
# write review to a markdown file
prrev . --output review.md
# fail in CI if there are warnings or worse
prrev . --fail-on warning
# show full tracebacks instead of short errors
prrev . --debug
Note: brand-new files don't appear in the diff until you git add them — PRRev will tell you when untracked files are being left out.
Configuration
Set API keys as environment variables:
export ANTHROPIC_API_KEY=YOUR_ANTHROPIC_KEY
export OPENAI_API_KEY=YOUR_OPENAI_KEY
export GITHUB_TOKEN=YOUR_GITHUB_TOKEN
Or use a config file at ~/.config/prrev/config.toml:
[llm]
provider = "anthropic"
model = "claude-haiku-4-5"
anthropic_api_key = "YOUR_ANTHROPIC_KEY"
[github]
token = "YOUR_GITHUB_TOKEN"
[review]
max_items = 20
You can also put a .prrev.toml in your repo root for per-project settings. API keys are ignored in repo config for security. They only load from env vars or the global config.
Precedence: CLI flags > env vars > repo config > global config > defaults.
Providers
# use claude (default)
prrev . --provider anthropic
# use gpt-4o
prrev . --provider openai
# override the model
prrev . --provider anthropic --model claude-opus-4-8
Models you can use
Anthropic:
| Model | ID |
|---|---|
| Claude Fable 5 | claude-fable-5 |
| Claude Sonnet 5 | claude-sonnet-5 (default) |
| Claude Opus 4.8 | claude-opus-4-8 |
| Claude Opus 4.7 | claude-opus-4-7 |
| Claude Opus 4.6 | claude-opus-4-6 |
| Claude Haiku 4.5 | claude-haiku-4-5 |
OpenAI:
| Model | ID |
|---|---|
| GPT-4o | gpt-4o (default) |
| GPT-4o mini | gpt-4o-mini |
| GPT-4 Turbo | gpt-4-turbo |
| o1 | o1 * |
| o1-mini | o1-mini * |
* o1 models don't support structured output (response_format). Reviews may fail or return unparseable responses.
Ensemble mode
Review with both providers at once and have one of them reconcile the results into a single review:
# both models review, claude reconciles (default judge)
prrev . --provider both
# pick the judge
prrev . --provider both --judge openai
# choose each provider's model
prrev . --provider both --model anthropic=claude-haiku-4-5 --model openai=gpt-4o-mini
Findings flagged by both models are marked as higher confidence. If one provider fails, the review degrades to a single-model review with a notice instead of failing. Ensemble mode needs both API keys set and costs roughly double a single review, plus one reconciliation call per chunk.
How It Works
The diff is sent to the LLM using each provider's structured output mechanism: Anthropic's tool use and OpenAI's response_format with a JSON schema. This guarantees the response matches the expected structure at the API level without fragile JSON text parsing.
For large diffs, PRRev automatically chunks by file based on actual token counts (not character estimates) and reviews each chunk in parallel. A single file too large for the context window is split further into hunk batches, so even oversized files get reviewed. Results are merged and truncated by severity: suggestions are dropped first, then warnings. Critical issues are never dropped.
Exit Codes
0:review completed, no issues at or above--fail-onthreshold1:issues found at or above--fail-onthreshold2:tool error (missing API key, invalid args, network failure)
Tool notices (a file skipped for size, a failed chunk) render as warnings but never count toward --fail-on, so CI fails only on real findings.
Tech Stack
- Typer: CLI framework
- Rich: terminal output with colored severity panels
- GitPython: local diff extraction
- httpx: GitHub API (fetch PR diffs, post inline comments)
- Anthropic SDK: Claude API with tool use for structured output
- OpenAI SDK: GPT-4o API with structured output
- tiktoken: token counting for OpenAI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prrev-0.2.0.tar.gz.
File metadata
- Download URL: prrev-0.2.0.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3ad9debb348c2376ba7709e5783ffb383c15749eb0399700c346c27a9875ce6
|
|
| MD5 |
05dd577edb3a1751a8f23274a94a6ce6
|
|
| BLAKE2b-256 |
293aa969f79991fd66d85d0a30d02fb7b8fcd897b481d32dd31eca9a254351f8
|
Provenance
The following attestation bundles were made for prrev-0.2.0.tar.gz:
Publisher:
publish.yml on timurmamedov1/PRRev
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prrev-0.2.0.tar.gz -
Subject digest:
f3ad9debb348c2376ba7709e5783ffb383c15749eb0399700c346c27a9875ce6 - Sigstore transparency entry: 2148327500
- Sigstore integration time:
-
Permalink:
timurmamedov1/PRRev@30dd2ba3ac81203a72e3c8a3b959ac576b42fbaf -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/timurmamedov1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@30dd2ba3ac81203a72e3c8a3b959ac576b42fbaf -
Trigger Event:
release
-
Statement type:
File details
Details for the file prrev-0.2.0-py3-none-any.whl.
File metadata
- Download URL: prrev-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27ea80d9e81ab331f038631773a3101f39e796b01f7a58f4cb34fe4b0ec97dbb
|
|
| MD5 |
e8a7a368f2b844a54f616ff448f982cc
|
|
| BLAKE2b-256 |
aeda789e1286946a389ce0eaba55cab9ed18ffb8a59514f06029d7f3b1091f33
|
Provenance
The following attestation bundles were made for prrev-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on timurmamedov1/PRRev
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prrev-0.2.0-py3-none-any.whl -
Subject digest:
27ea80d9e81ab331f038631773a3101f39e796b01f7a58f4cb34fe4b0ec97dbb - Sigstore transparency entry: 2148327511
- Sigstore integration time:
-
Permalink:
timurmamedov1/PRRev@30dd2ba3ac81203a72e3c8a3b959ac576b42fbaf -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/timurmamedov1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@30dd2ba3ac81203a72e3c8a3b959ac576b42fbaf -
Trigger Event:
release
-
Statement type: