The Problem

Reviewing a pull request means reconstructing the system's architecture and data flow from a diff by hand. PR Lens removes that step: it draws the change as animated architecture and data-flow diagrams and posts them as a comment inside the PR, so a reviewer sees the blast radius before reading a line.

What This Does

PR Lens is a pnpm monorepo with five packages. packages/cli analyzes a PR (git, workspace, LLM providers), packages/renderer turns the change into SVG diagrams, packages/schema defines and validates the graph/patch/manifest formats, packages/action is the GitHub Action wrapper, and packages/agent-skill exposes it as a coding-agent skill (SKILL.md).

The renderer produces architecture diagrams (blast radius) and animated data-flow sequences, with <details>-nested scoped views. It ships as a GitHub App, Action, CLI, or agent skill. 50 test files and golden SVG snapshots live under packages/renderer/test/__goldens__.

How It Is Wired

Execution starts at packages/cli/src/cli.ts, which dispatches to commands (analyze.ts, comment.ts, canvas.ts, render.ts, validate.ts, export.ts). Analysis reads the repo through git.ts and workspace.ts, then sends the diff to an LLM provider — providers/gemini.ts, providers/openai.ts, or providers/http.ts — which returns a structured graph. schema/src/graph.ts validates it (12 modules depend on it), renderer/src/index.ts (Ca 8) drives layout (layout/edges.ts, layout/architecture.ts, layout/dataflow.ts) and SVG emission (svg/architecture.ts, svg/dataflow.ts), and comment.ts posts the result to GitHub.

Three modules carry the widest blast radius: cli/src/errors.ts (19 importers), cli/src/terminal.ts (13), and schema/src/graph.ts (12) — all stable hubs, so churn there ripples widely. The providers form an import cycle (providers/index.ts ↔ gemini.ts ↔ openai.ts), making them harder to change in isolation. renderer/src/svg/architecture.ts imports 14 modules (instability 0.88), the least stable node.

How To Use It

Setup: pnpm install then pnpm build (root package.json; pnpm per .npmrc).

Run the CLI via the @coldtea/pr-lens-cli binary — npx @coldtea/pr-lens-cli — with a subcommand such as render or comment; the entry point is packages/cli/src/bin.ts. Configuration lives in pr-lens.config.json (schema at packages/schema/json-schema/config.schema.json); provider keys are handled per provider module. The GitHub App route needs no API key or workflow file. Exact command flags aren't documented in the analyzed files — the README points to the npm page rather than spelling out invocations.

Real-World Use

A team installs the GitHub App on a monorepo. Every push to a PR triggers a redraw: the bot comment shows the architecture blast radius (green new / amber changed / red gone), then an animated data-flow sequence of the changed path, then nested <details> views scoped to the new and retired paths. Reviewers scan the diagram before opening the diff.

Code Health & Issues

Static analysis (18 findings: 5 high, 13 medium) reports:

  • High — import cycle — cli/src/providers/index.ts, gemini.ts, openai.ts
  • High — deep nesting (depth 9) — cli/src/commands/canvas.ts, comment.ts
  • High — duplicated code: 30 repeated 6-line blocks across 12 files, notably renderer/src/svg/architecture.ts and svg/dataflow.ts
  • Medium — hub modules — cli/src/errors.ts, terminal.ts, schema/src/graph.ts
  • Medium — oversized files — renderer/src/layout/edges.ts (842 lines), docs/showcase/frame.ts, cli/test/canvas.test.ts
  • Medium — high branching density — cli/src/git.ts, workspace.ts, layout/edges.ts

SDLC gaps: no CI workflow exists, so nothing builds or tests on push; no Dependabot/Renovate across 6 manifests; @types/node pinned at ^20.19.0, six majors behind current. Tests, LICENSE, and lockfile are present; no committed secrets.

The Bottom Line

The package split is clean and the golden-SVG test suite is a strong asset. The main risks are the provider import cycle, the 842-line edges.ts, and the absence of any CI gate. Teams reviewing large PRs will get immediate value; the codebase needs a build pipeline before it's safe to extend.