Menu

Diagrams with AI agents

skemo is a good target for coding agents: the agent writes a short structural description, and the expensive part — coordinates, routing, rendering — runs on your CPU.

{"skemo":1,"name":"agent-loop.skemo","source":"//- The skemo pipeline, drawn by skemo\ndiagram(dir=\"right\" lang=\"en\")\n\n card#agent.ai(icon=\"bot\") Your AI agent\n | writes a few hundred tokens of text\n to(source)\n\n card#source.text(icon=\"file-code\") diagram.skemo\n | cards, zones, arrows\n | types styled in CSS\n to(engine)\n\n zone#cpu.local skemo, on your CPU\n card#engine.step(icon=\"cpu\") Layout + routing\n | deterministic, offline\n to(out) ~50 ms\n\n card#out.output(icon=\"image\") PNG · SVG · WebP · HTML\n | light, dark and print\n","css":[{"name":"agent-loop.css","content":".ai { --c: #7048E8; --label: \"LLM\"; }\n.text { --c: #3E6FC4; --label: \"TEXT\"; }\n.step { --c: #2F9E44; --label: \"ENGINE\"; }\n.output { --c: #D9892B; --label: \"IMAGE\"; }\n.local { --c: #2F9E44; }\n"}],"theme":"light"}LLMYour AI agentwrites a few hundred tokens of textdiagram.skemocards, zones, arrowstypes styled in CSSSKEMO, ON YOUR CPUENGINELayout + routingdeterministic, offlineIMAGEPNG · SVG · WebP · HTMLlight, dark and print~50 ms
{"skemo":1,"name":"agent-loop.skemo","source":"//- The skemo pipeline, drawn by skemo\ndiagram(dir=\"right\" lang=\"en\")\n\n card#agent.ai(icon=\"bot\") Your AI agent\n | writes a few hundred tokens of text\n to(source)\n\n card#source.text(icon=\"file-code\") diagram.skemo\n | cards, zones, arrows\n | types styled in CSS\n to(engine)\n\n zone#cpu.local skemo, on your CPU\n card#engine.step(icon=\"cpu\") Layout + routing\n | deterministic, offline\n to(out) ~50 ms\n\n card#out.output(icon=\"image\") PNG · SVG · WebP · HTML\n | light, dark and print\n","css":[{"name":"agent-loop.css","content":".ai { --c: #7048E8; --label: \"LLM\"; }\n.text { --c: #3E6FC4; --label: \"TEXT\"; }\n.step { --c: #2F9E44; --label: \"ENGINE\"; }\n.output { --c: #D9892B; --label: \"IMAGE\"; }\n.local { --c: #2F9E44; }\n"}],"theme":"dark"}LLMYour AI agentwrites a few hundred tokens of textdiagram.skemocards, zones, arrowstypes styled in CSSSKEMO, ON YOUR CPUENGINELayout + routingdeterministic, offlineIMAGEPNG · SVG · WebP · HTMLlight, dark and print~50 ms

Why it saves tokens

To draw a diagram directly, a model has to write every coordinate, path and colour of the picture. Measured on the gallery examples, the SVG of a diagram, written as lean as a careful hand would, is about 12 times longer, in tokens, than the skemo source it is rendered from (how it is measured). Over a whole task, where reading the input and looking at the images dominate, the first measurement gave about a third fewer tokens. Every output token is a pass of the model on a GPU: fewer tokens means less time, less cost and less energy. Edits shrink even more: renaming a card or adding one is a single changed line, where a drawn picture has to be regenerated.

The skemo skill

The skill is a SKILL.md file that teaches an agent the workflow (write, check, render), the syntax and the rules that keep diagrams short and correct. It works with Claude Code and with any agent that loads skills in this format.

mkdir -p ~/.claude/skills/skemo/references
curl -fsSL https://skemo.net/skill/skemo/SKILL.md -o ~/.claude/skills/skemo/SKILL.md
curl -fsSL https://skemo.net/skill/skemo/references/format.md -o ~/.claude/skills/skemo/references/format.md

For a single project, put the folder in .claude/skills/skemo/ at the root of the repository instead. The agent also needs the skemo binary on its PATH (install).

What the agent does

  1. Writes name.skemo (and a small name.css for its types) — no coordinates.
  2. Runs skemo lint name.skemo and fixes the reported lines.
  3. Renders with skemo name.skemo (PNG) or -o name.svg, and looks at the image to judge it.
  4. Later changes are line edits to the same file.

Tips for prompts

  • Say what the diagram is for and its direction: "a left-to-right skemo diagram of our deployment pipeline".
  • Ask for types in CSS rather than colours on each card.
  • Keep the .skemo file in the repository next to the docs it illustrates, and re-render it in CI with skemo lint --deny-warnings or skemo render --deny-warnings.

See also