Software diagrams your AI agent writes and you can edit by hand, in Claude Code, Codex, Cursor, Antigravity, Copilot, Grok Build or any other agent.
Your agent writes a short YAML spec. Linework lays it out, styles it and writes a .drawio.svg. That file is an ordinary SVG that renders in Markdown, on GitHub and in HTML, and it carries the full draw.io model. Open it in draw.io, move things around, save, and the same file updates. The next time the agent changes the diagram, your edits stay.
- Node 22.20 or newer for the skills installer in step 2. Linework itself runs on Node 20+. Check with
node -v. - Chrome, Edge, Chromium, Brave or another Chromium browser. Linework uses it in the background to measure text and draw. If you have none, run
npx -y @itsthecsguy/linework install-browser.npx -y @itsthecsguy/linework doctortells you whether your machine is ready, and what to fix if not. - Using Codex? Its sandbox stops Chrome from starting. Run
npx -y @itsthecsguy/linework install-browseronce, outside Codex. Linework's own headless Chromium does start inside the sandbox.
npx skills add itsthecsguy/lineworkThe skills installer finds the agents on your machine, asks which ones to set up, and puts the skill where each one looks. It covers Claude Code, Codex, Cursor, Antigravity, Gemini CLI, GitHub Copilot, Grok Build, OpenCode, Windsurf and about 70 more.
It installs for the current project by default. Add -g to install it for every project. To skip the prompts, name the agents:
npx skills add itsthecsguy/linework -g -a claude-code -a codex -yThis builds a two-box diagram without an agent:
printf 'type: flow\nnodes: { a: Hello, b: World }\nedges:\n - a -> b\n' | npx -y @itsthecsguy/linework build - -o hello.drawio.svg --png hello.pngIt should print check: 0 errors, 0 warnings and write hello.drawio.svg and hello.png. The first run takes a few seconds longer while npx downloads the package. If it says no browser was found, run npx -y @itsthecsguy/linework install-browser and try again. If something else goes wrong, npx -y @itsthecsguy/linework doctor checks Node, the browser and a test build, and prints the fix for whatever fails.
Start a new agent session so it loads the skill, then ask:
Add an architecture diagram of the checkout flow to docs/design.md.
The agent writes the spec, runs Linework, looks at the PNG preview, fixes what's off and embeds the .drawio.svg in the doc. You don't install anything else. The skill runs Linework through npx.
The skill works without this, but a global install skips the npx download check on every run and puts linework on your PATH:
npm install -g @itsthecsguy/lineworknpx skills update lineworkIf you installed the command globally, update it with npm install -g @itsthecsguy/linework@latest.
-
Agent can't run shell commands? Use the MCP server. See Connect over MCP.
-
Agent doesn't load skills? Add this line to your
AGENTS.md,CLAUDE.mdorGEMINI.md:For diagrams, use Linework: run `npx -y @itsthecsguy/linework skill` to get the guide's path, and read SKILL.md there before your first diagram.
A spec is a few lines of YAML:
type: architecture
nodes:
web: { label: Web app, kind: client, tech: Next.js }
api: { label: Checkout API, tech: Go }
db: { label: Orders, kind: database, tech: Postgres }
edges:
- web -> api: HTTPS
- api -> db: SQLnpx -y @itsthecsguy/linework build spec.yaml -o docs/checkout.drawio.svg --png /tmp/preview.pngLinework lays it out with ELK and draws it with draw.io's own renderer. It draws architecture, flow, state, sequence, ER and class diagrams and timelines, with AWS, Google Cloud, Azure and Kubernetes icons, and it converts Mermaid.
To change a diagram, the agent runs linework show to get the spec back, hand edits included, edits it and rebuilds. The rebuild merges into your layout. Your boxes stay where you put them, new ones go next to their neighbours, and only the edges that need it get rerouted (with draw.io's libavoid router).
These are first builds of the specs in examples/, with no hand edits. Each one is a .drawio.svg, so the image you see here is also the file you'd open in draw.io. Click one to see its spec.
| Architecture, with AWS icons |
Flow |
| Architecture, with Google Cloud icons |
Architecture, with Azure icons |
State
Sequence
ER
Class
Timeline
Linework goes both ways with Excalidraw. Write a copy of a diagram in its format, edit it there, and bring the edits back:
linework render docs/arch.drawio.svg -o arch.excalidraw # out to Excalidraw
linework import arch.excalidraw -o docs/arch.drawio.svg # and backOpen the .excalidraw file at excalidraw.com, or with an Excalidraw extension in your editor. Boxes, arrows, labels and cloud icons are where linework put them, hand edits included. Arrows are Excalidraw's own right-angle arrows, attached to their boxes, so they follow when you drag one. The parts of a node (shape, icon, label) are grouped and move together.
import reads what changed and merges it into the .drawio.svg, the same way a spec edit is merged:
| in Excalidraw | in the diagram |
|---|---|
| retype a name, a second line, a group title or an arrow label | the label changes |
| draw a box and type in it | a new node; a diamond in a flow is a decision |
| duplicate a box | a new node of the same kind, icon and color |
| draw an arrow between two boxes | a new edge |
| drag an arrow's end to another box | the edge connects there |
| delete a box, an arrow or a group | it's removed; a group's boxes stay |
| move or resize boxes, or drag one into or out of a group | they sit where you put them, and their arrows are routed again |
| pick a fill or stroke color | the nearest of linework's colors (color: red); back to none clears it |
| make an arrow dashed, or give it a second head or none | async, two-way, or a plain line |
| drag a segment of an arrow, or draw one with bends | that path is kept |
| sequence: draw a box level with the participants | a new participant, in that position |
| sequence: draw an arrow between two lifelines | a new message at that height; dashed is a reply |
| sequence: drag a message up or down, or into a frame | the order changes |
| sequence: delete a message, a note, a frame or a participant | it's removed, a participant with its messages |
| sequence: pick a color for a message | color: red on that message |
| ER, class: type a line of text in a table, or under its last row | a new column or member |
| ER, class: retype, delete or reorder a row | the column changes, goes, or moves |
| ER, class: draw a box with rows of text in it | a new table |
| timeline: drag or stretch a bar | new dates |
It prints each change it found. Then linework show gives you the updated spec (or pass --spec arch.yaml to have import write it). If the .drawio.svg is gone, import rebuilds it: the Excalidraw file carries the spec.
Importing on every save. --watch keeps running and imports each time the file is saved, so the diagram and its spec follow along while you draw:
linework import arch.excalidraw -o docs/arch.drawio.svg --spec docs/arch.yaml --watchThe same file can be imported any number of times. A box you drew is added once, not once per save.
One file that is both a picture and a drawing. Excalidraw can keep a scene inside an image. .excalidraw.svg and .excalidraw.png show in a README like any image, and open for editing in Excalidraw (and in its VS Code extension). import reads them too.
linework render docs/arch.drawio.svg -o docs/arch.excalidraw.svgA link. linework share docs/arch.drawio.svg prints an excalidraw.com link that opens the diagram there. It works the way Excalidraw's own "Shareable link" does: the drawing is encrypted on your machine and the ciphertext is stored on excalidraw.com; the key is only in the link. Anyone you give the link to can open the drawing, and it can't be taken back.
A library. linework library writes an .excalidrawlib of ready-made nodes to drop into a drawing: linework's own shapes, or cloud icons.
linework library shapes -o linework.excalidrawlib --style sketch
linework library aws lambda s3 sqs dynamodb -o aws.excalidrawlibA node dropped from one of these comes back through import as the right kind of node with its icon, not as an anonymous box. A provider has hundreds of icons (AWS over a thousand), so name the ones you use.
What doesn't come back:
- Exact shades, fonts and widths. A color you pick becomes the nearest of linework's nine, drawn in the diagram's style. Fonts and line widths stay as the style has them.
- Frames in a sequence diagram can be deleted, moved and renamed, but not drawn from scratch; add an
altorloopin the spec. - A class relationship's kind. Inheritance, composition and the rest keep the kind the spec gives them; a new arrow drawn in Excalidraw is a plain association.
Excalidraw also draws a few things its own way. It has one text weight, so names aren't bold. It has no database, table or lifeline shape, so each is built from grouped parts; double-click twice to edit text in a grouped node (the first enters the group). Share links and libraries can't hold images, so there the icons are drawn as shapes. And once Excalidraw reroutes an arrow (when you drag a box), that arrow gets its larger arrowhead and a path that may cross other boxes; importing routes it cleanly again. On a very short arrow, a double-click on the label can land on one of Excalidraw's segment handles instead: select the arrow and press Enter.
If you keep the YAML next to the diagram (docs/arch.yaml beside docs/arch.drawio.svg), linework sync rebuilds every diagram whose spec changed and leaves the rest alone:
linework sync docs # rebuild what's out of date, keeping each layout
linework sync docs --check # change nothing; exit 1 if anything is out of dateEach build records which spec it came from, so "out of date" means the YAML changed since. Moving boxes in draw.io doesn't count. --check needs no browser, which makes it cheap in a pre-commit hook.
In GitHub Actions:
- uses: actions/checkout@v4
- uses: itsthecsguy/linework@v0.9.0
with:
paths: docs
mode: check # or "update" to rebuild in the workspace for a later step to commitSet theme: in the spec.
| style | for |
|---|---|
clean (default) |
docs and READMEs. White boxes with hairline borders on gray group grounds, IBM Plex Sans. |
soft |
slides. Borderless pastel cards, tinted by kind. |
paper |
long reads and blogs. Warm cream ground, brown ink, earth-toned colors. |
dark |
dark-mode pages |
midnight |
dark slides and dashboards. Navy ground, softer contrast than dark. |
mono |
print, papers and RFCs. Black ink only: a color becomes a gray ground, a highlight solid black. |
bold |
slides and social posts. Thick outlines, bright flat fills, hard shadows. |
sketch |
early drafts. Hand-drawn lines and a handwriting font. |
blueprint |
technical deep dives. Blue ink on pale drafting paper, monospace. |
c4 |
C4-model diagrams, in quiet blues and grays |
The same spec in each style:
clean |
soft |
paper |
dark |
midnight |
mono |
bold |
sketch |
blueprint |
c4 |
Color is for meaning. Nodes stay neutral by default, and errors and successes are red and green in every style. Mark the part the doc is about with highlight: true on a node or ==> on an edge, and it's drawn in the style's accent color. Use color: red (or blue, violet, pink, orange, amber, green, teal, gray) for categories.
To match a brand, set accent: beside theme:. It takes one of those color names or a hex color in quotes, such as accent: "#E11D48", and every highlight in the diagram is drawn in it. Text on the color and lines against the page are adjusted to stay readable, so a pale brand color works too.
Linework sizes every box from the real width of its text in the font it renders with, wrapping long labels instead of widening boxes. Each SVG carries a subset of that font (about 10 to 15KB), so text fits the same way on GitHub, in a browser or in a doc. check flags labels that overflow, overlap a box, another label, another edge or a group border, and build moves edge labels until they're clear.
Linework needs Node 20+ and a Chromium-based browser, which it uses headless to measure text and render. It tries Playwright's Chromium, then Chrome, then Edge, then any Chromium-family browser on your PATH or in your applications folder (chromium, Brave, Vivaldi). If none is found, run linework install-browser, or set LINEWORK_CHROME to a browser binary. linework doctor shows which one it picked. If a browser is found but crashes on launch, an agent's sandbox is usually blocking it. Linework then retries Playwright's Chromium in single-process mode, which starts inside Codex's sandbox.
The first drawing command starts a background process that keeps Chromium running, and later commands hand their work to it. A build of the checkout example takes about 1.0s the first time and 0.16s after that. The process listens on a Unix socket in a folder only you can open, exits after 5 idle minutes, and is off on Windows and in CI. LINEWORK_NO_DAEMON=1 or --no-daemon turns it off, and linework daemon stop ends it.
Linework keeps the font subsets it embeds in your cache folder (~/Library/Caches/linework on macOS, ~/.cache/linework on Linux, %LOCALAPPDATA%\linework on Windows), so rebuilding a diagram doesn't compress the same fonts again. Set LINEWORK_NO_CACHE=1 to turn that off.
The MCP server is for chat apps and agents that can't run shell commands. Agents with a shell do better with the skill, since they can run the CLI and see its output directly.
| agent | command |
|---|---|
| Claude Code | claude mcp add linework -- npx -y @itsthecsguy/linework mcp |
| Codex | codex mcp add linework -- npx -y @itsthecsguy/linework mcp |
| Grok Build | grok mcp add linework -- npx -y @itsthecsguy/linework mcp |
| GitHub Copilot CLI | copilot mcp add linework -- npx -y @itsthecsguy/linework mcp |
| Gemini CLI | gemini mcp add -s user linework npx -- -y @itsthecsguy/linework mcp |
Everything else takes the same JSON block in its MCP config file:
{
"mcpServers": {
"linework": { "command": "npx", "args": ["-y", "@itsthecsguy/linework", "mcp"] }
}
}| app | config file |
|---|---|
| Antigravity | ~/.gemini/config/mcp_config.json, or .agents/mcp_config.json in the workspace |
| Cursor | ~/.cursor/mcp.json, or .cursor/mcp.json in the project |
| Claude Desktop | claude_desktop_config.json (Settings > Developer > Edit Config) |
| VS Code | .vscode/mcp.json, with "servers" in place of "mcpServers" and "type": "stdio" added |
Relative paths in tool calls resolve against the folder the server starts in. Add "--root", "/path/to/docs" to the args to pin it: with --root, the tools read and write only inside that folder, and a path that leads out of it is refused. The tools are build_diagram, show_diagram, check_diagram, render_diagram, tidy_diagram, import_mermaid, import_excalidraw, list_icons, edit_diagram, publish_diagram, get_config, lint_diagrams, and linework_guide, which hands the model the spec format and style rules. build_diagram returns a PNG preview, so a model that can see images checks its own work.
If you'd rather not use the skills installer, copy the skill into your agent's skills folder:
npx -y @itsthecsguy/linework skill install .agents/skills # Codex, Cursor, Antigravity, Gemini CLI, Copilot
npx -y @itsthecsguy/linework skill install .claude/skills # Claude Code
npx -y @itsthecsguy/linework skill install .grok/skills # Grok BuildCheck a linework.yaml into a repo and every diagram in it uses the same theme, names and rules, whoever or whatever draws it. Linework finds the file by walking up from the diagram.
extends: "@acme/linework-config" # share one config across repos: an npm package or a ./path
theme: acme
lockTheme: true
themes:
acme:
extends: clean
accent: "#0A6E5C"
font: { family: Acme Sans, regular: fonts/AcmeSans-Regular.woff2, bold: fonts/AcmeSans-SemiBold.woff2 }
statuses: { new: green, deprecated: gray, failure: red } # specs write "status: new", not "color: green"
legend: true
components:
stripe: { label: Stripe, kind: external, tech: Payments } # a spec writes "stripe: {}"
naming: { case: sentence, maxLength: 28 }
rules: { raw-color: error }- Your own theme and font. A theme starts from a built-in one and overrides colors, corner radius, line width and the font. Linework rejects a theme whose text falls under 4.5:1 contrast, and names the pair.
- One meaning per color. Statuses map a meaning to a color once. A legend for the ones a diagram uses is drawn under it.
- Shared components. Systems many diagrams draw get one label, kind and icon.
- Checked, not hoped for.
linework lint docschecks every diagram against the layout rules and the config, and exits non-zero for CI.linework restyle docsbrings old diagrams to the current theme without moving a box. - Agents follow it. The skill tells the agent to run
linework configfirst, which prints the settings that apply.
linework config init writes a starter file. Every option, a GitHub Actions step and a pre-commit hook are in skills/linework/references/team-config.md.
Once a diagram exists, a change to it keeps everything else where it is. That holds whether a person arranged the layout in draw.io or nobody has touched it.
linework set docs/checkout.drawio.svg api.label="Checkout API v2" api.highlight=true
linework add docs/checkout.drawio.svg "fraud: { label: Fraud check, in: vpc }" "api -> fraud: score"
linework rm docs/checkout.drawio.svg cache "api -> stripe"A renamed box grows in place. A new box goes next to the one it connects to, and its group grows to hold it without covering boxes outside the group. A removed box takes its edges with it, and its group closes up. linework build with an edited spec follows the same rules. It lays out from scratch only for a new file, a changed direction or theme on a layout nobody arranged, or --relayout.
After dragging boxes around in draw.io, linework tidy <file> reroutes the edges left behind and moves labels off whatever they landed on. Boxes stay where you put them.
Any draw.io editor works on these files: draw.io desktop, VS Code with the Draw.io Integration extension, or app.diagrams.net. Or:
npx -y @itsthecsguy/linework edit docs/checkout.drawio.svgThat opens the bundled draw.io editor in your browser, served from 127.0.0.1. Nothing goes online. Cmd/Ctrl+S writes the file. If an agent rebuilt the file while you had it open, your save goes to a side copy (checkout.edited-<time>.drawio.svg) instead of overwriting the agent's work.
Docs can't hold an SVG, so the diagram lives in Google Drive and draw.io's Google Docs add-on inserts it and refreshes it. linework publish copies diagrams into your Drive folder (via Google Drive for desktop) at a fixed path, and --pull brings back edits made from the doc. The steps are in skills/linework/references/google-docs.md.
| command | does |
|---|---|
linework build <spec|-> -o out.drawio.svg [--png p.png] [--relayout] [--watch] |
layout (or merge into an existing file), write, lint; --watch rebuilds on every save of the spec |
linework set <file> id.field=value... |
change a label, kind, color, theme, accent or title in place |
linework add <file> "id: {...}" "a -> b: label"... |
add boxes, groups and edges in place |
linework rm <file> id "a -> b"... |
remove boxes, groups and edges in place |
linework config [init] |
print the team settings that apply here, or write a starter linework.yaml |
linework lint [dir...] [--strict] |
check every diagram against layout rules and the team config |
linework restyle <dir...> |
bring existing diagrams to the team theme; boxes stay put |
linework new [template|type] [-o spec.yaml] |
print or write a team template, starter type, or built-in example spec |
linework show <file> [--geometry] |
print the spec of a diagram, including hand edits |
linework edit <file> [--no-open] |
edit in the bundled draw.io, in your browser; saves write the file |
linework check <file> [--strict] |
lint: overlaps, edges through nodes, labels that don't fit, too wide. Exits 1 on errors; with --strict, on warnings too |
linework render <file> -o out.png [--scale 2] |
preview image |
linework render <file> -o out.excalidraw |
a copy to open and edit in Excalidraw; .excalidraw.svg or .excalidraw.png for a picture that also opens there |
linework import <file.excalidraw> -o <file.drawio.svg> [--spec s.yaml] [--watch] |
bring edits made in Excalidraw back into the diagram, once or on every save |
linework share <file> |
an excalidraw.com link to the diagram |
linework library <shapes|aws|gcp|azure|k8s> [filter...] -o x.excalidrawlib |
an Excalidraw library of linework nodes |
linework sync [paths...] [--check] |
rebuild diagrams whose YAML spec changed, or fail if any is out of date |
linework tidy <file> |
after hand edits: reroute stale edges and move colliding labels; boxes stay |
linework import <file.mmd|doc.md> [-o out.drawio.svg] |
convert a Mermaid diagram (flowchart, state, sequence, ER, class, gantt) |
linework publish <file...> [--to dir] [--pull] |
copy diagrams into Google Drive for the Docs add-on |
linework icons <aws|gcp|k8s|azure> [filter] |
list icon names |
linework git-setup |
git diff shows diagram changes as spec changes |
linework skill [install <dir>] |
print or install the agent skill |
linework mcp [--root dir] |
MCP server over stdio |
linework kinds [type] |
node kinds per diagram type |
linework schema |
JSON Schema of the spec |
linework daemon [status|stop] |
the background process that keeps the browser running between builds |
linework install-browser |
download the headless Chromium build this version uses |
linework doctor |
check that this machine can draw: Node, the browser, a test build. Prints the fix for anything that fails |
linework version |
print the version |
Add --json to build, set, add, rm, check, lint, config, restyle, new, tidy, show, render, import, sync, icons, kinds or doctor, and stdout carries one JSON document instead of text:
linework build spec.yaml -o docs/arch.drawio.svg --json{
"ok": true,
"out": "docs/arch.drawio.svg",
"mode": "merge",
"direction": "LR",
"stats": { "nodes": 10, "edges": 10, "crossings": 0, "width": 596, "height": 1114 },
"check": { "errors": 0, "warnings": 1, "findings": [{ "level": "warning", "rule": "edge-through-group", "message": "..." }] },
"specWarnings": [],
"merge": { "kept": 9, "handMoved": 2, "placed": ["fraud"], "removed": [], "rerouted": 1 }
}A failure is a document too: { "ok": false, "error": { "kind": "spec", "message": "...", "issues": [{ "path": "edges[0]", "message": "..." }] } }, where kind is spec, usage or error. Fields are only ever added.
Exit codes are the same with or without --json: 0 when the command did its work, 1 when it failed or when check, lint, sync --check or doctor found a problem, 2 for a command line linework can't read. build exits 0 when it wrote the file even if lint has complaints; follow it with linework check <file> --strict to fail a job on any finding.
All five phases of PLAN.md are built. Two paths haven't been tried yet, because they need a real account or app: the Google Docs add-on round trip, and saving from the VS Code Draw.io Integration extension. Both use the same file format and protocol that the tests cover with draw.io's own editor.
npm install
npm run verify # typecheck, build dist/ and run every test (needs a Chromium-based browser)
npm run test:unit # only the tests that need no browser
npm run doctor # can this machine draw? says what to fix
npm run dev -- build examples/checkout.yaml -o out/checkout.drawio.svg --png out/checkout.pngAGENTS.md has the layout of the code, the rules a change has to keep, and how to check a change from the command line. Every push to main and every pull request runs the typecheck and the tests on Node 20, 22 and 24 in GitHub Actions. To run the suite with a browser that isn't in one of the usual places, set LINEWORK_CHROME=/path/to/chromium.
After a change to layout or rendering, rebuild the README gallery and look at what moved:
npm run build && node docs/gallery/build.mjsnpm run release # patch; or: npm run release -- minor | major | 1.2.3That bumps the version, commits it as Release x.y.z, tags vx.y.z and pushes both. The tag starts the release workflow, which runs the tests again, publishes to npm and opens a GitHub release with generated notes. Nobody logs in to npm: the workflow publishes through npm's trusted publishing, which is set up once in the package's settings on npmjs.com (GitHub Actions, repository itsthecsguy/linework, workflow release.yml).
assets/drawio holds the parts of the draw.io web app that linework runs: the renderer it uses headless, and the editor behind linework edit. draw.io is Apache-2.0; see NOTICE. To update it, check out a jgraph/drawio tag in vendor/drawio and run npm run assets.