Skip to main content

AI-powered GitHub PR code reviewer for teams

Project description

lens

AI-powered GitHub PR code reviewer for teams. Fetches a pull request, reviews each changed file against your coding guidelines using Claude or GPT-4o, and posts inline comments directly on GitHub.

Features

  • Reviews only added/modified files — skips deleted files and binary assets
  • Supports Anthropic Claude and OpenAI GPT-4o as AI backends
  • Bring your own guidelines via a simple YAML config file
  • Posts inline review comments on the diff using the GitHub Review API
  • Runs as a CLI tool locally or as a GitHub Action automatically on every PR
  • Prevents duplicate comments across repeated runs
  • Filters known AI false positives (hallucinated suggestions)

Installation

pip install prlens

Quick Start (CLI)

export GITHUB_TOKEN=ghp_...
export ANTHROPIC_API_KEY=sk-ant-...

prlens --repo owner/repo --pr 42 --model anthropic

Omit --pr to list open PRs and pick one interactively.

GitHub Action

Add this workflow to your repository to automatically review every pull request:

# .github/workflows/code-review.yml
name: Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: jodohq/prlens/.github/actions/review@main
        with:
          model: anthropic
          github-token: ${{ secrets.GITHUB_TOKEN }}
          anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}

Configuration

Copy .prlens.example.yml to .prlens.yml in your repository root:

# .prlens.yml
model: anthropic          # anthropic | openai
max_chars_per_file: 20000
batch_limit: 60

# Path to your team's coding guidelines (relative to repo root)
# guidelines: ./docs/guidelines.md

# Files/directories to skip — fnmatch globs or directory names
# exclude:
#   - migrations/
#   - "*.min.js"

# Set to true to review draft PRs (skipped by default)
review_draft_prs: false

The --model and --guidelines CLI flags override the config file. The config file overrides built-in defaults.

Custom Guidelines

Point guidelines in .prlens.yml to any Markdown file containing your team's coding standards:

guidelines: ./docs/guidelines.md

When not set, built-in generic guidelines are used as a starting point. Copy them from prlens/guidelines/ and customize.

Environment Variables

Variable Required Description
GITHUB_TOKEN Yes GitHub personal access token with pull_requests: write
ANTHROPIC_API_KEY When using Claude Anthropic API key
OPENAI_API_KEY When using GPT-4o OpenAI API key

CLI Reference

Usage: prlens [OPTIONS]

  AI-powered GitHub PR code reviewer.

Options:
  --repo TEXT                GitHub repository in owner/name format. [required]
  --pr INTEGER               Pull request number. Omit to list open PRs interactively.
  --model [anthropic|openai] AI model provider. Overrides config file.
  --config TEXT              Path to the configuration file. [default: .prlens.yml]
  -y, --yes                  Skip confirmation prompts and post comments automatically.
  --guidelines PATH          Path to a Markdown guidelines file. Overrides config file.
  -s, --shadow               Dry-run mode: print review comments to the terminal without posting to GitHub.
  --help                     Show this message and exit.

Contributing

See CONTRIBUTING.md for how to set up a development environment, run tests, and add new AI providers.

License

MIT

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

prlens-0.1.1.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

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

prlens-0.1.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prlens-0.1.1.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for prlens-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1c1069b6f2f5e48656045ec68265ff7aa2cc32395b34e543a29880fffed697d8
MD5 f8f1bdf636bc67e154a863adc47ad4e9
BLAKE2b-256 1ffd1fe6c46d4b211b21bdc945de793509c62fc0c41e286d21b23efe22fd0193

See more details on using hashes here.

File details

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

File metadata

  • Download URL: prlens-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for prlens-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 30814c1fec6bf57801de1344a92c1cd514a150a4280afa0e88b6888ef4bc19cb
MD5 1de9e6d196ef880f2d4c44d8d003d243
BLAKE2b-256 155c23007ba3d8230b1214dbdceafc37ca7df0e29696ed8cd25ba034768db0e8

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