Write

Diagrams

Draw editable draw.io diagrams that follow the theme.

Diagrams are native draw.io files, drawn with the drawio-design skill. Anyone can open and edit them later. One file serves the light and the dark theme.

An example diagram: docs/diagrams/docs-loop.drawio

Before you start

  • Install the agent skills. The driftless plugin installs drawio-design with it. Refer to Agent skills.
  • Install the draw.io desktop app. npm run diagrams uses it to export. Set DRAWIO to its path if drawio is not on PATH.

Draw a new diagram

  1. Ask for it

    In Claude Code, ask for the diagram and name the page it is for, for example “draw how a request moves through the API, for the API overview page”. The docs-diagram skill picks the type, states its plan, and builds the file from a script in docs/diagrams/src/<name>.py.

  2. Check it

    The skill runs drawio-design’s check_drawio.py and renders a preview. It fixes every defect the check names, such as text that does not fit or lines that cross a box.

  3. Export it

    Run npm run diagrams -- <name>. This writes docs/diagrams/<name>.svg, with theme tokens in place of colours.

  4. Place it

    Add the diagram to the page. The alt text says what the diagram shows, not how it looks.

    <Diagram name="request-flow" alt="A request goes from the browser to the API, then to the database." caption="How a request moves" />

Change a diagram

Open docs/diagrams/<name>.drawio in draw.io or diagrams.net, or ask Claude Code to edit the XML in place. Do not run the script in docs/diagrams/src again: it would overwrite manual edits. Then run check_drawio.py and npm run diagrams -- <name>.

How the theme works

  1. You draw with colours from the palette in driftless.config.ts. The default palette matches drawio-design’s default skin.
  2. npm run diagrams exports each .drawio file to SVG.
  3. The export changes each palette colour to a --d-* token from src/styles/tokens.css. Each token has a light and a dark value.

A colour outside the palette stays as drawn, and the export lists it. Set diagrams.strict: true to stop the export instead.

Rules

Rule Why
Canvas 560px wide Text draws at about its real size in the page column
Light skin only The site maps colours to theme tokens for dark mode
Plain-text labels, in sentence case HTML labels export as images
Accent on one or two items The accent marks what the diagram is about
About 9 boxes at most Over that, split it into an overview and a detail
Dashed outline for a boundary that someone else owns It shows who runs what