Skip to main content

PR Sentinel

CI PyPI version Python versions License: MIT

Free, self-hosted AI code review for pull requests. Point it at a free provider like Groq, Gemini, or a local Ollama model and it reads your diff, flags real problems, and leaves comments directly on the pull request. No subscription, no seat-based pricing, no vendor lock-in.

If your team has a budget for a paid model, PR Sentinel works with your own OpenAI or Anthropic key too. Nothing here requires it.

Why this exists

Automated PR review tools are useful, but the well known ones are paid products with per-seat pricing. That is a real cost for a solo developer, a student project, or a small open source repository, even when the actual review only needs a handful of API calls per pull request. PR Sentinel is the same idea built as a small, auditable, self-hosted tool: you choose the model, you hold the API key (or use none at all with a local model), and the entire pipeline runs inside your own GitHub Actions job.

What it does

  • Reads the diff for a pull request (or a local git diff) and reviews only the changed lines, using surrounding context to understand intent.
  • Flags bugs, security issues, performance problems, missing error handling, and missing tests, not personal style nitpicks.
  • Posts a single summary comment on the pull request, plus inline comments on the specific lines with a problem, and updates that same comment on every push instead of piling up duplicates.
  • Requests changes automatically when a critical issue is found, so it can act as a real merge gate if you want one.
  • Works from the command line too, so you can review a diff before you even open the pull request.
  • Exports findings as SARIF for the GitHub Security tab, or as plain JSON for your own tooling.
  • Caches results per diff chunk so re-running a workflow does not spend API quota reviewing the same lines twice.

Quickstart: GitHub Actions

Add this workflow at .github/workflows/pr-sentinel.yml:

name: PR Sentinel

on:
  pull_request:

permissions:
  contents: read
  pull-requests: write

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: Lethe044/prsentinel@v1
        with:
          provider: groq
          api-key: ${{ secrets.GROQ_API_KEY }}

Get a free Groq API key at console.groq.com/keys, add it as a repository secret named GROQ_API_KEY, and every new pull request gets reviewed automatically.

Quickstart: command line

pip install prsentinel-cli

export GROQ_API_KEY=your-key-here
prsentinel review --base origin/main --head HEAD

This prints a table of findings straight to your terminal, before you even push. Combine it with a pre-push git hook if you want a check before code leaves your machine at all.

Choosing a provider

Provider Cost Setup
groq Free tier API key from console.groq.com/keys, set GROQ_API_KEY
gemini Free tier API key from aistudio.google.com/apikey, set GEMINI_API_KEY
ollama Free, fully local Run ollama serve and pull a model, no key needed
openai Paid, bring your own key Set OPENAI_API_KEY
anthropic Paid, bring your own key Set ANTHROPIC_API_KEY

Run prsentinel providers at any time to see this list along with the default model used for each one.

Configuration

Run prsentinel init to write a starter .prsentinel.yml in your repository root. Every field is optional and falls back to a sensible default if the file does not exist at all.

provider: groq
model:
severity_threshold: suggestion
fail_on: critical
max_files: 60
max_diff_lines_per_chunk: 350
ignore:
  - "*.lock"
  - "dist/**"
  - "node_modules/**"
  - "vendor/**"
custom_rules:
  - "Flag any hardcoded API keys or secrets"
  - "Require a docstring on every public function"
post_summary_comment: true
inline_comments: true
request_changes_on_critical: true
cache_enabled: true

custom_rules is where PR Sentinel becomes specific to your project. Add plain English instructions and they get appended to every review prompt, alongside the general review.

fail_on controls the exit code (and therefore whether your CI check goes red). Set it to warning for a stricter gate, or suggestion for the strictest possible one.

Command line reference

prsentinel review          Review a diff and report findings
prsentinel init            Write a starter .prsentinel.yml
prsentinel providers       List providers and setup instructions
prsentinel clear-cache     Delete the local review cache

Useful flags on review:

--base, --head        Git refs to diff (defaults to origin/main...HEAD)
--diff-file           Review a saved unified diff file instead of running git
--provider, --model   Override the provider or model from config
--output              terminal (default), json, or sarif
--output-file         Write json/sarif output to a file
--post-to-github      Post results as a review on the current GitHub Actions PR
--fail-on             Override the fail_on threshold for this run
--no-cache            Skip the local response cache for this run

How review comments look

PR Sentinel posts one summary comment with a small table of counts by severity, followed by a breakdown per file, and inline comments on the exact lines a finding refers to. If a critical issue is found and request_changes_on_critical is enabled, the review is submitted as "Request changes" instead of a plain comment, so it behaves like a real review a teammate would leave.

Limitations, on purpose

PR Sentinel reviews diffs, not your entire codebase, and it does not replace a human reviewer. Language models make mistakes, including missing real issues and occasionally flagging something that is not actually a problem. Treat its output the way you would treat a review from a thorough but fallible colleague: worth reading, not worth merging blindly on faith either way. custom_rules and the severity_threshold and fail_on settings let you tune how much weight to give it in your workflow.

Contributing

Bug reports, feature requests, and pull requests are welcome. See CONTRIBUTING.md for how to get set up locally, how the provider interface works, and what a good pull request looks like here.

License

MIT. See LICENSE.

Download files

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

Source Distribution

prsentinel_cli-1.0.0.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

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

prsentinel_cli-1.0.0-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file prsentinel_cli-1.0.0.tar.gz.

File metadata

  • Download URL: prsentinel_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for prsentinel_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d59b22790d4e8810e7b1dab5ab97462d79e0c0147b7450246023616de37c82fd
MD5 c30d3ec9ac2a11b0c8e1547c97b60d56
BLAKE2b-256 9b9eba27c8773e748147e85b6811c30e3e9b7f09d4ce30c11e2b44f36d7701ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for prsentinel_cli-1.0.0.tar.gz:

Publisher: publish.yml on Lethe044/prsentinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prsentinel_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: prsentinel_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for prsentinel_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 373eedf5b9cea3c2b32f018946340070f7233e5aa83577fb520678810a68b316
MD5 391922b06c19fbf73c89ae337ce37954
BLAKE2b-256 27643816d13b9954c5fc38eb52e5eb98fac1abb9cd8740c955966dfe214268fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for prsentinel_cli-1.0.0-py3-none-any.whl:

Publisher: publish.yml on Lethe044/prsentinel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.1.0

2 files

This release

1.0.0 This release

2 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