For a non-trivial pull request, write a self-contained HTML design doc under the temporary `.pr/` directory and link a visibility-appropriate preview in the PR
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-pr-design-doc-63e64b16500d ,按照其中的说明把「pr-design-doc」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
A diff shows what changed line by line. It does not show the design: the shape of the change, the API before and after, and why this approach. Reviewers reconstruct that by hand, slowly. The scarce resource is the maintainer's attention and trust budget - not the agent's effort. Spend extra effort to hand them one self-contained HTML page that conveys the big picture and the before → after core difference, with every claim clickable back to the real code, then link it from the PR description.
This is the same craft as a "show me this change" explainer, aimed at one job: making a non-trivial PR easy to review.
.pr/ workflowUse the temporary .pr/ directory for PR-only artifacts. Before relying on automatic
cleanup, verify that the target repository has an enabled
.github/workflows/pr-artifacts.yml workflow that removes .pr/ after approval.
.pr/ after
approval..pr/ manually before
merge.The design doc is a review aid that lives with the branch while the PR is open. It must not ship in the merged tree.
Check out and verify the PR head. Do not write or commit the design doc from the base branch or an unrelated checkout. Start with a clean worktree, then inspect and check out the PR:
gh pr view <n> --json title,body,url,baseRefName,baseRefOid,headRefName,headRefOid,headRepository,headRepositoryOwner,isCrossRepository,files,additions,deletions
gh pr checkout <n>
git rev-parse HEAD
gh pr view <n> --json headRefOid --jq .headRefOid
The final two SHAs must match before you continue. If they do not, stop and fix the
checkout. Compute the merge-base SHA with
git merge-base <baseRefOid> <headRefOid>. Group changed files by area and keep both the
merge-base SHA and head SHA for source links.
Read both sides of each logical file. Compare
git show <merge-base-sha>:<path> with the verified head. Capture the
function-level behavioral difference - what the code did vs does now.
Classify each file. Logic change (behavior moved) → draw before/after. Mechanical
change (rename, constant, config, import move) → a one-line before → after row, no
diagram. Don't dilute the signal by drawing mechanical edits.
If the change is an API change, lead with the API. Show the signature/schema/type before and after side by side (function signature, endpoint + payload, config field, event shape). Name the compatibility impact plainly: additive, breaking, or behind a flag.
Find the cross-file story. If one call chain threads several files, draw a single overview before/after at the top; per-file cards drill in.
Build the page per references/html-craft.md - one
self-contained, offline, editorial HTML file with hand-drawn SVG figures. Save it to
the repo's .pr/ directory, e.g. .pr/design.html (or .pr/<topic>.html). Before
writing, reject a symlink at .pr or at the exact output path; never follow a
branch-controlled symlink outside the worktree.
test ! -L .pr && test ! -L .pr/design.html
mkdir -p .pr
Commit under .pr/, push to the verified PR head, and link it. Confirm that the push
remote resolves to headRepository.nameWithOwner; never push the artifact to the base
repository's default branch.
git add .pr/design.html
git commit -m "docs(.pr): design doc for <PR topic>"
git push <head-repo-remote> HEAD:<headRefName>
Query the base repository's visibility before choosing the link:
gh repo view <base-owner>/<base-repo> --json visibility,url
📄 Design doc: https://htmlpreview.github.io/?https://github.com/<fork-owner>/<repo>/blob/<pr-branch>/.pr/design.html
★ callout, with the most important changed path:line nearby. Stats (N files · +A / −D) are context, not the lead. If there's a cross-file flow, the overview
before/after SVG goes here.file:line
(changed nodes in orange), and the diff in a collapsed <details>. Mechanical files get a
small before → after table, no diagram.path:line, and links to the correct source revision where possible: the
merge-base SHA for before-state evidence and the verified head SHA for after-state
evidence. One click from "this changed" to the exact code..pr/ only, and temporary. The doc is a review aid, not project docs. Keep it in
.pr/ and ensure it is removed before merge. Rely on automatic cleanup only when the
repository's workflow has been verified; otherwise remove it manually. Do not move design
HTML into docs/ or ship it in the merged tree..pr/ (e.g. docs/), where it would merge into main.