flow-diagram-render
Skill8 starsChanged 27 days agoMITView on GitHub
Render Mermaid diagram sources to PNG/SVG image files for embedding where live Mermaid won't run — Confluence, Slack, slide decks, PDFs, email — with alt text for each image. Use whenever the user needs a flow/state/sequence diagram as an actual image file, wants to embed a diagram in Confluence (which has no native Mermaid), needs as-is + with-variant pairs of a flow rendered, or asks to "export the diagram", "turn this Mermaid into a PNG", "render the flow as an image". Pairs with requirements-to-decision-doc (source of the diagrams) and a Confluence mirror step, if you use one (consumer of the PNGs). Not for deciding what goes in the diagram (flow-capture, requirements-to-decision-doc).
In this repository19 other files it gives its agents.
- brand-tokens-translatorSkill
- case-study-captureSkill
- component-generatorSkill
- content-writerSkill
- design-accessibilitySkill
- design-brief-generatorSkill
- design-lead-thought-partnerSkill
- flow-captureSkill
- icon-generatorSkill
- intent-specSkill
- meeting-actions-to-tasksSkill
- portable-prototypeSkill
- requirements-to-decision-docSkill
- responsive-auditSkill
- spec-packSkill
- theme-generatorSkill
- token-auditSkill
- ui-edge-case-auditSkill
- visual-qaSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
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
- Distinctive: line 26
Hand off: Commit the PNGs so they're hosted (e.g.
- Very specific: line 30
When a flow has a proposed-layer variant (e.g.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Flow Diagram Render
Turn Mermaid source into image files. The reason this is its own skill: tools like Confluence Cloud, Slack, and slide decks cannot render Mermaid live, so a diagram that's interactive in an HTML artifact has to become a static PNG/SVG to travel. Keeping the .mmd source alongside the image means the diagram stays version-controlled and re-renderable, not a frozen screenshot.
Tool
@mermaid-js/mermaid-cli (mmdc), run through npx, pinned to 11.17.0. Verify with npx -y @mermaid-js/mermaid-cli@11.17.0 -V.
- Why pinned: Mermaid 12 (September 2026) re-lays out and recolors flowcharts and needs Node 22.13+. The decision-doc template renders with Mermaid 11, so images from 11.17.0 match what reviewers see in the hosted doc. Move both to 12 together, if ever, and keep the old look with
look: classicandlayout: dagrein the config. - First run is slow:
npxdownloads the package into its cache, and Puppeteer downloads a headless Chrome. Nothing is installed into the project, but expect a few hundred MB and a minute or two the first time; later runs are fast. - Linux containers and CI often can't start Chrome's sandbox. Pass a Puppeteer config:
-p puppeteer-config.jsoncontaining{"args": ["--no-sandbox"]}.
Workflow
- Collect the source(s). Either Mermaid you already have, or extract the
<pre class="mermaid">blocks from a decision-doc HTML. Save each as a.mmdfile in anassets/diagrams/(or similar) folder so it lives next to its output. - Sanitize for the CLI. The browser tolerates HTML entities (
—,③); the CLI does not parse all of them reliably. Replace entities with the literal character (—,②) in the.mmdfile. - Add a title and description to each
.mmdif it lacks them: anaccTitle:line and anaccDescr:line right after the diagram type. In an SVG they become the image's accessible title and description. - Render with the helper:
scripts/render-diagram.sh <file.mmd>(or callmmdcdirectly — see below). Default to PNG at 2× scale on a white background for crisp embedding. If a render fails, the script prints the error; fix the source and re-run. - Verify by viewing the output image — confirm labels aren't clipped and color-coding survived. State machines with many transitions can place annotations far from their node; if it's unreadable, prefer the flowchart variant or simplify. Check that status is also readable without color (a legend line or status words in labels).
- Write the text alternative. A PNG in Confluence, Slack, slides or email needs alt text (WCAG 2.2, 1.1.1). For each image, give the user a short alt text (what the diagram shows, in one sentence) and a one-paragraph text version of the flow to place beside it, since a long flow doesn't fit in alt text.
- Hand off. Commit the PNGs so they're hosted (e.g. Vercel) and can be embedded by URL, or pass the paths and alt text to your Confluence mirror step, if you use one.
As-is + variant pairs
When a flow has a proposed-layer variant (e.g. AI), render both: 02-assignment-flow.png and 02b-assignment-flow-ai.png. Use a stable naming scheme (NN-name.png / NNb-name-variant.png) so consumers can pair them.
Direct command
npx -y @mermaid-js/mermaid-cli@11.17.0 -i <in.mmd> -o <out.png> -b white -s 2-b white— white background (transparent looks broken on most embeds).-s 2— 2× scale for retina-crisp output. Use-o out.svgfor vector if the target supports it.- For an SVG that will be opened in a design tool (Figma, Illustrator, Inkscape), pass
-c config.jsonwith{"htmlLabels": false}. HTML labels are drawn in<foreignObject>, which those tools drop, so the labels would vanish.
Coloring variant nodes
Match the source artifact's conventions: color-code by lifecycle status, and draw proposed-layer (e.g. AI) nodes as dashed advisory nodes. For state diagrams, set note colors via an init directive so annotations match the layer color:
%%{init: {'themeVariables': {'noteBkgColor':'#f3e8ff','noteBorderColor':'#7c3aed','noteTextColor':'#4c1d95'}}}%%Reference
scripts/render-diagram.sh— wrapper that renders one or many.mmdfiles to 2× PNG, prints any render error, and reports which files succeeded or failed.
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
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.

