agentleFS
Sir-chawakornSir-chawakorn/sanook-cli/skills/mermaid-diagram/SKILL.md

mermaid-diagram

Skill9 starsChanged 6 months agoApache-2.0View on GitHub

Turn requirements, code, or a system description into validated Mermaid diagrams (flowchart, sequence, class, ER, state, C4, Gantt, mindmap, git graph) and verify they render via mermaid-cli before delivering.

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use paper-illustration, deepxiv and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • raja21068Skill

    paper-illustration

    Generate publication-quality AI illustrations for academic papers using Gemini image generation. Creates architecture diagrams, method illustrations with Claude-supervised iterative refinement loop. Use when user says \"生成图表\", \"画架构图\", \"AI绘图\", \"paper illustration\", \"generate diagram\", or needs visual figures for papers.

    Also in 5 projects that use this

  • raja21068Skill

    deepxiv

    Search and progressively read open-access academic papers through DeepXiv. Use when the user wants layered paper access, section-level reading, trending papers, or DeepXiv-backed literature retrieval.

    Also in 4 projects that use this

  • +10 more from raja21068

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If unsure between flowchart and sequence: does order-of-time + who-does-what matter?

    line 23
  2. Distinctive:

    Read the source of truth, don't guess: If diagramming code, open the actual files/functions and trace real control flow, call edges, or …

    line 27
  3. Very specific:

    Tighten for readability: before delivery: short node labels (offload detail to surrounding prose), subgraph to group related nodes, …

    line 38

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

When to Use

Trigger when the intent is "show this as a diagram" and the target is Mermaid (renders natively in GitHub, GitLab, Obsidian, VS Code, most docs). Map intent → diagram type up front; picking wrong wastes a render cycle:

Intent / phrasingDiagram typeHeader keyword
Steps, branches, "the flow of X", decision logicflowchartflowchart TD / LR
Actors talking over time, API calls, request/responsesequencesequenceDiagram
DB schema, tables + relations + cardinalityERerDiagram
OOP model, types, fields, inheritanceclassclassDiagram
Lifecycle, status machine, "states of an order"statestateDiagram-v2
System / container / service boundariesC4C4Context / C4Container
Timeline, project phases, dependencies-over-timeganttgantt
Hierarchy of ideas, brainstorm treemindmapmindmap
Branch/merge historygit graphgitGraph

If unsure between flowchart and sequence: does order-of-time + who-does-what matter? yes → sequence, no → flowchart.

Steps

  1. Read the source of truth, don't guess. If diagramming code, open the actual files/functions and trace real control flow, call edges, or schema — not an assumed design. For ER/class, pull field names and FKs from the real schema/models.
  2. Pick the type from the table above and the direction. Default flowchart TD (top-down) for processes; LR (left-right) when there are many sequential steps (wide reads better than tall).
  3. Write the Mermaid source to a temp file, e.g. /tmp/diagram.mmd — do not hand-build it inline; you need a file to validate.
  4. Validate by rendering — this is non-negotiable, a diagram that doesn't parse is a failure:
    npx -y @mermaid-js/mermaid-cli@latest -i /tmp/diagram.mmd -o /tmp/diagram.svg
    • First run downloads the package; that's expected. If mmdc is already on PATH, use it directly: mmdc -i in.mmd -o out.svg.
    • On headless/CI or if Chromium fails to launch, add a puppeteer config: write {"args":["--no-sandbox"]} to /tmp/pp.json and append -p /tmp/pp.json.
    • SVG is the cheapest/fastest output for a syntax check. Use -o out.png only if the user wants a raster image.
  5. If it fails, fix the root cause and re-render. Read the parser error (it gives a line/token), correct the syntax, run step 4 again. Loop until it renders clean. Never "soften" by deleting the failing node or wrapping problem text — fix the actual syntax (see Common Errors).
  6. Tighten for readability before delivery: short node labels (offload detail to surrounding prose), subgraph to group related nodes, consistent edge labels, and a sane direction. A correct-but-unreadable diagram still fails the task.
  7. Deliver as a fenced ```mermaid block ready to paste into markdown/Obsidian. Do not deliver the SVG path as the answer unless the user explicitly asked for an image file — the fenced source is the product.

Common Errors

  • Parens/brackets/quotes inside a label break the parser. A[Fetch (cached)] fails. Wrap the whole label in double quotes: A["Fetch (cached)"]. Same fix for :, ;, #, &, <, >, /.
  • HTML in labels needs <br/> not \n. Newlines inside a node use A["Line one<br/>Line two"]. A literal \n renders as text.
  • Reserved word end as a lowercase node id silently corrupts flowcharts. Use End, END, or e_end.
  • Sequence diagrams: declare or imply participants consistently. Mixing participant A as Auth then referring to Auth later (the alias, not the id) breaks. Reference the id in arrows, the alias is display-only.
  • ER cardinality syntax is strict: USER ||--o{ ORDER : places (one-to-many). Common crash is using 1 / * instead of the ||, o{, }o, |{ tokens.
  • C4 diagrams need the right header (C4Context, C4Container, C4Component) and Rel(a, b, "label") — they do NOT use flowchart arrow syntax. Don't mix the two grammars.
  • gantt dates must be ISO (YYYY-MM-DD) and need a dateFormat line; freeform dates fail.
  • %% is the comment marker, not // or #. A stray // comment is parsed as a node and throws.
  • graph is the legacy keyword; prefer flowchart. Both parse, but flowchart gets newer features (e.g. & chaining). Don't mix dialects in one block.
  • Indentation matters in mindmap — it's whitespace-structured like YAML, not bracket-structured. Inconsistent indent = wrong tree.

Verify

Done only when ALL hold:

  • mmdc/npx ... mermaid-cli exited 0 on the final source (an actual render happened — not "it looks right").
  • Diagram type matches the user's intent (flow vs sequence vs schema), not just "a diagram."
  • Every node/edge in the diagram maps to something real in the source code/spec — no invented steps, no dropped branches.
  • Labels are concise and the layout direction reads cleanly; groups use subgraph where it reduces crossing edges.
  • Delivered as a copy-paste-ready ```mermaid fenced block (plus the image path only if an image was requested).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.