token-engine-builder
AGENTS.md0 starsChanged 17 days agoMITView on GitHub
Human-written onboarding. Every line runs in every session — keep it under ~150 lines. Rationale lives in ARCHITECTURE.md; this file states rules. TypeScript + Vite (SSR/Node lib mode) builder that packages colocated AI agent skills. src/skills/<skill>/ → dist/<skill>/, 1:1. Each skill is standalone after copy into an agent's skills directory (for example ~/.agents/skills/<skill>/; node only, no install). Tiers: raw values only in primitive/; semantic/ (per-theme, same paths) and component/ are {alias}-only. audit.mjs enforces it — exit 0 ships, exit 1…
- Installs packages
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,700 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.
- design-tokensSkill
- setup-pre-tokensSkill
The file
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 48
Every user-visible change ships with a changeset file (.changeset/<name>.md, patch/minor).
≈ “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
AGENTS.md — token-engine-builder
Human-written onboarding. Every line runs in every session — keep it under ~150 lines. Rationale lives in
ARCHITECTURE.md; this file states rules.
WHAT — stack and layout
TypeScript + Vite (SSR/Node lib mode) builder that packages colocated AI agent skills. src/skills/<skill>/ → dist/<skill>/, 1:1. Each skill is standalone after copy into an agent's skills directory (for example ~/.agents/skills/<skill>/; node only, no install).
src/shared/— bundled engine:colors.ts(OKLCH),scales.ts(type/spacing),compiler.ts(Style Dictionary v5),paths.ts(portable resolution),types.ts(DTCG types).src/cli/— unified deterministic CLI (bin/token-engine→dist/cli/token-engine.mjs): single-passsync,init,audit,build,extract,scaffold.src/skills/— flagship cognitive skilldesign-tokens(Matt Pocock model: discovery, Socratic palette, single-pass sync, framework wiring) and prerequisite setup skillsetup-pre-tokens.scripts/build-all.mjs— one Vite pass per skill/CLI so no shared chunk leaks intodist/.vite.config.ts— entry discovery,sync-skill-packagesplugin (SKILL.md+templates/+assets/+examples/+references/mirror,chmod 0o755).skills/— generated mirror of builtdist/<skill>/fornpx skills add; never hand-edit, CI diff-gates it.
WHY — intent
Tiers: raw values only in primitive/; semantic/ (per-theme, same paths) and component/ are {alias}-only. audit.mjs enforces it — exit 0 ships, exit 1 stops.
HOW — commands (these get used; nothing else is blessed)
npm install # all deps are devDependencies — Vite inlines them
npm run check # typecheck + lint + lint:skills + test + build + lint:css
npm run build # → dist/<skill>/ + dist/cli/ via scripts/build-all.mjs
npm run deploy # link dist/* into ~/.agents/skills (default; --dir <path> for others; rebuilds stale, prunes dead)
npx token-engine # repo-local bin (checkout only); skills bundle dist/cli as scripts/token-engine.mjsNode >=22.12. Pure contracts verified via npm test (node:test unit tests in test/); portable smoke (lint:css) proves dist/* generation and gold parity.
Hard invariants (never violate; ESLint enforces #1)
colorjs.io/fnpartials only (ColorSpace,sRGB,OKLCH,to,serialize,contrastWCAG21,parse); register justsRGB+OKLCH. Monolithiccolorjs.ioentry is banned.devDependenciesonly. Vite inlines everything;node:*stays external.- Bundled scripts resolve
templates/+assets/fromimport.meta.url(paths.ts), never fromprocess.cwd(). User inputs (specs,--out) are cwd-relative by design. - Tier discipline: no
#hex/oklch()/px literals outsideprimitive/; semantic + component tokens alias only. - Agent-facing paths: SKILL.md commands use
<skill-root>(the folder containing the loadedSKILL.md) and<target-skill-root>for a handoff target. Never hardcode a home-directory install path; the agent resolves the placeholder, the human substitutes their install folder. Every SKILL.md with a <...-root> command carries the literal-execution guard; lint:skills enforces it.
Working rules
- Edit source, not the mirror: engine code in
src/shared/+src/cli/, skill content insrc/skills/<skill>/(SKILL.md,references/,assets/; token templates live insrc/shared/templates/tokens/and mirror into both skills at build). Never hand-editdist/orskills/. - Shared code goes in
src/shared/; skills import it — Rollup inlines it per skill at build time. - New CLI flag → update that skill's
SKILL.mdusage line in the same commit. - Token schema move → update
src/shared/templates+compiler.ts+ audit expectations together. - Build pipeline move → update
vite.config.ts+scripts/build-all.mjs+ARCHITECTURE.md§4 together. - Docs never restate
package.jsonscripts or--helpoutput — point at them. - Every user-visible change ships with a changeset file (
.changeset/<name>.md, patch/minor);npm run releaseconsumes them into a version bump.
Skill lifecycle (adding, renaming, deprecating)
- New skill: folder
src/skills/<slug>/withSKILL.md(name= slug, quoted trigger-styledescription,license,compatibility),scripts/,templates/,assets/as needed. Use<skill-root>/<target-skill-root>in commands; never hardcode an install directory. Register it: pipeline order words in description, README pipeline + Use sections, ARCHITECTURE diagram if it moves a seam, changeset file.lint:skillsenforces frontmatter;checkproves the bundle. - Rename: move folder + update every reference (grep the old slug, excluding lock/dist) + docs + changeset, one commit, no aliases.
- Deprecate: keep the folder one release with a
deprecated:frontmatter note and a changeset, remove next release.
Progressive disclosure (read on demand)
- Build rationale (per-skill passes, SSR/Node
fsfix, inline token merge):ARCHITECTURE.md§4. - Module contracts (exports per shared file):
ARCHITECTURE.md§2. - Token tier + alias rules:
ARCHITECTURE.md§3. - Skill runtime contract (entry conditions, exit codes): each
src/skills/<skill>/SKILL.md. - Token input contract:
src/shared/types.ts(StyleSpec), enforced bysrc/shared/spec.ts. - Product priorities and deferred register:
docs/ROADMAP.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

