What does infra-diagrams do?
Describe the environment in sentences → scene (JSON) → node infra-diagrams.mjs render → SVG (always) and PNG (when a
renderer is available). Deterministic: the same scene gives a byte-identical SVG. Only Node.js ≥ 18, no installation.
Answer the user in the language they write in; labels in the scene follow the user's language too.
Files of this skill
| File | Content |
|---|---|
infra-diagrams.mjs | Engine and tools in one file: init, status, render, stencil, check |
infra-diagrams-data.json | Components, designs, colours, brand register, brand images (must sit next to infra-diagrams.mjs) |
README.md | Scene format: iso nodes, "view": "2d", "view": "rack", levels, options |
catalog.md | All components (use), primitives (kind), rack devices, 2D elements with parameters |
examples.md | Prompts with finished scenes; use them as templates |
LESSONS.md | Rules for every scene (glow, legend, lines, layout); always follow them |
designs.md, stencils.md, logo-usage.md, building-components.md | Designs/company palette, device fronts from stencils, logo clearances, primitives |
cowork.md | Workflow with SharePoint, layout of folder B, limits, failure patterns |
Two folders
The user names two SharePoint folders; nothing else needs setting up:
- Folder A – stencils (read-only): your own or licensed Visio stencils whose licence allows conversion. Never write there.
- Folder B – workspace (read and write): the skill sets it up itself on the first call:
infra-diagrams.json(settings),library/(device fronts),stencils/stencil-index.json(catalogue of A),brands.local.json(logo clearances),scenes/(one scene per diagram),out/(images),README.md,knowledge/(shared memory of all sessions).
Locally: work/B/ mirrors B (only the fetched files, same paths), work/A/ holds single stencils fetched from A
(same relative path as in A).
Session start in Cowork (mandatory, before anything else)
- Engine: if
infra-diagrams.mjsandinfra-diagrams-data.jsonare not in the sandbox, download both from the skill folder side by side into one local folder (e.g.skill/) and callnode skill/infra-diagrams.mjs ….checkfinds the browser for PNG and adds--no-sandboxin containers by itself. Only if it reports no renderer or PNG fails, setPLAYWRIGHT_BROWSERS_PATH=<folder with chromium-*>,INFRA_DIAGRAMS_CHROME_NO_SANDBOX=1,INFRA_DIAGRAMS_PNG=chrome. Nopip/npm install, no version queries (blocked). - Shared knowledge first: if B has
knowledge/README.md, read it and the files it names (sandbox.md,workflow.md,lessons.md,scenes.md) before exploring anything. They are the memory of all users and take precedence; do not re-check what is written there with a check date, unless it fails. - Mirror B into
work/B/(see "Every call"), thenstatus --workspace work/B --json.knowledge.missing(with--listing) orneedsInit→init, which addsknowledge/without replacing anything. - Before a new scene look for a template in
knowledge/scenes.md. Real device first: look for the named device in the library (stencil lib), then in the stencil catalogue (stencil search;fmtshows whether its front is convertible), and use a generic component only when neither has it (or the licence forbids conversion). - If an organisational policy blocks downloads from SharePoint (uploads may still work): continue with what is already local, do not retry in a loop, and note it in the journal.
Session end in Cowork (mandatory)
- Upload the new scene and images, then library files, the shared indexes last (see "Ground rules").
- Create exactly ONE new journal file
knowledge/journal/YYYY-MM-DD-<initials>-<topic>.md(templateknowledge/journal/TEMPLATE.md: task, what had to be explored, result, assumptions, open points). - Add one line to
knowledge/scenes.md(download → add → write back in place; on a conflict download again and merge). - Only new, verified rules go into
knowledge/lessons.md, with date; guesses only into the journal. New sandbox facts intoknowledge/sandbox.mdwith check date. - Never delete, rename or blindly overwrite. An upload cannot replace a file: modify the downloaded copy and write it back.
Ground rules
- SharePoint is not a file system: fetch files with the M365 file functions, process them locally, then upload
exactly the files listed in
"upload"of the--jsonoutput, each to its"to"(path in B). - Never write to folder A. Never delete or rename anything in folder B; create files from
initonly if they do not exist in B yet (never replace). - Shared indexes last: fetch
library/index.jsonandstencils/stencil-index.jsonfrom B again right before uploading, then runstencil reindex --workspace work/Borstencil catalog --workspace work/B(they merge your own entries back in and delete nothing), then upload. Never--prune. - Work only in the working folder; never write into the skill folder.
- Extern is the default: without
--audience intern, vendor logos and device photos appear only for cleared brands (brands.local.json), otherwise text and a neutral front. Useinternonly for internal documents. - Stencils and library: the stencils' licence applies. Convert and copy into the library only if the licence allows conversion and copying; many vendor stencils only allow creating diagrams and forbid conversion, redistribution and public use. When in doubt, ask and render without stencil fronts (neutral fronts). Keep the library internal, never in a public repository.
- Keep agent turns cheap: one script run per task with a one-line JSON summary instead of many single steps; decisions that follow from a file format belong in code (the skill's commands already decide EMF vs raster), not in the agent; write big outputs (listings, indexes) to files and print only a summary; check visually with one downscaled image and at most one or two crops.
Without SharePoint (Claude Code, claude.ai, GitHub Copilot, local)
If the user names no folders A/B, everything about SharePoint, init and upload is dropped. infra-diagrams.mjs
sits in the same folder as this SKILL.md; call it with its full path, working folder = current folder:
node <skill-folder>/infra-diagrams.mjs check- Write the scene to
<name>.jsonin the working folder (formatREADME.md, building blockscatalog.md, templateexamples.md, rulesLESSONS.md). node <skill-folder>/infra-diagrams.mjs render <name>.json --out out --json(--audience internonly on request), and give the user the paths from the output (SVG always, PNG when a renderer is available).
Device fronts from stencils only if the user names a stencil folder and its licence allows conversion and copying:
stencil search <folder> "<query>",
stencil extract <folder> "<master>" --lib <library>, then render … --lib <library>. Your own
brands.local.json with --brands-local <file>. A local folder can also serve as a workspace like B
(init --workspace <folder>, then every command with --workspace <folder>).
First call
node infra-diagrams.mjs check(Node version, PNG renderer).- Fetch
infra-diagrams.jsonfrom B intowork/B/. If it exists, continue with "Every call". If B only holdsiso-visual.json(the skill's former name): fetch it;inittakes it over asinfra-diagrams.json(upload); the old file stays, delete nothing. - Otherwise: list B (names only) →
work/listing-B.json; list A (relative path, size, modification date, download nothing) →work/listing-A.json. Format: a JSON list withname/path,size,lastModifiedDateTime(the Graph API'svaluelist works as is) or text, onepath | bytes | dateper line. node infra-diagrams.mjs init --workspace work/B --stencils work/listing-A.json --listing work/listing-B.json --stencil-folder "<location of A>" --workspace-folder "<location of B>" --json- Create the folders from
"folders"in B, upload the files from"upload"to"to". If anything is listed under"fetch"(already in B): fetch it and runinitagain. A secondinitreports everythingunchanged,"upload": [].
Every call
- Fetch into
work/B/:infra-diagrams.json,library/index.json,stencils/stencil-index.json,brands.local.json.node infra-diagrams.mjs status --workspace work/B --json:nextnames the next step (needsInit→init, which only adds what is missing; a newer skill version adds new settings). - Check the library:
node infra-diagrams.mjs stencil lib "<model> front" --workspace work/B --json→ref(e.g.lib:<vendor>/<slug>) andfile; fetchlibrary/<file>and the.jsonnext to it intowork/B/library/. - Otherwise search the catalogue (downloads nothing):
node infra-diagrams.mjs stencil search "<vendor> <model> front" --workspace work/B --json- Hits with
master: pick the matching one (configuration from the prompt, e.g. a master with24D 2.5= 24 × 2.5"),download= path in A,bytes= size. - Hits with
"master": null(statuspendingorstale): file from A not read yet. A vendor or product family in the query finds them by file name. - New files in A: list A again,
stencil catalog work/listing-A.json --workspace work/B --json(new →pending, changed →stale, missing →removed; nothing is deleted).
- Hits with
- Fetch and convert (only if the licence allows conversion and copying): only the one file
downloadfrom A intowork/A/<download>, thennode infra-diagrams.mjs stencil extract "<master>" --stencils work/A --workspace work/B --json→ref. This also adds the stencil's master list to the catalogue. If the hit was a file without a master:stencil index work/A/<download> --stencils work/A --workspace work/B --json, then search again. - Write the scene to
work/B/scenes/<name>.json: format fromREADME.md, building blocks fromcatalog.md, template fromexamples.md, rules fromLESSONS.md. Device fronts with"asset": "lib:<vendor>/<slug>". Design, colours, link types, legend and audience come fromdefaultsininfra-diagrams.json; set in the scene only what should differ (the scene wins). To change an existing diagram: fetchscenes/<name>.json. - Render:
node infra-diagrams.mjs render work/B/scenes/<name>.json --workspace work/B --json(--audience internfor internal versions). Library, logo clearances andout/come from the workspace; a scene outsidescenes/is copied there. On errors the message names the next command. - Write back: every path from
"upload"to"to": images (out/), scene (scenes/), library files (library/<vendor>/<slug>.svg|json), catalogue sidecars (stencils/indexed/). The two indexes last, as above (fetch again,reindex/catalog, upload). Same input →unchanged, nothing to upload.
PNG
render --json reports "png": backend chrome (exact), rsvg/cairosvg (small deviations, note) or
null with skipped. Chrome/Chromium is found by itself (also Playwright browsers under /opt/*/chromium-*); in
Linux containers --no-sandbox is added automatically (check shows both). Without PNG, deliver the SVG: Word, PowerPoint, Teams and browsers show SVG directly; if
needed, a PNG can be made in PowerPoint via "Save as Picture". --png off switches PNG off, --png on turns a
missing PNG into an error (default from defaults.png).
Scenes in brief
{ "nodes": [
{ "use": "firewall", "id": "fw", "at": [0, 0, 0], "glow": "red" },
{ "use": "tag", "for": "fw", "title": "FG-01", "sub": "Gateway", "status": "active" }
] }
2D block diagram with "view": "2d" (groups, devices, nodes, lines with type), rack with "view": "rack"
(racks[].items[] with u, use or asset). Classic design "design": "classic" (alias klassisch; default hypermodern), company colours "colors".
Devices are vendor-neutral; a brand only when the user names one: iso "components": { "server-2u": { "faces": { "top": { "brand": { "id": "dell" } }, "front": { "brand": { "id": "dell" } } } } }, rack "brand": "dell" on the item, 2D "brand" + "asset" on the device (without an image of your own the name appears as text). A brand id that is not registered renders as text too, with a warning under "warnings".
Iso axes: x to the lower right, y to the lower left, z up; fronts face +y; details in README.md ("Iso coordinates and axes"). Primitives go with "kind" ("kind": "text"), components with "use".
Glow only when the user asks for it, as "glow": "gold" (or true, { "tone", "opacity", "spread" }) on the object (iso, 2D, rack); otherwise none. Legend with "legend": true.
2D layout by tiers (3-tier), always top to bottom: outside world (internet, WAN, cloud) → network (firewalls, switches, LAN nodes, OOB) → servers → storage. Backup (backup server, repository, tape) at storage height beside it, never at server height. SAN switches may sit as an intermediate tier between servers and storage. Several sites = one column each with the same tiers at the same height; connections between sites run horizontally at the height of their tier. Deviate only on explicit request.
Own device images (user attaches a photo)
When the user attaches a photo or front view of a device and wants it in the diagram (details: custom-images.md):
- Look at the image: find the device front (pixel box
x0,y0,x1,y1, top left and bottom right) and the rack units (19" front ≈ 10.86 : 1 per unit: 1U ≈ 10.9, 2U ≈ 5.4, 4U ≈ 2.7). Pick a brand id (acme) and the role of the device type:front-1u,front-2u(servers),front-backup-server,front-storage-2u,front-switch-1u, … (frontfor a 2D device,markfor a logo). - Save the attachment in the working folder, then
node infra-diagrams.mjs asset add <image> --brand <id> --role <role> [--name "<brand name>"] [--crop x0,y0,x1,y1] --workspace work/B --json(without a workspace:--brands-local brands.local.json). Readwarnings(rack units, size) and fix the crop if needed. - Use brand and role in the scene (
usein the output: rack"brand"on the item, 2D"brand"+"asset", iso"components"with the front brand) and render with--audience intern(and the same--workspaceor--brands-local). - Upload the files under
"upload"to"to"(image underassets/,brands.local.json).
Remind the user that they need the right to use the image, and that it stays private: only internal renders show
it; external renders show the brand name on a neutral front until the brand is cleared ("extern": true).