drawio-ai-kit
AGENTS.md657 starsChanged 31 days agoMITView on GitHub
drawio-ai-kit helps an AI draw correct, beautiful draw.io diagrams. [!IMPORTANT] Hard rule (see skills/drawio/SKILL.md): The kit is read-only infrastructure. Write generated .drawio/.xml output into the user's cwd, never into the repo folder.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,843 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Dependencies: add libraries as devDependencies.
- Very specific: line 22
After any
src/change: run bun run build before tests/benches (they exercise dist/). - Very specific: line 26
Color = Identity: Never recolor AWS icons away from their category color (colorFor: entry.color → categoryColors[category] → #232F3E).
- Very specific: line 30
Imports in user scripts: always import { ... } from "drawio-ai-kit", never a path into the kit.
- Distinctive: line 33
Run these in order. All must pass.
- Very specific: line 36
If you touched src/, data/ or catalog/: node scripts/bench.mjs --runtime both --compare bench/baseline.json (perf gate, +10% tolerance).
- Very specific: line 37
If you touched search (src/search.ts, data/aliases.json, bench/search/queries.json): node scripts/bench-search.mjs --compare …
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Repository Guidelines
drawio-ai-kit helps an AI draw correct, beautiful draw.io diagrams.
[!IMPORTANT] Hard rule (see
skills/drawio/SKILL.md): The kit is read-only infrastructure. Write generated.drawio/.xmloutput into the user's cwd, never into the repo folder.
Tech Stack & Runtime
- Node.js ≥20.6 or Bun (ESM,
.nvmrc= 22; running TS tests natively needs ≥22.18) is the user runtime."type": "module"; zero default exports (named exports only). - Dependencies: add libraries as
devDependencies; Bun bundles them intodist/, so users install nothing extra. Add a realdependenciesentry only if the library cannot be bundled (native addon, WASM file, dynamicrequire). Todayminisearchis bundled this way. Never add apostinstallhook. - Bun 1.4+ is the maintainer toolchain:
bun testruns thenode:testsuites.npm testruns the same suites on plain Node, and both must pass.bun run build(scripts/build.mjs,Bun.build) bundlessrc/cli.ts+src/kit.tsinto the minifieddist/, which ships in the npm tarball.dist/is gitignored: CI and the release job build it; never commit it.bun run build:checkrebuilds into a temp dir and fails if the build is non-deterministic.
package-lock.jsonis the only lockfile. Runnpm installafter changing dependencies. Never commitbun.lock.- For the architecture, directories, and files, see docs/developer-guide.md.
Code Conventions & Common Patterns
- Erasable-syntax TypeScript in
src/andtest/(.ts, no enums/namespaces/parameter properties);npm run typecheckmust pass. Bun is the only bundler, and it is used only to builddist/. Import local files with the.tsextension. Useimport typefor types. - Shared types live in
src/model.ts(types only, erased at build). A type used by one module stays in that module. src/must run on Node. NoBun.*APIs insrc/; they are allowed only inscripts/and CI. Sole exception:src/run-hook.tsusesBun.pluginbehind a runtime check (it only runs under Bun).- After any
src/change: runbun run buildbefore tests/benches (they exercisedist/). Do not commitdist/. - One skill:
skills/drawio/(SKILL.md+references/+workflows/). There are no per-domain skills; a new domain is a new reference file (seedocs/adding-a-domain.md). Write skill docs in short, explicit steps that small models (Haiku-class) can follow. - Catalog injection:
loadCatalog()returns the merged catalog; everycore.tsfunction takescatalogas first arg;builder.tsstores it asthis.c. - Declarative layout > coordinates: Build node trees with
layout-engine.tsfactories (group/frame/grid+icon/box) →renderTree(d, root)→Diagram. Hardcoding x/y coordinates violates the design pattern. - Color = Identity: Never recolor AWS icons away from their category color (
colorFor: entry.color →categoryColors[category]→#232F3E). - Nesting Hierarchy: Group nesting order is enforced by
GROUP_LEVEL: Cloud/Account/Region=0 → VPC=2 → AZ=3 → Subnet=4 → SG=5. - Edge Rounding Policy: Tree/fanout roles → sharp (
rounded=0); flow → type'sedgeCorner. - Icon search is
src/search.ts(minisearch, bundled). Curated shorthand and synonyms live indata/aliases.json(entry name → phrases). To fix a bad search, add an alias there. Do not edit scoring code first. - Imports in user scripts: always
import { ... } from "drawio-ai-kit", never a path into the kit. Run scripts withdrawio-ai run build.mjs. Examples andscaffoldoutput follow this rule.
Gates to run before you open a PR
Run these in order. All must pass.
bun run build, thenbun run build:check(tests and benches usedist/).npm run typecheck,bun test,npm test- If you touched
src/,data/orcatalog/:node scripts/bench.mjs --runtime both --compare bench/baseline.json(perf gate, +10% tolerance). Updatebench/RESULTS.mdif numbers move on purpose. - If you touched search (
src/search.ts,data/aliases.json,bench/search/queries.json):node scripts/bench-search.mjs --compare bench/search/baseline.json(quality gate, no drop allowed). Add a labeled query for every alias you add. - Characterization snapshots (
test/characterization/**) changed on purpose? Regenerate withUPDATE_SNAPSHOTS=1and say why in the commit message.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

