@radicool/throughline 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/adapters/codex/AGENTS.md +10 -10
  2. package/adapters/codex/prompts/component-builder.md +59 -15
  3. package/adapters/codex/prompts/document-component.md +42 -10
  4. package/adapters/codex/prompts/storybook-chromatic-builder.md +52 -9
  5. package/adapters/cursor/.cursor/commands/document-component.md +42 -10
  6. package/adapters/cursor/.cursor/rules/component-builder.mdc +60 -16
  7. package/adapters/cursor/.cursor/rules/component-pipeline.mdc +1 -1
  8. package/adapters/cursor/.cursor/rules/design-system-audit.mdc +1 -1
  9. package/adapters/cursor/.cursor/rules/figma-environment-setup.mdc +1 -1
  10. package/adapters/cursor/.cursor/rules/icon-system-builder.mdc +1 -1
  11. package/adapters/cursor/.cursor/rules/repository-builder.mdc +1 -1
  12. package/adapters/cursor/.cursor/rules/retrofit-planner.mdc +1 -1
  13. package/adapters/cursor/.cursor/rules/storybook-chromatic-builder.mdc +53 -10
  14. package/adapters/cursor/.cursor/rules/token-builder.mdc +1 -1
  15. package/adapters/cursor/.cursor/rules/token-crosswalk-builder.mdc +1 -1
  16. package/adapters/cursor/.cursor/rules/token-sheet-builder.mdc +1 -1
  17. package/adapters/cursor/.cursor/rules/token-sync-layer.mdc +1 -1
  18. package/adapters/generic/AGENTS.md +10 -10
  19. package/adapters/generic/commands/document-component.md +42 -10
  20. package/adapters/generic/skills/component-builder/SKILL.md +59 -15
  21. package/adapters/generic/skills/storybook-chromatic-builder/SKILL.md +52 -9
  22. package/package.json +1 -1
  23. package/references/component-doc-archetypes.md +15 -11
  24. package/references/component-doc-schema.md +23 -5
  25. package/references/doc-card-builder.md +565 -0
  26. package/references/doc-writing-standard.md +144 -0
  27. package/references/figma-component-standards.md +63 -16
  28. package/references/guide-voice.md +96 -0
  29. package/references/manifest-schema.md +22 -4
  30. package/scripts/README.md +23 -0
  31. package/scripts/build-doc-card-builder.mjs +143 -0
  32. package/scripts/docs-check.mjs +18 -4
  33. package/scripts/docs-lint.mjs +163 -0
  34. package/scripts/install.mjs +13 -1
  35. package/scripts/lib/doc-card-plan.mjs +101 -0
  36. package/scripts/lib/doc-card-render.figma.js +371 -0
@@ -4,18 +4,18 @@ ThroughLine builds a design system end to end. Load the matching prompt for the
4
4
 
5
5
  ## ThroughLine skills
6
6
 
7
- - `component-builder` — Build a foundational set of Figma components — buttons, inputs, cards, badges, chips, modals, and more — as properly structured components with variant matrices (types, sizes, states) and icon/component/content slots, bound to the design system's tokens and styles. → load `prompts/component-builder.md`.
7
+ - `component-builder` — Build Figma components — buttons, inputs, cards, badges, chips, modals, and more — with variant matrices (types, sizes, states) and icon/component/content slots bound to the design system's tokens and styles. → load `prompts/component-builder.md`.
8
8
  - `component-pipeline` — Take a single new component from Figma to fully-built-and-storied code, end to end — build it in Figma, sync any new tokens it introduced, then build its code component and stories. → load `prompts/component-pipeline.md`.
9
- - `design-system-audit` — Measure a pre-existing design system before retrofitting it onto tokens — size the code-side color surface and inventory the existing Figma file with verified per-class reads, then compute how semantic the system already is so the retrofit is right-sized. → load `prompts/design-system-audit.md`.
9
+ - `design-system-audit` — Measure a pre-existing design system before retrofitting it onto tokens, so the retrofit is right-sized. → load `prompts/design-system-audit.md`.
10
10
  - `figma-environment-setup` — Set up the local working folder and connect Codex to Figma so the design-system skills can read and write variables, styles, and components. → load `prompts/figma-environment-setup.md`.
11
- - `icon-system-builder` — Build an icon system in Figma — a dedicated "Icons" page populated with the user's chosen icon library (Lucide, Material, or custom SVGs) as well-named, scalable components using the fastest, most-automated mechanism per library (for Lucide, batch-fetching the curated subset's official SVGs from the source repo and componentizing them hands-off; for Material, the official community file or importer plugin) rather than hand-generating icons or making the user copy components by hand. → load `prompts/icon-system-builder.md`.
12
- - `repository-builder` — Graduate the local design-system folder into a real monorepo — a pnpm + Turborepo workspace with packages for tokens and UI components and room for apps — and walk the user from a plain folder to local git to a GitHub remote with PRs and CI. → load `prompts/repository-builder.md`.
13
- - `retrofit-planner` — Orchestrate a full brownfield design-system retrofit end to end — audit, refine variables in place, rebind components, sync, capture a Chromatic baseline, retrofit the code with dual output, adopt existing documentation then fill gaps, then remove the old tokens only after a zero-reference grep — with a human confirmation gate between every phase. → load `prompts/retrofit-planner.md`.
14
- - `storybook-chromatic-builder` — Stand up Storybook in the monorepo, build code components matching the Figma design system (consuming the synced tokens and implementing the captured slot contracts), generate stories for every component, set up Chromatic for visual regression testing, and wire Code Connect when the user's Figma plan supports it. → load `prompts/storybook-chromatic-builder.md`.
15
- - `token-builder` — Build a two-tier (primitive + semantic) design token system as Figma variables — color ramps, spacing, type scale, radius, shadows — with light/dark or brand modes. → load `prompts/token-builder.md`.
16
- - `token-crosswalk-builder` — Build the brownfield token crosswalk — a persistent three-way map between each new token, the old Figma variable, and the old code identifier(s) — as crosswalk.json, then install the vetted validator/reverse-index scripts into the monorepo and wire the tokens:validate CI gate. → load `prompts/token-crosswalk-builder.md`.
17
- - `token-sheet-builder` — Build a beautiful, on-brand "Foundations" page in Figma that visually documents every variable collection and style — color ramps with swatches, the type scale, spacing, radius, shadows/elevations — with swatches live-bound to the actual variables where Figma allows. → load `prompts/token-sheet-builder.md`.
18
- - `token-sync-layer` — Sync Figma design variables into code-ready token files by extracting them to DTCG-format JSON, running them through Style Dictionary, and emitting framework-specific outputs via per-platform adapters (shadcn/Tailwind, MUI, vanilla CSS, iOS Swift, Android Kotlin, or custom). → load `prompts/token-sync-layer.md`.
11
+ - `icon-system-builder` — Build an icon system in Figma — a dedicated "Icons" page of well-named, scalable icon components from Lucide, Tabler, Phosphor, Material, or custom SVGs. → load `prompts/icon-system-builder.md`.
12
+ - `repository-builder` — Graduate the local design-system folder into a real monorepo — a pnpm + Turborepo workspace with packages for tokens and UI components — and walk the user from a plain folder to local git to a GitHub remote with PRs and CI. → load `prompts/repository-builder.md`.
13
+ - `retrofit-planner` — Orchestrate a full brownfield design-system retrofit end to end — audit, refine, rebind, sync, baseline, code, docs, cleanup — with a human confirmation gate between every phase. → load `prompts/retrofit-planner.md`.
14
+ - `storybook-chromatic-builder` — Stand up Storybook in the monorepo, build code components matching the Figma design system, generate stories for every component, set up Chromatic for visual regression testing, and wire Code Connect when the user's Figma plan supports it. → load `prompts/storybook-chromatic-builder.md`.
15
+ - `token-builder` — Build a two-tier (primitive + semantic) design token system as Figma variables — color ramps, spacing, type scale, radius, shadows — with light/dark or brand modes, using one collection per category per tier. → load `prompts/token-builder.md`.
16
+ - `token-crosswalk-builder` — Build the brownfield token crosswalk — a persistent three-way map between each new token, the old Figma variable, and the old code identifier(s) — then wire the tokens:validate CI gate. → load `prompts/token-crosswalk-builder.md`.
17
+ - `token-sheet-builder` — Build an on-brand "Foundations" page in Figma that visually documents every variable collection and style — color ramps with swatches, the type scale, spacing, radius, shadows/elevations. → load `prompts/token-sheet-builder.md`.
18
+ - `token-sync-layer` — Sync Figma design variables into code-ready token files via DTCG JSON and Style Dictionary, emitting framework-specific outputs (shadcn/Tailwind, MUI, vanilla CSS, iOS Swift, Android Kotlin, or custom), and set up the reusable "sync figma tokens" command. → load `prompts/token-sync-layer.md`.
19
19
 
20
20
  ## ThroughLine commands
21
21
 
@@ -236,7 +236,9 @@ Read `.throughline/references/component-doc-schema.md` for the exact JSON
236
236
  schema, the fingerprint algorithm, and the projection contract.
237
237
 
238
238
  **Run the generation pipeline (each layer only fills what it legitimately knows;
239
- stamp `provenance` per block):**
239
+ stamp `provenance` per block):** all authored prose follows
240
+ `.throughline/references/doc-writing-standard.md` — its plain
241
+ reference register, not this skill's guide voice.
240
242
 
241
243
  0. **Ingest existing docs — brownfield only, runs first.** If docs already exist
242
244
  for this component (code JSDoc/MDX/README, or a populated Figma component
@@ -255,32 +257,74 @@ stamp `provenance` per block):**
255
257
  accessibility idiom to the target framework (the same field you read for variant
256
258
  vocabulary). Provenance `framework`.
257
259
  4. **Interview for the non-inferable.** Ask the user for brand/product-specific
258
- do's & don'ts and intent. Provenance `user`. **Show the whole drafted record and
259
- get explicit approval before writing anything** — layers 1–4 only fill blocks the
260
- ingest step did not, and an `imported`/`user` block is never overwritten.
260
+ do's & don'ts and intent. Provenance `user`. Write the draft to
261
+ `design-system/docs/components/<Name>.doc.json`, run
262
+ `node .throughline/scripts/docs-lint.mjs design-system/docs/components/<Name>.doc.json`,
263
+ and fix the warnings it raises. Do not raise a separate confirmation for
264
+ a warning on an `imported`/`user` block: draft the rewrite and carry it
265
+ into the approval gate below, shown as before/after and labelled with the
266
+ block's provenance. **Show the whole drafted record and get explicit
267
+ approval before projecting it anywhere** (Figma description, doc card,
268
+ manifest) — one approval covers the whole record. Blocks the user did not
269
+ clear keep their existing text; blocks the user did clear are stamped
270
+ `imported+user` so a later run neither re-asks nor rewrites them.
261
271
 
262
272
  **Write the record and project it:**
263
273
 
264
274
  - Write `design-system/docs/components/<Name>.doc.json` (JSON; required fields
265
275
  `name`, `summary`, `description`).
266
276
  - **Figma component description.** Set the component's native `description` field
267
- (via `figma_set_description`) to a compact markdown rendering summary,
268
- when-to-use/not, do's/don'ts, and the a11y summary and append a fingerprint
269
- marker line `<!-- tl:doc <fp> -->` (this is the surface Dev Mode and Code Connect
270
- read).
271
- - **Doc card body.** Extend the existing doc card (name/short-desc/status/date, per
272
- `.throughline/references/figma-component-standards.md`) with a usage body:
273
- when-to-use, do's/don'ts, an a11y line, and a variant/state legend — all
274
- token-bound (no hardcoded hex/px). Add a metadata text node named
275
- `Doc Fingerprint` holding `<fp>`.
277
+ (via `figma_set_description`) from this exact templatethis is the surface
278
+ Dev Mode and Code Connect read, and it must be reproducible byte-for-byte by
279
+ any agent from the same record:
280
+
281
+ ```
282
+ <summary>
283
+
284
+ **When to use**
285
+ - <whenToUse[n]>
286
+
287
+ **When not to use**
288
+ - <whenNotToUse[n]>
289
+
290
+ **Do**
291
+ - <dos[n]>
292
+
293
+ **Don't**
294
+ - <donts[n]>
295
+
296
+ **Accessibility**
297
+ - <accessibility.keyboard[n]>
298
+ - <accessibility.notes[n]>
299
+
300
+ <!-- tl:doc <fp> -->
301
+ ```
302
+
303
+ Rules: every line is a record string **verbatim** — no re-wording, no added
304
+ connectives, no sentences that appear nowhere in the record. A block whose
305
+ source array is empty is omitted along with its bold label. The **Accessibility**
306
+ label is omitted only when both `accessibility.keyboard` and `accessibility.notes`
307
+ are empty; when one is empty its bullets are simply absent and the label stays.
308
+ Sections are separated by exactly one blank line, and the fingerprint marker is
309
+ always last.
310
+ - **Doc card body.** Render the card's `Usage` band with the canonical builder
311
+ snippet in `.throughline/references/doc-card-builder.md` (via
312
+ `figma_execute` with an explicit `timeout`, one card per call): fill the
313
+ RECORD/CANONICAL_FP slots, resolve the nine required semantic variables and
314
+ the `Body/Default` text style per that file's call contract, run it, and
315
+ verify the returned summary (`rowsRendered`, `blocksCreated`, `cardWidth`) —
316
+ not a screenshot. The builder creates the `Doc Fingerprint` node itself and
317
+ is the only thing that may build the usage body — never hand-assemble it.
276
318
  - Compute `<fp>` as the canonical fingerprint defined in the schema reference
277
319
  (sha256 of the projected record without `provenance`, first 16 hex chars).
278
320
 
279
321
  **Update the manifest (fields this skill owns):** set
280
322
  `components.meta[<Name>].doc` to `{ path, fingerprint: <fp>, surfaces: {
281
323
  figmaDescription: { src: <fp>, render: <hash of the description text> }, docCard: {
282
- src: <fp>, render: <hash of the card body content> } } }`. The code surfaces
283
- (`storybookMdx`) are added later by `storybook-chromatic-builder`.
324
+ src: <fp>, render: <summary.renderHash>, renderer: <summary.rendererVersion> } } }`
325
+ the docCard entry is stamped from the builder's returned summary, never by
326
+ re-reading the card. The code surfaces (`storybookMdx`) are added later by
327
+ `storybook-chromatic-builder`.
284
328
 
285
329
  Run the standard doc-card visual-validation + post-build audit
286
330
  (`.throughline/references/figma-component-standards.md`) after enriching
@@ -8,17 +8,49 @@ Ask which component to document (e.g. "Button"), then:
8
8
  the `component-builder` prompt's *Author the documentation record* step —
9
9
  ingest any existing docs first (brownfield), then infer → enrich (from
10
10
  `.throughline/references/component-doc-archetypes.md`) → specialize →
11
- interview. The user approves the drafted record; `imported`/`user` blocks are
12
- never overwritten.
11
+ interview. Authored prose follows
12
+ `.throughline/references/doc-writing-standard.md`. Set `updatedAt` to
13
+ today's date (ISO, `YYYY-MM-DD`) whenever the record is written or rewritten —
14
+ it is a projected field and the doc card's header renders it. Once the record is
15
+ written, run `node .throughline/scripts/docs-lint.mjs
16
+ design-system/docs/components/<Name>.doc.json` and fix its warnings. Do not
17
+ raise a separate confirmation for a warning on an `imported`/`user` block:
18
+ draft the rewrite and carry it into the approval gate below, shown as
19
+ before/after and labelled with the block's provenance, so one approval covers
20
+ the whole record. The user approves the drafted record before anything is
21
+ projected (Figma description, doc card, manifest). Blocks the user did not
22
+ clear keep their existing text; blocks the user did clear are stamped
23
+ `imported+user` so a later run neither re-asks nor rewrites them.
13
24
  2. **Project it.** Write `design-system/docs/components/<Name>.doc.json`, set the
14
- Figma component `description`, enrich the doc card, and (if the repo/code side
15
- exists) render MDX/JSDoc and run `docs:digest` per the
16
- `storybook-chromatic-builder` render step.
17
- 3. **Reconcile drift.** Run `docs:check`. For each drifted surface, offer a per-item
18
- choice **re-render** (canonical wins) or **pull-back** (fold the surface edit
19
- into the record) and land the result as a reviewable change. On a brownfield
20
- component's first pass, adopt existing content (`provenance: imported`) rather
21
- than overwriting it.
25
+ Figma component `description`, rebuild the doc card's `Usage` band with the
26
+ canonical builder (`.throughline/references/doc-card-builder.md`
27
+ verify its returned summary and stamp `surfaces.docCard.{src,render,renderer}`
28
+ from it), and (if the repo/code side exists) render MDX/JSDoc and run
29
+ `docs:digest` per the `storybook-chromatic-builder` render step.
30
+ 3. **Reconcile drift.** Before trusting `docs:check`, confirm the repo's copy of
31
+ the doc scripts is current: compare `DOC_CARD_RENDERER_VERSION` in the repo's
32
+ `scripts/lib/doc-card-plan.mjs` against the same constant in
33
+ `.throughline/scripts/lib/doc-card-plan.mjs`. If the repo file is
34
+ missing, or its version is lower, `docs:check` is reading stale rules and its
35
+ "no drift" is meaningless — say so plainly, and offer to refresh the repo's
36
+ doc scripts from the plugin copy. Refresh the whole set and re-check the npm
37
+ registrations, both per **Documentation scripts — install as a set** in
38
+ `.throughline/scripts/README.md` — a refreshed file whose script was
39
+ never registered is the same failure in a new place. Run `docs:check` (with the
40
+ refreshed scripts, if any). For each drifted surface, offer a per-item
41
+ choice — **re-render** (canonical wins) or **pull-back**
42
+ (fold the surface edit into the record) — and land the result as a reviewable
43
+ change. On a brownfield component's first pass, adopt existing content
44
+ (`provenance: imported`) rather than overwriting it.
45
+ `docs:check` may also report `layout-upgrade-available` (informational, never
46
+ failing): the card's layout predates the current builder. Offer to re-render
47
+ the `Usage` band now — rebuild happens on this touch, never unprompted.
48
+ 4. **Close the flow.** Hand back in the four-beat guide voice from
49
+ `.throughline/references/guide-voice.md`: the outcome, what you set
50
+ aside and why, one recommended next step, and at most one light alternative.
51
+ Read existing state to name what is actually outstanding rather than guessing —
52
+ a component at `status: "draft"` with no code surface in `meta[name].doc.surfaces`
53
+ means the code side is deferred. Do not close with a grid of co-equal options.
22
54
 
23
55
  See `.throughline/references/component-doc-schema.md` for the record schema,
24
56
  fingerprint contract, and projection mapping. If a component was never built in
@@ -27,15 +27,16 @@ system). Wire it to consume `packages/tokens` output so stories render with the
27
27
  real design tokens (import the generated CSS/theme). Checkpoint: confirm
28
28
  Storybook runs and shows the token-themed canvas.
29
29
 
30
- Install the documentation scripts alongside the token scripts (copy from the
31
- plugin's `scripts/` `build-docs-digest.mjs`, `docs-check.mjs`, and
32
- `lib/doc-record.mjs` into the repo and register npm scripts):
33
-
34
- - `"docs:digest": "node scripts/build-docs-digest.mjs"`
35
- - `"docs:check": "node scripts/docs-check.mjs"`
30
+ Install the documentation scripts alongside the token scripts: copy the five
31
+ files and register the three npm scripts listed under **Documentation scripts —
32
+ install as a set** in `.throughline/scripts/README.md`. That table is
33
+ the single source of truth for what a consuming repo gets; do not restate the
34
+ list here.
36
35
 
37
36
  These are the documentation analog of `tokens:validate`; see
38
- `.throughline/scripts/README.md`.
37
+ `.throughline/scripts/README.md`. This copy is setup, not a forever-fork:
38
+ `/document-component` re-checks these files' freshness on every run and refreshes
39
+ them from the plugin when it has moved on.
39
40
 
40
41
  **pnpm build-script allowlist (first-run gotcha).** On pnpm workspaces, the
41
42
  `@storybook/react-vite` install pulls `esbuild`, whose postinstall is blocked by
@@ -159,6 +160,43 @@ Configure Chromatic to snapshot everything (do **not** set `onlyChanged`), and
159
160
  verify a token-only PR re-snapshots all stories — they should flip orange against
160
161
  the green baseline.
161
162
 
163
+ ### Usage & cost guardrails
164
+
165
+ The full-snapshot default above is the right call for catching regressions, and it
166
+ is also the **maximum-usage** choice: every story, every run. Chromatic bills per
167
+ snapshot, so name this cost shape to the user when you set Chromatic up, and put the
168
+ guardrails in *before* the first big token PR, not after the bill.
169
+
170
+ What Chromatic actually offers (re-verify the live numbers at
171
+ `chromatic.com/pricing` — they drift):
172
+
173
+ - **Free plan (~5,000 snapshots/month):** testing **auto-pauses** when the ceiling
174
+ is hit. No surprise bill, but visual-regression coverage silently *stops* until
175
+ the monthly reset or an upgrade. For a full-suite design system that ceiling
176
+ arrives fast — treat a *paused* build as a red flag, not a passing one.
177
+ - **Paid plans: no hard spending cap.** Overage snapshots auto-bill at month-end.
178
+ The only native guardrail is **usage alerts** — an email when consumption crosses
179
+ a threshold you set (e.g. 90%).
180
+
181
+ The math, so the user sizes the plan honestly: **snapshots ≈ stories × modes ×
182
+ builds.** One `/sync-figma-tokens` PR re-snapshots the *entire* suite × every mode
183
+ in a single build — e.g. 40 components × 2 modes = 80 snapshots per build, and a
184
+ handful of token PRs plus daily `main` builds clears a free tier in a week.
185
+
186
+ So the guardrails, all of them user-controlled (Chromatic will not cap you):
187
+
188
+ 1. **Set usage alerts** at ~80% on a paid plan so the bill cannot sneak up. On the
189
+ free plan, make sure the user knows testing *pauses* at the ceiling.
190
+ 2. **Scope the CI trigger.** Run Chromatic on **pull requests and `main` only** —
191
+ never on every branch push — path-filter out docs-only changes, and keep it to
192
+ one Chromatic build per commit (no duplicate runs).
193
+ 3. **Size the plan to the math** before the first token PR. A large story count is
194
+ also the *only* reason to revisit TurboSnap (see above), and even then treat
195
+ every token change as a full run.
196
+
197
+ Do not silently pick a plan or leave the trigger wide open. Name the tradeoff and
198
+ let the user choose with the numbers in front of them.
199
+
162
200
  ## Step 5 — Code Connect (plan-gated, skip gracefully)
163
201
 
164
202
  Code Connect ties Figma components to their code counterparts so Figma's dev
@@ -234,8 +272,10 @@ the `figma_execute` scripting gotchas — `getNodeByIdAsync` and an explicit
234
272
  re-render the affected surfaces so `docs:check` stays green.
235
273
  - If Figma is connected (per `figma.mechanism`), open the component's doc card and
236
274
  update the `Status Label` text to `stable`, re-bind the `Status` chip fill to
237
- the **success** semantic color variable (mode-aware, not a hardcoded hex), and
238
- set `Last Updated` to today's date then screenshot to confirm the chip
275
+ the **success** semantic color variable (mode-aware, not a hardcoded hex), then
276
+ re-run the canonical doc-card builder against the same card to refresh the
277
+ header date from the `record.updatedAt` already set above (it locates the date
278
+ node under either header shape) — then screenshot to confirm the chip
239
279
  recolored and the date changed.
240
280
  - If Figma isn't connected, still update the manifest and tell the user the card
241
281
  will reconcile next Figma session (or offer to reconnect and fix it now).
@@ -296,6 +336,9 @@ that may not exist.
296
336
  - Never rely on TurboSnap (`onlyChanged: true`) for a token-driven design system
297
337
  — its incremental model keeps missing global token changes. Default to full
298
338
  snapshots (every story, every run); revisit only at large story counts.
339
+ - Never leave Chromatic's cost shape unspoken or the CI trigger wide open — there
340
+ is no hard spend cap on paid plans, so set usage alerts, run it on PRs + `main`
341
+ only, and size the plan to stories × modes × builds before the first token PR.
299
342
  - Never use the sequential model for story-gen — parallelize via subagents.
300
343
  - Never capture the Chromatic baseline *after* a code retrofit — baseline before, so
301
344
  intended drift-fixes are distinguishable from regressions.
@@ -8,17 +8,49 @@ Ask which component to document (e.g. "Button"), then:
8
8
  the `component-builder` rule's *Author the documentation record* step —
9
9
  ingest any existing docs first (brownfield), then infer → enrich (from
10
10
  `.throughline/references/component-doc-archetypes.md`) → specialize →
11
- interview. The user approves the drafted record; `imported`/`user` blocks are
12
- never overwritten.
11
+ interview. Authored prose follows
12
+ `.throughline/references/doc-writing-standard.md`. Set `updatedAt` to
13
+ today's date (ISO, `YYYY-MM-DD`) whenever the record is written or rewritten —
14
+ it is a projected field and the doc card's header renders it. Once the record is
15
+ written, run `node .throughline/scripts/docs-lint.mjs
16
+ design-system/docs/components/<Name>.doc.json` and fix its warnings. Do not
17
+ raise a separate confirmation for a warning on an `imported`/`user` block:
18
+ draft the rewrite and carry it into the approval gate below, shown as
19
+ before/after and labelled with the block's provenance, so one approval covers
20
+ the whole record. The user approves the drafted record before anything is
21
+ projected (Figma description, doc card, manifest). Blocks the user did not
22
+ clear keep their existing text; blocks the user did clear are stamped
23
+ `imported+user` so a later run neither re-asks nor rewrites them.
13
24
  2. **Project it.** Write `design-system/docs/components/<Name>.doc.json`, set the
14
- Figma component `description`, enrich the doc card, and (if the repo/code side
15
- exists) render MDX/JSDoc and run `docs:digest` per the
16
- `storybook-chromatic-builder` render step.
17
- 3. **Reconcile drift.** Run `docs:check`. For each drifted surface, offer a per-item
18
- choice **re-render** (canonical wins) or **pull-back** (fold the surface edit
19
- into the record) and land the result as a reviewable change. On a brownfield
20
- component's first pass, adopt existing content (`provenance: imported`) rather
21
- than overwriting it.
25
+ Figma component `description`, rebuild the doc card's `Usage` band with the
26
+ canonical builder (`.throughline/references/doc-card-builder.md`
27
+ verify its returned summary and stamp `surfaces.docCard.{src,render,renderer}`
28
+ from it), and (if the repo/code side exists) render MDX/JSDoc and run
29
+ `docs:digest` per the `storybook-chromatic-builder` render step.
30
+ 3. **Reconcile drift.** Before trusting `docs:check`, confirm the repo's copy of
31
+ the doc scripts is current: compare `DOC_CARD_RENDERER_VERSION` in the repo's
32
+ `scripts/lib/doc-card-plan.mjs` against the same constant in
33
+ `.throughline/scripts/lib/doc-card-plan.mjs`. If the repo file is
34
+ missing, or its version is lower, `docs:check` is reading stale rules and its
35
+ "no drift" is meaningless — say so plainly, and offer to refresh the repo's
36
+ doc scripts from the plugin copy. Refresh the whole set and re-check the npm
37
+ registrations, both per **Documentation scripts — install as a set** in
38
+ `.throughline/scripts/README.md` — a refreshed file whose script was
39
+ never registered is the same failure in a new place. Run `docs:check` (with the
40
+ refreshed scripts, if any). For each drifted surface, offer a per-item
41
+ choice — **re-render** (canonical wins) or **pull-back**
42
+ (fold the surface edit into the record) — and land the result as a reviewable
43
+ change. On a brownfield component's first pass, adopt existing content
44
+ (`provenance: imported`) rather than overwriting it.
45
+ `docs:check` may also report `layout-upgrade-available` (informational, never
46
+ failing): the card's layout predates the current builder. Offer to re-render
47
+ the `Usage` band now — rebuild happens on this touch, never unprompted.
48
+ 4. **Close the flow.** Hand back in the four-beat guide voice from
49
+ `.throughline/references/guide-voice.md`: the outcome, what you set
50
+ aside and why, one recommended next step, and at most one light alternative.
51
+ Read existing state to name what is actually outstanding rather than guessing —
52
+ a component at `status: "draft"` with no code surface in `meta[name].doc.surfaces`
53
+ means the code side is deferred. Do not close with a grid of co-equal options.
22
54
 
23
55
  See `.throughline/references/component-doc-schema.md` for the record schema,
24
56
  fingerprint contract, and projection mapping. If a component was never built in
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Build a foundational set of Figma components — buttons, inputs, cards, badges, chips, modals, and more — as properly structured components with variant matrices (types, sizes, states) and icon/component/content slots, bound to the design system's tokens and styles. Use this when the user wants to create components, build a component library, make buttons/inputs/cards/etc. in Figma, or set up the foundational UI kit. Also trigger after tokens and icons exist, when the user is ready to build actual UI components. Make sure to use this whenever someone wants real, variant-rich components in their Figma design system, not just tokens."
2
+ description: "Build Figma components — buttons, inputs, cards, badges, chips, modals, and more — with variant matrices (types, sizes, states) and icon/component/content slots bound to the design system's tokens and styles. Use this when the user wants to create components, build a component library, make buttons/inputs/cards/etc. in Figma, or set up the foundational UI kit. Also trigger after tokens and icons exist, when the user is ready to build actual UI components."
3
3
  alwaysApply: false
4
4
  ---
5
5
  # Component builder
@@ -240,7 +240,9 @@ Read `.throughline/references/component-doc-schema.md` for the exact JSON
240
240
  schema, the fingerprint algorithm, and the projection contract.
241
241
 
242
242
  **Run the generation pipeline (each layer only fills what it legitimately knows;
243
- stamp `provenance` per block):**
243
+ stamp `provenance` per block):** all authored prose follows
244
+ `.throughline/references/doc-writing-standard.md` — its plain
245
+ reference register, not this skill's guide voice.
244
246
 
245
247
  0. **Ingest existing docs — brownfield only, runs first.** If docs already exist
246
248
  for this component (code JSDoc/MDX/README, or a populated Figma component
@@ -259,32 +261,74 @@ stamp `provenance` per block):**
259
261
  accessibility idiom to the target framework (the same field you read for variant
260
262
  vocabulary). Provenance `framework`.
261
263
  4. **Interview for the non-inferable.** Ask the user for brand/product-specific
262
- do's & don'ts and intent. Provenance `user`. **Show the whole drafted record and
263
- get explicit approval before writing anything** — layers 1–4 only fill blocks the
264
- ingest step did not, and an `imported`/`user` block is never overwritten.
264
+ do's & don'ts and intent. Provenance `user`. Write the draft to
265
+ `design-system/docs/components/<Name>.doc.json`, run
266
+ `node .throughline/scripts/docs-lint.mjs design-system/docs/components/<Name>.doc.json`,
267
+ and fix the warnings it raises. Do not raise a separate confirmation for
268
+ a warning on an `imported`/`user` block: draft the rewrite and carry it
269
+ into the approval gate below, shown as before/after and labelled with the
270
+ block's provenance. **Show the whole drafted record and get explicit
271
+ approval before projecting it anywhere** (Figma description, doc card,
272
+ manifest) — one approval covers the whole record. Blocks the user did not
273
+ clear keep their existing text; blocks the user did clear are stamped
274
+ `imported+user` so a later run neither re-asks nor rewrites them.
265
275
 
266
276
  **Write the record and project it:**
267
277
 
268
278
  - Write `design-system/docs/components/<Name>.doc.json` (JSON; required fields
269
279
  `name`, `summary`, `description`).
270
280
  - **Figma component description.** Set the component's native `description` field
271
- (via `figma_set_description`) to a compact markdown rendering summary,
272
- when-to-use/not, do's/don'ts, and the a11y summary and append a fingerprint
273
- marker line `<!-- tl:doc <fp> -->` (this is the surface Dev Mode and Code Connect
274
- read).
275
- - **Doc card body.** Extend the existing doc card (name/short-desc/status/date, per
276
- `.throughline/references/figma-component-standards.md`) with a usage body:
277
- when-to-use, do's/don'ts, an a11y line, and a variant/state legend — all
278
- token-bound (no hardcoded hex/px). Add a metadata text node named
279
- `Doc Fingerprint` holding `<fp>`.
281
+ (via `figma_set_description`) from this exact templatethis is the surface
282
+ Dev Mode and Code Connect read, and it must be reproducible byte-for-byte by
283
+ any agent from the same record:
284
+
285
+ ```
286
+ <summary>
287
+
288
+ **When to use**
289
+ - <whenToUse[n]>
290
+
291
+ **When not to use**
292
+ - <whenNotToUse[n]>
293
+
294
+ **Do**
295
+ - <dos[n]>
296
+
297
+ **Don't**
298
+ - <donts[n]>
299
+
300
+ **Accessibility**
301
+ - <accessibility.keyboard[n]>
302
+ - <accessibility.notes[n]>
303
+
304
+ <!-- tl:doc <fp> -->
305
+ ```
306
+
307
+ Rules: every line is a record string **verbatim** — no re-wording, no added
308
+ connectives, no sentences that appear nowhere in the record. A block whose
309
+ source array is empty is omitted along with its bold label. The **Accessibility**
310
+ label is omitted only when both `accessibility.keyboard` and `accessibility.notes`
311
+ are empty; when one is empty its bullets are simply absent and the label stays.
312
+ Sections are separated by exactly one blank line, and the fingerprint marker is
313
+ always last.
314
+ - **Doc card body.** Render the card's `Usage` band with the canonical builder
315
+ snippet in `.throughline/references/doc-card-builder.md` (via
316
+ `figma_execute` with an explicit `timeout`, one card per call): fill the
317
+ RECORD/CANONICAL_FP slots, resolve the nine required semantic variables and
318
+ the `Body/Default` text style per that file's call contract, run it, and
319
+ verify the returned summary (`rowsRendered`, `blocksCreated`, `cardWidth`) —
320
+ not a screenshot. The builder creates the `Doc Fingerprint` node itself and
321
+ is the only thing that may build the usage body — never hand-assemble it.
280
322
  - Compute `<fp>` as the canonical fingerprint defined in the schema reference
281
323
  (sha256 of the projected record without `provenance`, first 16 hex chars).
282
324
 
283
325
  **Update the manifest (fields this skill owns):** set
284
326
  `components.meta[<Name>].doc` to `{ path, fingerprint: <fp>, surfaces: {
285
327
  figmaDescription: { src: <fp>, render: <hash of the description text> }, docCard: {
286
- src: <fp>, render: <hash of the card body content> } } }`. The code surfaces
287
- (`storybookMdx`) are added later by `storybook-chromatic-builder`.
328
+ src: <fp>, render: <summary.renderHash>, renderer: <summary.rendererVersion> } } }`
329
+ the docCard entry is stamped from the builder's returned summary, never by
330
+ re-reading the card. The code surfaces (`storybookMdx`) are added later by
331
+ `storybook-chromatic-builder`.
288
332
 
289
333
  Run the standard doc-card visual-validation + post-build audit
290
334
  (`.throughline/references/figma-component-standards.md`) after enriching
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Take a single new component from Figma to fully-built-and-storied code, end to end — build it in Figma, sync any new tokens it introduced, then build its code component and stories. This is an orchestrator that sequences the component-builder, token-sync-layer, and storybook-chromatic-builder skills with a human confirmation between each stage. Use this when the user wants to add a new component to an existing design system, ship a component end-to-end, or run the full new-component flow. Also trigger on \"/new-component\" or when someone says they want one component built all the way through to code. Make sure to use this when the design system foundations already exist and the user wants to add one more component through the whole pipeline."
2
+ description: "Take a single new component from Figma to fully-built-and-storied code, end to end — build it in Figma, sync any new tokens it introduced, then build its code component and stories. Orchestrates component-builder, token-sync-layer, and storybook-chromatic-builder with a human confirmation between each stage. Use this when the user wants to add a new component to an existing design system, ship a component end-to-end, or run the full new-component flow. Also trigger on \"/new-component\" or when someone wants one component built all the way through to code."
3
3
  alwaysApply: false
4
4
  ---
5
5
  # Component pipeline (orchestrator)
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Measure a pre-existing design system before retrofitting it onto tokens — size the code-side color surface and inventory the existing Figma file with verified per-class reads, then compute how semantic the system already is so the retrofit is right-sized. This is a PROCESS skill and the brownfield front door. Use this when retrofitting a design system onto a mature codebase and an already-populated Figma file, when the user wants to audit an existing system, size a retrofit, count existing tokens/variables/bindings, or figure out how much work a migration is. Also trigger when figma-environment-setup detects a brownfield situation (existing repo or populated Figma file), before any building. Make sure to use this whenever someone is converging two mature, drifted artifacts rather than building greenfield."
2
+ description: "Measure a pre-existing design system before retrofitting it onto tokens, so the retrofit is right-sized. This is a PROCESS skill and the brownfield front door. Use this when retrofitting a design system onto a mature codebase and an already-populated Figma file, when the user wants to audit an existing system, size a retrofit, count existing tokens/variables/bindings, or figure out how much work a migration is. Also trigger when figma-environment-setup detects a brownfield situation (existing repo or populated Figma file), before any building."
3
3
  alwaysApply: false
4
4
  ---
5
5
  # Design-system audit (brownfield front door)
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Set up the local working folder and connect Cursor to Figma so the design-system skills can read and write variables, styles, and components. This is a SETUP/PROCESS skill — it must run BEFORE brainstorming, not after it, because there is nothing to brainstorm until the environment exists. Invoke this skill immediately when the user wants to start, set up, or begin building a design system — phrases like 'let's setup my design system', 'let's get started', 'connect Figma', or 'build my design system' should all trigger this skill first, ahead of brainstorming. Also trigger when the user wants to fix a broken Figma connection, or mentions the Figma Console MCP, the desktop bridge plugin, or a Figma access token. It is the required foundation everything else depends on — always run it before any other design-system skill."
2
+ description: "Set up the local working folder and connect Cursor to Figma so the design-system skills can read and write variables, styles, and components. Run this BEFORE brainstorming and before any other design-system skill. Invoke it immediately when the user wants to start, set up, or begin building a design system — phrases like 'let's setup my design system', 'let's get started', 'connect Figma', or 'build my design system' should all trigger this skill first, ahead of brainstorming. Also trigger when the user wants to fix a broken Figma connection, or mentions the Figma Console MCP, the desktop bridge plugin, or a Figma access token."
3
3
  alwaysApply: false
4
4
  ---
5
5
  # Figma environment setup
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Build an icon system in Figma — a dedicated \"Icons\" page populated with the user's chosen icon library (Lucide, Material, or custom SVGs) as well-named, scalable components using the fastest, most-automated mechanism per library (for Lucide, batch-fetching the curated subset's official SVGs from the source repo and componentizing them hands-off; for Material, the official community file or importer plugin) rather than hand-generating icons or making the user copy components by hand. Use this when the user wants to set up icons, add an icon library, import Lucide or Material icons, create icon components, or build an icon set in Figma. Also trigger when the user mentions iconography, an icon page, or needs icons for their components. Make sure to use this whenever someone needs a managed set of icon components in their Figma design system."
2
+ description: "Build an icon system in Figma — a dedicated \"Icons\" page of well-named, scalable icon components from Lucide, Tabler, Phosphor, Material, or custom SVGs. Use this when the user wants to set up icons, add an icon library, import Lucide or Material icons, create icon components, or build an icon set in Figma. Also trigger when the user mentions iconography, an icon page, or needs icons for their components."
3
3
  alwaysApply: false
4
4
  ---
5
5
  # Icon system builder
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Graduate the local design-system folder into a real monorepo — a pnpm + Turborepo workspace with packages for tokens and UI components and room for apps — and walk the user from a plain folder to local git to a GitHub remote with PRs and CI. Use this when the user wants to set up a repo, create a GitHub repository, add version control, turn their folder into a real project, or prepare to sync tokens to code. Also trigger when the user mentions monorepo, Turborepo, pnpm workspace, GitHub, version control, or when the token-sync or Storybook skills report that a repo isn't set up yet. Make sure to use this skill when someone is moving from the Figma/design phase into the code phase, even if they just say \"I want to turn this into code\" — it's the bridge between the two halves."
2
+ description: "Graduate the local design-system folder into a real monorepo — a pnpm + Turborepo workspace with packages for tokens and UI components — and walk the user from a plain folder to local git to a GitHub remote with PRs and CI. Use this when the user wants to set up a repo, create a GitHub repository, add version control, turn their folder into a real project, or say \"I want to turn this into code\". Also trigger when the user mentions monorepo, Turborepo, pnpm workspace, GitHub, version control, or when the token-sync or Storybook skills report that a repo isn't set up yet."
3
3
  alwaysApply: false
4
4
  ---
5
5
  # Repository builder
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Orchestrate a full brownfield design-system retrofit end to end — audit, refine variables in place, rebind components, sync, capture a Chromatic baseline, retrofit the code with dual output, adopt existing documentation then fill gaps, then remove the old tokens only after a zero-reference grep — with a human confirmation gate between every phase. Use this when the user wants to run a complete retrofit, migrate a mature codebase and populated Figma file onto tokens, resume an in-progress retrofit, or be walked through the safe retrofit sequence. Also trigger after design-system-audit has sized the system, or when figma-environment-setup detects an in-progress retrofit. Make sure to use this whenever someone wants the guided, gated, multi-session brownfield retrofit rather than running the individual skills by hand."
2
+ description: "Orchestrate a full brownfield design-system retrofit end to end — audit, refine, rebind, sync, baseline, code, docs, cleanup — with a human confirmation gate between every phase. Use this when the user wants to run a complete retrofit, migrate a mature codebase and populated Figma file onto tokens, resume an in-progress retrofit, or be walked through the safe retrofit sequence. Also trigger after design-system-audit has sized the system, or when figma-environment-setup detects an in-progress retrofit."
3
3
  alwaysApply: false
4
4
  ---
5
5
  # Retrofit planner (orchestrator)