Diagrams as code
A .skemo file is a few lines of text. It lives in the repository next to what it describes, changes in
pull requests like the code, and renders to the same image on every machine.
docs-as-code.skemo
//- A diagram that lives with the code: checked and rendered on every push
diagram(dir="right")
card#file.src(icon="file-code") architecture.skemo
| in the repository, reviewed in pull requests
to(check)
zone#ci.ci CI job
card#check.step skemo lint
| --deny-warnings
to(render)
card#render.step skemo render
| same image on every machine
to(png svg html)
zone#out.out Published
card#png.img architecture.png
| README, wiki
card#svg.img architecture.svg
| docs site
card#html.img architecture.html
| slides, stepsdocs-as-code.css
.src { --c: #7048E8; --label: "Source"; }
.step { --c: #2F9E44; --label: "Command"; }
.img { --c: #3E6FC4; --label: "Output"; }Why text
- Reviewable. Adding a service is one line in the diff, not a binary image to compare by eye.
- Deterministic. Fonts and theme are built into the binary: the same file gives the same pixels everywhere, so rendered images can be committed and compared.
- Stable when edited. A change only moves the arrows attached to what changed; pin a card with
at="x,y"to keep it in place. - Offline. One executable, no browser, no Node, no network: the diagram of a private system never leaves your machine.
Check and render in CI
skemo lint docs/*.skemo --deny-warnings # exit code 1 on any problem
skemo render docs/architecture.skemo -o docs/architecture.svg --deny-warnings
A GitHub Actions step, for instance:
- run: curl -fsSL https://skemo.net/install.sh | sh
- run: ~/.local/bin/skemo lint docs/*.skemo --deny-warnings
Outputs
| Format | Use |
|---|---|
| PNG, WebP | READMEs, wikis, chat, slides (--scale 2 for sharp screens, --transparent) |
| SVG | documentation sites: sharp at any size, text selectable and indexed by search engines |
| HTML | a standalone page with light and dark themes, step-by-step reader and animated arrows |
| GIF, APNG, animated WebP | animations where no script runs |
Images that reopen
Every image skemo renders carries its source and stylesheets in metadata that viewers ignore. Share the PNG alone; later,
skemo extract diagram.png gives the text back, and any command accepts the image in place of the source. Render with
--no-source when the source must not travel with the image.
Live preview while you write
skemo docs/architecture.skemo --watch --css docs/architecture.css # http://127.0.0.1:8710
The page reloads on every save. skemo lint --fix keeps files in one canonical form, so diffs stay small.
See also
- Command line: every command and option.
- AI agents: let a coding agent write and update the files.
- Errors and warnings: what
skemo lintreports.
