SKILL.md
SKILL.mdBrowse 5 files
2,498 tokens
9,726 bytes
Token encoding: o200k_base
Snapshot 24fd22b
1---2name: pr-lens3description: "Draw code changes as animated architecture/data-flow SVGs."4version: 1.0.05author: Coldtea AI (adapted by Nous Research)6license: MIT7platforms: [linux, macos]8metadata:9 hermes:10 tags: [diagrams, pull-requests, code-review, svg]11 category: software-development12 related_skills: []13 upstream: https://github.com/coldteadotai/pr-lens (pinned 0993b4d)14---15 16# PR Lens Skill17 18PR Lens draws code as visually rich animated diagrams: diffs, architecture, data flows. You describe the diff or codebase as one JSON document (lanes, nodes, edges, ordered flows) and the CLI renders it as animated SVGs. There is no findings lens — PR Lens is a comprehension layer, not a review bot. There is no field for a bug, risk, or security note, and a document that invents one is rejected.19 20## When to Use21 22- Asked to diagram, visualise, or explain a code change or a system.23- A pull request should carry an architecture or data-flow diagram.24- Keywords: PR Lens, diagram, architecture, data flow, visualise, pull request.25 26## Prerequisites27 28- Node.js with `npx` (the CLI runs via `npx @coldtea/pr-lens-cli@latest`; no install step).29- `gh` (GitHub CLI) — optional, only for attaching diagrams to PRs.30- Optional canvas publishing calls the third-party service prlens.dev (see step 4b).31 32## How to Run33 34Run all commands with the terminal tool from the repository root.35 361. **Read the diff.** When representing a code change: `git diff --find-renames <base>...<head>`. The base is the merge base, not the tip of the base branch. If not expressing a diff, read the code to be visualised.37 382. **Write the document** to `.pr-lens/graph.json`, following `references/graph-document.md`. `references/example.graph.json` is a valid reference with three lanes, all four delta states, a hero edge, a seven-step flow, a nested drill-down tree and a six-step walkthrough. Read it before writing your first document — quicker than reading the reference.39 403. **Validate, and fix.**41 42 ```bash43 npx @coldtea/pr-lens-cli@latest validate .pr-lens/graph.json44 ```45 46 Fix every failure and run it again. Do not render an invalid document; do not "work around" a failure by deleting the element it names.47 484. **Render.**49 50 ```bash51 npx @coldtea/pr-lens-cli@latest render .pr-lens/graph.json --theme light52 ```53 54 Render light by default unless the user requests another theme. The SVGs, the manifest and `drawn.graph.json` land in `.pr-lens/`, which the CLI adds to the repository's .gitignore. Do not commit any of it — these files are rebuilt from the diff on demand. Each SVG is named after its view, theme and content hash; `manifest.json` lists them by lens and view.55 564b. **Canvas push — OPTIONAL, opt-in.** Only when the user explicitly asks for a shareable link. This publishes `.pr-lens/drawn.graph.json` to the third-party service prlens.dev:57 58 ```bash59 npx @coldtea/pr-lens-cli@latest canvas push60 ```61 62 It prints three links. Give the user the **view link** (`https://prlens.dev/c/{id}`): the full-screen diagram, every view on one page, no login. The **edit link** (ending in `#w=…`) lets its holder overwrite the canvas — it is a secret: leave it out of the reply unless asked, never paste it anywhere public. The embed link serves the top view as an SVG for a README. Pushing the same file again updates the same canvas, so "rename that node" is: edit, validate, render, push — the link stays the same. If the push fails, say so and tell the user where the local SVGs are and which is the top view.63 645. **Attach to a PR, when there is one.** Upstream documents `gh pr create/edit/comment --attach <path>`, but `--attach` arrived in GitHub CLI 2.99 — check `gh --version` first (e.g. gh 2.97 does NOT have it). With gh ≥ 2.99: write the body with a Markdown image `` (an HTML `<img>` is left as written and the file appended at the bottom instead; alt text is the one-line caption a reader without images gets), then repeat `--attach <path>` per referenced diagram:65 66 ```bash67 gh pr create --title "…" --body-file .pr-lens/body.md --attach .pr-lens/overview-light-<hash>.svg68 ```69 70 Without `--attach`, use a commit-free path:71 - Upload the SVGs to a gist: `gh gist create .pr-lens/<view>.svg`, then reference the raw gist URL in the PR body/comment, or72 - Publish via the canvas link (step 4b, with user consent) and link the view URL, or73 - Note the local `.pr-lens/` path in the PR body so reviewers can rebuild.74 75 Once published somewhere durable, let the CLI compose the comment markdown:76 77 ```bash78 npx @coldtea/pr-lens-cli@latest comment \79 --graph .pr-lens/drawn.graph.json \80 --manifest .pr-lens/manifest.json \81 --asset-base-url <where you published the SVGs>82 ```83 84 `--graph` takes `drawn.graph.json`, not the document you wrote — the CLI refuses a document its manifest does not describe. Leave out `--asset-base-url` and the markdown points at local paths no reader can fetch. The markdown goes to stdout; posting it is your business.85 86 Attach the views a reviewer needs and leave the rest in `.pr-lens/`: the top architecture view first, then a data flow if the change has a sequence worth following. Two diagrams usually beat four.87 886. **Optional automation:** `npx @coldtea/pr-lens-cli@latest analyze --base <ref>` does steps 1–2 by asking a provider (Gemini, OpenAI, or any `/chat/completions` endpoint) with a key of your own. That is the only path here that needs one; normally you author the document yourself.89 90## What makes a document worth reading91 92- **Include what did not change.** Unchanged neighbours a change touches are the context; mark them `delta: "unchanged"`.93- **Lanes are the reader's mental model** (a runtime, a tier, a boundary), not the folder tree.94- **One hero edge**, two at the outside: the connection the change is really about.95- **Add a flow only when there is a sequence** worth animating. One good flow beats three thin ones.96- **Attach file refs**: they become the permalinks a reviewer clicks.97- Architecture views are a C4-inspired decision tree: system context → container → component, each child materially narrower. Skip empty or repetitive levels; keep data-flow views as separate roots; set `defaultOpen: true` on the highest useful architecture view.98- **Walkthroughs** (2–12 steps, aim 3–7): write one for anything non-trivial. Each step = one change (added/removed/moved), headline change first, overview last. Headings ≤48 chars built from change words; bodies ≤140 chars on behaviour, required. Write for a smart twelve-year-old; no "leverages"/"orchestrates". Keep consecutive steps on the same stage. The walkthrough field needs CLI ≥ 0.4.0 (contract 0.1.1).99- **Fixing a wrong map:** never edit the generated document — write corrections into `.github/pr-lens.yml` (see `references/config.md`), then validate it: `npx @coldtea/pr-lens-cli@latest validate .github/pr-lens.yml`. Prefer path globs over `id:` matches.100 101## Quick Reference102 103| Command | Purpose |104| --- | --- |105| `npx @coldtea/pr-lens-cli@latest validate .pr-lens/graph.json` | validate the document (also validates `.github/pr-lens.yml`) |106| `npx @coldtea/pr-lens-cli@latest render .pr-lens/graph.json --theme light` | render SVGs + manifest into `.pr-lens/` |107| `npx @coldtea/pr-lens-cli@latest canvas push` | OPTIONAL: publish to prlens.dev (opt-in only) |108| `npx @coldtea/pr-lens-cli@latest comment --graph … --manifest … --asset-base-url …` | compose PR comment markdown to stdout |109| `npx @coldtea/pr-lens-cli@latest analyze --base <ref>` | auto-author document via an LLM provider (needs API key) |110 111Validator failure codes:112 113| Code | What you did |114| --- | --- |115| `BROKEN_REFERENCE` | an edge, flow step, view or walkthrough step names an id you never declared |116| `INVALID_DOCUMENT` | an invented field; the schemas are strict, unknown keys are rejected |117| `DUPLICATE_ID` | two nodes, edges or views sharing an id |118| `UNSUPPORTED_SCHEMA_VERSION` | `schemaVersion` is not the contract version installed |119 120## Pitfalls121 122- Six rules are parser-only, not in the JSON Schema (referential integrity, inverted line ranges, disagreeing `self` endpoints, identical patch commits, too many views for a manifest, flow-step focus on the wrong stage) — always run `validate`, structured output alone is not enough.123- Do not commit anything in `.pr-lens/`; it is regenerated and gitignored by the CLI.124- The `--attach` gh flag needs gh ≥ 2.99; older gh silently lacks it — check before writing a body around it.125- The canvas edit link (`#w=…`) is a write credential — never share it unprompted or paste it publicly.126- A stored map never carries a walkthrough; a walkthrough tells the story of one change.127- `pr-lens render` reports corrections in `.github/pr-lens.yml` that matched nothing — that is drift worth fixing, not an error.128 129## Verification130 131Smoke test (live-verified 2026-09-12 with `@coldtea/pr-lens-cli` via npx, node on Linux):132 133```bash134cp references/example.graph.json /tmp/prlens-smoke/ && cd /tmp/prlens-smoke135npx -y @coldtea/pr-lens-cli@latest validate example.graph.json136# ✓ example.graph.json — graph document · 3 lanes, 10 nodes, 13 edges, 1 flow · 6 walkthrough steps137npx -y @coldtea/pr-lens-cli@latest render example.graph.json --theme light138# ✓ .pr-lens/manifest.json — 4 SVGs across 4 diagrams139```140 141Expect exit 0 on both and four `*-light-<hash>.svg` files plus `manifest.json` and `drawn.graph.json` in `.pr-lens/`.142 143---144 145Adapted from [coldteadotai/pr-lens](https://github.com/coldteadotai/pr-lens) (packages/agent-skill, pinned 0993b4d), MIT License, Copyright (c) 2026 Coldtea AI. See LICENSE.txt.146 Discovery context
Discovered by repository scan. No exact path reference found in the snapshot’s root AGENTS.md.