Skip to main content

diffjudge

AI-powered pull request reviewer — with zero dependencies.

diffjudge fetches a pull request's diff, asks a language model to review it, and either prints the review or posts it back as a PR comment. It works with any OpenAI-compatible API: the OpenAI platform, OpenRouter, or a local llama.cpp / Ollama server. The whole thing is built on the Python standard library — no requests, no SDKs, nothing to audit but a few hundred lines.

Use it as a CLI for ad-hoc reviews, or drop the bundled GitHub Action into a workflow to get an automatic review on every pull request.

What a review looks like

## diffjudge review

## Summary
Adds retry handling to the upload client and a backoff helper.

## Findings
- **major** `client.py`: the retry loop never breaks on a 4xx response, so a bad
  request is retried 5 times before failing.
- **minor** `client.py`: `backoff()` ignores the `jitter` argument.

## Suggestions
- Consider adding a test for the 4xx-no-retry path.

Install

pip install diffjudge
# or, for an isolated CLI:
pipx install diffjudge

Requires Python 3.8+.

CLI usage

export OPENAI_API_KEY=sk-...
export GITHUB_TOKEN=ghp_...        # only needed to fetch private diffs or to --post

# Print a review to your terminal
diffjudge --repo octocat/hello-world --pr 42

# Post the review as a comment on the PR
diffjudge --repo octocat/hello-world --pr 42 --post

# Use a different model or provider
diffjudge --repo octocat/hello-world --pr 42 --model gpt-4o
diffjudge --repo me/proj --pr 7 --base-url http://localhost:8080/v1 --model local-model

Options

Flag Description
--repo OWNER/NAME Repository to review (required).
--pr N Pull request number (required).
--model NAME Model name (default gpt-4o-mini, or $DIFFJUDGE_MODEL).
--base-url URL OpenAI-compatible base URL (default $OPENAI_BASE_URL or OpenAI).
--api-key KEY LLM API key (default $OPENAI_API_KEY).
--github-token TOKEN GitHub token (default $GITHUB_TOKEN).
--max-diff-bytes N Truncate diffs larger than this (default 60000).
--post Post the review as a PR comment instead of printing it.

GitHub Action

Add a workflow that reviews every pull request. Store your provider key as a repository secret (e.g. OPENAI_API_KEY):

name: diffjudge
on:
  pull_request:

permissions:
  contents: read
  pull-requests: write

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: Sev7nOfNine/diffjudge@v0.1.0
        with:
          api-key: ${{ secrets.OPENAI_API_KEY }}
          model: gpt-4o-mini

Point base-url at any OpenAI-compatible endpoint to use a different provider or a self-hosted model.

Privacy note

diffjudge sends the pull request diff to whatever provider you configure. Only point it at providers you trust with your code, and prefer a self-hosted model (--base-url) for private repositories where that matters.

Development

pip install -e ".[test]"
python -m pytest

The HTTP layers accept an injectable opener, so the whole suite runs offline with no real API calls.

License

MIT — see LICENSE.

Metadata

Release files for diffjudge 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diffjudge 0.1.0
File Size Uploaded
diffjudge-0.1.0.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for diffjudge 0.1.0
File Interpreter ABI Platform
diffjudge-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / diffjudge-0.1.0.tar.gz

Download URL diffjudge-0.1.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
22b247b26d1e5c4dcd4536c98febdcf4d5731b6fb2ea602b13bf4e16d869473f
BLAKE2b-256 checksum
How to use checksums
89acd6f19eb480856484525ed80f42b7873026da0222f48749eaea4aff5542e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release files / diffjudge-0.1.0-py3-none-any.whl

Download URL diffjudge-0.1.0-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9e8c442bb936e264a0f2ecaa337976e90868bf4f2860bfd4d9db5833adcca3b
BLAKE2b-256 checksum
How to use checksums
ad4d695885b160ea5acfd6ae72d5ee29db039a781e7f06438b69f548ec0b46dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page