Animated flow diagram
This skill turns a description of a system into a figure where things visibly move between components. The figure is one inline SVG:
- The rails are SVG paths with rounded corners.
- The tokens are small shapes that ride those exact paths with SMIL
<animateMotion>. - The dotted background is a CSS
radial-gradientof one 0.7px dot, tiled every 5px. Boxes are filled with the background color so they cover it. See "Dotted background" inreferences/spec.mdto tune or disable it. - A few lines of script add Pause and Play, pause the animation when it is off screen, and honor reduced motion.
The browser runs SMIL with no JavaScript and no library. That is why the figure embeds anywhere.
The hard part to do by hand is geometry: keeping every token exactly on its rail and every rail clear of the boxes. A bundled script does that geometry. Your job is the story and the layout.
Files in this skill
scripts/build.mjs: turns a JSON spec into the figure, and checks it for overlaps, overflow and rails that cross boxes. Node 18 or later, no dependencies.references/design.md: how to turn a description into a clear layout. Read it before writing a spec for a new figure.references/spec.md: every spec field, the routing rules and the built-in icons. Read it when writing or editing a spec.references/embedding.md: how to place the output in Next.js, React, MDX, Astro, WordPress, Ghost, Hugo, Jekyll, plain HTML or an iframe. Read it when the figure goes into a site.assets/example-habitat.json: wide figure (960). Clients fan in to a platform group on a shared bus, and CDC events fan out to a row of sinks.assets/example-stripe-webhook.json: blog-width figure (800). A request chain, a hop out of the app group to a queue and back in, and four kinds with distinct shapes.
Copy whichever example is closer to your case as a starting point.
Workflow
1. Get the real components
Use what the user gave you. If they point at a codebase, docs or an article, read enough to name the actual components and what passes between them. Don't use generic placeholders like "Service A". If an important part of the flow is unclear, ask one focused question. Don't guess.
2. Plan the story
Read references/design.md. Before you write any coordinates, write down:
- the subject
- the callers on the left
- the downstream parts below or to the right
- the token kinds and their directions
Keep it to about 12 boxes or fewer. If there are more, propose splitting it into two figures.
3. Write the spec
Start from the closer example in assets/ and see references/spec.md. Set width to the column the figure will live in (720 to 800 for a blog body). Line peers up on shared x values and a fixed gap. Give rails that fan in the same bend so they merge into one bus.
Where to save the spec:
- If the figure goes into a project, save it next to where the component will live, for example
components/figures/<id>.flow.json. Later edits are then just "change the spec and rebuild". - Otherwise save it as
figures/<id>/<id>.flow.jsonin the current folder.
4. Build and fix warnings
node <skill-dir>/scripts/build.mjs path/to/<id>.flow.json --check
node <skill-dir>/scripts/build.mjs path/to/<id>.flow.json --out path/to/output-dir
Treat every warning as a bug in the layout. Each warning names the node or edge and how to fix it: move boxes, widen a box, set bend, or give explicit points. Rebuild until it reports 0 warnings.
5. Look at it
The script can't judge whether the diagram reads well. You have to look:
- Open
<id>.preview.htmlin a browser. Use whatever browser or screenshot tool you have; a local static server works iffile://is blocked. - Take a screenshot at the target column width, and another at phone width (375px).
- Check that every token rides a rail.
- Check that buses merge cleanly, no text is clipped, and the legend matches what moves.
- Check the figure in dark mode if the site has one.
Two things can look like bugs during this check but aren't:
- The figure pauses itself while its tab is hidden or off screen. An embedded or background browser pane often reports
document.visibilityState === "hidden", so the tokens freeze and Play seems to do nothing. Checksvg.getCurrentTime()advancing in a visible tab before you debug. - Tokens start partway along their rails on purpose (negative
beginoffsets), so the first frame already looks busy.
If you have no way to render a page, say so in your report rather than claiming it looks right.
6. Embed it, if a site is involved
Follow references/embedding.md. Inspect the target project first: its framework, where posts live, and how existing posts embed components. Then use the matching output: the .tsx component for React and MDX, or the .html snippet for everything else. Fit it into the project's existing conventions.
Map the figure's CSS variables to the site's fonts and colors in the site's own stylesheet, not in the generated files. For a blog post, put the figure where the text introduces the system. Add a sentence before it saying what to watch for.
7. Report back
Tell the user:
- where the spec and output files are
- where the figure was placed
- how to change it later: edit the spec and rerun the build command
- anything you could not verify
Editing an existing figure
Find the .flow.json spec, change it, and rebuild over the old outputs. Don't hand-edit the generated .html or .tsx files, because the next build overwrites them. If a figure has no spec (someone hand-edited it), rebuild a spec from it first.
When this skill is the wrong tool
- A static diagram for a document that can't run HTML, such as a PDF, a slide export or a printed page: draw a static SVG or image instead.
- Charts of numbers over time: use a charting approach.
- Sequence diagrams with many ordered steps between two or three actors: the tokens here loop continuously and don't show order. A stepped sequence diagram is clearer.