agentleFS
sparklabxsparklabx/drawio-ai-kit/AGENTS.md

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.

  • In this repository2 other files it gives its agents.

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
  1. Very specific:

    Dependencies: add libraries as devDependencies.

    line 10
  2. Very specific:

    After any src/ change: run bun run build before tests/benches (they exercise dist/).

    line 22
  3. Very specific:

    Color = Identity: Never recolor AWS icons away from their category color (colorFor: entry.color → categoryColors[category] → #232F3E).

    line 26
  4. Very specific:

    Imports in user scripts: always import { ... } from "drawio-ai-kit", never a path into the kit.

    line 30
  5. Distinctive:

    Run these in order. All must pass.

    line 33
  6. Very specific:

    If you touched src/, data/ or catalog/: node scripts/bench.mjs --runtime both --compare bench/baseline.json (perf gate, +10% tolerance).

    line 36
  7. Very specific:

    If you touched search (src/search.ts, data/aliases.json, bench/search/queries.json): node scripts/bench-search.mjs --compare …

    line 37

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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/.xml output 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 into dist/, so users install nothing extra. Add a real dependencies entry only if the library cannot be bundled (native addon, WASM file, dynamic require). Today minisearch is bundled this way. Never add a postinstall hook.
  • Bun 1.4+ is the maintainer toolchain:
    • bun test runs the node:test suites. npm test runs the same suites on plain Node, and both must pass.
    • bun run build (scripts/build.mjs, Bun.build) bundles src/cli.ts + src/kit.ts into the minified dist/, which ships in the npm tarball. dist/ is gitignored: CI and the release job build it; never commit it.
    • bun run build:check rebuilds into a temp dir and fails if the build is non-deterministic.
  • package-lock.json is the only lockfile. Run npm install after changing dependencies. Never commit bun.lock.
  • For the architecture, directories, and files, see docs/developer-guide.md.

Code Conventions & Common Patterns

  • Erasable-syntax TypeScript in src/ and test/ (.ts, no enums/namespaces/parameter properties); npm run typecheck must pass. Bun is the only bundler, and it is used only to build dist/. Import local files with the .ts extension. Use import type for 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. No Bun.* APIs in src/; they are allowed only in scripts/ and CI. Sole exception: src/run-hook.ts uses Bun.plugin behind a runtime check (it only runs under Bun).
  • After any src/ change: run bun run build before tests/benches (they exercise dist/). Do not commit dist/.
  • One skill: skills/drawio/ (SKILL.md + references/ + workflows/). There are no per-domain skills; a new domain is a new reference file (see docs/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; every core.ts function takes catalog as first arg; builder.ts stores it as this.c.
  • Declarative layout > coordinates: Build node trees with layout-engine.ts factories (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's edgeCorner.
  • Icon search is src/search.ts (minisearch, bundled). Curated shorthand and synonyms live in data/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 with drawio-ai run build.mjs. Examples and scaffold output follow this rule.

Gates to run before you open a PR

Run these in order. All must pass.

  1. bun run build, then bun run build:check (tests and benches use dist/).
  2. npm run typecheck, bun test, npm test
  3. If you touched src/, data/ or catalog/: node scripts/bench.mjs --runtime both --compare bench/baseline.json (perf gate, +10% tolerance). Update bench/RESULTS.md if numbers move on purpose.
  4. 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.
  5. Characterization snapshots (test/characterization/**) changed on purpose? Regenerate with UPDATE_SNAPSHOTS=1 and say why in the commit message.

Download now (ZIP)

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.