codemermaid
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCodeMermaid
CodeMermaid
Generate a multi-page interactive HTML site that teaches a codebase as scrollable essays — architecture views, default Build-Up walkthroughs, beautiful-mermaid diagrams, typed pedagogical units (concept, quiz, takeaway, diagram, code-walk, code-graph, whoa) carrying the lesson. Zero build tools, zero npm. Each output page links shared CSS, runtime JS, and the beautiful-mermaid browser bundle; diagrams render client-side with Raycast dark theming.
生成一个多页交互式HTML站点,以可滚动的文章形式讲解代码库——包含架构视图、默认的Build-Up导览、美观的Mermaid图表、承载课程内容的多种教学单元(concept、quiz、takeaway、diagram、code-walk、code-graph、whoa)。无需构建工具,无需npm。每个输出页面都会链接共享CSS、运行时JS以及beautiful-mermaid浏览器包;图表采用Raycast深色主题在客户端渲染。
When to Use
适用场景
- "Generate an interactive course for this codebase"
- "Create a visual walkthrough of this project's architecture"
- "Make an interactive module dependency diagram"
- "Build a tutorial page from this codebase"
- "为这个代码库生成交互式课程"
- "创建该项目架构的可视化导览"
- "制作交互式模块依赖图"
- "基于这个代码库构建教程页面"
Output
输出内容
Directory:
docs/codemermaid/style.css <- Copied from assets/style.css
runtime.js <- Copied from assets/runtime.js
index.html <- Entry page (perspective + module cards)
architecture.html <- Architecture perspective (essay, always generated)
build-up.html <- Build-Up Walkthrough perspective (essay, always generated)
<perspective>.html <- Other user-requested or auto-inferred perspectives (essays)
module-<name>.html <- Per-module deep dives (essays, optional module-level Build-Up when useful)Each HTML page links , , , and via and . Diagrams use Mermaid.js syntax rendered via the beautiful-mermaid browser bundle. The assembly process copies these assets from to the output directory alongside the HTML files.
style.cssruntime.jsbeautiful-mermaid.bundle.jsmermaid-bridge.js<link><script src>assets/目录:
docs/codemermaid/style.css <- 从assets/style.css复制而来
runtime.js <- 从assets/runtime.js复制而来
index.html <- 入口页面(视角概览 + 模块卡片)
architecture.html <- 架构视角页面(文章形式,始终生成)
build-up.html <- Build-Up导览视角页面(文章形式,始终生成)
<perspective>.html <- 其他用户请求或自动推断的视角页面(文章形式)
module-<name>.html <- 逐模块深度解析页面(文章形式,必要时包含模块级Build-Up内容)每个HTML页面通过和链接、、和。图表使用Mermaid.js语法,通过beautiful-mermaid浏览器包渲染。生成过程会将这些资源从目录复制到输出目录,与HTML文件放在一起。
<link><script src>style.cssruntime.jsbeautiful-mermaid.bundle.jsmermaid-bridge.jsassets/Parallel Generation Mode
并行生成模式
If subagents are available and the repo has enough independent modules, read before dispatching work.
references/subagent-generation.mdThe main agent remains coordinator and owns the module registry, filename registry, perspective list, index page, link graph, and final validation. Subagents may only work inside assigned scopes.
如果有子代理可用且代码仓库包含足够多的独立模块,在分配任务前请阅读。
references/subagent-generation.md主代理作为协调者,负责模块注册表、文件名注册表、视角列表、索引页面、链接图和最终验证。子代理只能在指定范围内工作。
Phase 1: Scan
阶段1:扫描
Read the codebase exhaustively. The goal is to discover ALL meaningful modules, not just the obvious ones.
全面读取代码库。目标是发现所有有意义的模块,而不仅仅是明显的模块。
Step 1.1: Structural Scan
步骤1.1:结构扫描
- Root directory — list all top-level folders and files
- Source directories — for each top-level folder, list its contents recursively (2 levels deep)
- Entry files — ,
main.*,index.*,app.*,server.*,cmd/,src/,lib/pkg/ - Config files — ,
package.json,go.mod,Cargo.toml,pyproject.toml,Makefile, equivalentdocker-compose.yml - Framework detection — language, framework, runtime from config and imports
- Test directories — ,
test/,tests/,spec/,__tests__/*_test.*
- 根目录 — 列出所有顶级文件夹和文件
- 源目录 — 对每个顶级文件夹,递归列出其内容(深度为2层)
- 入口文件 — 、
main.*、index.*、app.*、server.*、cmd/、src/、lib/pkg/ - 配置文件 — 、
package.json、go.mod、Cargo.toml、pyproject.toml、Makefile及同类文件docker-compose.yml - 框架检测 — 从配置文件和导入语句中识别语言、框架和运行时
- 测试目录 — 、
test/、tests/、spec/、__tests__/*_test.*
Step 1.2: Deep Module Discovery
步骤1.2:深度模块发现
For EACH source directory found above, determine if it qualifies as a module:
- A module is any directory or file that has a clear single responsibility
- Read the first 30 lines of every entry file to understand purpose
- Use Grep to find ,
import,require,usepatterns — map dependency edgesfrom - Check ,
exports,module.exports,pub— identify public interfacespublic
What counts as a module:
| Type | Examples |
|---|---|
| Top-level source dir | |
| Standalone config file | |
| Utility/helper dir | |
| Plugin/extension dir | |
| Data layer | |
| Build/CI config | |
| Skill/command dir | |
| Single important file | |
What to skip:
- ,
node_modules/,vendor/,.git/,dist/, cache dirsbuild/ - Generated files, lock files (except if meaningful)
skills-lock.json - Test fixtures, static assets with no logic
对于上述发现的每个源目录,判断其是否符合模块的定义:
- 模块指任何具有明确单一职责的目录或文件
- 读取每个入口文件的前30行,了解其用途
- 使用Grep查找、
import、require、use等模式——绘制依赖关系边from - 检查、
exports、module.exports、pub——识别公共接口public
符合模块定义的类型:
| 类型 | 示例 |
|---|---|
| 顶级源目录 | |
| 独立配置文件 | |
| 工具/辅助目录 | |
| 插件/扩展目录 | |
| 数据层 | |
| 构建/CI配置 | |
| 技能/命令目录 | |
| 重要独立文件 | |
需要跳过的内容:
- 、
node_modules/、vendor/、.git/、dist/、缓存目录build/ - 生成文件、锁文件(除非具有重要意义)
skills-lock.json - 测试 fixtures、无逻辑的静态资源
Step 1.3: Dependency Mapping
步骤1.3:依赖关系映射
For every module discovered, trace its imports:
Module A → imports from → Module B, Module C
Module B → imports from → Module D
Module C → imports from → Module D (optional)This becomes the edge list for Mermaid diagrams. Use Glob and Grep extensively. Read actual code. Do NOT guess.
对于每个发现的模块,追踪其导入关系:
模块A → 导入自 → 模块B、模块C
模块B → 导入自 → 模块D
模块C → 导入自 → 模块D(可选)这将成为Mermaid图表的边列表。广泛使用Glob和Grep工具,读取实际代码,不要猜测。
Phase 2: Analyze
阶段2:分析
From scan results:
- Architecture pattern — MVC, microservices, monolith, event-driven, hexagonal, layered, etc.
- Data flow — trace the primary request path entry → response, and secondary flows
- Module graph — full dependency graph from Phase 1.3, identify cycles and layers
- Key abstractions — interfaces, base classes, core types that define the system's vocabulary
- Module categorization — group modules into layers:
| Layer | Typical Modules |
|---|---|
| Entry | HTTP handlers, CLI commands, main entry points |
| Core | Business logic, domain models, services |
| Data | Database, repositories, ORM, state management |
| Infra | Config, logging, middleware, error handling |
| Output | Templates, serializers, API responses |
| DevX | Build tools, CI/CD, skills, commands |
Prioritization: If the codebase has more than 12 modules, organize into sub-graphs.
- Default perspective requirements — Architecture and Build-Up are always included. gives the finished-system map;
architecture.htmlgives the gradual learning route from smallest useful capability to complete system.build-up.html - User perspective requirements — parse user prompt for explicit perspective requests. User-requested perspectives are mandatory.
- Auto-infer perspectives — from project characteristics:
- Has HTTP handlers, WebSocket, or event streams → Data Flow perspective
- Has database/ORM → Data Model perspective
- Has state management → State Machine perspective
- 10+ modules → Module Dependency perspective
- Has CI/CD config → Build Pipeline perspective
- Merge perspective list — default + user-specified + auto-inferred, deduplicated. Recommended index order: Architecture Overview, Build-Up Walkthrough, then user-requested and auto-inferred perspectives. Every discovered module must be reachable from at least one perspective page.
- Derive Build-Up route — before drafting , read
build-up.htmland choose a reader-comprehension order from discovered modules and dependency evidence.references/build-up.md
从扫描结果中:
- 架构模式 — MVC、微服务、单体应用、事件驱动、六边形架构、分层架构等
- 数据流 — 追踪主请求路径的入口→响应流程,以及次要流程
- 模块图 — 阶段1.3生成的完整依赖图,识别循环和分层
- 核心抽象 — 定义系统词汇的接口、基类、核心类型
- 模块分类 — 将模块分组为不同层级:
| 层级 | 典型模块 |
|---|---|
| 入口层 | HTTP处理器、CLI命令、主入口点 |
| 核心层 | 业务逻辑、领域模型、服务 |
| 数据层 | 数据库、仓库、ORM、状态管理 |
| 基础设施层 | 配置、日志、中间件、错误处理 |
| 输出层 | 模板、序列化器、API响应 |
| DevX层 | 构建工具、CI/CD、技能、命令 |
优先级: 如果代码库包含超过12个模块,组织为子图。
- 默认视角要求 — 始终包含Architecture和Build-Up视角。展示完整系统的架构图;
architecture.html提供从最小可用功能到完整系统的渐进式学习路径。build-up.html - 用户视角要求 — 解析用户提示中的明确视角请求。用户指定的视角是必填项。
- 自动推断视角 — 根据项目特征推断:
- 包含HTTP处理器、WebSocket或事件流 → 数据流视角
- 包含数据库/ORM → 数据模型视角
- 包含状态管理 → 状态机视角
- 模块数量≥10 → 模块依赖视角
- 包含CI/CD配置 → 构建流水线视角
- 合并视角列表 — 合并默认、用户指定和自动推断的视角,去重。推荐的索引顺序:架构概览、Build-Up导览,然后是用户请求和自动推断的视角。每个发现的模块必须至少能从一个视角页面访问到。
- 推导Build-Up路径 — 在编写之前,阅读
build-up.html,根据发现的模块和依赖证据选择便于读者理解的顺序。references/build-up.md
Phase 3: Build Page Data
阶段3:构建页面数据
Each per-module and per-perspective page has a , optional , and a array. Read for concrete patterns and for tone.
learningPromiseprereqsunits[]references/units-examples.mdreferences/voice-examples.md每个模块页面和视角页面都包含、可选的和数组。请阅读获取具体模式,阅读了解语气要求。
learningPromiseprereqsunits[]references/units-examples.mdreferences/voice-examples.mdCOURSE (per-module page, module-<name>.html
)
module-<name>.html课程(模块页面,module-<name>.html
)
module-<name>.htmljavascript
const COURSE = {
module: "auth",
learningPromise: "...",
prereqs: ["..."],
units: []
};Module pages may include a module-level Build-Up section when the module has a natural internal progression. This section is optional; read before adding one.
references/build-up.mdjavascript
const COURSE = {
module: "auth",
learningPromise: "...",
prereqs: ["..."],
units: []
};当模块具有自然的内部演进逻辑时,模块页面可包含模块级Build-Up部分。此部分为可选内容;添加前请阅读。
references/build-up.mdPERSPECTIVE (per-perspective page, e.g. architecture.html
)
architecture.html视角(视角页面,例如architecture.html
)
architecture.htmljavascript
const PERSPECTIVE = {
perspective: "architecture",
learningPromise: "...",
prereqs: ["..."],
units: []
};javascript
const PERSPECTIVE = {
perspective: "architecture",
learningPromise: "...",
prereqs: ["..."],
units: []
};BUILD_UP (default perspective page, build-up.html
)
build-up.htmlBuild-Up(默认视角页面,build-up.html
)
build-up.htmlBuild-Up is a required perspective. Before drafting it, read for route design, capability increments, examples, module-level Build-Up criteria, and Mermaid/code pairing rules.
references/build-up.mdBuild-Up是必填视角。编写前请阅读,了解路径设计、功能增量、示例、模块级Build-Up标准以及Mermaid/代码配对规则。
references/build-up.mdINDEX (entry page, index.html
)
index.html索引(入口页面,index.html
)
index.htmljavascript
const INDEX = {
project: { name, description, language, framework },
perspectives: [{ title, description, page, unitCount }],
modules: [{ title, description, page, unitCount }]
};javascript
const INDEX = {
project: { name, description, language, framework },
perspectives: [{ title, description, page, unitCount }],
modules: [{ title, description, page, unitCount }]
};Unit kinds (7 types)
单元类型(7种)
javascript
{ kind: "concept", title, body, style? } // style: "callout" for surprise-style red border
{ kind: "quiz", question, options: [{letter, text, correct}], explanation }
{ kind: "takeaway", body }
{ kind: "diagram", title, mermaid, caption, zoomable? } // Mermaid syntax, zoomable defaults true
{ kind: "code-walk", title, file, startLine?, code, highlights: [{line, note}], layout? } // layout defaults "split"
{ kind: "code-graph", title, file, startLine?, code, highlights: [{line, note, graphNode?}], svg } // left code, right mini graph
{ kind: "whoa", angle, title, body, evidence? } // angle: "code" | "product" | "ux" | "architecture"javascript
{ kind: "concept", title, body, style? } // style: "callout"表示带红色边框的提示样式
{ kind: "quiz", question, options: [{letter, text, correct}], explanation }
{ kind: "takeaway", body }
{ kind: "diagram", title, mermaid, caption, zoomable? } // Mermaid语法,zoomable默认值为true
{ kind: "code-walk", title, file, startLine?, code, highlights: [{line, note}], layout? } // layout默认值为"split"
{ kind: "code-graph", title, file, startLine?, code, highlights: [{line, note, graphNode?}], svg } // 左侧代码,右侧迷你图
{ kind: "whoa", angle, title, body, evidence? } // angle: "code" | "product" | "ux" | "architecture"Whoa unit rules
Whoa单元规则
Use only for rare design moments with strong evidence that explains why the project is unusually well-designed. Use zero units when there is no strong evidence. When evidence exists, a normal course should stay around 3-5 units total across all pages.
whoawhoawhoaRequired fields:
- : one of
angle,code,product, orux.architecture - : a concrete statement of the design win.
title - : explains the constraint, why the design is strong, and what would be worse without it.
body
Optional fields:
evidencejavascript
{
files?: string[],
modules?: string[],
interactions?: string[],
constraints?: string[]
}Use one visual treatment for every angle. changes the label and placement, not the color palette.
angle仅当存在充分证据表明项目设计异常出色时,才使用单元。若无充分证据,则不使用单元。当存在证据时,一个标准课程在所有页面中总共应包含3-5个单元。
whoawhoawhoa必填字段:
- :取值为
angle、code、product或ux之一。architecture - :明确说明设计亮点的具体陈述。
title - :解释约束条件、设计优势以及如果没有该设计会带来的问题。
body
可选字段:
evidencejavascript
{
files?: string[],
modules?: string[],
interactions?: string[],
constraints?: string[]
}每个使用一种视觉样式。会改变标签和位置,但不会改变调色板。
angleangleVoice rules
语气规则
Before writing generated prose, read . Follow that file for voice, signposts, anti-patterns, and rewrite recipes.
references/voice-examples.md在编写生成的文本之前,请阅读。遵循该文件中的语气、提示语、反模式和改写规则。
references/voice-examples.mdCode explanation depth (mandatory — do not skimp)
代码解释深度(必填 — 切勿简化)
Every piece of code shown to the reader MUST be thoroughly explained. This is the core value of the course — the reader is here to understand code they couldn't read on their own.
concept units before a code-walk must explain:
- What the module/function does and why it exists (its role in the system)
- What pattern or tradeoff is at play (why this approach over alternatives)
- Any non-obvious context the reader needs before seeing the code
code-walk highlights[].note must explain:
- What the highlighted line does (not just restate the code — explain the why)
- How it connects to the surrounding logic (data flow, control flow, side effects)
- Any implicit behavior not visible in the code (e.g., "this returns null because the upstream function hasn't resolved yet")
- Non-trivial API usage (e.g., "Array.from creates a shallow copy — we do this because the NodeList returned by querySelectorAll is live, meaning it updates when the DOM changes")
diagram captions must explain:
- What the diagram shows and why that flow/structure matters
- Where the interesting part is (not just "this is the architecture")
quiz explanations must explain:
- Why the correct answer is correct (with specific code evidence)
- Why each wrong answer is wrong (briefly)
ANTI-PATTERN: Lazy notes. The following are banned:
- Notes that restate the code: when the code says
note: "Calls verify() on line 3"const user = await verify(token) - Notes that say "see above" or "as mentioned earlier" without re-explaining
- Concept bodies that say "this module handles X" without explaining how or why
- Captions that say "Module dependency diagram" without saying what's interesting about the dependencies
GOOD example:
{ line: 5, note: "verify() is async because it makes a network call to the JWT issuer's .well-known/jwks.json endpoint. The await here means the middleware pauses — no downstream handler runs until this resolves. That's fine for auth, but it means every request pays this latency cost, even for public endpoints that don't need auth." }BAD example:
{ line: 5, note: "Calls verify() to validate the JWT token." }展示给读者的每一段代码都必须进行详尽解释。这是课程的核心价值——读者来此是为了理解他们自己无法读懂的代码。
code-walk之前的concept单元必须解释:
- 模块/函数的功能及其存在的原因(在系统中的角色)
- 所采用的模式或权衡(为什么选择这种方法而非其他)
- 读者在查看代码前需要了解的任何非显而易见的上下文
code-walk的highlights[].note必须解释:
- 高亮行的作用(不仅仅是重述代码——要解释背后的原因)
- 它与周围逻辑的关联(数据流、控制流、副作用)
- 代码中不可见的隐式行为(例如:"这会返回null,因为上游函数尚未解析完成")
- 非平凡的API用法(例如:"Array.from创建浅拷贝——我们这样做是因为querySelectorAll返回的NodeList是动态的,意味着DOM变化时它会更新")
图表说明必须解释:
- 图表展示的内容以及该流程/结构的重要性
- 有趣的部分在哪里(不仅仅是"这是架构图")
测验解释必须解释:
- 正确答案为何正确(附带具体代码证据)
- 每个错误答案为何错误(简要说明)
反模式:敷衍的注释。以下内容被禁止:
- 重述代码的注释:当代码为时,注释写
const user = await verify(token)note: "第3行调用verify()" - 写"见上文"或"如前所述"但不重新解释的注释
- 仅说明"此模块处理X"但不解释如何处理或为什么处理的concept内容
- 仅写"模块依赖图"但不说明依赖关系有趣之处的说明
良好示例:
{ line: 5, note: "verify()是异步函数,因为它会向JWT发行方的.well-known/jwks.json端点发起网络请求。这里的await意味着中间件会暂停——直到该请求解析完成,下游处理器才会运行。这对于认证来说没问题,但意味着每个请求都会产生此延迟成本,即使是不需要认证的公共端点也是如此。" }糟糕示例:
{ line: 5, note: "调用verify()验证JWT令牌。" }Unit quality guidelines (soft limits)
单元质量指南(软限制)
Prefer depth over brevity. These are upper bounds, not targets — write as much as needed to truly explain the code.
| Unit | Suggested scope |
|---|---|
| 80–200 words — must explain why, not just what |
| question ≤ 2 sentences, 4 options, explanation ≤ 100 words — must reference specific code |
| 3–5 sentences — must synthesize, not just repeat |
| ≤ 8 nodes, caption 20–50 words — must say what's interesting, not just what it shows |
| 8–20 lines code + 3–6 annotations — each note must explain the reasoning, not just restate what the code says |
| 8–15 lines code + mini SVG (4–6 nodes) — same depth as code-walk for annotations |
Rule of thumb: If you can remove an annotation note and the reader loses no understanding, the note wasn't detailed enough — rewrite it, don't remove it.
There is no fixed unit budget. A module page should include as many units as needed to teach its content thoroughly. If a page exceeds ~15 units, consider splitting into sub-modules.
优先考虑深度而非简洁。这些是上限,而非目标——为了真正解释清楚代码,需要写多少就写多少。
| 单元类型 | 建议范围 |
|---|---|
| 80–200字 — 必须解释原因,而非仅仅说明内容 |
| 问题≤2句话,4个选项,解释≤100字 — 必须引用具体代码 |
| 3–5句话 — 必须进行总结,而非仅仅重复内容 |
| ≤8个节点,说明20–50字 — 必须说明有趣之处,而非仅仅说明展示内容 |
| 8–20行代码 + 3–6条注释 — 每条注释必须解释背后的逻辑,而非仅仅重述代码内容 |
| 8–15行代码 + 迷你SVG(4–6个节点) — 注释深度与code-walk相同 |
经验法则: 如果移除一条注释后读者不会失去任何理解,说明该注释不够详细——请重写,不要删除。
没有固定的单元数量限制。模块页面应包含足够多的单元,以彻底讲解其内容。如果页面超过约15个单元,考虑拆分为子模块。
Pedagogy enforcement (mandatory)
教学规则(必填)
Every generated page MUST satisfy these rules:
- Every module MUST have a non-empty .
learningPromise - Every module's MUST contain ≥ 1
units[].quiz - Every module's MUST end with a
units[].takeaway - Every perspective's MUST start with a
units[]and end with aconcept.takeaway - There is no hard cap on unit count; quality of explanation determines the length.
每个生成的页面必须满足以下规则:
- 每个模块必须包含非空的。
learningPromise - 每个模块的必须包含至少1个
units[]。quiz - 每个模块的必须以
units[]结尾。takeaway - 每个视角的必须以
units[]开头,以concept结尾。takeaway - 单元数量没有硬性上限;解释质量决定长度。
Real code only
仅使用真实代码
All values must be exact, unmodified copies from real source files. This includes:
codecode-walk.codecode-graph.code
Prohibited:
- Inventing code that does not exist in the source
- Simplifying logic (e.g., removing a ternary, reordering statements)
- Changing prop names, variable names, or function signatures
- Adding comments that don't exist in the source
- Using ellipsis to hide lines inside a snippet (use
...comment only at the top level to mark elision)// ...
Allowed:
- Extracting a contiguous slice of a function with at top/bottom to show it's truncated
// ... - Removing import statements and surrounding boilerplate to focus on the logic
- Normalizing indentation to match the snippet's context
所有值必须是真实源文件的精确、未修改副本。包括:
codecode-walk.codecode-graph.code
禁止:
- 发明源文件中不存在的代码
- 简化逻辑(例如:移除三元运算符、重新排序语句)
- 更改属性名、变量名或函数签名
- 添加源文件中不存在的注释
- 使用省略号隐藏代码片段内部的行(仅在顶层使用
...注释标记省略部分)// ...
允许:
- 提取函数的连续片段,并在顶部/底部使用标记为截断内容
// ... - 移除导入语句和周围的样板代码,聚焦于核心逻辑
- 调整缩进以匹配代码片段的上下文
Code presentation rules
代码展示规则
Keep teaching snippets tight:
- Trim leading and trailing blank lines from every value.
code - Collapse repeated interior blank lines to one blank line.
- Prefer or
// ...elision comments over airy blank rows when skipping irrelevant source.# ... - is the original source file line used for editor/file actions only;
startLineremains snippet-local after trimming.highlights[].line - Highlight numbers are 1-based and must match the visible line numbers within the extracted snippet after trimming.
- Verification rule: Before finalizing a page, manually count lines in every value. Ensure every
codepoints to a line that actually exists in that snippet and contains meaningful code.highlights[].line - Common pitfall: When extracting a 15-line function from a 200-line file, the highlights must reference line numbers 1–15 (the snippet), NOT the original file's line numbers 186–200.
- Do not highlight blank separator lines; move highlights to the nearest meaningful source line.
- Annotation-note alignment: The note text must describe what happens on the highlighted line(s). If the note says "mergeMessage dedupes by id" but the highlighted line is , the highlight is on the wrong line.
...state,
保持教学代码片段简洁:
- 移除每个值开头和结尾的空白行。
code - 将内部重复的空白行合并为一行。
- 跳过无关代码时,优先使用或
// ...省略注释,而非空行。# ... - 仅用于编辑器/文件操作的原始源文件行号;修剪后,
startLine为代码片段内的行号。highlights[].line - 高亮行号是基于1的,必须与修剪后提取的代码片段中的可见行号匹配。
- 验证规则: 在最终确定页面之前,手动统计每个值的行数。确保每个
code指向该片段中实际存在且包含有意义代码的行。highlights[].line - 常见陷阱: 从200行文件中提取15行函数时,高亮行号必须引用1–15(代码片段的行号),而非原始文件的186–200行。
- 不要高亮空白分隔行;将高亮移动到最近的有意义代码行。
- 注释与高亮对齐: 注释文本必须描述高亮行的行为。如果注释写"mergeMessage按id去重"但高亮行是,则高亮行选择错误。
...state,
Code file action controls
代码文件操作控件
When a or unit has a real source file path, render file actions in the next to the file label.
code-walkcode-graph.codewalk-headUse an absolute file path in when the source repository path is known. Append when the unit provides ; otherwise append .
data-copy-path:{startLine}startLine:1Required HTML shape:
html
<div class="codewalk-head">
<span class="codewalk-file">{FILE}</span>
<span class="file-actions">
<span class="editor-menu" data-editor-menu data-editor="cursor">
<button class="file-action-select editor-menu-trigger" type="button" aria-haspopup="listbox" aria-expanded="false" data-editor-trigger>
<span data-editor-current>Cursor</span>
<span class="gg-chevron-down" aria-hidden="true"></span>
</button>
<span class="editor-menu-list" role="listbox" hidden data-editor-list>
<button class="editor-menu-item" type="button" role="option" aria-selected="true" data-editor-option="cursor">Cursor</button>
<button class="editor-menu-item" type="button" role="option" aria-selected="false" data-editor-option="vscode">VS Code</button>
</span>
</span>
<button class="file-action" type="button" data-copy-path="{ABSOLUTE_FILE_PATH}:{START_LINE}">Copy path</button>
</span>
</div>The selected editor option opens immediately. Selecting the already-active option still opens the file, because the menu uses buttons instead of a native .
<select>当或单元包含真实源文件路径时,在中文件标签旁边渲染文件操作按钮。
code-walkcode-graph.codewalk-head当已知源仓库路径时,在中使用绝对文件路径。如果单元提供,则追加;否则追加。
data-copy-pathstartLine:startLine:1必填HTML结构:
html
<div class="codewalk-head">
<span class="codewalk-file">{FILE}</span>
<span class="file-actions">
<span class="editor-menu" data-editor-menu data-editor="cursor">
<button class="file-action-select editor-menu-trigger" type="button" aria-haspopup="listbox" aria-expanded="false" data-editor-trigger>
<span data-editor-current>Cursor</span>
<span class="gg-chevron-down" aria-hidden="true"></span>
</button>
<span class="editor-menu-list" role="listbox" hidden data-editor-list>
<button class="editor-menu-item" type="button" role="option" aria-selected="true" data-editor-option="cursor">Cursor</button>
<button class="editor-menu-item" type="button" role="option" aria-selected="false" data-editor-option="vscode">VS Code</button>
</span>
</span>
<button class="file-action" type="button" data-copy-path="{ABSOLUTE_FILE_PATH}:{START_LINE}">Copy path</button>
</span>
</div>选中的编辑器选项会立即打开。选择已激活的选项仍会打开文件,因为菜单使用按钮而非原生。
<select>Unit examples
单元示例
Before drafting unit data, read for concrete object shapes, unit-specific options, defaults, and interaction bindings.
references/units-examples.mdKeep the unit-level traps in mind: callout concepts use , quizzes need exactly one correct answer, code-walk line numbers are snippet-local, and code-graph bindings must match SVG values.
style: "callout"data-node-id在编写单元数据之前,请阅读获取具体对象结构、单元特定选项、默认值和交互绑定。
references/units-examples.md牢记单元级注意事项:提示性concept使用,测验需要恰好一个正确答案,code-walk行号是代码片段内的行号,code-graph绑定必须匹配SVG的值。
style: "callout"data-node-idPhase 4: Build Mermaid Diagrams
阶段4:构建Mermaid图表
Before writing diagrams, read .
references/svg-patterns.mdUse Mermaid for units and raw inline SVG only for mini-graphs that need click-sync. Keep node IDs consistent across pages, use descriptive labels, and do not inline theme overrides; the Raycast dark theme is configured in .
diagramcode-graphdata-node-idmermaid-bridge.js在编写图表之前,请阅读。
references/svg-patterns.mddiagramcode-graphdata-node-idmermaid-bridge.jsPhase 5: Generate Page List
阶段5:生成页面列表
| File | Skeleton | Condition |
|---|---|---|
| | Always |
| | Always |
| | Always |
| | One per non-default perspective |
| | One per discovered module |
All generated course files go in . Filenames are kebab-case except the fixed .
docs/codemermaid/index.htmlBefore generating HTML pages, copy shared assets to the output directory:
- Copy →
assets/style.cssdocs/codemermaid/style.css - Copy →
assets/runtime.jsdocs/codemermaid/runtime.js - Copy →
assets/beautiful-mermaid.bundle.jsdocs/codemermaid/beautiful-mermaid.bundle.js - Copy →
assets/mermaid-bridge.jsdocs/codemermaid/mermaid-bridge.js
These are linked by every generated HTML page.
| 文件 | 骨架模板 | 生成条件 |
|---|---|---|
| | 始终生成 |
| | 始终生成 |
| | 始终生成 |
| | 每个非默认视角生成一个 |
| | 每个发现的模块生成一个 |
所有生成的课程文件都放在目录中。文件名使用短横线分隔式(kebab-case),固定文件名除外。
docs/codemermaid/index.html在生成HTML页面之前,将共享资源复制到输出目录:
- 复制→
assets/style.cssdocs/codemermaid/style.css - 复制→
assets/runtime.jsdocs/codemermaid/runtime.js - 复制→
assets/beautiful-mermaid.bundle.jsdocs/codemermaid/beautiful-mermaid.bundle.js - 复制→
assets/mermaid-bridge.jsdocs/codemermaid/mermaid-bridge.js
这些资源会被每个生成的HTML页面链接。
Phase 6: Write HTML Pages
阶段6:编写HTML页面
For each page in the file list (Phase 5):
对于阶段5中的每个页面:
Assembly process
组装流程
- Read the skeleton template: or
assets/skeleton-essay.htmlassets/skeleton-index.html - Generate content HTML for each marker (see below)
<!-- SLOT:... --> - Replace all slots with their content HTML
- Pre-flight verification (mandatory — do not skip):
- Every points to an existing, non-blank line in its snippet
highlights[].line - Every code snippet is an exact copy from source (no invented lines, no reordered statements)
- No placeholders — all back/next links point to real files
href="#" - No markdown — use
**bold**instead<strong></strong> - Inside ,
<pre class="code-block">spans are adjacent with NO whitespace between them.line - Quiz has exactly 1 option with
data-correct="true" - No double HTML entity escaping — scan for or
&#or&lt;patterns and fix them&gt; - Mermaid syntax is valid — no unclosed brackets, no missing quotes in edge labels
- links to
index.htmlin the Perspectives sectionbuild-up.html - exists, starts with a
build-up.html, contains at least oneconcept, and ends with aquiztakeaway - Build-Up copy describes a learning order, not an unverified implementation chronology
- Every Build-Up step explains a capability change; it is not only a module inventory
- Every unit has
whoa,angle, andtitlebody - Every is
whoa.angle,code,product, oruxarchitecture - units use one visual treatment; no angle-specific color classes
whoa - Every rendered file action with points to a real source file path and includes a line number
data-copy-path
- Every
- Dispatch a subagent reviewer to validate the generated HTML
- Write the completed HTML to
docs/codemermaid/<filename>.html
- 读取骨架模板:或
assets/skeleton-essay.htmlassets/skeleton-index.html - 为每个标记生成内容HTML(见下文)
<!-- SLOT:... --> - 将所有插槽替换为对应的内容HTML
- 预飞验证(必填 — 切勿跳过):
- 每个指向其代码片段中存在的非空白行
highlights[].line - 每个代码片段都是源文件的精确副本(无虚构行,无重新排序的语句)
- 无占位符 — 所有上一页/下一页链接都指向真实文件
href="#" - 无格式的markdown — 使用
**bold**替代<strong></strong> - 在内,
<pre class="code-block">元素必须相邻,之间无空白.line - 测验恰好有一个选项带有
data-correct="true" - 无双重HTML实体转义 — 扫描、
&#或&lt;模式并修复&gt; - Mermaid语法有效 — 无未闭合的括号,无缺失引号的边标签
- 在Perspectives部分链接到
index.htmlbuild-up.html - 存在,以
build-up.html开头,包含至少一个concept,并以quiz结尾takeaway - Build-Up内容描述学习顺序,而非未经验证的实现时间线
- 每个Build-Up步骤解释功能变化;不仅仅是模块清单
- 每个单元包含
whoa、angle和titlebody - 每个取值为
whoa.angle、code、product或uxarchitecture - 单元使用一种视觉样式;无特定角度的颜色类
whoa - 每个带有的渲染文件操作指向真实源文件路径并包含行号
data-copy-path
- 每个
- 分配子代理审核员验证生成的HTML
- 写入完成的HTML到
docs/codemermaid/<filename>.html
Essay page slots
文章页面插槽
<!-- SLOT:HERO -->html
<section class="hero">
<div class="eyebrow">{PROJECT_NAME}</div>
<h1>{PAGE_TITLE}</h1>
<p class="learning-promise">{LEARNING_PROMISE}</p>
<ul class="prereqs">{PREREQ_CHIPS}</ul>
</section><!-- SLOT:TOC -->html
<nav class="toc">
<div class="toc-label">On this page</div>
<ol class="toc-list">
<li><a class="toc-item" href="#unit-0"><span class="toc-num">1</span>{TITLE}<span class="toc-kind">{KIND}</span></a></li>
<!-- one per unit -->
</ol>
</nav><!-- SLOT:UNITS --><section>html
<section class="unit unit-{KIND}" id="unit-{INDEX}">
<!-- unit content HTML -->
</section>For units, render:
whoahtml
<section class="unit unit-whoa" id="unit-{INDEX}" data-angle="{ANGLE}">
<div class="whoa-label">whoa · {ANGLE}</div>
<h2>{TITLE}</h2>
<p>{BODY}</p>
<div class="whoa-evidence">
<span>{EVIDENCE_ITEM}</span>
</div>
</section>Render only when evidence exists. Flatten evidence in this order: files, modules, interactions, constraints. Keep evidence text short enough to fit in a pill; use file basenames or repo-relative paths rather than long absolute paths inside evidence chips.
For evidence chips, repeat one per flattened evidence item.
.whoa-evidence<span>{EVIDENCE_ITEM}</span><!-- SLOT:FOOTER -->html
<footer class="page-footer">
<a class="next-link" href="{NEXT_LINK}">{NEXT_LABEL} →</a>
<p class="recap">{LEARNING_PROMISE_RECAP}</p>
</footer><!-- SLOT:HERO -->html
<section class="hero">
<div class="eyebrow">{PROJECT_NAME}</div>
<h1>{PAGE_TITLE}</h1>
<p class="learning-promise">{LEARNING_PROMISE}</p>
<ul class="prereqs">{PREREQ_CHIPS}</ul>
</section><!-- SLOT:TOC -->html
<nav class="toc">
<div class="toc-label">本页内容</div>
<ol class="toc-list">
<li><a class="toc-item" href="#unit-0"><span class="toc-num">1</span>{TITLE}<span class="toc-kind">{KIND}</span></a></li>
<!-- 每个单元对应一个 -->
</ol>
</nav><!-- SLOT:UNITS --><section>html
<section class="unit unit-{KIND}" id="unit-{INDEX}">
<!-- 单元内容HTML -->
</section>对于单元,渲染:
whoahtml
<section class="unit unit-whoa" id="unit-{INDEX}" data-angle="{ANGLE}">
<div class="whoa-label">whoa · {ANGLE}</div>
<h2>{TITLE}</h2>
<p>{BODY}</p>
<div class="whoa-evidence">
<span>{EVIDENCE_ITEM}</span>
</div>
</section>仅当存在证据时才渲染。按以下顺序展平证据:文件、模块、交互、约束。保持证据文本足够短以适应标签;在证据标签中使用文件名或仓库相对路径,而非长绝对路径。对于证据标签,每个展平的证据项对应一个。
.whoa-evidence<span>{EVIDENCE_ITEM}</span><!-- SLOT:FOOTER -->html
<footer class="page-footer">
<a class="next-link" href="{NEXT_LINK}">{NEXT_LABEL} →</a>
<p class="recap">{LEARNING_PROMISE_RECAP}</p>
</footer>Unit HTML templates
单元HTML模板
concept (normal):
html
<span class="unit-kind">concept</span>
<h2>{TITLE}</h2>
<p>{BODY}</p>concept (callout/surprise style):
html
<div class="unit-surprise">
<span class="unit-kind">concept</span>
<h2>{TITLE}</h2>
<p>{BODY}</p>
</div>quiz:
html
<div class="quiz">
<div class="quiz-question">{QUESTION}</div>
<div class="quiz-options">
<div class="quiz-option" data-correct="true"><span class="quiz-option-letter">A</span><span>{TEXT}</span></div>
<div class="quiz-option" data-correct="false"><span class="quiz-option-letter">B</span><span>{TEXT}</span></div>
<div class="quiz-option" data-correct="false"><span class="quiz-option-letter">C</span><span>{TEXT}</span></div>
<div class="quiz-option" data-correct="false"><span class="quiz-option-letter">D</span><span>{TEXT}</span></div>
</div>
<div class="quiz-explanation"><strong>Correct: {LETTER}</strong> — {EXPLANATION}</div>
</div>takeaway:
html
<div class="unit-takeaway">
<span class="unit-kind">takeaway</span>
<p>{BODY}</p>
</div>diagram:
html
<figure class="figure">
{ZOOMABLE ? '<button class="zoom-btn" data-zoom-trigger>Zoom</button>' : ''}
<div class="figure-diagram"><pre class="mermaid">{MERMAID_CODE}</pre></div>
<figcaption>{CAPTION}</figcaption>
</figure>code-walk (split layout):
html
<div class="codewalk-split">
<!-- Use the Code file action controls header from above when a real source path exists. Otherwise render a simple header with <span class="codewalk-file">{FILE}</span>. -->
<div class="codewalk-head"><span class="codewalk-file">{FILE}</span><span>{LANG}</span></div>
<div class="codewalk-split-body">
<pre class="code-block">{LINES}</pre>
<div class="codewalk-annotations">{ANNOTATIONS}</div>
</div>
</div>Each line:
<span class="line{? line-hl}" data-line="{N}"><span class="ln">{N}</span><span class="code-text">{CODE}</span></span>CRITICAL: spans inside MUST be adjacent with NO whitespace (newlines, spaces) between them.
.line<pre>Each annotation:
<div class="codewalk-annotation" data-note-lines="{LINES}"><span class="annotation-line">L{N}</span><p>{NOTE}</p></div>code-graph:
html
<div class="codegraph-split">
<!-- Use the Code file action controls header from above when a real source path exists. Otherwise render a simple header with <span class="codewalk-file">{FILE}</span>. -->
<div class="codewalk-head"><span class="codewalk-file">{FILE}</span><span>{LANG}</span></div>
<div class="codegraph-split-body">
<pre class="code-block">{LINES with data-graph-node}</pre>
<div class="codegraph-graph">{SVG}</div>
</div>
</div>Code lines with graph binding:
<span class="line{? line-hl}" data-line="{N}" data-graph-node="{NODE_ID}"><span class="ln">{N}</span><span class="code-text">{CODE}</span></span>concept(普通样式):
html
<span class="unit-kind">concept</span>
<h2>{TITLE}</h2>
<p>{BODY}</p>concept(提示/惊喜样式):
html
<div class="unit-surprise">
<span class="unit-kind">concept</span>
<h2>{TITLE}</h2>
<p>{BODY}</p>
</div>quiz:
html
<div class="quiz">
<div class="quiz-question">{QUESTION}</div>
<div class="quiz-options">
<div class="quiz-option" data-correct="true"><span class="quiz-option-letter">A</span><span>{TEXT}</span></div>
<div class="quiz-option" data-correct="false"><span class="quiz-option-letter">B</span><span>{TEXT}</span></div>
<div class="quiz-option" data-correct="false"><span class="quiz-option-letter">C</span><span>{TEXT}</span></div>
<div class="quiz-option" data-correct="false"><span class="quiz-option-letter">D</span><span>{TEXT}</span></div>
</div>
<div class="quiz-explanation"><strong>正确答案:{LETTER}</strong> — {EXPLANATION}</div>
</div>takeaway:
html
<div class="unit-takeaway">
<span class="unit-kind">takeaway</span>
<p>{BODY}</p>
</div>diagram:
html
<figure class="figure">
{ZOOMABLE ? '<button class="zoom-btn" data-zoom-trigger>放大</button>' : ''}
<div class="figure-diagram"><pre class="mermaid">{MERMAID_CODE}</pre></div>
<figcaption>{CAPTION}</figcaption>
</figure>code-walk(拆分布局):
html
<div class="codewalk-split">
<!-- 当存在真实源路径时,使用上述代码文件操作控件头部。否则渲染简单头部:<span class="codewalk-file">{FILE}</span>。 -->
<div class="codewalk-head"><span class="codewalk-file">{FILE}</span><span>{LANG}</span></div>
<div class="codewalk-split-body">
<pre class="code-block">{LINES}</pre>
<div class="codewalk-annotations">{ANNOTATIONS}</div>
</div>
</div>每行代码:
<span class="line{? line-hl}" data-line="{N}"><span class="ln">{N}</span><span class="code-text">{CODE}</span></span>关键注意事项: 内的元素必须相邻,之间无空白(换行符、空格)。
<pre>.line每个注释:
<div class="codewalk-annotation" data-note-lines="{LINES}"><span class="annotation-line">第{N}行</span><p>{NOTE}</p></div>code-graph:
html
<div class="codegraph-split">
<!-- 当存在真实源路径时,使用上述代码文件操作控件头部。否则渲染简单头部:<span class="codewalk-file">{FILE}</span>。 -->
<div class="codewalk-head"><span class="codewalk-file">{FILE}</span><span>{LANG}</span></div>
<div class="codegraph-split-body">
<pre class="code-block">{LINES with data-graph-node}</pre>
<div class="codegraph-graph">{SVG}</div>
</div>
</div>带有图绑定的代码行:
<span class="line{? line-hl}" data-line="{N}" data-graph-node="{NODE_ID}"><span class="ln">{N}</span><span class="code-text">{CODE}</span></span>Index page slots
索引页面插槽
<!-- SLOT:INDEX_HEADER -->html
<div class="project-header">
<h1>{PROJECT_NAME}</h1>
<p>{PROJECT_DESCRIPTION}</p>
<div class="badges">
<span class="badge">{LANGUAGE}</span>
{FRAMEWORK_BADGE}
</div>
</div><!-- SLOT:ARCHITECTURE_DIAGRAM -->html
<div class="section">
<div class="section-title">Architecture</div>
<figure class="figure">
<div class="figure-diagram"><pre class="mermaid">{MERMAID_CODE}</pre></div>
<figcaption>{CAPTION}</figcaption>
</figure>
</div><!-- SLOT:PERSPECTIVE_CARDS -->html
<div class="section">
<div class="section-title">Perspectives</div>
<div class="card-grid">
<a class="card" href="{PAGE}"><span class="card-type">perspective</span><h3>{TITLE}</h3><p>{DESCRIPTION}</p><div class="card-meta">{N} units</div></a>
</div>
</div>Perspective cards should list default perspectives first: Architecture Overview, then Build-Up Walkthrough, followed by user-requested and auto-inferred perspectives. The Build-Up card must link to and describe the gradual route from smallest useful capability to complete system.
build-up.html<!-- SLOT:MODULE_CARDS -->html
<div class="section">
<div class="section-title">Module Deep Dives</div>
<div class="card-grid">
<a class="card" href="module-{NAME}.html"><span class="card-type">module</span><h3>{TITLE}</h3><p>{DESCRIPTION}</p><div class="card-meta">{N} units</div></a>
</div>
</div><!-- SLOT:INDEX_HEADER -->html
<div class="project-header">
<h1>{PROJECT_NAME}</h1>
<p>{PROJECT_DESCRIPTION}</p>
<div class="badges">
<span class="badge">{LANGUAGE}</span>
{FRAMEWORK_BADGE}
</div>
</div><!-- SLOT:ARCHITECTURE_DIAGRAM -->html
<div class="section">
<div class="section-title">架构</div>
<figure class="figure">
<div class="figure-diagram"><pre class="mermaid">{MERMAID_CODE}</pre></div>
<figcaption>{CAPTION}</figcaption>
</figure>
</div><!-- SLOT:PERSPECTIVE_CARDS -->html
<div class="section">
<div class="section-title">视角</div>
<div class="card-grid">
<a class="card" href="{PAGE}"><span class="card-type">perspective</span><h3>{TITLE}</h3><p>{DESCRIPTION}</p><div class="card-meta">{N}个单元</div></a>
</div>
</div>视角卡片应先列出默认视角:架构概览,然后是Build-Up导览,接着是用户请求和自动推断的视角。Build-Up卡片必须链接到,并描述从最小可用功能到完整系统的渐进式学习路径。
build-up.html<!-- SLOT:MODULE_CARDS -->html
<div class="section">
<div class="section-title">模块深度解析</div>
<div class="card-grid">
<a class="card" href="module-{NAME}.html"><span class="card-type">module</span><h3>{TITLE}</h3><p>{DESCRIPTION}</p><div class="card-meta">{N}个单元</div></a>
</div>
</div>Design System
设计系统
Use the bundled Raycast-inspired dark theme in . For visual rationale and token guidance, read and .
assets/style.cssDESIGN.mdreferences/design-system.md使用中捆绑的Raycast风格深色主题。如需了解视觉原理和令牌指南,请阅读和。
assets/style.cssDESIGN.mdreferences/design-system.mdImportant Rules
重要规则
- Read Build-Up reference — before creating or a module-level Build-Up section, read
build-up.html.references/build-up.md - Default perspectives — always generate and
architecture.html.build-up.html - Real code only — never invent, simplify, or modify code snippets.
- Cover every module — every module discovered in Phase 1 must appear in at least one perspective page AND have its own .
module-<name>.html - Linked shared assets — copy ,
style.css,runtime.js, andbeautiful-mermaid.bundle.jsto the output directory. Each HTML links them viamermaid-bridge.jsand<link>.<script src> - Vanilla JS only — no React, no build tools.
- beautiful-mermaid via browser bundle — all units use Mermaid syntax rendered by the beautiful-mermaid browser bundle +
diagram.mermaid-bridge.jsmini-graphs use raw SVG forcode-graphclick-sync.data-node-id - Build-Up is learning order — describe capability increments in the order that teaches the system, not unverified git or implementation history.
- Module-level Build-Up is optional — include it only when the module has a natural internal progression. Do not force it into every module page.
- Pre whitespace rule — inside ,
<pre class="code-block">spans must be adjacent with NO whitespace between them..line - Quiz correctness — every quiz must have exactly 1 option with .
data-correct="true" - Consistent node IDs — same module = same node ID across all pages.
- User perspective overrides — user-specified perspectives are mandatory; auto-inferred are supplementary.
- Annotation alignment — the runtime's handles vertical positioning. CSS
alignAnnotations()ongapmust be.codewalk-annotations.0
- 阅读Build-Up参考文档 — 在创建或模块级Build-Up部分之前,请阅读
build-up.html。references/build-up.md - 默认视角 — 始终生成和
architecture.html。build-up.html - 仅使用真实代码 — 切勿发明、简化或修改代码片段。
- 覆盖所有模块 — 阶段1中发现的每个模块必须至少出现在一个视角页面中,并且拥有自己的页面。
module-<name>.html - 链接共享资源 — 将、
style.css、runtime.js和beautiful-mermaid.bundle.js复制到输出目录。每个HTML页面通过mermaid-bridge.js和<link>链接它们。<script src> - 仅使用原生JS — 不使用React,不使用构建工具。
- 通过浏览器包使用beautiful-mermaid — 所有单元使用Mermaid语法,由beautiful-mermaid浏览器包 +
diagram渲染。mermaid-bridge.js迷你图使用原始SVG实现code-graph点击同步。data-node-id - Build-Up是学习顺序 — 按便于读者学习系统的顺序描述功能增量,而非未经验证的git或实现历史。
- 模块级Build-Up是可选的 — 仅当模块具有自然的内部演进逻辑时才包含。不要强行添加到每个模块页面。
- 预空白规则 — 在内,
<pre class="code-block">元素必须相邻,之间无空白。.line - 测验正确性 — 每个测验必须恰好有一个选项带有。
data-correct="true" - 一致的节点ID — 同一模块在所有页面中使用相同的节点ID。
- 用户视角优先 — 用户指定的视角是必填项;自动推断的视角是补充项。
- 注释对齐 — 运行时的处理垂直定位。
alignAnnotations()的CSS.codewalk-annotations必须为gap。0
Common Mistakes
常见错误
| Mistake | Fix |
|---|---|
Missing | Always generate the required Build-Up Walkthrough perspective and link it from |
| Build-Up reads like git history | Reframe it as reader learning order unless git history was explicitly inspected and cited. |
| Build-Up is just a module list | Rewrite each step around a capability change and name the code that makes the change possible. |
| Forced module-level Build-Up | Remove it when a normal code-walk teaches the module more clearly. |
| Blank lines between code lines | |
| Highlight points to wrong line | Count lines within the extracted snippet, not the original source file. |
| Code snippet has invented lines | Paste the snippet back into a temp file and run the type checker. |
| Replace with actual relative paths. Never leave placeholder links. |
| Side-by-side code looks cramped | Ensure |
| Quiz has no correct answer | Exactly 1 option must have |
| Double HTML entity escaping | Scan output for |
| Mermaid edge label missing quotes | Use pipe syntax: `A --> |
| Annotations not aligned with code | Confirm CSS |
| beautiful-mermaid not rendering | Ensure |
| 错误 | 修复方案 |
|---|---|
缺失 | 始终生成必填的Build-Up导览视角,并从 |
| Build-Up内容读起来像git历史 | 将其重构为读者学习顺序,除非明确检查并引用了git历史。 |
| Build-Up只是模块列表 | 围绕功能重写每个步骤,并说明实现该功能的代码。 |
| 强行添加模块级Build-Up | 当普通code-walk能更清晰地讲解模块时,移除该部分。 |
| 代码行之间存在空白行 | |
| 高亮指向错误行 | 统计提取的代码片段内的行号,而非原始源文件的行号。 |
| 代码片段包含虚构行 | 将片段粘贴到临时文件并运行类型检查器。 |
链接中存在 | 替换为实际相对路径。切勿保留占位符链接。 |
| 并排代码看起来拥挤 | 确保应用了 |
| 测验没有正确答案 | 必须恰好有一个选项带有 |
| 双重HTML实体转义 | 扫描输出中的 |
| Mermaid边标签缺失引号 | 使用管道语法:`A --> |
| 注释与代码未对齐 | 确认CSS |
| beautiful-mermaid未渲染 | 确保 |
File Organization
文件组织
skills/codemermaid/
SKILL.md
DESIGN.md
references/
design-system.md
svg-patterns.md
subagent-generation.md
units-examples.md
voice-examples.md
assets/
skeleton-essay.html
skeleton-index.html
style.css
runtime.js
beautiful-mermaid.bundle.js
mermaid-bridge.jsskills/codemermaid/
SKILL.md
DESIGN.md
references/
design-system.md
svg-patterns.md
subagent-generation.md
units-examples.md
voice-examples.md
assets/
skeleton-essay.html
skeleton-index.html
style.css
runtime.js
beautiful-mermaid.bundle.js
mermaid-bridge.jsRelationship to Other Skills
与其他技能的关系
- presentation — Slidev-based slides (slide deck). Use for interactive exploration,
codemermaidfor linear slide-based talks.presentation - codebase-to-course — single-page HTML course. Use for multi-page interactive sites,
codemermaidfor single-page courses.codebase-to-course
- presentation — 基于Slidev的幻灯片(演示文稿)。使用进行交互式探索,使用
codemermaid进行线性幻灯片演示。presentation - codebase-to-course — 单页HTML课程。使用生成多页交互式站点,使用
codemermaid生成单页课程。codebase-to-course