pisan-labs

Diagram Layout Engine — Data skill for Claude Code

Data community

A from-scratch layout engine for Mermaid flowcharts: a parser, the Sugiyama pipeline, edge routing and themeable SVG, with a stage-by-stage inspector, visual diffs that keep nodes in place, and a 50-g.

How to install Diagram Layout Engine

This entry records only its repository, not the path inside it, so there is no exact command to give. Open pisan-labs/diagram-layout-engine and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Diagram Layout Engine does

A from-scratch layout engine for Mermaid flowcharts: a parser, the Sugiyama pipeline, edge routing and themeable SVG, with a stage-by-stage inspector, visual diffs that keep nodes in place, and a 50-graph benchmark. Built with Claude Code.

Alternatives in Data

  • n8n Code JavaScript — JavaScript in n8n Code nodes with data access patterns 3.6k ★
  • SVG Diagram — Agent skill that draws architecture, flowchart, sequence, data-flow and lifecycle diagrams as hand-placed SVG 414 ★
  • Dashboard Layout — Design and build a complete dashboard layout — sidebar navigation, KPI cards, chart areas, data tables, filter 309 ★

README

Diagram Layout Engine

A layout engine for a subset of Mermaid flowchart syntax, written from scratch: a recursive-descent parser, the five-step Sugiyama pipeline, an edge router and a themeable SVG writer, plus a visual diff, a stage-by-stage inspector and a benchmark. No Mermaid, dagre or ELK; no dependencies at runtime. Everything runs in the browser.

Live: [diagram-layout-engine.hintwise.org](https://diagram-layout-engine.hintwise.org)

![Typing a new edge into the Mermaid source re-lays out the CI/CD flowchart, then switching direction to top-to-bottom and the theme to blueprint redraws it, and hovering a node highlights its edges](demo.gif)

Built from the 2026-10-18 idea "Build Your Own Diagram Layout Engine", a five-week classroom assignment prompted by the HN thread on Pele (Obsidian's themeable Mermaid renderer), where people mostly asked for readable large diagrams and for visual diffs. This is a reference solution and a test harness for that assignment.

![Desktop: the Microservices example with nested subgraphs in their own directions](desktop.png)

What you can do

  • Editor. Type Mermaid and the diagram re-lays out as you type. Ten bundled examples cover a CI/CD pipeline, a login flow with retry loops, nested microservice subgraphs, a compiler pipeline whose middle end runs in another direction, the TCP state machine, a CS prerequisite DAG, release branching drawn right to left, a shape gallery, a styled order flow and the engine's own pipeline. Every step of the pipeline has a switch (cycle removal, layering, ordering, transposition, sweeps, coordinates, edge style, gaps), and the metrics strip shows crossings, layers, dummy nodes, reversed edges, area, edge length, bends and time. Hover a node to highlight its edges; click it for its layer, order and size and a jump to its line in the source. Pan by dragging or scrolling, zoom with ctrl/cmd + wheel, pinch or the buttons, double-click to fit.
  • Errors. The first par