agentleFS
YassimbaYassimba/loom/skills/mermaid-skill/SKILL.md

mermaid-skill

Skill9 starsChanged 3 months agoApache-2.0View on GitHub

Generate Mermaid diagrams as code (.mmd) and export to PNG/SVG/PDF with mmdc. Use when the user wants a diagram — flowchart, sequence, class, ER, state, gantt, git graph, architecture, timeline, mindmap — proactively when explaining a system with 3+ components, a runtime flow, a schema, or a lifecycle, and when another skill (e.g. show-me) needs a diagram authored or exported to an image.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Mermaid Diagrams

Author .mmd text files and compile them to images with mmdc. Mermaid lays everything out automatically — no coordinates — and the text source lives in git and embeds in Markdown.

Route elsewhere when the request needs: pixel-precise placement, branded icons, or heavy styling → drawio; a hand-drawn aesthetic → excalidraw/tldraw; a freeform whiteboard → tldraw; strict conventional UML notation → plantuml.

Setup

mmdc renders through Puppeteer and needs a headless Chrome:

npm install -g @mermaid-js/mermaid-cli
npx puppeteer browsers install chrome-headless-shell   # mmdc has no bundled browser

Could not find Chrome is a toolchain failure, never a diagram error. mmdc --version passes without Chrome, and a perfectly valid .mmd still fails to compile. Install the browser above or set PUPPETEER_EXECUTABLE_PATH to a system Chrome; leave the .mmd alone.

Workflow

  1. Author — pick the type from the shape of the content:

    The content is…Type
    steps, branches, dependenciesflowchart
    who calls whom, in what ordersequenceDiagram
    tables and relations / types and inheritanceerDiagram / classDiagram
    statuses one thing moves throughstateDiagram-v2
    deployed services and their wiringarchitecture-beta
    schedule / branch history / proportions / idea treegantt / gitGraph / pie / mindmap
    events over time / effort-impact grid / plotted datatimeline / quadrantChart / xychart-beta

    One diagram answers one question — past ~20 nodes, split by concern into separate .mmds instead of cramming. Syntax references, consult when unsure: FLOWCHART · SEQUENCE · CLASS-ER · ARCHITECTURE (architecture-beta — newer syntax, read before first use) · OTHER-TYPES (state, gantt, gitGraph, pie, mindmap, journey, timeline, quadrant, xychart, C4). Done when every node, participant, and label names a real thing from the content being diagrammed — no placeholders.

  2. Compile — the compile is the syntax check; a parse error is a bug in the .mmd, fix and re-compile until it renders:

    mmdc -i diagram.mmd -o diagram.png --size 2048

    Themes: -t default|dark|neutral|forest (base works only inside a %%{init: {'theme':'base'}}%% directive). SVG/PDF: same command with .svg/.pdf output.

  3. Self-check (vision) — a clean compile only proves the syntax; read the exported PNG and judge it as its audience will. Mermaid positions everything itself, so look for content defects, not overlaps:

    CheckWhat to look forFix
    Label truncationNode / edge text clippedShorten the label, or wrap with <br/>
    Cramped densityNodes crammed together; tangled linesFlip direction (TD↔LR), split into subgraphs, or reduce nodes
    Wrong aspectFar too wide or too tall to readChange flowchart TD↔LR (or set direction in class/state)
    Edge spaghettiMany crossings, hard to followReorder declarations so connected nodes sit adjacent; group with subgraph
    Wrong diagram typeType doesn't suit the contentRe-pick from the step-1 table
    Low contrastText blends into the node fillclassDef (FLOWCHART § Styling) or -t theme

    Re-compile after every fix. Max 2 self-check rounds, then show the user regardless. No vision available → skip straight to the review loop.

  4. Review loop — show the image, apply the minimal .mmd edit per request, re-compile. Overwrite the same .mmd/.png each round — no v1, v2, … After 5 rounds, suggest the user fine-tune at mermaid.live.
  5. Report — give the user the .mmd and image paths.

Gotchas

SymptomFix
Parse error on a label with special charsQuote it: A["Label: value"]
Parse error on a subgraph name with spacesQuote it: subgraph "My Layer"
Maximum text size in diagram exceededSplit the diagram; last resort -c config.json {"maxTextSize": 200000}
Chrome crashes in CI / as root-p puppeteer.json with {"args": ["--no-sandbox"]}
Architecture icons missing / logos: name not foundRegister the pack at compile time — ARCHITECTURE § Icons
Blank or tiny PNGAdd --size 2048

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.