Understand a pull request before you approve it. More and more pull requests are vibe-coded: written by a teammate
with an AI assistant, or opened by a coding agent on its own. They can be large and hard to follow, and the description
may not match what the code does. prlense lets a human step back in: it checks the work against the code itself and
explains the reason behind the change, so you can tell whether it makes sense instead of scrolling through thousands of
lines of diff. It works with any model that can call tools.
Each report is one HTML page in six steps: why the change was made, what changed, which data models and contracts changed, which functions changed, the detailed changes with links into the PR, and notes for the reviewer. It explains. It does not review, judge, or comment on other reviewers.
-
Make sure you have git, Node 22 or newer, the GitHub CLI logged in (
gh auth status), and a model to run: Claude Code logged in (claude auth status) works with no setup, or point prlense at any other model (see Engines). -
Install
prlense:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/anvk/prlense/main/tools/install.sh)"- Inside a checkout of the repo the PR belongs to:
prlense doctor
prlense explain https://github.com/acme/shop/pull/482A typical run takes a few minutes, and prints the turns and time it took at the end.
You need git, Node 22 or newer, the GitHub CLI logged in (gh auth status), and a model: Claude Code logged in, or an
API key (or a local server) for any engine in Engines. With curl:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/anvk/prlense/main/tools/install.sh)"
prlense doctoror with wget:
sh -c "$(wget -qO- https://raw.githubusercontent.com/anvk/prlense/main/tools/install.sh)"This clones the repository into ~/.prlense-cli, builds it, and links the prlense command globally. Set
PRLENSE_HOME before running it to install somewhere else.
Updates are automatic. A run takes minutes anyway, so before each one prlense asks GitHub where main is. That
takes under a second when you are current, and about twenty when it has to update, after which it re-runs your command
on the new code. Every report is therefore generated by the newest version. A build that fails is rolled back, and that
commit is skipped until main moves on. Only the managed install is touched, never a checkout you have npm linked.
prlense update |
Update now |
prlense update --check |
Report whether an update is waiting (exits non-zero when behind) |
PRLENSE_NO_AUTO_UPDATE=1 |
Turn self-update off |
render, doctor, clean and update, and explain on a report file, never update on their own, so opening a
report works offline. prlense --version prints the commit date and short sha, e.g. 2026-09-30 (a1b2c3d), and every
report records it.
Uninstall: npm rm -g prlense && rm -rf ~/.prlense-cli. Reports stay in ~/.prlense until you remove it too.
Inside a checkout of the repo the PR belongs to:
prlense explain https://github.com/acme/shop/pull/482 # or 482, or #482prlense explain <target> a PR number or URL; or a report JSON path or link, which is opened (default command)
-C, --repo <path> local checkout of the target repo (default: current directory)
--remote <name> which git remote owns the PR
--context <glob...> extra repo docs to hand the model, on top of the AGENTS.md and CLAUDE.md files
--with-rules also load agent rule files (.claude/rules, .cursor/rules) near the changed files
--skip <glob...> treat these paths as generated too
--out <dir> reports directory (default ~/.prlense/reports)
--no-open write the report without opening a browser
--engine <name> engine preset from ~/.prlense/config.json, or claude-cli (default: the config's engine)
--model <id> model id for the engine, overriding the config
--keep-worktree leave the temporary worktree in place
--timestamp keep every run instead of overwriting pr-<n>.html
--yes run even when the PR has more than 300 traceable files
--verbose print one line per tool call while the model works
prlense render <report.json> re-render the HTML from a saved JSON, no model run
prlense clean remove worktrees and refs left by interrupted runs
prlense doctor check git, gh, the repo, the config file and the engine login
Reports land in ~/.prlense/reports/<owner>-<repo>/pr-<n>.html and pr-<n>.json, with a
pr-<n>.transcript.jsonl of the raw model events for debugging.
GitHub Enterprise works the same way: a PR URL on your company's host, and a checkout whose remote points there.
A bare PR number is ambiguous in a checkout with more than one GitHub remote: pass the PR URL (its owner/repo picks
the remote) or --remote <name>. If the URL's repo matches none of the remotes, prlense stops rather than guess.
- Reads the PR with
ghand fetches its head into a temporary git worktree. Your working tree is never touched. - Lists the changed files, marking generated files and tests so the model does not trace them.
- Collects the repo's own instructions: the AGENTS.md and CLAUDE.md files above the changed code, plus anything from
--context. - Runs the model in the worktree with read-only tools and a fixed prompt, asking for JSON matching a schema. The prompt, the schema and the page are the same whichever engine and model run it.
- Validates the JSON, adds GitHub links, and writes one self-contained HTML page with the JSON next to it.
Every claim is meant to come from something the model read or ran. What it could not confirm carries an unverified badge saying what would confirm it, and the PR body is treated as a claim to check against the code.
- Why: the problem and what the change does about it, in plain language, plus ticket references.
- What changed: a one-line lead, then one section per area the PR touches (architecture, backend, UI, tools, models, other).
- Model changes: storage, domain types, contracts and config, with field-by-field shapes. The ones a reviewer must not miss are flagged. "No data model changes." is a valid answer.
- Functions changed: handlers, services, components and hooks, grouped by top-level folder, one line each, linked to the diff and to the detailed change.
- Detailed changes: before and after in behaviour terms, files with line numbers, callers found by searching, and tests that show intent.
- Review notes: risks as facts with consequences (in the code and at deploy), questions the code does not answer, and a glossary. Every change flagged in step 3 appears among the risks.
The footer lists what was traced, what was skipped as generated or test code, what could not be traced, and which context files the model was given.
Lenses. The picker under the title filters the page by audience. Product stops after the overview and keeps the
glossary; Backend and Frontend show the code walk for their side, decided by path (ui/**, web/**, frontend/**,
client/**, apps/web/** by default; see frontendMatch below). The choice is remembered in your browser.
Every page carries the report it was made from and can open any other: Download JSON saves it, and Load JSON,
or dropping a .json file on the page, shows another one. The person opening it does not need prlense installed. The
renderer is inlined into the page (about 17 KB), which keeps a report one file with no network access.
prlense explain <file.json> opens a report from disk, and prlense explain <url> fetches one (through your gh
login for GitHub links) and saves it next to your own.
A page or a prlense install reads only its own report format. A report from an older version has to be generated
again; one from a newer version needs prlense update. Both say so when you try to open them.
There is no per-repo config. Anything that varies by run is a flag (--context, --with-rules, --skip, above).
--skip adds to the built-in generated-file list: *_gen.go, *.pb.go, *.generated.*, openapi.yaml, vendor/,
minified files, snapshots and lockfiles (npm, yarn, pnpm, Go, Cargo, Poetry, Bundler, Composer). Test files are found by
name and folder for Go, JavaScript and TypeScript, Python, Ruby and Java (*_test.go, *.test.*, *.spec.*,
test_*.py, *_spec.rb, tests/, spec/, src/test/ and similar). Rule files are off by default because they are
mostly about writing code and add tokens on every turn.
Per-person defaults go in the optional ~/.prlense/config.json: which engine to use, and named presets to switch
between with --engine. Keys never go in this file, only the name of the environment variable that holds one:
{
"reportsDir": "~/.prlense/reports",
"contextMaxBytes": 150000,
"frontendMatch": ["ui/**", "web/**", "frontend/**", "client/**"],
"generatedMatch": ["**/*.gen.ts"],
"testMatch": ["**/qa/**"],
"engine": { "kind": "openai-compat", "baseUrl": "https://api.openai.com/v1", "model": "gpt-4.1", "apiKeyEnv": "OPENAI_API_KEY" },
"engines": {
"local": { "kind": "openai-compat", "baseUrl": "http://localhost:11434/v1", "model": "qwen2.5-coder:32b" },
"claude": { "kind": "claude-cli", "model": "claude-opus-5-5", "effort": "high" }
}
}With this file, prlense explain 482 uses OpenAI, --engine local a local Ollama model, and --engine claude Claude
Code. --model swaps the model for one run. Without the file, prlense uses Claude Code. contextMaxBytes caps the repo
documentation handed to the model. generatedMatch and testMatch add your own patterns to the built-in generated
and test lists.
An engine is how prlense runs a model. The prompt, the report schema and the page never change with it, so any model
that can call tools can explain a PR. Check a setup with prlense doctor --engine <name>.
- openai-compat works with any API that speaks OpenAI's chat completions format, which covers most providers and
local servers. The model asks for tools and prlense runs them itself, inside the worktree and read-only: read a file,
list files, search with
git grep, and run a command such asgit difforgh pr view. Paths cannot leave the worktree, and commands go through the same read-only list as below. The model's final answer is checked against the schema; when it does not fit, the problem is sent back and a corrected answer is asked for (twice at most).maxSteps(default 80) caps the tool rounds before the model has to answer. - claude-cli runs
claude -pin the worktree with your Claude Code login, so there is no API key. It allows only Read, Glob, Grep and Bash, switches off the repo's own settings and MCP servers, and asks for structured JSON. A hook denies any shell command not on a read-only list (git/ghreads,rg,grep,catand similar).
Either way, nothing is written to the repo or to GitHub.
Presets for common providers ("kind": "openai-compat"; put your key in the named environment variable):
| Provider | baseUrl |
apiKeyEnv |
|---|---|---|
| OpenAI | https://api.openai.com/v1 |
OPENAI_API_KEY |
| Anthropic API | https://api.anthropic.com/v1 |
ANTHROPIC_API_KEY |
| Google Gemini | https://generativelanguage.googleapis.com/v1beta/openai |
GEMINI_API_KEY |
| xAI Grok | https://api.x.ai/v1 |
XAI_API_KEY |
| OpenRouter (many models) | https://openrouter.ai/api/v1 |
OPENROUTER_API_KEY |
| Ollama (local) | http://localhost:11434/v1 |
none |
| LM Studio (local) | http://localhost:1234/v1 |
none |
Set "model" to a model id from that provider. Report quality follows the model: it needs reliable tool calling and a
long context, so small local models produce thinner reports than large hosted ones.
| Symptom | What to do |
|---|---|
gh is not logged in |
gh auth login |
Engine claude-cli is not ready: not logged in |
claude login |
environment variable … is not set |
export the key the engine's apiKeyEnv names, or pick another --engine |
… answered 401 / 404 |
check the preset's baseUrl, model and key with prlense doctor --engine <name> |
a bare PR number is ambiguous |
pass the PR URL or --remote <name> |
The PR belongs to X, but this checkout only has remotes for ... |
run inside a checkout of that repo, or pass -C |
Explain failed (schema_failed) |
the raw answer is saved as pr-<n>.raw.txt; rerun, or share the transcript |
it was made by an older prlense |
generate the report again with prlense explain |
| Leftover worktrees after Ctrl-C | prlense clean |
| Browser did not open | open the printed file:// path |
git clone https://github.com/anvk/prlense.git && cd prlense
npm install
npm test
npm run lint # ESLint
npm run format # Prettier; CI fails on unformatted code
npm run dev -- doctor
npm run dev -- explain https://github.com/acme/shop/pull/482 --verbose --keep-worktree
npm run dev -- render ~/.prlense/reports/acme-shop/pr-482.json # iterate on the page without a model run
npm run build && npm link # point the global `prlense` at this checkout
cd ~/.prlense-cli && npm link # point it back at the managed installThe source is grouped by job: cli/ (commands and output), github/ (the PR, remotes, worktrees and diff),
context/ (repo docs for the model), engine/ (how the model runs), prompt/, report/ (schema and validation),
render/ (the HTML page), update/ (self-update) and core/ (config and helpers).