markdown-mermaid-writing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Markdown and Mermaid Writing

Markdown与Mermaid撰写指南

Overview

概述

This skill teaches you — and enforces a standard for — creating scientific documentation using markdown with embedded Mermaid diagrams as the default and canonical format.
The core bet: a relationship expressed as a Mermaid diagram inside a
.md
file is more valuable than any image. It is text, so it diffs cleanly in git. It requires no build step. It renders natively on GitHub, GitLab, Notion, VS Code, and any markdown viewer. It uses fewer tokens than a prose description of the same relationship. And it can always be converted to a polished image later — but the text version remains the source of truth.
"The more you get your reports and files in .md in just regular text, which mermaid is as well as being a simple 'script language'. This just helps with any downstream rendering and especially AI generated images (using mermaid instead of just long form text to describe relationships < tokens). Additionally mermaid can render along with markdown for easy use almost anywhere by humans or AI."
— Clayton Young (@borealBytes), community discussion, 2026-02-19
本技能将教会你——并强制执行一套标准——如何使用嵌入Mermaid图表的Markdown作为默认且权威的格式创建科学文档。
核心理念:在
.md
文件中用Mermaid图表表达的关系,比任何图片都更具价值。它是文本格式,在git中能清晰显示差异;无需构建步骤;可在GitHub、GitLab、Notion、VS Code及任何Markdown查看器中原生渲染;相比用散文式描述表达相同关系,它占用的token更少;而且它随时可以转换为精美的图片——但文本版本始终是事实来源。
“你越是将报告和文件以纯文本的.md格式保存(Mermaid也属于一种简单的‘脚本语言’),就越有助于后续的渲染工作,尤其是AI生成图像(用Mermaid代替长篇文本描述关系,token消耗更少)。此外,Mermaid可与Markdown一起渲染,方便人类或AI在几乎任何场景下使用。”
——Clayton Young (@borealBytes),社区讨论,2026-02-19

When to Use This Skill

何时使用本技能

Use this skill when:
  • Creating any scientific document — reports, analyses, manuscripts, methods sections
  • Writing any documentation — READMEs, how-tos, decision records, project docs
  • Producing any diagram — workflows, data pipelines, architectures, timelines, relationships
  • Generating any output that will be version-controlled — if it's going into git, it should be markdown
  • Working with any other skill — this skill defines the documentation layer that wraps every other output
  • Someone asks you to "add a diagram" or "visualize the relationship" — Mermaid first, always
Do NOT start with Python matplotlib, seaborn, or AI image generation for structural or relational diagrams. Those are Phase 2 and Phase 3 — only used when Mermaid cannot express what's needed (e.g., scatter plots with real data, photorealistic images).
在以下场景中使用本技能:
  • 创建任何科学文档——报告、分析、手稿、方法章节
  • 编写任何文档——README、操作指南、决策记录、项目文档
  • 制作任何图表——工作流、数据管道、架构、时间线、关系图
  • 生成任何需要版本控制的输出内容——如果要存入git,就应该用Markdown格式
  • 任何其他技能配合使用——本技能定义了包裹所有其他输出内容的文档层
  • 有人要求你“添加图表”或“可视化关系”时——优先使用Mermaid,始终如此
不要一开始就用Python的matplotlib、seaborn或AI图像生成工具来创建结构或关系型图表。这些属于第二阶段和第三阶段——仅当Mermaid无法表达所需内容时才使用(例如带真实数据的散点图、逼真图像)。

🎨 The Source Format Philosophy

🎨 源格式理念

Why text-based diagrams win

基于文本的图表为何更优

What mattersMermaid in MarkdownPython / AI Image
Git diff readable❌ binary blob
Editable without regenerating
Token efficient vs. prose✅ smaller❌ larger
Renders without a build step❌ needs hosting
Parseable by AI without vision
Works in GitHub / GitLab / Notion⚠️ if hosted
Accessible (screen readers)✅ accTitle/accDescr⚠️ needs alt text
Convertible to image later✅ anytime— already image
关键特性Markdown中的MermaidPython/AI生成图像
Git差异可读性❌ 二进制大对象
无需重新生成即可编辑
相比散文式描述更节省token✅ 占用更少❌ 占用更多
无需构建步骤即可渲染❌ 需要托管
无需视觉能力即可被AI解析
在GitHub/GitLab/Notion中可用⚠️ 需托管
可访问性(屏幕阅读器)✅ 支持accTitle/accDescr⚠️ 需要替代文本
可随时转换为图像✅ 任何时候—— 已是图像

The three-phase workflow

三阶段工作流

mermaid
flowchart LR
    accTitle: Three-Phase Documentation Workflow
    accDescr: Phase 1 Mermaid in markdown is always required and is the source of truth. Phases 2 and 3 are optional downstream conversions for polished output.

    p1["📄 Phase 1<br/>Mermaid in Markdown<br/>(ALWAYS — source of truth)"]
    p2["🐍 Phase 2<br/>Python Generated<br/>(optional — data charts)"]
    p3["🎨 Phase 3<br/>AI Generated Visuals<br/>(optional — polish)"]
    out["📊 Final Deliverable"]

    p1 --> out
    p1 -.->|"when needed"| p2
    p1 -.->|"when needed"| p3
    p2 --> out
    p3 --> out

    classDef required fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
    classDef optional fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
    classDef output fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d

    class p1 required
    class p2,p3 optional
    class out output
Phase 1 is mandatory. Even if you proceed to Phase 2 or 3, the Mermaid source stays committed.
mermaid
flowchart LR
    accTitle: Three-Phase Documentation Workflow
    accDescr: Phase 1 Mermaid in markdown is always required and is the source of truth. Phases 2 and 3 are optional downstream conversions for polished output.

    p1["📄 Phase 1<br/>Mermaid in Markdown<br/>(ALWAYS — source of truth)"]
    p2["🐍 Phase 2<br/>Python Generated<br/>(optional — data charts)"]
    p3["🎨 Phase 3<br/>AI Generated Visuals<br/>(optional — polish)"]
    out["📊 Final Deliverable"]

    p1 --> out
    p1 -.->|"when needed"| p2
    p1 -.->|"when needed"| p3
    p2 --> out
    p3 --> out

    classDef required fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
    classDef optional fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
    classDef output fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d

    class p1 required
    class p2,p3 optional
    class out output
第一阶段是强制性的。即使你进入第二或第三阶段,Mermaid源文件也必须保留并提交。

What Mermaid can express

Mermaid可表达的内容

Mermaid covers 24 diagram types. Almost every scientific relationship fits one:
Use caseDiagram typeFile
Experimental workflow / decision logicFlowchart
references/diagrams/flowchart.md
Service interactions / API calls / messagingSequence
references/diagrams/sequence.md
Data model / schemaER diagram
references/diagrams/er.md
State machine / lifecycleState
references/diagrams/state.md
Project timeline / roadmapGantt
references/diagrams/gantt.md
Proportions / compositionPie
references/diagrams/pie.md
System architecture (zoom levels)C4
references/diagrams/c4.md
Concept hierarchy / brainstormMindmap
references/diagrams/mindmap.md
Chronological events / historyTimeline
references/diagrams/timeline.md
Class hierarchy / type relationshipsClass
references/diagrams/class.md
User journey / satisfaction mapUser Journey
references/diagrams/user_journey.md
Two-axis comparison / prioritizationQuadrant
references/diagrams/quadrant.md
Requirements traceabilityRequirement
references/diagrams/requirement.md
Flow magnitude / resource distributionSankey
references/diagrams/sankey.md
Numeric trends / bar + line chartsXY Chart
references/diagrams/xy_chart.md
Component layout / spatial arrangementBlock
references/diagrams/block.md
Work item status / task columnsKanban
references/diagrams/kanban.md
Cloud infrastructure / service topologyArchitecture
references/diagrams/architecture.md
Multi-dimensional comparison / skills radarRadar
references/diagrams/radar.md
Hierarchical proportions / budgetTreemap
references/diagrams/treemap.md
Binary protocol / data formatPacket
references/diagrams/packet.md
Git branching / merge strategyGit Graph
references/diagrams/git_graph.md
Code-style sequence (programming syntax)ZenUML
references/diagrams/zenuml.md
Multi-diagram composition patternsComplex Examples
references/diagrams/complex_examples.md
💡 Pick the right type, not the easy one. Don't default to flowcharts for everything. A timeline beats a flowchart for chronological events. A sequence beats a flowchart for service interactions. Scan the table and match.

Mermaid支持24种图表类型。几乎所有科学关系都能找到对应的类型:
使用场景图表类型文件路径
实验工作流/决策逻辑流程图
references/diagrams/flowchart.md
服务交互/API调用/消息传递序列图
references/diagrams/sequence.md
数据模型/schemaER图
references/diagrams/er.md
状态机/生命周期状态图
references/diagrams/state.md
项目时间线/路线图甘特图
references/diagrams/gantt.md
比例/构成饼图
references/diagrams/pie.md
系统架构(缩放层级)C4图
references/diagrams/c4.md
概念层级/头脑风暴思维导图
references/diagrams/mindmap.md
时序事件/历史时间线图
references/diagrams/timeline.md
类层级/类型关系类图
references/diagrams/class.md
用户旅程/满意度地图用户旅程图
references/diagrams/user_journey.md
双轴对比/优先级排序象限图
references/diagrams/quadrant.md
需求可追溯性需求图
references/diagrams/requirement.md
流大小/资源分布桑基图
references/diagrams/sankey.md
数值趋势/柱状+折线图XY图表
references/diagrams/xy_chart.md
组件布局/空间排列块图
references/diagrams/block.md
工作项状态/任务列看板图
references/diagrams/kanban.md
云基础设施/服务拓扑架构图
references/diagrams/architecture.md
多维对比/技能雷达雷达图
references/diagrams/radar.md
层级比例/预算树状图
references/diagrams/treemap.md
二进制协议/数据格式数据包图
references/diagrams/packet.md
Git分支/合并策略Git图
references/diagrams/git_graph.md
代码风格序列(编程语法)ZenUML
references/diagrams/zenuml.md
多图表组合模式复杂示例
references/diagrams/complex_examples.md
💡 选择合适的类型,而非简单的类型。不要什么都默认用流程图。对于时序事件,时间线图比流程图更合适;对于服务交互,序列图比流程图更合适。浏览上表,匹配对应的类型。

🔧 Core workflow

🔧 核心工作流

Step 1: Identify the document type

步骤1:确定文档类型

Check if a template exists before writing from scratch:
Document typeTemplate
Pull request record
templates/pull_request.md
Issue / bug / feature request
templates/issue.md
Sprint / project board
templates/kanban.md
Architecture decision (ADR)
templates/decision_record.md
Presentation / briefing
templates/presentation.md
Research paper / analysis
templates/research_paper.md
Project documentation
templates/project_documentation.md
How-to / tutorial
templates/how_to_guide.md
Status report
templates/status_report.md
在从头开始撰写前,先检查是否有可用的模板:
文档类型模板路径
拉取请求记录
templates/pull_request.md
问题/bug/功能请求
templates/issue.md
迭代/项目看板
templates/kanban.md
架构决策记录(ADR)
templates/decision_record.md
演示/简报
templates/presentation.md
研究论文/分析报告
templates/research_paper.md
项目文档
templates/project_documentation.md
操作指南/教程
templates/how_to_guide.md
状态报告
templates/status_report.md

Step 2: Read the style guide

步骤2:阅读样式指南

Before writing any
.md
file: read
references/markdown_style_guide.md
.
Key rules to internalize:
  • One H1 per document — the title. Never more.
  • Emoji on H2 headings only — one emoji per H2, none in H3/H4
  • Cite everything — every external claim gets a footnote
    [^N]
    with full URL
  • Bold sparingly — max 2-3 bold terms per paragraph, never full sentences
  • Horizontal rule after every
    </details>
    — mandatory
  • Tables over prose for comparisons, configurations, structured data
  • Diagrams over walls of text — if it describes flow, structure, or relationships, add Mermaid
在撰写任何
.md
文件前:阅读
references/markdown_style_guide.md
需要牢记的关键规则:
  • 每个文档仅一个H1标题——即文档标题,绝不能有多个。
  • 仅在H2标题中使用表情符号——每个H2标题一个表情符号,H3/H4中不使用。
  • 所有内容都要引用——每个外部观点都要添加脚注
    [^N]
    并附上完整URL。
  • 谨慎使用粗体——每段最多2-3个粗体术语,绝不要整句加粗。
  • 每个
    </details>
    标签后必须添加水平分隔线
    ——强制性要求。
  • 对比、配置、结构化数据优先使用表格而非散文式描述。
  • 图表优先于大段文本——如果内容涉及流程、结构或关系,就添加Mermaid图表。

Step 3: Pick the diagram type and read its guide

步骤3:选择图表类型并阅读对应指南

Before creating any Mermaid diagram: read
references/mermaid_style_guide.md
.
Then open the specific type file (e.g.,
references/diagrams/flowchart.md
) for the exemplar, tips, and copy-paste template.
Mandatory rules for every diagram:
accTitle: Short Name 3-8 Words
accDescr: One or two sentences explaining what this diagram shows.
  • No
    %%{init}
    directives
    — breaks GitHub dark mode
  • No inline
    style
    — use
    classDef
    only
  • One emoji per node max — at the start of the label
  • snake_case
    node IDs
    — match the label
在创建任何Mermaid图表前:阅读
references/mermaid_style_guide.md
然后打开对应类型的文件(例如
references/diagrams/flowchart.md
),查看示例、技巧和可复制粘贴的模板。
每个图表必须遵守的规则:
accTitle: 3-8字的简短名称
accDescr: 1-2句话解释该图表展示的内容。
  • 禁止使用
    %%{init}
    指令
    ——会破坏GitHub深色模式。
  • 禁止使用内联
    style
    ——仅使用
    classDef
  • 每个节点最多一个表情符号——放在标签开头。
  • 节点ID使用
    snake_case
    命名
    ——与标签匹配。

Step 4: Write the document

步骤4:撰写文档

Start from the template. Apply the markdown style guide. Place diagrams inline with related text — not in a separate "Figures" section.
从模板开始撰写。应用Markdown样式指南。将图表与相关文本内联放置——不要放在单独的“图表”章节中。

Step 5: Commit as text

步骤5:以文本形式提交

The
.md
file with embedded Mermaid is what gets committed. If you also generated a PNG or AI image, those are supplementary — the markdown is the source.

嵌入Mermaid的
.md
文件是需要提交的内容。如果你还生成了PNG或AI图像,这些只是补充内容——Markdown文件才是源文件。

⚠️ Common pitfalls

⚠️ 常见陷阱

Radar chart syntax (
radar-beta
)

雷达图语法(
radar-beta

WRONG:
mermaid
radar
title Example
x-axis ["A", "B", "C"]
"Series" : [1, 2, 3]
CORRECT:
mermaid
radar-beta
title Example
axis a["A"], b["B"], c["C"]
curve series["Series"]{1, 2, 3}
max 3
  • Use
    radar-beta
    not
    radar
    (the bare keyword doesn't exist)
  • Use
    axis
    to define dimensions, not
    x-axis
  • Use
    curve
    to define data series, not quoted labels with colon
  • No
    accTitle
    /
    accDescr
    — radar-beta doesn't support accessibility annotations; always add a descriptive italic paragraph above the diagram
错误写法:
mermaid
radar
title Example
x-axis ["A", "B", "C"]
"Series" : [1, 2, 3]
正确写法:
mermaid
radar-beta
title Example
axis a["A"], b["B"], c["C"]
curve series["Series"]{1, 2, 3}
max 3
  • **使用
    radar-beta
    **而非
    radar
    (后者不存在)
  • **使用
    axis
    **定义维度,不要使用
    x-axis
  • **使用
    curve
    **定义数据系列,不要使用带冒号的引号标签
  • 不要添加
    accTitle
    /
    accDescr
    ——radar-beta不支持无障碍注释;务必在图表上方添加一段描述性的斜体文字

XY Chart vs Radar confusion

XY图表与雷达图的混淆

DiagramKeywordAxis syntaxData syntax
XY Chart (bars/lines)
xychart-beta
x-axis ["Label1", "Label2"]
bar [10, 20]
or
line [10, 20]
Radar (spider/web)
radar-beta
axis id["Label"]
curve id["Label"]{10, 20}
图表关键字轴语法数据语法
XY图表(柱状/折线)
xychart-beta
x-axis ["Label1", "Label2"]
bar [10, 20]
line [10, 20]
雷达图(蜘蛛/网状)
radar-beta
axis id["Label"]
curve id["Label"]{10, 20}

Forgetting
accTitle
/
accDescr
on supported types

忘记在支持的类型中添加
accTitle
/
accDescr

Only some diagram types support
accTitle
/
accDescr
. For those that don't, always place a descriptive italic paragraph directly above the code block:
Radar chart comparing three methods across five performance dimensions. Note: Radar charts do not support accTitle/accDescr.
mermaid
radar-beta
...

只有部分图表类型支持
accTitle
/
accDescr
。对于不支持的类型,务必在代码块上方直接添加一段描述性的斜体文字:
雷达图比较了三种方法在五个性能维度上的表现。注意:雷达图不支持accTitle/accDescr。
mermaid
radar-beta
...

🔗 Integration with other skills

🔗 与其他技能的集成

With
scientific-schematics

scientific-schematics
集成

scientific-schematics
generates AI-powered publication-quality images (PNG). Use the Mermaid diagram as the brief for the schematic:
Workflow:
1. Create the concept as Mermaid in .md (this skill — Phase 1)
2. Describe the same concept to scientific-schematics for a polished PNG (Phase 3)
3. Commit both — the .md as source, the PNG as a supplementary figure
scientific-schematics
可生成AI驱动的出版物级图像(PNG)。将Mermaid图表作为示意图的概要
工作流:
1. 用本技能将概念创建为.md文件中的Mermaid图表(第一阶段)
2. 向scientific-schematics描述同一概念以生成精美的PNG(第三阶段)
3. 同时提交两者——.md文件作为源文件,PNG作为补充图表

With
scientific-writing

scientific-writing
集成

When
scientific-writing
produces a manuscript, all diagrams and structural figures should use this skill's standards. The writing skill handles prose and citations; this skill handles visual structure.
Workflow:
1. Use scientific-writing to draft the manuscript
2. For every figure that shows a workflow, architecture, or relationship:
   - Replace placeholder with a Mermaid diagram following this skill's guide
3. Use scientific-schematics only for figures that truly need photorealistic/complex rendering
scientific-writing
生成手稿时,所有图表和结构图形都应遵循本技能的标准。写作技能负责散文内容和引用;本技能负责视觉结构。
工作流:
1. 使用scientific-writing起草手稿
2. 对于每个展示工作流、架构或关系的图表:
   - 按照本技能的指南,用Mermaid图表替换占位符
3. 仅当图表确实需要逼真/复杂渲染时,才使用scientific-schematics

With
literature-review

literature-review
集成

Literature review produces summaries with lots of relationship data. Use this skill to:
  • Create concept maps (Mindmap) of the literature landscape
  • Show publication timelines (Timeline or Gantt)
  • Compare methodologies (Quadrant or Radar)
  • Diagram data flows described in papers (Sequence or Flowchart)
文献综述会生成包含大量关系数据的摘要。使用本技能可以:
  • 创建文献格局的概念图(思维导图)
  • 展示出版时间线(时间线图或甘特图)
  • 比较方法论(象限图或雷达图)
  • 绘制论文中描述的数据流(序列图或流程图)

With any skill that produces output documents

与任何生成输出文档的技能集成

Before finalizing any document from any skill, apply this skill's checklist:
  • Does the document use a template? If so, did I start from the right one?
  • Are all diagrams in Mermaid with
    accTitle
    +
    accDescr
    ?
  • No
    %%{init}
    , no inline
    style
    , only
    classDef
    ?
  • Are all external claims cited with
    [^N]
    ?
  • One H1, emoji on H2 only?
  • Horizontal rules after every
    </details>
    ?

在最终确定任何技能生成的文档前,应用本技能的检查清单:
  • 文档是否使用了模板?如果是,是否从正确的模板开始?
  • 所有图表是否都是带
    accTitle
    +
    accDescr
    的Mermaid图表?
  • 没有
    %%{init}
    ,没有内联
    style
    ,仅使用
    classDef
  • 所有外部观点是否都用
    [^N]
    引用了?
  • 仅一个H1标题,仅H2标题带表情符号?
  • 每个
    </details>
    标签后都有水平分隔线?

📚 Reference index

📚 参考索引

Style guides

样式指南

GuidePathLinesWhat it covers
Markdown Style Guide
references/markdown_style_guide.md
~733Headings, formatting, citations, tables, Mermaid integration, templates, quality checklist
Mermaid Style Guide
references/mermaid_style_guide.md
~458Accessibility, emoji set, color classes, theme neutrality, type selection, complexity tiers
指南路径行数涵盖内容
Markdown样式指南
references/markdown_style_guide.md
~733标题、格式、引用、表格、Mermaid集成、模板、质量检查清单
Mermaid样式指南
references/mermaid_style_guide.md
~458可访问性、表情符号集、颜色类、主题中立性、类型选择、复杂度层级

Diagram type guides (24 types)

图表类型指南(24种)

Each file contains: production-quality exemplar, tips specific to that type, and a copy-paste template.
references/diagrams/
— architecture, block, c4, class, complex_examples, er, flowchart, gantt, git_graph, kanban, mindmap, packet, pie, quadrant, radar, requirement, sankey, sequence, state, timeline, treemap, user_journey, xy_chart, zenuml
每个文件包含:生产级示例、特定类型的技巧、可复制粘贴的模板。
references/diagrams/
— architecture, block, c4, class, complex_examples, er, flowchart, gantt, git_graph, kanban, mindmap, packet, pie, quadrant, radar, requirement, sankey, sequence, state, timeline, treemap, user_journey, xy_chart, zenuml

Document templates (9 types)

文档模板(9种)

templates/
— decision_record, how_to_guide, issue, kanban, presentation, project_documentation, pull_request, research_paper, status_report
templates/
— decision_record, how_to_guide, issue, kanban, presentation, project_documentation, pull_request, research_paper, status_report

Examples

示例

assets/examples/example-research-report.md
— a complete scientific research report demonstrating proper heading hierarchy, multiple diagram types (flowchart, sequence, gantt), tables, footnote citations, collapsible sections, and all style guide rules applied.

assets/examples/example-research-report.md
— 一份完整的科学研究报告,展示了正确的标题层级、多种图表类型(流程图、序列图、甘特图)、表格、脚注引用、可折叠章节以及所有样式指南规则的应用。

📝 Attribution

📝 署名

All style guides, diagram type guides, and document templates in this skill are ported from the
SuperiorByteWorks-LLC/agent-project
repository under the Apache-2.0 License.
This skill (as part of academic-skills) is distributed under the MIT License. The included Apache-2.0 content is compatible for downstream use with attribution retained, as preserved in the file headers throughout this skill.

本技能中的所有样式指南、图表类型指南和文档模板均源自
SuperiorByteWorks-LLC/agent-project
仓库,遵循Apache-2.0许可证。
本技能(作为academic-skills的一部分)以MIT许可证分发。所包含的Apache-2.0许可内容可兼容下游使用,需保留署名,正如本技能中所有文件头所保留的那样。