explain-pr

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Explain a PR

解释一个 PR

Deliver a portable HTML bundle that lets the reader explain the changed behavior and locate the decisions that produce it. Organize by journeys, weighted by significance rather than line count. A 1,000-line threshold is a useful signal, not a prerequisite.
交付一个可移植的 HTML 包,使读者能够解释变更后的行为,并定位产生这些行为的关键决策。按用户旅程组织,并根据重要性而非代码行数分配篇幅。1,000 行阈值是一个有用信号,但不是前提条件。

1. Establish the reader and evidence

1. 确定读者与证据

Always load and apply
simple-language
, including its final self-check. Resolve it from the available skills or the sibling skill; if unavailable, ask for its location before drafting.
Identify the reader, their question, the PR, and its base and head commits. Default to an engineer familiar with the product but unfamiliar with this change. Read the linked issue/specification, PR description, complete changed-file inventory, and diff. Inventory screenshots embedded in the PR description, including their surrounding text and intended before/after or journey context. Match local sources to the recorded commits; distinguish the diff baseline from the target branch tip.
Finish when the comparison is reproducible and the original user need is either sourced or explicitly unknown. Separate documented intent, observed implementation, and inference throughout the guide. If evidence is inaccessible or truncated, state the missing coverage and produce only a clearly labeled partial explanation.
始终加载并应用
simple-language
,包括其最终自检。从可用 skills 或同级 skill中解析该 skill;如果不可用,起草前先询问其位置。
确定读者、他们的问题、PR 及其 base commit 和 head commit。默认读者是熟悉产品但不了解本次变更的工程师。阅读关联的 issue/specification、PR 描述、完整的变更文件清单和 diff。盘点 PR 描述中嵌入的所有截图,包括其周边文本以及预期的前后对比或旅程上下文。将本地源码与记录的 commit 进行匹配;区分 diff 基线和目标分支的最新提交。
当对比可复现,且原始用户需求已有来源或被明确标记为未知时,本阶段完成。始终在指南中区分已记录的意图、观察到的实现和推断。如果证据无法访问或已被截断,请说明缺失的覆盖范围,并且只生成明确标注为部分内容的说明。

2. Reconstruct the journeys

2. 重建用户旅程

Choose a concrete user scenario for each materially distinct behavior. Trace its entrypoint, decisions, data transformations, side effects, and visible outcome through the changed code. Inspect unchanged callers and dependencies where needed to verify connections. For migrations, build tooling, or configuration, trace the lifecycle trigger and affected behavior instead of forcing a request-shaped story.
Follow consequential branches: authorization, validation, failure, retries, and asynchronous handoffs. For queues or events, identify producer, payload, consumer, and completion or failure signal; draw a handoff rather than a synchronous call.
Account for every changed file in a compact working map: a journey, a cross-cutting change, supporting tests, mechanical/generated changes, or unresolved evidence. Group repetitive changes. Finish when all files are accounted for and every narrated connection has source evidence; explicitly retain unresolved edges as uncertainty.
为每种实质不同的行为选择一个具体的用户场景。沿变更代码追踪其入口点、决策、数据转换、副作用和可见结果。必要时检查未变更的调用方和依赖项,以验证这些关联。对于迁移、构建工具或配置,应追踪生命周期触发条件及其影响的行为,而不是强行套用请求式的叙事。
追踪影响重大的分支:授权、验证、失败、重试和异步交接。对于队列或事件,应确定生产者、payload、消费者以及完成或失败信号;绘制交接关系,而不是绘制同步调用。
使用紧凑的工作映射涵盖每个变更文件:将其归入某条用户旅程、横向变更、配套测试、机械性或生成内容变更,或者尚未查明的证据缺口。对重复性变更进行归组。当所有文件均已被纳入说明,且每条叙述中的关联都有来源证据时,本阶段完成;明确保留尚未厘清的关联,将其作为不确定性呈现。

3. Write the explanation

3. 编写说明

Lead with the user's need and a concrete before/after example. Then explain the main journey, followed by independent journeys and cross-cutting changes that affect them.
At each meaningful step, explain the actor's responsibility, what changed, and the consequence. Mark existing, changed, added, or removed behavior with words as well as visual styling. Use small code excerpts only where they clarify a decision. Anchor implementation claims to verified symbols and lines, preferably immutable repository links at the appropriate base/head commit; validate URL schemes and escape source text for HTML.
When the PR description contains screenshots, embed them in the explanation beside the state, comparison, or journey step they demonstrate. Preserve their documented ordering and meaning rather than collecting them into an unconnected gallery. Give each image useful alternative text and a caption that distinguishes what the screenshot visibly shows from what the surrounding PR text claims; link the caption to the original PR description when possible. Treat screenshots as supporting evidence, not proof of implementation. Account for every description screenshot, explicitly naming any image omitted because it is inaccessible, redundant, sensitive, or unrelated to the changed behavior.
Use Mermaid when it clarifies relationships: sequence diagrams for calls and handoffs, flowcharts for decisions. Keep one question per diagram and provide a short textual equivalent. Verify every arrow against the code. Explain decision rationale only when supported; label inferred reasons.
Close with relevant test evidence, remaining uncertainty, and a short reading route through the most informative source locations. Distinguish tests inspected, reported by CI, and run during this task. Treat explaining and reviewing as separate outcomes: report a discovered concern with evidence, without presenting the guide as approval to merge.
Finish when a reader can state the new behavior, follow its cause, and find the supporting code without reading the entire diff.
首先介绍用户需求和一个具体的前后对比示例。然后解释主要用户旅程,再介绍相互独立的旅程以及会影响这些旅程的横向变更。
在每个关键步骤,说明参与者的职责、发生的变化及其后果。同时通过文字和视觉样式标明既有、变更、新增或移除的行为。仅在有助于解释决策时使用简短的代码摘录。将实现相关论断关联到经过验证的符号和代码行,最好使用指向适当 base/head commit 的不可变仓库链接;验证 URL scheme,并对 HTML 中的源文本进行转义。
当 PR 描述包含截图时,将它们嵌入说明中,并放置在其所展示的状态、对比或用户旅程步骤旁。保留已记录的顺序和含义,而不是将截图集中成互不关联的图库。为每张图片提供实用的替代文本和说明文字,区分截图可见展示的内容与周边 PR 文本提出的主张;可能时,将说明文字链接到原始 PR 描述。将截图视为辅助证据,而不是实现层面的证明。交代 PR 描述中的每张截图,并明确指出因无法访问、重复、敏感或与变更行为无关而省略的任何图片。
在 Mermaid 有助于澄清关系时使用它:使用时序图表示调用和交接,使用流程图表示决策。每张图只回答一个问题,并提供等效的简短文本说明。对照代码验证每个箭头。仅在有证据支持时解释决策理由;将推断的原因明确标注为推断。
最后介绍相关测试证据、剩余不确定性和一条简短阅读路径,引导读者前往最有信息量的源码位置。区分已检查的测试、CI 报告的测试和本次任务中实际运行的测试。将解释与审查视为不同结果:报告发现的问题并提供证据,但不要将指南呈现为可以合并的批准。
当读者无需阅读完整 diff,就能说明新行为、追踪其原因并找到支撑代码时,本阶段完成。

4. Build and verify the bundle

4. 构建并验证资源包

Read and copy assets/pr-explanation.html into the bundle root as
index.html
. It is the presentation source of truth. Replace its illustrative content, adapt section count to actual journeys, update the document language/title, and synchronize navigation with section IDs. Keep CSS and narrative inline; keep the pinned CDN renderer, textual fallback, and accessible Mermaid source. Place source citations beside their claims.
Create one portable directory at the user's chosen output location, otherwise in a writable artifact directory outside the reviewed repository. Name it for the PR and keep
index.html
at its root. Store every included PR-description screenshot under
assets/screenshots/
with stable, descriptive filenames and reference it from the HTML with a relative path. Preserve the source image bytes and useful file extension when possible. The bundle must not depend on remote image URLs or absolute filesystem paths; external source links in captions may still point to the PR. Keep required narrative visible; use expandable details for supporting code and evidence. Preserve responsive navigation, keyboard focus, diagram overflow handling, and print styles.
Check the filled bundle for example residue, broken anchors, unescaped code, invented citations, and missing or distorted screenshots from the PR description. Move or copy the complete directory to a temporary location and open
index.html
there when possible; verify that every screenshot still loads from the bundle, desktop/mobile reading works, and details remain usable. Also verify rendered diagrams and their textual fallback with the CDN unavailable. Check print layout if claiming PDF readiness. Report any verification that could not run. Deliver a clickable link to
index.html
, identify the bundle directory, and give a concise coverage statement. Create a
.zip
, publish, or post externally only when requested.
读取并复制 assets/pr-explanation.html 到资源包根目录,并将其命名为
index.html
。它是展示内容的唯一事实来源。替换其中的示例内容,根据实际用户旅程调整章节数量,更新文档语言和标题,并使导航与章节 ID 保持同步。保持 CSS 和叙述内容内联;保留固定版本的 CDN 渲染器、文本回退和可访问的 Mermaid 源码。将来源引用放在对应论断旁。
在用户选择的输出位置创建一个可移植目录;如果未指定,则在所审查仓库之外的可写产物目录中创建。以 PR 命名该目录,并将
index.html
放在其根目录。将所有包含的 PR 描述截图存放在
assets/screenshots/
下,使用稳定且具有描述性的文件名,并通过相对路径从 HTML 中引用。尽可能保留源图片字节和合适的文件扩展名。该资源包不得依赖远程图片 URL 或绝对文件系统路径;图片说明中的外部来源链接仍可指向 PR。保持必要的叙述内容可见;使用可展开的
details
元素容纳支撑代码和证据。保留响应式导航、键盘焦点、图表溢出处理和打印样式。
检查填充后的资源包中是否残留示例内容、存在断裂锚点、未转义的代码、虚构的引用,以及缺失或变形的 PR 描述截图。将完整目录移动或复制到临时位置,并在可行时从那里打开
index.html
;验证每张截图仍能从资源包中加载,桌面端和移动端均可正常阅读,并且
details
元素仍可使用。还需在 CDN 不可用时验证渲染后的图表及其文本回退。如果声称支持 PDF,则检查打印布局。报告所有无法执行的验证。提供指向
index.html
的可点击链接,说明资源包目录,并给出简洁的覆盖范围说明。仅在用户明确要求时创建
.zip
、发布或对外发布。