@friedbotstudio/create-baseline 0.1.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 (197) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +222 -0
  3. package/bin/cli.js +247 -0
  4. package/obj/template/.claude/agents/swarm-worker.md +52 -0
  5. package/obj/template/.claude/bin/LICENSE +201 -0
  6. package/obj/template/.claude/bin/NOTICE +48 -0
  7. package/obj/template/.claude/commands/approve-spec.md +29 -0
  8. package/obj/template/.claude/commands/approve-swarm.md +27 -0
  9. package/obj/template/.claude/commands/grant-commit.md +19 -0
  10. package/obj/template/.claude/commands/init-project.md +191 -0
  11. package/obj/template/.claude/hooks/artifact_template_guard.sh +141 -0
  12. package/obj/template/.claude/hooks/consent_gate_grant.sh +89 -0
  13. package/obj/template/.claude/hooks/destructive_cmd_guard.sh +42 -0
  14. package/obj/template/.claude/hooks/env_guard.sh +36 -0
  15. package/obj/template/.claude/hooks/git_commit_guard.sh +93 -0
  16. package/obj/template/.claude/hooks/harness_continuation.sh +121 -0
  17. package/obj/template/.claude/hooks/lib/__pycache__/resume_writer.cpython-314.pyc +0 -0
  18. package/obj/template/.claude/hooks/lib/common.sh +328 -0
  19. package/obj/template/.claude/hooks/lib/resume_writer.py +341 -0
  20. package/obj/template/.claude/hooks/lint_runner.sh +55 -0
  21. package/obj/template/.claude/hooks/memory_pre_compact.sh +36 -0
  22. package/obj/template/.claude/hooks/memory_session_start.sh +244 -0
  23. package/obj/template/.claude/hooks/memory_stop.sh +173 -0
  24. package/obj/template/.claude/hooks/plantuml_syntax_guard.sh +161 -0
  25. package/obj/template/.claude/hooks/process_lifecycle_guard.sh +89 -0
  26. package/obj/template/.claude/hooks/setup_guard.sh +50 -0
  27. package/obj/template/.claude/hooks/spec_approval_guard.sh +81 -0
  28. package/obj/template/.claude/hooks/spec_design_calls_guard.sh +183 -0
  29. package/obj/template/.claude/hooks/spec_diagram_presence_guard.sh +141 -0
  30. package/obj/template/.claude/hooks/swarm_approval_guard.sh +39 -0
  31. package/obj/template/.claude/hooks/swarm_boundary_guard.sh +136 -0
  32. package/obj/template/.claude/hooks/tdd_order_guard.sh +176 -0
  33. package/obj/template/.claude/hooks/test_runner.sh +75 -0
  34. package/obj/template/.claude/hooks/tests/fixtures/ac008_byte_equal_reference.txt +12 -0
  35. package/obj/template/.claude/hooks/tests/memory_session_start_test.sh +285 -0
  36. package/obj/template/.claude/hooks/track_guard.sh +127 -0
  37. package/obj/template/.claude/hooks/verify_pass_guard.sh +88 -0
  38. package/obj/template/.claude/memory/README.md +108 -0
  39. package/obj/template/.claude/memory/_pending.md +15 -0
  40. package/obj/template/.claude/memory/_resume.md +12 -0
  41. package/obj/template/.claude/memory/conventions.md +26 -0
  42. package/obj/template/.claude/memory/decisions.md +29 -0
  43. package/obj/template/.claude/memory/landmarks.md +26 -0
  44. package/obj/template/.claude/memory/landmines.md +27 -0
  45. package/obj/template/.claude/memory/libraries.md +27 -0
  46. package/obj/template/.claude/memory/pending-questions.md +28 -0
  47. package/obj/template/.claude/project.json +221 -0
  48. package/obj/template/.claude/settings.json +110 -0
  49. package/obj/template/.claude/skills/archive/SKILL.md +48 -0
  50. package/obj/template/.claude/skills/archive/archive.sh +145 -0
  51. package/obj/template/.claude/skills/audit-baseline/SKILL.md +80 -0
  52. package/obj/template/.claude/skills/audit-baseline/audit.sh +919 -0
  53. package/obj/template/.claude/skills/brd/SKILL.md +44 -0
  54. package/obj/template/.claude/skills/brd/template.md +83 -0
  55. package/obj/template/.claude/skills/chore/SKILL.md +99 -0
  56. package/obj/template/.claude/skills/claude-automation-recommender/LICENSE +202 -0
  57. package/obj/template/.claude/skills/claude-automation-recommender/NOTICE +69 -0
  58. package/obj/template/.claude/skills/claude-automation-recommender/SKILL.md +358 -0
  59. package/obj/template/.claude/skills/claude-automation-recommender/references/hooks-patterns.md +226 -0
  60. package/obj/template/.claude/skills/claude-automation-recommender/references/mcp-servers.md +263 -0
  61. package/obj/template/.claude/skills/claude-automation-recommender/references/plugins-reference.md +98 -0
  62. package/obj/template/.claude/skills/claude-automation-recommender/references/skills-reference.md +408 -0
  63. package/obj/template/.claude/skills/claude-automation-recommender/references/subagent-templates.md +181 -0
  64. package/obj/template/.claude/skills/code-structure/SKILL.md +204 -0
  65. package/obj/template/.claude/skills/commit/SKILL.md +21 -0
  66. package/obj/template/.claude/skills/copywriting/SKILL.md +252 -0
  67. package/obj/template/.claude/skills/copywriting/evals/evals.json +111 -0
  68. package/obj/template/.claude/skills/copywriting/references/ai-writing-detection.md +200 -0
  69. package/obj/template/.claude/skills/copywriting/references/copy-frameworks.md +344 -0
  70. package/obj/template/.claude/skills/copywriting/references/natural-transitions.md +272 -0
  71. package/obj/template/.claude/skills/design-ui/SKILL.md +175 -0
  72. package/obj/template/.claude/skills/design-ui/references/design-vs-development.md +89 -0
  73. package/obj/template/.claude/skills/design-ui/references/intent-table.md +64 -0
  74. package/obj/template/.claude/skills/design-ui/references/orchestration.md +121 -0
  75. package/obj/template/.claude/skills/design-ui/references/state-machine.md +125 -0
  76. package/obj/template/.claude/skills/document/SKILL.md +66 -0
  77. package/obj/template/.claude/skills/documentation/SKILL.md +50 -0
  78. package/obj/template/.claude/skills/harness/SKILL.md +169 -0
  79. package/obj/template/.claude/skills/humanizer/SKILL.md +489 -0
  80. package/obj/template/.claude/skills/humanizer/references/ai-writing-detection.md +208 -0
  81. package/obj/template/.claude/skills/impeccable/PROJECT_NOTES.md +22 -0
  82. package/obj/template/.claude/skills/impeccable/SKILL.md +153 -0
  83. package/obj/template/.claude/skills/impeccable/agents/openai.yaml +4 -0
  84. package/obj/template/.claude/skills/impeccable/reference/adapt.md +190 -0
  85. package/obj/template/.claude/skills/impeccable/reference/animate.md +173 -0
  86. package/obj/template/.claude/skills/impeccable/reference/audit.md +134 -0
  87. package/obj/template/.claude/skills/impeccable/reference/bolder.md +113 -0
  88. package/obj/template/.claude/skills/impeccable/reference/brand.md +104 -0
  89. package/obj/template/.claude/skills/impeccable/reference/clarify.md +174 -0
  90. package/obj/template/.claude/skills/impeccable/reference/cognitive-load.md +106 -0
  91. package/obj/template/.claude/skills/impeccable/reference/color-and-contrast.md +105 -0
  92. package/obj/template/.claude/skills/impeccable/reference/colorize.md +154 -0
  93. package/obj/template/.claude/skills/impeccable/reference/craft.md +138 -0
  94. package/obj/template/.claude/skills/impeccable/reference/critique.md +213 -0
  95. package/obj/template/.claude/skills/impeccable/reference/delight.md +302 -0
  96. package/obj/template/.claude/skills/impeccable/reference/distill.md +111 -0
  97. package/obj/template/.claude/skills/impeccable/reference/document.md +427 -0
  98. package/obj/template/.claude/skills/impeccable/reference/extract.md +70 -0
  99. package/obj/template/.claude/skills/impeccable/reference/harden.md +347 -0
  100. package/obj/template/.claude/skills/impeccable/reference/heuristics-scoring.md +234 -0
  101. package/obj/template/.claude/skills/impeccable/reference/interaction-design.md +195 -0
  102. package/obj/template/.claude/skills/impeccable/reference/layout.md +141 -0
  103. package/obj/template/.claude/skills/impeccable/reference/live.md +513 -0
  104. package/obj/template/.claude/skills/impeccable/reference/motion-design.md +99 -0
  105. package/obj/template/.claude/skills/impeccable/reference/onboard.md +234 -0
  106. package/obj/template/.claude/skills/impeccable/reference/optimize.md +258 -0
  107. package/obj/template/.claude/skills/impeccable/reference/overdrive.md +130 -0
  108. package/obj/template/.claude/skills/impeccable/reference/personas.md +178 -0
  109. package/obj/template/.claude/skills/impeccable/reference/polish.md +232 -0
  110. package/obj/template/.claude/skills/impeccable/reference/product.md +62 -0
  111. package/obj/template/.claude/skills/impeccable/reference/quieter.md +99 -0
  112. package/obj/template/.claude/skills/impeccable/reference/responsive-design.md +114 -0
  113. package/obj/template/.claude/skills/impeccable/reference/shape.md +136 -0
  114. package/obj/template/.claude/skills/impeccable/reference/spatial-design.md +100 -0
  115. package/obj/template/.claude/skills/impeccable/reference/teach.md +137 -0
  116. package/obj/template/.claude/skills/impeccable/reference/typeset.md +124 -0
  117. package/obj/template/.claude/skills/impeccable/reference/typography.md +159 -0
  118. package/obj/template/.claude/skills/impeccable/reference/ux-writing.md +107 -0
  119. package/obj/template/.claude/skills/impeccable/scripts/cleanup-deprecated.mjs +284 -0
  120. package/obj/template/.claude/skills/impeccable/scripts/command-metadata.json +94 -0
  121. package/obj/template/.claude/skills/impeccable/scripts/design-parser.mjs +820 -0
  122. package/obj/template/.claude/skills/impeccable/scripts/detect-csp.mjs +198 -0
  123. package/obj/template/.claude/skills/impeccable/scripts/is-generated.mjs +69 -0
  124. package/obj/template/.claude/skills/impeccable/scripts/live-accept.mjs +465 -0
  125. package/obj/template/.claude/skills/impeccable/scripts/live-browser.js +4684 -0
  126. package/obj/template/.claude/skills/impeccable/scripts/live-inject.mjs +436 -0
  127. package/obj/template/.claude/skills/impeccable/scripts/live-poll.mjs +187 -0
  128. package/obj/template/.claude/skills/impeccable/scripts/live-server.mjs +679 -0
  129. package/obj/template/.claude/skills/impeccable/scripts/live-wrap.mjs +395 -0
  130. package/obj/template/.claude/skills/impeccable/scripts/live.mjs +247 -0
  131. package/obj/template/.claude/skills/impeccable/scripts/load-context.mjs +93 -0
  132. package/obj/template/.claude/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
  133. package/obj/template/.claude/skills/impeccable/scripts/pin.mjs +214 -0
  134. package/obj/template/.claude/skills/implement/SKILL.md +83 -0
  135. package/obj/template/.claude/skills/intake/SKILL.md +46 -0
  136. package/obj/template/.claude/skills/intake/template.md +61 -0
  137. package/obj/template/.claude/skills/integrate/SKILL.md +62 -0
  138. package/obj/template/.claude/skills/memory-flush/SKILL.md +172 -0
  139. package/obj/template/.claude/skills/memory-flush/sweep.py +286 -0
  140. package/obj/template/.claude/skills/memory-flush/tests/run.sh +327 -0
  141. package/obj/template/.claude/skills/prose/SKILL.md +119 -0
  142. package/obj/template/.claude/skills/rca/SKILL.md +42 -0
  143. package/obj/template/.claude/skills/rca/template.md +83 -0
  144. package/obj/template/.claude/skills/research/SKILL.md +75 -0
  145. package/obj/template/.claude/skills/scenario/SKILL.md +64 -0
  146. package/obj/template/.claude/skills/scout/SKILL.md +72 -0
  147. package/obj/template/.claude/skills/security/SKILL.md +75 -0
  148. package/obj/template/.claude/skills/simplify/SKILL.md +67 -0
  149. package/obj/template/.claude/skills/spec/SKILL.md +69 -0
  150. package/obj/template/.claude/skills/spec/template.md +274 -0
  151. package/obj/template/.claude/skills/spec-diagram-review/SKILL.md +81 -0
  152. package/obj/template/.claude/skills/spec-lint/SKILL.md +55 -0
  153. package/obj/template/.claude/skills/spec-lint/lint.sh +218 -0
  154. package/obj/template/.claude/skills/spec-render/SKILL.md +45 -0
  155. package/obj/template/.claude/skills/spec-render/render.sh +109 -0
  156. package/obj/template/.claude/skills/spec-traceability-review/SKILL.md +72 -0
  157. package/obj/template/.claude/skills/swarm-dispatch/SKILL.md +212 -0
  158. package/obj/template/.claude/skills/swarm-dispatch/swarm_merge.sh +154 -0
  159. package/obj/template/.claude/skills/swarm-plan/SKILL.md +90 -0
  160. package/obj/template/.claude/skills/swarm-plan/validate.sh +181 -0
  161. package/obj/template/.claude/skills/tdd/SKILL.md +100 -0
  162. package/obj/template/.claude/skills/technical-tutorials/SKILL.md +569 -0
  163. package/obj/template/.claude/skills/technical-tutorials/references/audience-context-README.md +53 -0
  164. package/obj/template/.claude/skills/technical-tutorials/references/audience-context.md +246 -0
  165. package/obj/template/.claude/skills/technical-tutorials/references/audience-example.md +175 -0
  166. package/obj/template/.claude/skills/technical-tutorials/references/audience-template.md +152 -0
  167. package/obj/template/.claude/skills/triage/SKILL.md +55 -0
  168. package/obj/template/.claude/skills/verify/SKILL.md +74 -0
  169. package/obj/template/.mcp.json +24 -0
  170. package/obj/template/CLAUDE.md +327 -0
  171. package/obj/template/docs/init/seed.md +585 -0
  172. package/obj/template/manifest.json +214 -0
  173. package/package.json +48 -0
  174. package/src/.mcp.template.json +24 -0
  175. package/src/.npmrc.template +2 -0
  176. package/src/CLAUDE.template.md +327 -0
  177. package/src/agents/swarm-worker.template.md +51 -0
  178. package/src/cli/conflict.js +31 -0
  179. package/src/cli/doctor.js +152 -0
  180. package/src/cli/install.js +93 -0
  181. package/src/cli/io.js +27 -0
  182. package/src/cli/manifest.js +38 -0
  183. package/src/cli/mcp.js +54 -0
  184. package/src/cli/merge.js +107 -0
  185. package/src/cli/plantuml.js +121 -0
  186. package/src/cli/util.js +10 -0
  187. package/src/memory/_pending.template.md +15 -0
  188. package/src/memory/_resume.template.md +12 -0
  189. package/src/memory/conventions.template.md +26 -0
  190. package/src/memory/decisions.template.md +29 -0
  191. package/src/memory/landmarks.template.md +26 -0
  192. package/src/memory/landmines.template.md +27 -0
  193. package/src/memory/libraries.template.md +27 -0
  194. package/src/memory/pending-questions.template.md +28 -0
  195. package/src/project.template.json +221 -0
  196. package/src/seed.template.md +585 -0
  197. package/src/settings.template.json +110 -0
@@ -0,0 +1,513 @@
1
+ Interactive live variant mode: select elements in the browser, pick a design action, and get AI-generated HTML+CSS variants hot-swapped via the dev server's HMR.
2
+
3
+ ## Prerequisites
4
+
5
+ A running dev server with hot module replacement (Vite, Next.js, Bun, etc.), OR a static HTML file open in the browser.
6
+
7
+ ## The contract (read once)
8
+
9
+ Execute in order. No step skipped, no step reordered.
10
+
11
+ 1. `live.mjs` — boot.
12
+ 2. Navigate to the URL that serves `pageFile` (infer from `package.json`, docs, terminal output, or an open tab). If you can't infer it confidently, tell the user once to open their dev/preview URL. Never use `serverPort` as that URL — it's the helper, not the app.
13
+ 3. Poll loop with the default long timeout (600000 ms). After every event or `--reply`, run `live-poll.mjs` again immediately. Never pass a short `--timeout=`.
14
+ 4. On `generate` — read screenshot if present; load the action's reference; plan three distinct directions; write all variants in one edit; `--reply done`; poll again.
15
+ 5. On `accept` / `discard` — the poll script already cleaned up; just poll again.
16
+ 6. On `exit` — run the cleanup at the bottom.
17
+
18
+ Harness policy:
19
+ - **Claude Code**: run the poll as a **background task** (no short timeout). The harness notifies you when it completes, so the main conversation stays free. Do not block the shell.
20
+ - **Cursor**: run the poll in the **foreground** (blocking shell — not a background terminal, not a subagent). Cursor background terminals and subagents do not reliably resume the chat with poll stdout.
21
+ - **Codex**: run the poll in the **foreground** (blocking shell — not a background task, not a subagent). Codex background exec sessions do not reliably surface poll stdout back into the conversation at the moment events arrive, so a "fire-and-forget" background poll will stall live mode.
22
+ - **Other harnesses**: foreground unless you know stdout reliably returns to this session.
23
+
24
+ Chat is overhead. No recap, no tutorial output, no pasting PRODUCT / DESIGN bodies. Spend tokens on tools and edits; on failure, one or two short sentences.
25
+
26
+ ## Start
27
+
28
+ ```bash
29
+ node .claude/skills/impeccable/scripts/live.mjs
30
+ ```
31
+
32
+ Output JSON: `{ ok, serverPort, serverToken, pageFiles, hasProduct, product, productPath, hasDesign, design, designPath, migrated }`. `pageFiles` is the list of HTML entries the live script was injected into. Keep PRODUCT.md and DESIGN.md in mind for variant generation — **DESIGN.md wins on visual decisions; PRODUCT.md wins on strategic/voice decisions.** If `migrated: true`, the loader auto-renamed legacy `.impeccable.md` to `PRODUCT.md`; mention this once and suggest `$impeccable document` for the matching DESIGN.md.
33
+
34
+ `serverPort` and `serverToken` belong to the small **Impeccable live helper** HTTP server (serves `/live.js`, SSE, and `/poll`). That port is **not** your dev server and is usually not the URL you open to view the app. The browser page is whatever origin serves one of the `pageFiles` entries (Vite / Next / Bun / tunnel / LAN hostname).
35
+
36
+ If output is `{ ok: false, error: "config_missing" | "config_invalid", path }`, this project hasn't been configured for live mode (or its config is stale). See **First-time setup** at the bottom.
37
+
38
+ ## Poll loop
39
+
40
+ ```
41
+ LOOP:
42
+ node .claude/skills/impeccable/scripts/live-poll.mjs # default long timeout; no --timeout=
43
+ Read JSON; dispatch on "type"
44
+
45
+ "generate" → Handle Generate; reply done; LOOP
46
+ "accept" → Handle Accept; LOOP
47
+ "discard" → Handle Discard; LOOP
48
+ "prefetch" → Handle Prefetch; LOOP
49
+ "timeout" → LOOP
50
+ "exit" → break → Cleanup
51
+ ```
52
+
53
+ ## Handle `generate`
54
+
55
+ Event: `{id, action, freeformPrompt?, count, pageUrl, element, screenshotPath?, comments?, strokes?}`.
56
+
57
+ Speed matters — the user is watching a spinner. Minimize tool calls by using the `wrap` helper and writing all variants in a single edit.
58
+
59
+ ### 1. Read the screenshot (if present)
60
+
61
+ `event.screenshotPath` is **only sent when the user placed at least one comment or stroke before Go.** When present, it's an absolute path to a PNG of the element as rendered with the annotations baked in. **Read it before planning** — annotations encode user intent not recoverable from `element.outerHTML` alone.
62
+
63
+ When `screenshotPath` is absent, don't ask for one and don't go looking for the current rendering. The omission is deliberate: without annotations, a screenshot would anchor the model on the existing design and fight the three-distinct-directions brief. Work from `element.outerHTML`, the computed styles in `event.element`, and the freeform prompt if present.
64
+
65
+ `event.comments` and `event.strokes` carry structured metadata alongside the visual. Treat the screenshot as primary; use the structured data for specifics worth quoting (e.g. the exact text of a comment).
66
+
67
+ Reading annotations precisely:
68
+
69
+ - **Comment position is load-bearing.** Its `{x, y}` is element-local CSS px (same coord space as `element.boundingRect`). Find the child under that point and apply the comment text LOCALLY to that sub-element. A comment near the title is about the title, not a global description.
70
+ - **Comments and strokes are independent annotations** unless clearly paired by overlap or tight proximity. Don't let the visual weight of a prominent stroke override the precise location of a textually-specific comment elsewhere.
71
+ - **Strokes are gestures — read them by shape.** Closed loop = "this thing" (emphasis / focus); arrow = direction (move / point to); cross or slash = delete; free scribble = emphasis or delete depending on context. A loop around region X means "pay attention to X," not "only change pixels inside X."
72
+ - **When a stroke's intent is ambiguous** (circle or arrow? emphasis or move?), state your reading in one sentence of rationale rather than silently guessing. If the uncertainty materially changes the brief, ask one short clarifying question before generating.
73
+
74
+ ### 2. Wrap the element
75
+
76
+ ```bash
77
+ node .claude/skills/impeccable/scripts/live-wrap.mjs --id EVENT_ID --count EVENT_COUNT --element-id "ELEMENT_ID" --classes "class1,class2" --tag "div"
78
+ ```
79
+
80
+ Flag mapping — keep them separate, don't collapse into `--query`:
81
+
82
+ - `--element-id` ← `event.element.id`
83
+ - `--classes` ← `event.element.classes` joined with commas
84
+ - `--tag` ← `event.element.tagName`
85
+
86
+ The helper searches ID first, then classes, then tag + class combo. If `event.pageUrl` implies the file (e.g. `/` is usually `index.html`), pass `--file PATH` to skip the search. `--query` is a fallback for raw text search only — do not use it for normal element lookups.
87
+
88
+ Output on success: `{ file, insertLine, commentSyntax }`.
89
+
90
+ **Fallback errors.** Wrap only writes into files it judges to be source (tracked by git, not marked GENERATED, not listed in config's `generatedFiles`). If it can't land on a source file, it errors without writing — accepting a variant into a generated file is silent data loss. Three shapes:
91
+
92
+ - `{ error: "file_is_generated", file, hint }` — user-supplied `--file` points at a generated file.
93
+ - `{ error: "element_not_in_source", generatedMatch, hint }` — element exists only in a generated file (the next build would wipe any edits).
94
+ - `{ error: "element_not_found", hint }` — element isn't in any project file; likely runtime-injected (JS component, data-driven render).
95
+
96
+ All three carry `fallback: "agent-driven"`. Follow **Handle fallback** below.
97
+
98
+ ### 3. Load the action's reference
99
+
100
+ If `event.action` is `impeccable` (the default freeform action), use SKILL.md's shared laws plus the loaded register reference (`brand.md` or `product.md`). Do not load a sub-command reference. **Freeform is not a pass to skip parameters:** you still follow the composition budget and the freeform bias in **§7 Parameters** below. Sub-command files list MUST-have signature knobs; freeform has no such file, so sizing knobs from surface weight and primary axes is entirely on you.
101
+
102
+ Any other `event.action` (`bolder`, `quieter`, `distill`, `polish`, `typeset`, `colorize`, `layout`, `adapt`, `animate`, `delight`, `overdrive`): Read `reference/<action>.md` before planning. Each sub-command encodes a specific discipline; skipping its reference produces generic output. Those files may require specific params; layer them on top of the §7 budget, not instead of it.
103
+
104
+ ### 4. Plan three genuinely distinct directions
105
+
106
+ Before writing a single line of code, name each variant.
107
+
108
+ **For freeform (`action` is `impeccable`, or the user supplied a free prompt):** each variant must anchor to a different **archetype** — a real-world design analogue specific enough to be recognizable at a glance. Not "modern landing page." Not "minimal product hero." Examples:
109
+
110
+ - *Broadsheet masthead with rule-divided columns* (think NYT print edition)
111
+ - *Klim Type Foundry specimen page* (dense, technical, catalog-driven)
112
+ - *Japanese print-poster minimalism with a single oversize glyph*
113
+ - *Bloomberg Terminal status bar*
114
+ - *Condé Nast Traveler feature layout*
115
+
116
+ Then commit each variant to a different **primary axis** of difference:
117
+
118
+ 1. **Hierarchy** — which element commands the eye?
119
+ 2. **Layout topology** — stacked / side-by-side / grid / asymmetric / overlay
120
+ 3. **Typographic system** — pairing, scale ratio, case/weight strategy
121
+ 4. **Color strategy** — Restrained / Committed / Full palette / Drenched
122
+ 5. **Density** — minimal / comfortable / dense
123
+ 6. **Structural decomposition** — merge, split, progressive disclosure
124
+
125
+ Three variants → three DIFFERENT primary axes, not three riffs on color.
126
+
127
+ **When the primary axis is color or theme, forbid the trio from sharing theme + dominant hue.** Two dark-plus-one-dark is not distinct. Aim for one dark-neutral-accent, one light-drenched, one full-palette-saturated — three color worlds, not three shades of the same.
128
+
129
+ **The squint test (before writing code).** Write the three one-sentence descriptions side by side:
130
+
131
+ > V1: Broadsheet masthead, ruled columns, 24px ink on cream.
132
+ > V2: Enormous italic title, catalog spec rows, heavy monospace data.
133
+ > V3: Card-framed poster with one oversize glyph, magenta veil.
134
+
135
+ If two of them rhyme ("both use big type" / "both are stacks of sections" / "both feature the CTA prominently"), rework the offender. Freeform variants failing the squint test is the primary failure mode of this flow — three-of-the-same with minor styling tweaks.
136
+
137
+ **For action-specific invocations**, each variant must vary along the dimension the action names:
138
+
139
+ - `bolder` — amplify a different dimension per variant (scale / saturation / structural change). Not three "slightly bigger" variants.
140
+ - `quieter` — pull back a different dimension (color / ornament / spacing).
141
+ - `distill` — remove a different class of excess (visual noise / redundant content / nested structure).
142
+ - `polish` — target a different refinement axis (rhythm / hierarchy / micro-details like corner radii, focus states, optical kerning).
143
+ - `typeset` — different type pairing AND different scale ratio each. Not three riffs on one pairing.
144
+ - `colorize` — different hue family each (not shades of one hue). Vary chroma and contrast strategy.
145
+ - `layout` — different structural arrangement (stacked / side-by-side / grid / asymmetric). Not spacing tweaks.
146
+ - `adapt` — different target context per variant (mobile-first / tablet / desktop / print or low-data). Don't make three mobile layouts.
147
+ - `animate` — different motion vocabulary (cascade stagger / clip wipe / scale-and-focus / morph / parallax). Not three staggered fades.
148
+ - `delight` — different flavor of personality (unexpected micro-interaction / typographic surprise / illustrated accent / sonic-or-haptic moment / easter-egg interaction).
149
+ - `overdrive` — different convention broken (scale / structure / motion / input model / state transitions). Skip `overdrive.md`'s "propose and ask" step — live mode is non-interactive.
150
+
151
+ ### 5. Apply the freeform prompt (if present)
152
+
153
+ `event.freeformPrompt` is the user's ceiling on direction — all variants must honor it — but still explore meaningfully different *interpretations*. "Make it feel like a newspaper front page" → variant 1 = broadsheet masthead + rule-divided columns, variant 2 = tabloid headline + single dominant image, variant 3 = minimalist editorial with oversized drop cap. Not three newspapers in the same voice.
154
+
155
+ ### 6. Write all variants in a single edit
156
+
157
+ Complete HTML replacement of the original element for each variant, not a CSS-only patch. Consider the element's context (computed styles, parent structure, CSS variables from `event.element`).
158
+
159
+ Write CSS + all variants in ONE edit at the `insertLine` reported by `wrap`. Colocate scoped CSS as a `<style>` tag inside the variant wrapper — `<style>` works anywhere in modern browsers and this ensures CSS and HTML arrive atomically (no FOUC).
160
+
161
+ ```html
162
+ <!-- Variants: insert below this line -->
163
+ <style data-impeccable-css="SESSION_ID">
164
+ @scope ([data-impeccable-variant="1"]) { ... }
165
+ @scope ([data-impeccable-variant="2"]) { ... }
166
+ </style>
167
+ <div data-impeccable-variant="1">
168
+ <!-- variant 1: full element replacement (single top-level element) -->
169
+ </div>
170
+ <div data-impeccable-variant="2" style="display: none">
171
+ <!-- variant 2: full element replacement -->
172
+ </div>
173
+ <div data-impeccable-variant="3" style="display: none">
174
+ <!-- variant 3: full element replacement -->
175
+ </div>
176
+ ```
177
+
178
+ **Each variant div contains exactly one top-level element — the full replacement for the original.** Use the same tag as the original (e.g. `<section>` if the user picked a `<section>`). Loose siblings (heading + paragraph + div as direct children of the variant div) break the outline tracking and the accept flow, which both assume one child.
179
+
180
+ The first variant has no `display: none` (visible by default). All others do. If variants use only inline styles and no scoped CSS, omit the `<style>` tag entirely. Use `@scope` for CSS isolation (Chrome 118+ / Firefox 128+ / Safari 17.4+).
181
+
182
+ One edit, all variants — the browser's MutationObserver picks everything up in one pass.
183
+
184
+ ### 7. Parameters (composition-sized, 0–4 per variant)
185
+
186
+ Each variant can expose **coarse** knobs alongside the full HTML/CSS replacement. The browser docks a small panel to the right of the outline with one control per parameter. The user drags/clicks and sees instant feedback: there is zero regeneration cost because the knob toggles a CSS variable or data attribute that the variant's scoped CSS is already authored against.
187
+
188
+ **What “optional” does not mean.** Parameters are not nice-to-have decoration on large work. The word meant “omit controls that are redundant or cosmetic,” not “default to zero because three variants were enough work.”
189
+
190
+ **When to add.** As soon as the variant’s scoped CSS has a meaningful continuous or stepped axis: density, color amount, type scale, motion intensity, column weight, and so on. If you can imagine the user muttering “a bit tighter” or “a touch more accent” **without** wanting a full regeneration, wire that axis. **Not** micro-margins or one-off nudges; those are not parameters.
191
+
192
+ **Freeform (`action` is `impeccable`) bias.** You did not load `reference/bolder.md` (etc.), so you must **choose** 1–2 signature-like axes yourself. Prefer knobs that sit on the same dimensions as your three directions (e.g. all three riffs on editorial density → expose `density` or a `steps` “air / snug / packed”; two directions differ mostly in chroma → add `color-amount`). A hero, section, or other **large** surface that ships with **0** params needs a one-line reason in your head (e.g. “truly a fixed-point A/B/C comparison, no shared dial”), not a default habit.
193
+
194
+ **Budget scales with the element's visual weight, not token budget.** Knobs need real estate to read as tunable; three sliders on a single control are noise.
195
+
196
+ - **Leaf / tiny** — a single button, icon, input, bare heading, solitary paragraph: **0 params.**
197
+ - **Small composition** — labeled input, simple card, short callout (≤ ~5 visual children): **0–1** params when one dominant axis is obvious; otherwise **0.**
198
+ - **Medium composition** — section component, nav cluster, dense card, short feature block (6–15 visual children): **target 2**; **1** is acceptable if the block is simple; **0** only when variants are truly fixed points.
199
+ - **Large composition** — hero section, full page region, spread layout, strong internal structure (16+ visual children or multiple sub-sections): **target 2–3**; **up to 4** when several independent axes (e.g. structure `steps` + `density` + one accent) are all authored in scoped CSS.
200
+
201
+ **When in doubt, ask whether a dial exists before defaulting to zero.** The user can always request more variants, but the point of live mode is instant tuning without another Go. Crowding the panel is bad; **under-shipping** knobs on a dense composition is the more common failure for freeform. Count by **visual** children, not DOM depth; a shallow-but-wide hero is still large.
202
+
203
+ **Hard cap per variant** — at most **four** parameters so the panel stays legible; rare fifth only if the reference explicitly allows it.
204
+
205
+ **How to declare.** Put a JSON manifest on the variant wrapper:
206
+
207
+ ```html
208
+ <div data-impeccable-variant="1" data-impeccable-params='[
209
+ {"id":"color-amount","kind":"range","min":0,"max":1,"step":0.05,"default":0.5,"label":"Color amount"},
210
+ {"id":"density","kind":"steps","default":"snug","label":"Density","options":[
211
+ {"value":"airy","label":"Airy"},
212
+ {"value":"snug","label":"Snug"},
213
+ {"value":"packed","label":"Packed"}
214
+ ]},
215
+ {"id":"serif","kind":"toggle","default":false,"label":"Serif display"}
216
+ ]'>
217
+ ...variant content...
218
+ </div>
219
+ ```
220
+
221
+ **Three kinds:**
222
+
223
+ - `range` — smooth slider. Drives a CSS custom property `--p-<id>` on the variant wrapper. Author CSS with `var(--p-color-amount, 0.5)`. Fields: `min`, `max`, `step`, `default` (number), `label`.
224
+ - `steps` — segmented radio. Drives a data attribute `data-p-<id>` on the variant wrapper. Author CSS with `:scope[data-p-density="airy"] .grid { ... }`. Fields: `options` (array of `{value, label}`), `default` (string), `label`.
225
+ - `toggle` — on/off switch. Drives BOTH a CSS var (`--p-<id>: 0|1`) and a data attribute (present when on, absent when off). Use whichever is more convenient. Fields: `default` (boolean), `label`.
226
+
227
+ **Signature params per action.** For named sub-commands, read that action’s `reference/<action>.md` for one or two **MUST** params (e.g. `layout` → `density`). Those are non-negotiable when the design can express them. **Freeform has no file-level MUST**; the **Freeform (`impeccable`) bias** in this section is the stand-in. If the user’s action is both stylized and sub-command (e.g. `colorize`), the sub-command’s MUST list takes precedence for its axes; still respect the **Hard cap** and add no redundant duplicate knobs.
228
+
229
+ **Reset on variant switch.** User dials density on v1, flips to v2, v2 starts at v2's declared defaults. Known limitation; preservation across variants may land later.
230
+
231
+ **On accept**, the browser sends the user's current values in the accept event. `live-accept.mjs` writes them as a sibling comment:
232
+
233
+ ```html
234
+ <!-- impeccable-param-values SESSION_ID: {"color-amount":0.7,"density":"packed"} -->
235
+ ```
236
+
237
+ The carbonize cleanup step (see below) reads that comment and bakes the chosen values into the final CSS. For `steps`/`toggle` attribute selectors: keep only the branch matching the chosen value, drop the others, collapse `:scope[data-p-density="packed"] .grid` to a semantic class rule. For `range` vars: either substitute the literal or keep the var with the chosen value as its new default.
238
+
239
+ ### 8. Signal done
240
+
241
+ ```bash
242
+ node .claude/skills/impeccable/scripts/live-poll.mjs --reply EVENT_ID done --file RELATIVE_PATH
243
+ ```
244
+
245
+ `RELATIVE_PATH` is relative to project root (`public/index.html`, `src/App.tsx`, etc.) — the browser fetches source directly if the dev server lacks HMR.
246
+
247
+ Then run `live-poll.mjs` again immediately.
248
+
249
+ ## Handle fallback
250
+
251
+ When wrap returns `fallback: "agent-driven"`, the deterministic flow doesn't apply. Pick up here.
252
+
253
+ The goal is the same: give the user three variants to choose from AND persist the accepted one in a place the next build won't wipe. The difference is that you have to pick the right source file yourself.
254
+
255
+ ### Step 1: Identify where the element actually lives
256
+
257
+ Use the error payload:
258
+
259
+ - `element_not_in_source` with `generatedMatch: "public/docs/foo.html"` — the served HTML is generated. Find the generator (grep for writers of that path, e.g. `scripts/build-sub-pages.js`, an Astro/Next template) and locate the template or partial that emits this element.
260
+ - `element_not_found` — the element is runtime-injected. Look for the component that renders it (React/Vue/Svelte), the JS that assembles it, or the data source that feeds it.
261
+ - `file_is_generated` with `file: "..."` — user pointed at a generated file explicitly. Same resolution as `element_not_in_source`.
262
+
263
+ Read the candidate source until you're confident where a change to the element would belong. If the change is purely visual, that source might be a shared stylesheet, not the template.
264
+
265
+ ### Step 2: Show three variants in the DOM for preview
266
+
267
+ The browser bar is waiting for variants. Even without a wrapper in source, you still need to show something:
268
+
269
+ 1. Manually write the wrapper scaffold into the **served** file (the one the browser actually loaded). Use the same structure `live-wrap.mjs` produces — `<!-- impeccable-variants-start ID --><div data-impeccable-variants="ID" data-impeccable-variant-count="3" style="display: contents">…</div><!-- end -->`.
270
+ 2. Insert your three variant divs inside it, same shape as the deterministic path.
271
+ 3. Signal done with `--reply EVENT_ID done --file <served file>`. The browser's no-HMR fallback will fetch and inject.
272
+
273
+ This served-file edit is **temporary** — next regen wipes it, and that's fine. The real work happens on accept.
274
+
275
+ ### Step 3: On accept, write to true source
276
+
277
+ When the accept event arrives (`_acceptResult.handled` will usually be `false` here because accept also refuses to persist into generated files — see Handle accept for the carbonize branch), extract the accepted variant's content and write it into the source you identified in Step 1:
278
+
279
+ - Structural change → edit the template / component source.
280
+ - Visual-only change → add or update rules in the appropriate stylesheet; remove the inline `<style>` scope.
281
+ - Data-driven → update the data source or the render logic.
282
+
283
+ Then remove the temporary wrapper from the served file if it's still there.
284
+
285
+ ### Step 4: On discard, clean up the served file
286
+
287
+ Remove the wrapper you inserted in Step 2. Nothing else to do.
288
+
289
+ ## Handle `accept`
290
+
291
+ Event: `{id, variantId, _acceptResult}`. The poll script already ran `live-accept.mjs` to handle the file operation deterministically; the browser DOM is already updated.
292
+
293
+ - `_acceptResult.handled: true` and `carbonize: false` — nothing to do. Poll again.
294
+ - `_acceptResult.handled: true` and `carbonize: true` — **post-accept cleanup is required before the next poll.** See the "Required after accept (carbonize)" section below. The `event._acceptResult.todo` field and a stderr banner both list the steps explicitly; neither is decorative.
295
+ - `_acceptResult.handled: false, mode: "fallback"` — the session lived in a generated file and the script refused to persist there. You've already written the accepted variant into true source during Handle fallback Step 3; just clean up the temporary wrapper in the served file if any, and poll again.
296
+ - `_acceptResult.handled: false` without `mode` — manual cleanup: read file, find markers, edit.
297
+
298
+ ### Required after accept (carbonize)
299
+
300
+ When `_acceptResult.carbonize === true`, the accepted variant was stitched into source with helper markers and inline CSS so the browser can render it immediately with no visual gap. That stitch-in is **temporary**. The agent must rewrite it into permanent form before doing anything else. Skipping this leaves dead `@scope` rules for unaccepted variants, a pointless `data-impeccable-variant` wrapper, and `impeccable-carbonize-start/end` comment noise in the source file — all of which accumulate across sessions.
301
+
302
+ Do these five steps in the current thread, synchronously, before the next poll. Do not poll again until the file is clean.
303
+
304
+ 1. **Locate the carbonize block** in the source file (`_acceptResult.file`). It's bracketed by `<!-- impeccable-carbonize-start SESSION_ID -->` and `<!-- impeccable-carbonize-end SESSION_ID -->` and contains a `<style data-impeccable-css="SESSION_ID">` element. If the variant declared parameters, an `<!-- impeccable-param-values SESSION_ID: {...} -->` comment sits alongside the style tag with the user's chosen values — read it first; it drives steps 3 and 4 below.
305
+ 2. **Move the CSS rules** into the project's real stylesheet. Which stylesheet depends on the project (e.g. `public/css/workflow.css` for this repo, or the component's co-located CSS file for a Vite/Next project — pick whichever already owns styling for the surrounding element).
306
+ 3. **Bake in parameter values while rewriting selectors.** For `@scope ([data-impeccable-variant="N"])` wrappers: retarget to real, semantic classes on the accepted HTML (`.why-visual--v2 .v2-label { … }`). For `:scope[data-p-<id>="VALUE"]` selectors: keep only the branch matching the chosen value from the param-values comment; drop the others (they're dead after accept). For `var(--p-<id>, DEFAULT)` in the CSS: either substitute the literal value, or if the param is still useful as a knob going forward, leave the var and update its initial declaration to the chosen value.
307
+ 4. **Unwrap the accepted content.** Delete the `<div data-impeccable-variant="N" style="display: contents">` that wraps it. Drop `data-impeccable-params` and any `data-p-*` attributes from it — those are live-mode plumbing, not source.
308
+ 5. **Delete the inline `<style>` block, the `<!-- impeccable-param-values -->` comment if present, and both `<!-- impeccable-carbonize-start/end -->` markers.** Also drop any `@scope` rules for variants other than the accepted one — those are dead code now.
309
+
310
+ Then poll again.
311
+
312
+ A background agent may be used for the rewrite, but the current thread is responsible for verifying the five steps are complete before issuing the next poll. In practice, inline is usually faster and less error-prone.
313
+
314
+ ## Handle `discard`
315
+
316
+ Event: `{id, _acceptResult}`. The poll script already restored the original and removed all variant markers. Nothing to do. Poll again.
317
+
318
+ ## Handle `prefetch`
319
+
320
+ Event: `{pageUrl}`. The browser fires this the first time the user selects an element on a given route, as a latency shortcut — it signals the user is likely about to Go on a page you haven't read yet.
321
+
322
+ Resolve `pageUrl` to the underlying file:
323
+
324
+ - Root `/` → the `pageFile` returned by `live.mjs` (usually `public/index.html` or equivalent).
325
+ - Sub-routes (e.g. `/docs`, `/docs/live`) → the generated or source file for that route. Use your knowledge of the project layout (multi-page static sites often resolve `/foo` → `public/foo/index.html`; SPAs may map all routes to a single entry).
326
+
327
+ Read the file into context, then poll again. No `--reply` — this is speculative pre-work; Go will come later. If you can't confidently resolve the route to a file, skip and poll again.
328
+
329
+ Dedupe is the browser's job (one prefetch per unique pathname per session) — trust it. If the same file shows up twice from different routes mapping to the same file, the second Read is cached anyway.
330
+
331
+ ## Exit
332
+
333
+ The user can stop live mode by:
334
+ - Saying "stop live mode" / "exit live" in chat
335
+ - Closing the browser tab (SSE drops, poll returns `exit` after 8s)
336
+ - The browser's exit button
337
+
338
+ When the poll returns `exit`, proceed to cleanup. If the poll is still running as a background task, kill it first.
339
+
340
+ ## Cleanup
341
+
342
+ ```bash
343
+ node .claude/skills/impeccable/scripts/live-server.mjs stop
344
+ ```
345
+
346
+ Stops the HTTP server and runs `live-inject.mjs --remove` to strip `localhost:…/live.js` from the HTML entry. To stop the server but keep the inject tag (for a quick restart), use `stop --keep-inject`. `config.json` persists for future sessions.
347
+
348
+ Then:
349
+ - Remove any leftover variant wrappers (search for `impeccable-variants-start` markers).
350
+ - Remove any leftover carbonize blocks (search for `impeccable-carbonize-start` markers).
351
+
352
+ ## First-time setup (config missing or invalid)
353
+
354
+ If `live.mjs` outputs `{ ok: false, error: "config_missing" | "config_invalid", path }`, write `config.json` at the reported path.
355
+
356
+ Schema:
357
+
358
+ ```json
359
+ {
360
+ "files": ["<path-or-glob>", "<path-or-glob>", ...],
361
+ "exclude": ["<optional-glob>", ...],
362
+ "insertBefore": "</body>",
363
+ "commentSyntax": "html",
364
+ "cspChecked": true
365
+ }
366
+ ```
367
+
368
+ `files` is the inject target — **the HTML files the browser actually loads**, not necessarily source. Each entry is either a literal path (`"public/index.html"`) or a glob pattern (`"public/**/*.html"`). Tracked or generated doesn't matter here; wrap has its own generated-file guard and routes accepts through the fallback flow.
369
+
370
+ `exclude` (optional) is a list of glob patterns matching files to skip, even if a `files` glob would have included them. Use for email templates, demo fixtures, or any HTML that isn't a live page.
371
+
372
+ `cspChecked` tracks whether the CSP detection step below has already run. Absent on first setup; set to `true` after CSP is checked (whether patched, declined, or not needed).
373
+
374
+ **Hard-excluded paths (cannot be overridden).** `**/node_modules/**` and `**/.git/**` are never matched regardless of what the user writes. These are vendor/metadata directories and injecting into them would silently instrument third-party code.
375
+
376
+ **Glob syntax.** `**` matches any number of path segments (including zero), `*` matches any characters except `/`, `?` matches a single character except `/`. Paths are always relative to the project root with forward slashes.
377
+
378
+ | Framework | `files` | `insertBefore` | `commentSyntax` |
379
+ |-----------|---------|----------------|-----------------|
380
+ | SPA with single shell (Vite / React / Plain HTML) | `["index.html"]` | `</body>` | `html` |
381
+ | Next.js (App Router) | `["app/layout.tsx"]` | `</body>` | `jsx` |
382
+ | Next.js (Pages) | `["pages/_document.tsx"]` | `</body>` | `jsx` |
383
+ | Nuxt | `["app.vue"]` | `</body>` | `html` |
384
+ | Svelte / SvelteKit | `["src/app.html"]` | `</body>` | `html` |
385
+ | Astro | `[" <root layout .astro>"]` | `</body>` | `html` |
386
+ | Multi-page (separate HTML per route) | `["public/**/*.html"]` — a glob covering the served directory | `</body>` | `html` |
387
+
388
+ Pick an anchor that exists in every file (`</body>` almost always works). Use `insertAfter` if the anchor should match **after** a specific line.
389
+
390
+ For multi-page sites, **prefer a glob over a literal file list**. New pages added later are picked up automatically on the next `live-inject.mjs` run; no config maintenance needed.
391
+
392
+ For multi-page sites whose pages are *rebuilt* by a generator (Astro, static-site generators, custom scripts like `build-sub-pages.js`), the inject survives only until the next regeneration. Re-run `live.mjs` after each build. Accept is unaffected — it writes to true source via the fallback flow.
393
+
394
+ ### Drift-heal warning
395
+
396
+ On every `live.mjs` boot, after inject, the project is scanned for HTML files under common page-source roots (`public/`, `src/`, `app/`, `pages/`). If any exist that aren't covered by the resolved `files` list, the output includes a `configDrift` field:
397
+
398
+ ```json
399
+ {
400
+ "ok": true,
401
+ "serverPort": 8400,
402
+ "pageFiles": [ "..." ],
403
+ "configDrift": {
404
+ "orphans": ["public/new-section/index.html", "public/docs/new-command.html"],
405
+ "orphanCount": 2,
406
+ "hint": "2 HTML file(s) exist but aren't in config.files. Consider adding them, or use a glob pattern like \"public/**/*.html\"."
407
+ }
408
+ }
409
+ ```
410
+
411
+ When `configDrift` is present, surface it to the user once per session before entering the poll loop:
412
+
413
+ > Noticed N HTML file(s) in the project that aren't in `config.files`:
414
+ >
415
+ > - `public/new-section/index.html`
416
+ > - `public/docs/new-command.html`
417
+ >
418
+ > Add them, or switch `files` to a glob like `["public/**/*.html"]` and let it track new pages automatically?
419
+
420
+ Don't auto-update the config — let the user decide. `configDrift` is `null` when there's no drift.
421
+
422
+ ### CSP detection (first-time only)
423
+
424
+ If `config.cspChecked === true`, skip this entire section. You already asked this user once; the answer sticks.
425
+
426
+ Otherwise, run the detection helper:
427
+
428
+ ```bash
429
+ node .claude/skills/impeccable/scripts/detect-csp.mjs
430
+ ```
431
+
432
+ Output: `{ shape, signals }` where `shape` is one of `append-arrays`, `append-string`, `middleware`, `meta-tag`, or `null`. The shape is named by *patch mechanism*, so one template covers many frameworks.
433
+
434
+ - **`null`** — no CSP; skip to writing `config.json` with `cspChecked: true`.
435
+ - **`append-arrays`** — CSP defined as structured directive arrays. Auto-patchable. See *append-arrays* below. Covers:
436
+ - Monorepo helpers with `additionalScriptSrc` / `additionalConnectSrc` options (Next.js + shared config package)
437
+ - SvelteKit `kit.csp.directives`
438
+ - Nuxt `nuxt-security` module's `contentSecurityPolicy`
439
+ - **`append-string`** — CSP written as a literal value string. Auto-patchable. See *append-string* below. Covers:
440
+ - Inline `next.config.*` `headers()` with a CSP literal
441
+ - Nuxt `routeRules` / `nitro.routeRules` headers
442
+ - **`middleware`** or **`meta-tag`** — rarer. Detected but not auto-patched in v1. Show the user the detected files and ask them to add `http://localhost:8400` to `script-src` and `connect-src` manually, then mark `cspChecked: true` and proceed.
443
+
444
+ #### Consent prompt template
445
+
446
+ Use this phrasing so the experience is consistent across agents:
447
+
448
+ > **CSP patch needed.** I detected a Content Security Policy in your project that blocks `http://localhost:8400` — the live picker won't load without an allowance. Here's the change I'd make:
449
+ >
450
+ > ```diff
451
+ > [file: <patchTarget>]
452
+ > [exact diff, 2–5 lines]
453
+ > ```
454
+ >
455
+ > It's guarded by `NODE_ENV === "development"` so the extra entry only appears in dev and never reaches production. You can remove it any time by reverting this file. Apply? [y/n]
456
+
457
+ On "no": skip the patch, mention live won't work until the user adds the allowance manually, still write `cspChecked: true` (the question's been asked).
458
+
459
+ On "yes": apply the Shape-specific patch below, then write `cspChecked: true`.
460
+
461
+ #### append-arrays
462
+
463
+ CSP expressed as structured directive arrays. Patch mechanism: declare a dev-only array, spread it into the script-src and connect-src arrays.
464
+
465
+ **Declare near the top of the file that holds the CSP arrays:**
466
+
467
+ ```ts
468
+ // Dev-only allowance so impeccable live mode can load. Guarded by NODE_ENV.
469
+ const __impeccableLiveDev =
470
+ process.env.NODE_ENV === "development" ? ["http://localhost:8400"] : [];
471
+ ```
472
+
473
+ **Append `...__impeccableLiveDev` to the script-src and connect-src directive arrays.** Per-framework specifics:
474
+
475
+ - **Next.js + monorepo helper** — edit the *app's* `next.config.*` (not the shared helper), appending to `additionalScriptSrc` and `additionalConnectSrc` passed into `createBaseNextConfig` (or equivalent). Keeps the shared package clean.
476
+ - **SvelteKit** — edit `svelte.config.js`, appending to `kit.csp.directives['script-src']` and `kit.csp.directives['connect-src']`.
477
+ - **Nuxt + nuxt-security** — edit `nuxt.config.*`, appending to `security.headers.contentSecurityPolicy['script-src']` and `['connect-src']`.
478
+
479
+ Reference outputs:
480
+ - `tests/framework-fixtures/nextjs-turborepo/expected-after-patch.ts` (Next.js)
481
+ - `tests/framework-fixtures/sveltekit-csp/expected-after-patch.js` (SvelteKit)
482
+
483
+ Idempotency: if `__impeccableLiveDev` already exists in the file, the patch is already applied; skip asking and just mark `cspChecked: true`.
484
+
485
+ #### append-string
486
+
487
+ CSP built as a literal value string. Two-point patch: declare a dev-only string near the top, interpolate it into the CSP at the `script-src` and `connect-src` directives.
488
+
489
+ ```ts
490
+ // Dev-only allowance so impeccable live mode can load.
491
+ const __impeccableLiveDev =
492
+ process.env.NODE_ENV === "development" ? " http://localhost:8400" : "";
493
+ ```
494
+
495
+ Then in the CSP value string:
496
+ - `script-src 'self' 'unsafe-inline'` → `` `script-src 'self' 'unsafe-inline'${__impeccableLiveDev}` ``
497
+ - `connect-src 'self'` → `` `connect-src 'self'${__impeccableLiveDev}` ``
498
+
499
+ (Leading space on the dev string so it concatenates cleanly into the existing value. Convert the literal CSP directives into template strings as part of the edit if they aren't already.)
500
+
501
+ Per-framework specifics:
502
+ - **Next.js inline `headers()`** — edit `next.config.*`, splicing the variable into the CSP value.
503
+ - **Nuxt `routeRules`** — edit `nuxt.config.*`, splicing into the CSP in `routeRules['/**'].headers['Content-Security-Policy']`.
504
+
505
+ Reference outputs:
506
+ - `tests/framework-fixtures/nextjs-inline-csp/expected-after-patch.js` (Next.js)
507
+ - `tests/framework-fixtures/nuxt-csp/expected-after-patch.ts` (Nuxt)
508
+
509
+ ### Troubleshooting
510
+
511
+ If a user says "no" to the CSP patch at setup time and later complains that live doesn't work: their dev CSP blocks `http://localhost:8400`. Fix: delete `cspChecked` from `config.json` and re-run `live.mjs` — setup will ask again.
512
+
513
+ Then re-run `live.mjs`.
@@ -0,0 +1,99 @@
1
+ # Motion Design
2
+
3
+ ## Duration: The 100/300/500 Rule
4
+
5
+ Timing matters more than easing. These durations feel right for most UI:
6
+
7
+ | Duration | Use Case | Examples |
8
+ |----------|----------|----------|
9
+ | **100-150ms** | Instant feedback | Button press, toggle, color change |
10
+ | **200-300ms** | State changes | Menu open, tooltip, hover states |
11
+ | **300-500ms** | Layout changes | Accordion, modal, drawer |
12
+ | **500-800ms** | Entrance animations | Page load, hero reveals |
13
+
14
+ **Exit animations are faster than entrances**—use ~75% of enter duration.
15
+
16
+ ## Easing: Pick the Right Curve
17
+
18
+ **Don't use `ease`.** It's a compromise that's rarely optimal. Instead:
19
+
20
+ | Curve | Use For | CSS |
21
+ |-------|---------|-----|
22
+ | **ease-out** | Elements entering | `cubic-bezier(0.16, 1, 0.3, 1)` |
23
+ | **ease-in** | Elements leaving | `cubic-bezier(0.7, 0, 0.84, 0)` |
24
+ | **ease-in-out** | State toggles (there → back) | `cubic-bezier(0.65, 0, 0.35, 1)` |
25
+
26
+ **For micro-interactions, use exponential curves**—they feel natural because they mimic real physics (friction, deceleration):
27
+
28
+ ```css
29
+ /* Quart out - smooth, refined (recommended default) */
30
+ --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
31
+
32
+ /* Quint out - slightly more dramatic */
33
+ --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
34
+
35
+ /* Expo out - snappy, confident */
36
+ --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
37
+ ```
38
+
39
+ **Avoid bounce and elastic curves.** They were trendy in 2015 but now feel tacky and amateurish. Real objects don't bounce when they stop—they decelerate smoothly. Overshoot effects draw attention to the animation itself rather than the content.
40
+
41
+ ## The Only Two Properties You Should Animate
42
+
43
+ **transform** and **opacity** only—everything else causes layout recalculation. For height animations (accordions), use `grid-template-rows: 0fr → 1fr` instead of animating `height` directly.
44
+
45
+ ## Staggered Animations
46
+
47
+ Use CSS custom properties for cleaner stagger: `animation-delay: calc(var(--i, 0) * 50ms)` with `style="--i: 0"` on each item. **Cap total stagger time**—10 items at 50ms = 500ms total. For many items, reduce per-item delay or cap staggered count.
48
+
49
+ ## Reduced Motion
50
+
51
+ This is not optional. Vestibular disorders affect ~35% of adults over 40.
52
+
53
+ ```css
54
+ /* Define animations normally */
55
+ .card {
56
+ animation: slide-up 500ms ease-out;
57
+ }
58
+
59
+ /* Provide alternative for reduced motion */
60
+ @media (prefers-reduced-motion: reduce) {
61
+ .card {
62
+ animation: fade-in 200ms ease-out; /* Crossfade instead of motion */
63
+ }
64
+ }
65
+
66
+ /* Or disable entirely */
67
+ @media (prefers-reduced-motion: reduce) {
68
+ *, *::before, *::after {
69
+ animation-duration: 0.01ms !important;
70
+ transition-duration: 0.01ms !important;
71
+ }
72
+ }
73
+ ```
74
+
75
+ **What to preserve**: Functional animations like progress bars, loading spinners (slowed down), and focus indicators should still work—just without spatial movement.
76
+
77
+ ## Perceived Performance
78
+
79
+ **Nobody cares how fast your site is—just how fast it feels.** Perception can be as effective as actual performance.
80
+
81
+ **The 80ms threshold**: Our brains buffer sensory input for ~80ms to synchronize perception. Anything under 80ms feels instant and simultaneous. This is your target for micro-interactions.
82
+
83
+ **Active vs passive time**: Passive waiting (staring at a spinner) feels longer than active engagement. Strategies to shift the balance:
84
+
85
+ - **Preemptive start**: Begin transitions immediately while loading (iOS app zoom, skeleton UI). Users perceive work happening.
86
+ - **Early completion**: Show content progressively—don't wait for everything. Video buffering, progressive images, streaming HTML.
87
+ - **Optimistic UI**: Update the interface immediately, handle failures gracefully. Instagram likes work offline—the UI updates instantly, syncs later. Use for low-stakes actions; avoid for payments or destructive operations.
88
+
89
+ **Easing affects perceived duration**: Ease-in (accelerating toward completion) makes tasks feel shorter because the peak-end effect weights final moments heavily. Ease-out feels satisfying for entrances, but ease-in toward a task's end compresses perceived time.
90
+
91
+ **Caution**: Too-fast responses can decrease perceived value. Users may distrust instant results for complex operations (search, analysis). Sometimes a brief delay signals "real work" is happening.
92
+
93
+ ## Performance
94
+
95
+ Don't use `will-change` preemptively—only when animation is imminent (`:hover`, `.animating`). For scroll-triggered animations, use Intersection Observer instead of scroll events; unobserve after animating once. Create motion tokens for consistency (durations, easings, common transitions).
96
+
97
+ ---
98
+
99
+ **Avoid**: Animating everything (animation fatigue is real). Using >500ms for UI feedback. Ignoring `prefers-reduced-motion`. Using animation to hide slow loading.