David Vasandani

Mermaid and diagram-design

by David Vasandani

Good integration docs need diagrams: how a partner's delivery moves from submission to launch, and what the API says back when a payload is wrong. I wanted to know if two tools could share that work. Mermaid is text-first and renders on GitHub. diagram-design is an agent skill that draws polished diagrams and says it can import Mermaid.

The short answer: they work well together if you treat Mermaid as the source and diagram-design as the presentation layer. Nothing flows back the other way.

How each tool works #

Mermaid on GitHub. Put a fenced code block marked mermaid in any Markdown file and GitHub draws it. GitHub's HTML pipeline swaps the block for a placeholder, then an iframe to its Viewscreen service runs Mermaid.js in your browser. Without JavaScript, including the REST Markdown API, you see the code. I checked: gh api markdown returns the block as highlighted source. The diagram lives next to the docs, so it gets reviewed and edited like code. The layout is automatic, and it looks like it.

diagram-design. This is a skill for coding agents such as Claude Code, Codex and Copilot. It writes one HTML file with an inline SVG, following strict rules: 45 diagram types, a budget of 9 nodes and 12 arrows, right-angle connectors only, labels on opaque masks clear of their lines, one or two accent elements, and an accessible title and description on every figure. It comes with Python checkers for those rules and an SVG exporter.

The import path is the important part. The skill never renders Mermaid. mermaid_extract.py parses the text into a digest (nodes, edges, decisions, cycles, hubs, budget) without executing anything. The agent then redraws from scratch and reports a fidelity ledger: everything it merged, renamed or dropped. It doesn't write Mermaid back.

The test #

I wrote two Mermaid diagrams of a generic partner content delivery and ran them through the skill's import procedure. The skill was pinned to commit 97d7951 (v2.6). I skinned it with this blog's colours and system fonts, so the published images make no network requests. Here is the flowchart source, which GitHub renders in the repository:

flowchart LR
  P([Partner]) -->|POST package| A[Authenticate submission]
  A --> V{Schema valid?}
  V -- no --> R[Remediate with partner]
  R -->|resubmit| A
  V -- yes --> O[Orchestrate metadata, artwork, video]
  O --> M[(Metadata store)]
  O --> AV[Set availability window]
  AV --> L([Ready to launch])

This is Mermaid's own default render, from Mermaid CLI 12.0.0 with Mermaid 12.2.0 (GitHub runs its own version, so its render will differ a little):

Mermaid's automatic layout of the partner delivery flowchart: boxes in one long row, the remediation loop drawn above the row, and edge labels sitting on top of their lines.

Open Mermaid's render

And the diagram-design redraw:

Flowchart: a partner posts a package, it is authenticated and schema-checked. An invalid package goes back for remediation and resubmission. A valid one has its metadata, artwork and video orchestrated, metadata stored, and an availability window set before it is ready to launch.

Open the flowchart redraw

The second diagram is the API exchange behind "Schema valid?": a sequenceDiagram with an alt block for 422 versus 202.

Sequence: a partner posts a JSON manifest to the delivery API, which asks a validator to check it. On a schema mismatch the validator returns errors and the API answers 422 Unprocessable Entity. Otherwise the validator returns ok and the API answers 202 Accepted.

Open the sequence redraw

What worked #

Where it falls short #

Verdict #

Use both, for different jobs. Keep Mermaid in the repository as the source of truth: it renders on GitHub, reviews like code, and anyone can edit it. When a diagram is going in front of people (a partner integration guide, a launch review, a blog post), run it through diagram-design for the polished copy. Pin the skill version and add a check that fails when the copy drifts from its source.

The sources, redraws and check script are in the blog's repository.