跳转到内容

HTML 报告格式

架构评审会渲染为一个独立的 HTML 文件,保存在操作系统的临时目录中。Tailwind 和 Mermaid 都通过 CDN 加载。Mermaid 能可靠地处理图形结构的示意图;手工编写的 div 和内联 SVG 更适合编辑式视觉呈现(体量图、剖面图)。两者结合使用:不要什么都依赖 Mermaid,否则看起来会越来越普通。

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Architecture review for {{repo name}}</title>
<script src="https://cdn.tailwindcss.com"></script>
<script type="module">
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
</script>
<style>
/* small custom layer for things Tailwind doesn't cover cleanly:
dashed seam lines, hand-drawn-feeling arrow heads, etc. */
.seam { stroke-dasharray: 4 4; }
.leak { stroke: #dc2626; }
.deep { background: linear-gradient(135deg, #0f172a, #1e293b); }
</style>
</head>
<body class="bg-stone-50 text-slate-900 font-sans">
<main class="max-w-5xl mx-auto px-6 py-12 space-y-12">
<header>...</header>
<section id="candidates" class="space-y-10">...</section>
<section id="top-recommendation">...</section>
</main>
</body>
</html>

仓库名称、日期,以及简洁的图例:实线框 = module,虚线 = seam,红色箭头 = 泄漏,粗深色框 = 深模块。不要写引言段。直接进入候选项。

示意图承载主要信息。文字说明精简、直白,并自然使用术语表中的词(来自 /codebase-design skill)。

每个候选项都是一个 <article>:

  • 标题:简短,点明要加深的部分(例如“合并订单接收流水线”)。
  • 徽标行:推荐强度(Strong = 翡翠色,Worth exploring = 琥珀色,Speculative = 石板灰),再加一个依赖类别标签(in-process、local-substitutable、ports & adapters、mock)。
  • 文件:等宽字体列表,font-mono text-sm。
  • 改造前 / 改造后示意图:页面中心内容。并排两栏。参见下方模式。
  • 问题:一句话说明痛点。
  • 解决方案:一句话说明改动。
  • 收益:项目符号,每条不超过 6 个词。例如:“测试只经过一个 interface”“定价逻辑不再泄漏”“删除 4 个浅模块封装”。
  • ADR 提示(如适用):琥珀色背景框中的一行文字。

不要写解释段落。如果示意图需要靠段落才能看懂,就重画示意图。

选择适合候选项的模式。交替使用,不要让所有示意图看起来都一样。多样性本身就是目的之一。

Mermaid 图(依赖关系 / 调用流程的主力)

Section titled “Mermaid 图(依赖关系 / 调用流程的主力)”

当重点是“X 调用 Y,Y 调用 Z,看看这团乱麻”时,使用 Mermaid flowchart 或 graph。用 Tailwind 样式的卡片包起来,让它看起来浑然一体。通过 classDef 将泄漏边缘标成红色,并将深模块设为深色。对于“改造前:6 次往返;改造后:1 次”,时序图也很合适。

<div class="rounded-lg border border-slate-200 bg-white p-4">
<pre class="mermaid">
flowchart LR
A[OrderHandler] --> B[OrderValidator]
B --> C[OrderRepo]
C -.leak.-> D[PricingClient]
classDef leak stroke:#dc2626,stroke-width:2px;
class C,D leak
</pre>
</div>

手工绘制的方框与箭头(Mermaid 布局不合适时)

Section titled “手工绘制的方框与箭头(Mermaid 布局不合适时)”

用带边框和标签的 <div> 表示模块。箭头用内联 SVG 的 <line> 或 <path> 元素表示,绝对定位在相对定位容器上方。如果希望“改造后”的示意图呈现为一个粗边框的深模块,内部细节淡化处理,可以用这种方式;Mermaid 无法以合适的视觉权重呈现这种效果。

剖面图(适合展示层层浅薄的结构)

Section titled “剖面图(适合展示层层浅薄的结构)”

叠放水平带状区域(h-12 border-l-4),展示一次调用要经过哪些层。改造前:6 个薄层,每层都没做什么。改造后:1 个厚带状区域,标注整合后的职责。

体量图(适合展示“interface 和实现一样宽”)

Section titled “体量图(适合展示“interface 和实现一样宽”)”

每个模块用两个矩形表示:一个表示 interface 表面,一个表示实现。改造前:interface 矩形几乎和实现矩形一样高(浅)。改造后:interface 矩形较矮,实现矩形较高(深)。

改造前:将函数调用树渲染为嵌套方框。改造后:将同一棵树折叠成一个方框,并在内部淡化显示现在已归入其中的调用。

  • 采用编辑式风格,不要做成企业仪表盘。留足空白。标题可以使用衬线字体(font-serif 和石色 / 石板色搭配效果不错)。
  • 少量使用颜色:一种强调色(翡翠色或靛蓝色),红色表示泄漏,琥珀色表示警告。
  • 示意图高度保持在约 320px,让改造前后可以并排舒适显示,无需滚动。
  • 在示意图内的模块标签上使用 text-xs uppercase tracking-wider,让它们看起来像示意图,而不是 UI。
  • 脚本只包括 Tailwind CDN 和 Mermaid ESM 导入。报告其他部分都是静态内容,没有应用代码,也没有 Mermaid 自身渲染之外的交互。

放一张更大的卡片。写上候选项名称、一句话说明理由,并添加指向该候选卡片的锚点链接。仅此而已。

使用简洁直白的英文,但架构名词和动词直接采用 /codebase-design skill 中的说法。简洁不代表可以偏离术语。

只能使用: module、interface、implementation、depth、deep、shallow、seam、adapter、leverage、locality。

绝不能替换成: component、service、unit(用来指 module)· API、signature(用来指 interface)· boundary(用来指 seam)· layer、wrapper(用来指 module)。

符合风格的表述:

  • “订单接收 module 很浅:interface 几乎和实现一样宽。”
  • “定价逻辑从 seam 泄漏出去。”
  • “加深:一个 interface,一个测试位置。”
  • “两个 adapter 足以证明 seam 的合理性:生产环境用 HTTP,测试中用内存实现。”

收益项目符号要用术语表中的词点明收益:“locality:bug 集中在一个 module”、“leverage:一个 interface,N 个调用点”、“interface 缩小;实现吸收这些封装”。不要写“更容易维护”或“代码更整洁”,因为这些词不在术语表里,不值得占位置。

不要含糊,不要铺垫,不要说“值得一提的是……”。一句话能写成项目符号,就写成项目符号。项目符号能删掉,就删掉。如果某个术语不在 /codebase-design 术语表里,先从术语表中找一个合适的,再考虑创造新说法。

英文 HTML-REPORT.md
# HTML Report Format
The architectural review is rendered as a single self-contained HTML file in the OS temp directory. Tailwind and Mermaid both come from CDNs. Mermaid handles graph-shaped diagrams reliably; hand-built divs and inline SVG handle the more editorial visuals (mass diagrams, cross-sections). Mix the two: don't lean on Mermaid for everything, it'll start to look generic.
## Scaffold
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Architecture review for {{repo name}}</title>
<script src="https://cdn.tailwindcss.com"></script>
<script type="module">
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
</script>
<style>
/* small custom layer for things Tailwind doesn't cover cleanly:
dashed seam lines, hand-drawn-feeling arrow heads, etc. */
.seam { stroke-dasharray: 4 4; }
.leak { stroke: #dc2626; }
.deep { background: linear-gradient(135deg, #0f172a, #1e293b); }
</style>
</head>
<body class="bg-stone-50 text-slate-900 font-sans">
<main class="max-w-5xl mx-auto px-6 py-12 space-y-12">
<header>...</header>
<section id="candidates" class="space-y-10">...</section>
<section id="top-recommendation">...</section>
</main>
</body>
</html>
```
## Header
Repo name, date, and a compact legend: solid box = module, dashed line = seam, red arrow = leakage, thick dark box = deep module. No introduction paragraph. Straight into the candidates.
## Candidate card
The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms (from the `/codebase-design` skill) without ceremony.
Each candidate is one `<article>`:
- **Title**: short, names the deepening (e.g. "Collapse the Order intake pipeline").
- **Badge row**: recommendation strength (`Strong` = emerald, `Worth exploring` = amber, `Speculative` = slate), plus a tag for the dependency category (`in-process`, `local-substitutable`, `ports & adapters`, `mock`).
- **Files**: monospaced list, `font-mono text-sm`.
- **Before / After diagram**: the centrepiece. Two columns, side by side. See patterns below.
- **Problem**: one sentence. What hurts.
- **Solution**: one sentence. What changes.
- **Wins**: bullets, ≤6 words each. e.g. "Tests hit one interface", "Pricing logic stops leaking", "Delete 4 shallow wrappers".
- **ADR callout** (if applicable): one line in an amber-tinted box.
No paragraphs of explanation. If the diagram needs a paragraph to be understood, redraw the diagram.
## Diagram patterns
Pick the pattern that fits the candidate. Mix them. Don't make every diagram look the same. Variety is part of the point.
### Mermaid graph (the workhorse for dependencies / call flow)
Use a Mermaid `flowchart` or `graph` when the point is "X calls Y calls Z, and look at the mess." Wrap it in a Tailwind-styled card so it doesn't feel parachuted in. Style with classDef to colour leakage edges red and the deep module dark. Sequence diagrams work well for "before: 6 round-trips; after: 1."
```html
<div class="rounded-lg border border-slate-200 bg-white p-4">
<pre class="mermaid">
flowchart LR
A[OrderHandler] --> B[OrderValidator]
B --> C[OrderRepo]
C -.leak.-> D[PricingClient]
classDef leak stroke:#dc2626,stroke-width:2px;
class C,D leak
</pre>
</div>
```
### Hand-built boxes-and-arrows (when Mermaid's layout fights you)
Modules as `<div>`s with borders and labels. Arrows as inline SVG `<line>` or `<path>` elements positioned absolutely over a relative container. Reach for this when you want the "after" diagram to feel like one thick-bordered deep module with greyed-out internals, since Mermaid won't render that with the right weight.
### Cross-section (good for layered shallowness)
Stack horizontal bands (`h-12 border-l-4`) to show layers a call passes through. Before: 6 thin layers each doing nothing. After: 1 thick band labelled with the consolidated responsibility.
### Mass diagram (good for "interface as wide as implementation")
Two rectangles per module: one for interface surface area, one for implementation. Before: interface rectangle is nearly as tall as the implementation rectangle (shallow). After: interface rectangle is short, implementation rectangle is tall (deep).
### Call-graph collapse
Before: a tree of function calls rendered as nested boxes. After: the same tree collapsed into one box, with the now-internal calls shown faded inside it.
## Style guidance
- Lean editorial, not corporate-dashboard. Generous whitespace. Serif optional for headings (`font-serif` works well with stone/slate).
- Colour sparingly: one accent (emerald or indigo) plus red for leakage and amber for warnings.
- Keep diagrams ~320px tall so before/after sits comfortably side by side without scrolling.
- Use `text-xs uppercase tracking-wider` for module labels inside diagrams, so they read as schematic, not as UI.
- The only scripts are the Tailwind CDN and the Mermaid ESM import. The report is otherwise static: no app code, no interactivity beyond Mermaid's own rendering.
## Top recommendation section
One larger card. Candidate name, one sentence on why, anchor link to its card. That's it.
## Tone
Plain English, concise, but the architectural nouns and verbs come straight from the `/codebase-design` skill. Concision is not an excuse to drift.
**Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
**Never substitute:** component, service, unit (for module) · API, signature (for interface) · boundary (for seam) · layer, wrapper (for module, when you mean module).
**Phrasings that fit the style:**
- "Order intake module is shallow: interface nearly matches the implementation."
- "Pricing leaks across the seam."
- "Deepen: one interface, one place to test."
- "Two adapters justify the seam: HTTP in prod, in-memory in tests."
**Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"*, because those terms aren't in the glossary and don't earn their place.
No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in the `/codebase-design` glossary, reach for one that is before inventing a new one.

非官方学习站,与 Matt Pocock 和 AI Hero 没有隶属关系。本站不提供可安装的中文技能包。

技能原文采用 MIT 许可。Copyright (c) 2026 Matt Pocock

鲁ICP备2025189036号