@radicool/throughline 0.12.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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/adapters/codex/AGENTS.md +29 -0
  4. package/adapters/codex/codex-mcp.toml +4 -0
  5. package/adapters/codex/prompts/component-builder.md +272 -0
  6. package/adapters/codex/prompts/component-pipeline.md +81 -0
  7. package/adapters/codex/prompts/design-system-audit.md +122 -0
  8. package/adapters/codex/prompts/design-system-status.md +41 -0
  9. package/adapters/codex/prompts/figma-environment-setup.md +456 -0
  10. package/adapters/codex/prompts/icon-system-builder.md +268 -0
  11. package/adapters/codex/prompts/new-component.md +13 -0
  12. package/adapters/codex/prompts/repository-builder.md +163 -0
  13. package/adapters/codex/prompts/retrofit-planner.md +136 -0
  14. package/adapters/codex/prompts/start.md +22 -0
  15. package/adapters/codex/prompts/storybook-chromatic-builder.md +261 -0
  16. package/adapters/codex/prompts/sync-figma-tokens.md +22 -0
  17. package/adapters/codex/prompts/token-builder.md +361 -0
  18. package/adapters/codex/prompts/token-crosswalk-builder.md +120 -0
  19. package/adapters/codex/prompts/token-sheet-builder.md +162 -0
  20. package/adapters/codex/prompts/token-sync-layer.md +232 -0
  21. package/adapters/cursor/.cursor/commands/design-system-status.md +41 -0
  22. package/adapters/cursor/.cursor/commands/new-component.md +13 -0
  23. package/adapters/cursor/.cursor/commands/start.md +22 -0
  24. package/adapters/cursor/.cursor/commands/sync-figma-tokens.md +22 -0
  25. package/adapters/cursor/.cursor/mcp.json +14 -0
  26. package/adapters/cursor/.cursor/rules/component-builder.mdc +276 -0
  27. package/adapters/cursor/.cursor/rules/component-pipeline.mdc +85 -0
  28. package/adapters/cursor/.cursor/rules/design-system-audit.mdc +126 -0
  29. package/adapters/cursor/.cursor/rules/figma-environment-setup.mdc +460 -0
  30. package/adapters/cursor/.cursor/rules/icon-system-builder.mdc +272 -0
  31. package/adapters/cursor/.cursor/rules/repository-builder.mdc +167 -0
  32. package/adapters/cursor/.cursor/rules/retrofit-planner.mdc +140 -0
  33. package/adapters/cursor/.cursor/rules/storybook-chromatic-builder.mdc +265 -0
  34. package/adapters/cursor/.cursor/rules/token-builder.mdc +365 -0
  35. package/adapters/cursor/.cursor/rules/token-crosswalk-builder.mdc +124 -0
  36. package/adapters/cursor/.cursor/rules/token-sheet-builder.mdc +166 -0
  37. package/adapters/cursor/.cursor/rules/token-sync-layer.mdc +236 -0
  38. package/adapters/generic/AGENTS.md +46 -0
  39. package/adapters/generic/commands/design-system-status.md +41 -0
  40. package/adapters/generic/commands/new-component.md +13 -0
  41. package/adapters/generic/commands/start.md +22 -0
  42. package/adapters/generic/commands/sync-figma-tokens.md +22 -0
  43. package/adapters/generic/skills/component-builder/SKILL.md +272 -0
  44. package/adapters/generic/skills/component-pipeline/SKILL.md +81 -0
  45. package/adapters/generic/skills/design-system-audit/SKILL.md +122 -0
  46. package/adapters/generic/skills/figma-environment-setup/SKILL.md +456 -0
  47. package/adapters/generic/skills/icon-system-builder/SKILL.md +268 -0
  48. package/adapters/generic/skills/repository-builder/SKILL.md +163 -0
  49. package/adapters/generic/skills/retrofit-planner/SKILL.md +136 -0
  50. package/adapters/generic/skills/storybook-chromatic-builder/SKILL.md +261 -0
  51. package/adapters/generic/skills/token-builder/SKILL.md +361 -0
  52. package/adapters/generic/skills/token-crosswalk-builder/SKILL.md +120 -0
  53. package/adapters/generic/skills/token-sheet-builder/SKILL.md +162 -0
  54. package/adapters/generic/skills/token-sync-layer/SKILL.md +232 -0
  55. package/package.json +29 -0
  56. package/references/brainstorm-before-build.md +139 -0
  57. package/references/brownfield-retrofit.md +93 -0
  58. package/references/coding-level.md +70 -0
  59. package/references/crosswalk-schema.md +113 -0
  60. package/references/figma-component-standards.md +532 -0
  61. package/references/figma-publishing.md +125 -0
  62. package/references/figma-scripting.md +278 -0
  63. package/references/manifest-schema.md +341 -0
  64. package/references/scaling-up-handoff.md +61 -0
  65. package/references/sync-adapters.md +141 -0
  66. package/scripts/README.md +78 -0
  67. package/scripts/adapters/emit-codex.mjs +58 -0
  68. package/scripts/adapters/emit-cursor.mjs +26 -0
  69. package/scripts/adapters/emit-generic.mjs +41 -0
  70. package/scripts/adapters/generate.mjs +73 -0
  71. package/scripts/adapters/read-sources.mjs +54 -0
  72. package/scripts/adapters/translate.mjs +51 -0
  73. package/scripts/build-reverse-index.mjs +56 -0
  74. package/scripts/crosswalk.schema.json +33 -0
  75. package/scripts/grep-color-usage.mjs +143 -0
  76. package/scripts/guard-token-removal.mjs +95 -0
  77. package/scripts/install.mjs +143 -0
  78. package/scripts/lib/crosswalk.mjs +91 -0
  79. package/scripts/validate-crosswalk.mjs +96 -0
@@ -0,0 +1,460 @@
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."
3
+ alwaysApply: false
4
+ ---
5
+ # Figma environment setup
6
+
7
+ This skill does three foundational jobs, in order:
8
+
9
+ 1. **Discover where you're working** — find or create the project directory,
10
+ scan what's already there, and set expectations.
11
+ 2. **Create the local working folder** and write the `design-system.json`
12
+ manifest into it (if not already present from step 1).
13
+ 3. **Connect Cursor to Figma** so later skills can read and write the file,
14
+ then verify the connection works.
15
+
16
+ It is the required first step. Every other Figma skill does a cheap liveness
17
+ check and, if it fails, points the user back here.
18
+
19
+ ## Who you're talking to
20
+
21
+ Assume the user is design-fluent but may have **never set up a developer tool,
22
+ created an API token, or used a terminal before**. Explain every concept the
23
+ first time it appears, in one plain sentence. Never assume they know what a
24
+ "token", "MCP server", "config file", or "package manager" is. Be warm and
25
+ concrete. When you ask them to do something outside the chat (in Figma, on a
26
+ website), give the exact click path, not a vague instruction.
27
+
28
+ Read `.throughline/references/manifest-schema.md` before writing the manifest so you use the
29
+ correct field names and defaults.
30
+
31
+ ## Step 0 — Intake (Locate → Scan → Brief)
32
+
33
+ This step runs before everything else. Establish where you're working, read
34
+ what's already there, and set the user's expectations before taking any action.
35
+ It has three phases in sequence.
36
+
37
+ ### Phase 1: Locate
38
+
39
+ Open by surfacing the user's current working directory and presenting three
40
+ explicit options — no assumptions made about where they want to work or whether
41
+ they have started anything already:
42
+
43
+ > "Before we get started, I want to make sure we're working in the right place.
44
+ > You're currently in: `[current working directory path]`
45
+ >
46
+ > Where should we set up?
47
+ > - **Here** — this directory is where the design system should live
48
+ > - **Somewhere else** — I have a project at a different path
49
+ > - **A new folder** — create a fresh folder somewhere"
50
+
51
+ **"Here":** Proceed to the existing manifest check below.
52
+
53
+ **"Somewhere else":** Ask for the path. Expand it to an absolute path (resolve
54
+ `~`, relative segments like `../`, etc.) and verify it exists on disk as a
55
+ directory. If it doesn't exist, ask them to double-check the spelling. Once
56
+ confirmed, proceed to the existing manifest check.
57
+
58
+ **"A new folder":** Ask what they'd like to name it and where it should live
59
+ (suggest the current directory as the default). Create it. Confirm where it was
60
+ created: "I've created `[name]` at `[full path]`." Proceed to the existing
61
+ manifest check.
62
+
63
+ **Existing manifest check:** Before scanning, check whether `design-system.json`
64
+ already exists in the confirmed directory.
65
+
66
+ - **If it exists:** Read it. If `schemaVersion` is out of date, migrate forward
67
+ (add missing fields with defaults, bump `schemaVersion` — do not delete
68
+ unrecognised fields). Tell the user:
69
+ > "Looks like we've worked here before — I'll pick up where we left off."
70
+ Skip Phases 2 and 3. Continue into Step 2 with the existing manifest loaded.
71
+
72
+ - **If it does not exist:** Proceed to Phase 2.
73
+
74
+ ### Phase 2: Scan
75
+
76
+ Scan the confirmed directory for the following signals. Check in priority order
77
+ — monorepo status is the most consequential and is checked first.
78
+
79
+ | Signal | What it means |
80
+ |---|---|
81
+ | `turbo.json` **and** `pnpm-workspace.yaml` both present | Already a monorepo |
82
+ | `package.json` present, no `turbo.json` or `pnpm-workspace.yaml` | Repo exists, not yet a monorepo |
83
+ | `.storybook/` directory present | Storybook already installed |
84
+ | `tokens.json` or `tokens/` directory present | Existing token pipeline |
85
+ | `style-dictionary.config.js` or `*.style-dictionary.js` files present | Existing sync layer |
86
+
87
+ After scanning, write a full `design-system.json` using all schema defaults
88
+ from `.throughline/references/manifest-schema.md`, then populate the
89
+ `workspace.origin` and `workspace.detectedLayers` fields with the scan results:
90
+
91
+ ```json
92
+ "workspace": {
93
+ "origin": "<greenfield|existing-repo|existing-monorepo|unknown>",
94
+ "detectedLayers": {
95
+ "monorepo": <true|false>,
96
+ "storybook": <true|false>,
97
+ "tokens": <true|false>,
98
+ "syncLayer": <true|false>
99
+ }
100
+ }
101
+ ```
102
+
103
+ **Setting `origin`:**
104
+ - No `package.json` found → `"greenfield"`
105
+ - `package.json` found, no `turbo.json`/`pnpm-workspace.yaml` → `"existing-repo"`
106
+ - Both `turbo.json` and `pnpm-workspace.yaml` found → `"existing-monorepo"`
107
+ - Signals present but contradictory or incomplete → `"unknown"`
108
+
109
+ **Setting `detectedLayers`:** set each boolean independently from the table
110
+ above. A directory can have `origin: "existing-monorepo"` and
111
+ `detectedLayers.storybook: false` — they are independent fields.
112
+
113
+ **Do not overwrite `workspace.origin` on subsequent runs.** If it is already
114
+ set to a non-null value, skip the scan and proceed to Phase 3.
115
+
116
+ ### Phase 3: Brief
117
+
118
+ Produce a short, warm, plain-language situational summary. The goal is to set
119
+ expectations so nothing downstream feels like a surprise. No jargon. No alarm.
120
+ If something requires action before a later skill can run, say so as a
121
+ heads-up, not a warning.
122
+
123
+ **Format:**
124
+
125
+ > "Here's what I found in `[path]`:
126
+ > [plain-language bullet list of detected signals and what they mean]
127
+ >
128
+ > Here's what that means for us:
129
+ > [brief tailored roadmap: what works the same, what will be different, what
130
+ > to know before we hit it]
131
+ >
132
+ > Ready to continue?"
133
+
134
+ **By scenario:**
135
+
136
+ *Greenfield (no signals detected) — condensed, no need for the full format:*
137
+ > "Clean slate — we're building everything fresh. Ready to continue?"
138
+
139
+ *Existing single repo (`origin: "existing-repo"`):*
140
+ > "Here's what I found in `[path]`:
141
+ > - You have an existing repo, but it's not yet set up as a monorepo
142
+ > [any additional detected layers, one bullet each]
143
+ >
144
+ > Here's what that means for us: everything in the Figma phase — tokens,
145
+ > components, variables — works exactly the same. When we get to the code
146
+ > phase, you'll need to convert this repo to a monorepo first. I'll walk you
147
+ > through that step-by-step when we get there — it's a one-time setup.
148
+ > Because you already have a system here, we'll start by **auditing** what exists — measuring your current colors in code and what's in your Figma file — so we right-size the work before changing anything. That's the `design-system-audit` step.
149
+ > [one line per additional detected layer, e.g.: 'Storybook is already installed
150
+ > — we'll build on top of what you have rather than starting fresh.']
151
+ >
152
+ > Ready to continue?"
153
+
154
+ *Existing monorepo (`origin: "existing-monorepo"`):*
155
+ > "Here's what I found in `[path]`:
156
+ > - Your repo is already set up as a monorepo ✓
157
+ > [any additional detected layers, one bullet each]
158
+ >
159
+ > Here's what that means for us: you're already in great shape for the code
160
+ > phase. We'll build the Figma side first, then work inside your existing
161
+ > monorepo structure when we get to code.
162
+ > Because you already have a system here, we'll start by **auditing** what exists — measuring your current colors in code and what's in your Figma file — so we right-size the work before changing anything. That's the `design-system-audit` step.
163
+ > [one line per additional detected layer]
164
+ >
165
+ > Ready to continue?"
166
+
167
+ *Unknown:*
168
+ > "Here's what I found in `[path]`:
169
+ > - I can see some project files but I'm not sure of the full setup
170
+ >
171
+ > Before we continue: do you have an existing git repo here? And is it already
172
+ > set up as a monorepo (does it have a `turbo.json` or `pnpm-workspace.yaml`)?"
173
+ >
174
+ > Wait for the user to clarify, then update `workspace.origin` manually based
175
+ > on their answer before proceeding.
176
+
177
+ Once the user confirms they're ready, proceed to Step 2.
178
+
179
+ ## Step 2 — Create the working folder and manifest
180
+
181
+ **When Step 0 already set the directory:** if the user chose "Here" or
182
+ "Somewhere else" in Step 0, or an existing `design-system.json` was loaded,
183
+ the directory already exists and the manifest has been created or loaded. In
184
+ that case, skip folder creation below. The only thing to confirm is that
185
+ `workspace.name` is set — if it is `null` or `"my-design-system"` (the
186
+ placeholder default), ask the user what they'd like to name their design system
187
+ and update the field. Then proceed directly to Step 2.5.
188
+
189
+ ---
190
+
191
+ Ask the user what they'd like to name their design system (suggest something
192
+ like `my-design-system` if they're unsure). Then:
193
+
194
+ - Create a folder with that name in a sensible location (their current directory
195
+ is fine; confirm where it'll live so they can find it later).
196
+ - Write `design-system.json` into it using the schema defaults from
197
+ `.throughline/references/manifest-schema.md`, with:
198
+ - `workspace.name` = their chosen name
199
+ - `workspace.stage` = `"folder"`
200
+ - everything else at defaults
201
+
202
+ Tell them, in plain language, what just happened: "I've made a folder called
203
+ `my-design-system` on your computer, and put a small file called
204
+ `design-system.json` inside it. That file is a checklist of what we've set up —
205
+ you can open it anytime, and later I can read it back to remember where we are.
206
+ Right now everything in it says 'not done yet', which is exactly right."
207
+
208
+ **Do not** set up git or GitHub here. The whole Figma phase works with just this
209
+ folder. Git arrives later, only when there's code to version (the
210
+ repository-builder skill handles that).
211
+
212
+ ## Step 2.5 — Calibrate the coding level
213
+
214
+ Establish how much to explain code/git/terminal concepts in the later
215
+ code-touching skills. Read `.throughline/references/coding-level.md` and follow its
216
+ determination method: ask the **concrete anchoring questions** (have you set up
217
+ a GitHub repo before? used a terminal? worked with `.env` files?) rather than
218
+ "are you technical?" — self-assessment is unreliable.
219
+
220
+ Infer `new` / `some` / `comfortable` from the answers, confirm it in plain terms,
221
+ and record it in `user.codingLevel`. When in doubt, choose the lower level.
222
+
223
+ Frame this warmly and without judgment: "A couple quick questions so I explain
224
+ things at the right level for you — no wrong answers, and I can adjust anytime."
225
+ Make clear it changes only how much detail they get, never what they can build.
226
+
227
+ This is set now because it colors every later interaction. The Figma phase
228
+ itself doesn't lean on it much, but the code phase (repo, sync, Storybook) does.
229
+
230
+ ## Step 3 — Choose the Figma write mechanism
231
+
232
+ Explain there are two ways to connect Cursor to Figma, and recommend the first:
233
+
234
+ - **Figma Console MCP (recommended).** More capable — it can create many
235
+ variables at once efficiently (which saves time and usage), and it can read
236
+ your variables on any Figma plan, including free and Pro. Slightly more setup:
237
+ you'll create one access token and run a small helper plugin inside Figma.
238
+ - **Official Figma plugin (simpler fallback).** Less setup, but more limited —
239
+ some bulk operations are slower, and reading variables through it can be
240
+ restricted on non-Enterprise plans. Fine if the user wants the lightest path.
241
+
242
+ Let the user choose. Record their choice in `figma.mechanism`
243
+ (`"console-mcp"` or `"official-plugin"`). Default to `console-mcp` if they have
244
+ no preference.
245
+
246
+ The MCP server configuration ships **bundled with this plugin** (in the plugin's
247
+ `.mcp.json`), so the user does not hand-edit any config files. The one thing the
248
+ bundle can't contain is their personal access token — that's a per-user secret,
249
+ handled in the next step.
250
+
251
+ ## Step 4 — Connect to Figma (Console MCP path)
252
+
253
+ Walk through these one at a time, confirming each before moving on. Never rush
254
+ the user past a step.
255
+
256
+ ### 4a. The golden rule: use the Figma **desktop app**, not the browser
257
+
258
+ State this up front and clearly: **the Figma desktop app must be installed,
259
+ open, and signed in, with the file you want to work in open in it.** The
260
+ browser version of Figma causes connection and token errors that are painful to
261
+ debug. If they don't have the desktop app, point them to figma.com/downloads to
262
+ install it first. Desktop app, every time.
263
+
264
+ ### 4b. Create a Figma access token
265
+
266
+ A token is like a password that lets Cursor talk to Figma on your behalf. Walk
267
+ them through it:
268
+
269
+ 1. In a browser, go to figma.com and sign in (same account as the desktop app).
270
+ 2. Click your account menu, then Settings.
271
+ 3. Open the **Security** tab.
272
+ 4. Find **Personal access tokens** and click **Generate new token**.
273
+ 5. Give it a name they'll recognize, like `claude-design-system`.
274
+ 6. Copy the token immediately — Figma only shows it once. It starts with
275
+ `figd_`.
276
+
277
+ **Secret-handling rule (non-negotiable):** the token value must never pass
278
+ through the chat. Do not ask the user to paste it to you. Instead, tell them
279
+ exactly where it goes (the plugin's MCP configuration expects it in an
280
+ environment variable named `FIGMA_ACCESS_TOKEN`) and have them place it there
281
+ themselves, following the plugin's setup notes. If they're unsure where that is,
282
+ walk them to it, but you never see or handle the token. Reassure them this is
283
+ normal and good — their password-like token stays theirs.
284
+
285
+ ### 4c. Run the desktop bridge plugin and pair
286
+
287
+ The Console MCP talks to Figma through a small "bridge" plugin running inside
288
+ the desktop app.
289
+
290
+ 1. Import/run the Figma Console MCP **Desktop Bridge** plugin in their open
291
+ Figma file (one-time import; the setup docs for the MCP cover the exact
292
+ import step).
293
+ 2. The plugin shows a **pairing code**.
294
+ 3. Tell the user to keep the plugin panel open. When they ask you (in chat) to
295
+ connect, you'll initiate the connection and they'll enter/confirm the pairing
296
+ code in the plugin panel to authorize it.
297
+
298
+ Explain the shape of it plainly: "Figma needs to know it's really you allowing
299
+ this. The little plugin window shows a short code; you'll confirm it, and then
300
+ Cursor and Figma are linked for this session."
301
+
302
+ ### 4d. Restart the MCP client if needed
303
+
304
+ If the config was just added (token placed for the first time), the MCP client
305
+ may need a restart to load it. Tell them how, simply, and confirm they're back.
306
+
307
+ ## Step 4 (alt) — Connect to Figma (official plugin path)
308
+
309
+ If the user chose the official plugin, the flow is lighter: install the official
310
+ Figma plugin for Cursor per its setup, ensure the desktop app is open with
311
+ the file, and authenticate through the desktop app (again: desktop, not
312
+ browser). The same secret-handling rule applies — any token goes into config by
313
+ the user, never through the chat.
314
+
315
+ ## Step 5 — Capture the file key
316
+
317
+ Ask the user for the URL of the Figma file they want to build the design system
318
+ in. Extract the file key from it (the segment after `/file/` or `/design/`) and
319
+ store it in `figma.fileKey`. Explain: "This just tells Cursor which of your
320
+ Figma files to work in, so I don't have to ask every time."
321
+
322
+ ## Step 6 — Liveness check (prove it actually works)
323
+
324
+ Don't declare success on faith. Run one trivial **read** against Figma to prove
325
+ the connection is live — for example, a low-cost call such as reading the file
326
+ name or a single variable collection. This probe proves *connectivity only*.
327
+
328
+ **Do not report an inventory from this probe (the false-empty read bugs B1/B2).** A cheap or early read
329
+ can come back empty on a fully-populated file (pages not yet loaded, cache/read
330
+ error), and reporting "0 variables" or "no text styles" off the back of it is a
331
+ confidence-destroying first impression. Proving the connection is live is a
332
+ separate concern from inventorying what's in the file — the full per-class
333
+ inventory (with `loadAllPagesAsync` and independent reads for variables, text
334
+ styles, and effect styles) belongs to the `design-system-audit` rule, which
335
+ applies the read discipline in
336
+ `.throughline/references/brownfield-retrofit.md`. Here, only confirm the
337
+ call succeeded — never announce counts.
338
+
339
+ If the liveness probe succeeds:
340
+
341
+ - Set `figma.connected` = `true` and `figma.lastVerified` to the current
342
+ timestamp.
343
+ - Append `figma-environment-setup` to `completedSkills`.
344
+ - Tell the user warmly that the connection works and what they just unlocked:
345
+ "Cursor can now see and edit your Figma file. You're ready to build your first
346
+ tokens whenever you are."
347
+
348
+ If it fails, first figure out **which kind** of failure it is, because the fixes
349
+ are completely different:
350
+
351
+ **A. The MCP server never started.** The Console MCP is downloaded and launched
352
+ on demand by `npx`. If the error text mentions `npx`, `npm`, `EACCES`,
353
+ `permission denied`, `ENOENT`, a cache path like `~/.npm/_cacache`, or a network
354
+ / registry timeout, the *server process itself* failed to come up — this is an
355
+ environment problem, not a Figma or token problem. Walking the user through
356
+ tokens or pairing here is useless. Diagnose in order:
357
+
358
+ - **npm cache permission error (`EACCES` writing to `~/.npm`).** This is the
359
+ common one. It means some files in the user's npm cache are owned by `root`,
360
+ usually because `npm` was run with `sudo` at some point, so `npx` can't write
361
+ there. Confirm by checking ownership of `~/.npm` (look for files owned by
362
+ `root` rather than the user). The fix is for the **user** to run, in their own
363
+ terminal, the standard npm-recommended command to give the cache back to
364
+ themselves:
365
+
366
+ ```
367
+ sudo chown -R $(whoami) ~/.npm
368
+ ```
369
+
370
+ Explain it plainly: "A past install left a few files in npm's download folder
371
+ locked to the system account, so the Figma helper can't download. This one
372
+ command hands that folder back to you. It'll ask for your Mac password." Never
373
+ run `sudo` for them — surface the command and let them run it. Then retry the
374
+ liveness check.
375
+ - **Network / registry timeout.** Have them check their connection (and any
376
+ VPN/proxy/corporate registry), then retry.
377
+ - **`node`/`npm` not installed.** `npx` needs Node.js. If it's missing entirely,
378
+ point them to install Node (nodejs.org LTS) and retry.
379
+
380
+ **B. The server started but the connection failed.** If there's no launch error
381
+ and the server is clearly running, diagnose gently and in order: Is the desktop
382
+ app open with the file? Was the token placed correctly (have them re-check,
383
+ without showing you the value)? Is the bridge plugin running and paired? Did the
384
+ client need a restart? Walk them back through the relevant sub-step.
385
+
386
+ Do not move on until the liveness check passes.
387
+
388
+ ## Step 6.5 — Prove writes work (throwaway)
389
+
390
+ The liveness check above is a *read*. Before handing off, confirm Cursor can also
391
+ **write** to the file — but do **not** leave a permanent artifact behind. The
392
+ file's branded **Cover** page is built later, by `token-sheet-builder`, once
393
+ tokens and styles actually exist, so it can be genuinely on-brand instead of a
394
+ neutral placeholder built against nothing.
395
+
396
+ - Create one trivial throwaway node (e.g. a small frame or text node named
397
+ `__throughline write test`) on any page.
398
+ - Confirm it landed with a quick read or `figma_capture_screenshot`.
399
+ - **Delete it.** If both the write and the delete succeed, writes are proven.
400
+
401
+ Leave `figma.coverPageBuilt` = `false` here — that flag is set later, when the
402
+ real Cover page is built. Keep this step quick; it's plumbing, not design.
403
+
404
+ ## Step 7 — Hand off
405
+
406
+ Once live, tell the user what comes next without forcing it: "The natural next
407
+ step is building your color, spacing, and type tokens — just say something like
408
+ 'let's build my tokens' and I'll take it from there. Or if you'd rather explore
409
+ first, that's fine too." Update the manifest and stop. Don't auto-run the next
410
+ skill.
411
+
412
+ ## Step 8 — Brownfield routing + rollback baseline (existing systems)
413
+
414
+ After the liveness check passes, decide where to send the user. Most greenfield runs
415
+ continue to token building. A **brownfield** run — a mature codebase and/or an
416
+ already-populated Figma file — routes into the audit first, and an **in-progress
417
+ retrofit** resumes where it left off. This is the front-door routing the spec calls
418
+ for; apply the read discipline in
419
+ `.throughline/references/brownfield-retrofit.md` to every read here.
420
+
421
+ **Read the manifest and route:**
422
+
423
+ 1. **Resume an in-progress retrofit.** If `retrofit.phase` is set and not `"done"`,
424
+ a retrofit is already underway — hand back to **`retrofit-planner`** to resume at
425
+ that phase, rather than starting anything new. Say plainly where it left off
426
+ (e.g. "Looks like we're mid-retrofit at the `sync` phase — want to pick up there?").
427
+ 2. **Route a mature system to the audit.** If `workspace.origin` is `"existing-repo"`
428
+ or `"existing-monorepo"` (a mature codebase), recommend **`design-system-audit`**
429
+ as the next step instead of `token-builder`: "You've got an existing system — let's
430
+ audit it first so we right-size the retrofit." The audit also covers a populated
431
+ Figma file via its verified per-class reads.
432
+ 3. **Greenfield stays greenfield.** If `workspace.origin` is `"greenfield"`, continue
433
+ the normal path (brainstorm → token-builder). Don't push greenfield users through
434
+ the audit.
435
+
436
+ **Capture a rollback baseline before any mutation (brownfield only).** A retrofit
437
+ changes a file that already has value in it, so before *any* write lands, capture a
438
+ restore point:
439
+ - **Figma version checkpoint** — note the current version (e.g. via
440
+ `figma_get_file_versions`) or have the user name a Figma version so there's a known-good
441
+ point to restore to. The plugin can read versions; it does not auto-create named
442
+ versions, so if none exists, ask the user to add one ("File → Save to version
443
+ history") and record that you did.
444
+ - **Token export** — if the repo already emits tokens, snapshot the current generated
445
+ output (git is the natural baseline once `workspace.stage` is `local-git`+).
446
+
447
+ Do this **before** routing into any skill that writes (the audit only reads, so the
448
+ baseline must be in place before `token-builder`'s refine phase runs). Frame it as
449
+ cheap insurance, not alarm.
450
+
451
+ ## What this skill must NOT do
452
+
453
+ - Never set up git or GitHub (wrong phase — that's repository-builder).
454
+ - Never ask for, accept, store, or echo the Figma access token or any secret.
455
+ - Never hand-edit MCP config on the user's behalf in a way that embeds a secret.
456
+ - Never skip the liveness check.
457
+ - Never assume the browser version of Figma will work — always require desktop.
458
+ - Never overwrite `workspace.origin` once it has been set — it is immutable
459
+ after intake.
460
+