pr-lens
它能做什么
这项技能把代码改动或代码库转换为可视化图表,展示各部分如何连接以及数据如何流动。适合想向他人解释拉取请求或系统的开发者。
适用场景
- ✓你想要一张解释某个代码改动作用的图表的时候。
- ✓你想为拉取请求提供系统的架构图或数据流图的时候。
- ✓你要求 AI 将代码库的结构可视化或加以解释的时候。
技能链接
https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/software-development/pr-lens/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为这个拉取请求制作一张架构图,让审阅者能看到数据是如何流动的。”
每周 5 个新技能,1 分钟读完。
工作原理
这项技能让你的 AI 编写一份描述泳道、节点和连线的 JSON,然后运行 PR Lens 命令行工具,渲染出动态 SVG 图表。它不会查找错误。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
PR Lens Skill
PR 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.
When to Use
- Asked to diagram, visualise, or explain a code change or a system.
- A pull request should carry an architecture or data-flow diagram.
- Keywords: PR Lens, diagram, architecture, data flow, visualise, pull request.
Prerequisites
- Node.js with
npx(the CLI runs vianpx @coldtea/pr-lens-cli@latest; no install step). gh(GitHub CLI) — optional, only for attaching diagrams to PRs.- Optional canvas publishing calls the third-party service prlens.dev (see step 4b).
How to Run
Run all commands with the terminal tool from the repository root.
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.Write the document to
.pr-lens/graph.json, followingreferences/graph-document.md.references/example.graph.jsonis 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.Validate, and fix.
npx @coldtea/pr-lens-cli@latest validate .pr-lens/graph.jsonFix every failure and run it again. Do not render an invalid document; do not "work around" a failure by deleting the element it names.
Render.
npx @coldtea/pr-lens-cli@latest render .pr-lens/graph.json --theme lightRender light by default unless the user requests another theme. The SVGs, the manifest and
drawn.graph.jsonland 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.jsonlists them by lens and view.
4b. 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:
npx @coldtea/pr-lens-cli@latest canvas push
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.
Attach to a PR, when there is one. Upstream documents
gh pr create/edit/comment --attach <path>, but--attacharrived in GitHub CLI 2.99 — checkgh --versionfirst (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:gh pr create --title "…" --body-file .pr-lens/body.md --attach .pr-lens/overview-light-<hash>.svgWithout
--attach, use a commit-free path:- Upload the SVGs to a gist:
gh gist create .pr-lens/<view>.svg, then reference the raw gist URL in the PR body/comment, or - Publish via the canvas link (step 4b, with user consent) and link the view URL, or
- Note the local
.pr-lens/path in the PR body so reviewers can rebuild.
Once published somewhere durable, let the CLI compose the comment markdown:
npx @coldtea/pr-lens-cli@latest comment \ --graph .pr-lens/drawn.graph.json \ --manifest .pr-lens/manifest.json \ --asset-base-url <where you published the SVGs>--graphtakesdrawn.graph.json, not the document you wrote — the CLI refuses a document its manifest does not descr- Upload the SVGs to a gist:
常见问题
它能发现错误或安全问题吗?
不能。技能说明 PR Lens 是一个理解工具,没有用于记录错误或风险的字段。
需要安装吗?
技能通过 npx 运行该工具,因此没有单独的安装步骤,但需要 Node.js。
图表可以放到拉取请求上吗?
可以。技能说明 GitHub CLI 可以把图表附加到拉取请求上,不过这一步是可选的。
详情
热度
- GitHub 星标
- 260k
- 排名
- #573
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
agent-merge-conflict-arbiter
260k以中立第三方的身份,解决两个智能体分支之间的 git 合并冲突,为代码仓库生成一个合并结果。
antigravity-cli
260k指导你安装、更新和排查 Antigravity 命令行工具,包括其插件、登录和沙盒。
blackbox
260k让你的智能体把编程任务交给 Blackbox AI 命令行工具,它会运行多个 AI 模型并挑选最佳结果。
dynamic-workflow
260k教你的智能体把大量相似的工作保存为脚本批量运行,使只有经过验证的结果才返回主对话。