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.
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
- Writes
name.skemo(and a smallname.cssfor its types) — no coordinates. - Runs
skemo lint name.skemoand fixes the reported lines. - Renders with
skemo name.skemo(PNG) or-o name.svg, and looks at the image to judge it. - 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
.skemofile in the repository next to the docs it illustrates, and re-render it in CI withskemo lint --deny-warningsorskemo render --deny-warnings.
See also
- Diagrams as code: check and render the agent's files in CI.
- SKILL.md, the skill itself.
