@thanhnguyxn/pixelcraft 0.0.0-stage → 0.2.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 (455) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/.antigravity-plugin/plugin.json +32 -0
  3. package/.claude-plugin/marketplace.json +20 -0
  4. package/.claude-plugin/plugin.json +22 -0
  5. package/.codex-plugin/plugin.json +45 -0
  6. package/.cursor-plugin/marketplace.json +17 -0
  7. package/.cursor-plugin/plugin.json +27 -0
  8. package/.devin-plugin/plugin.json +21 -0
  9. package/.github/plugin/marketplace.json +34 -0
  10. package/CHANGELOG.md +159 -0
  11. package/GEMINI.md +1 -0
  12. package/LICENSE +21 -0
  13. package/README.md +264 -2
  14. package/SECURITY.md +28 -0
  15. package/assets/README.md +28 -0
  16. package/assets/pixelcraft-logo-128.png +0 -0
  17. package/assets/pixelcraft-logo-256.png +0 -0
  18. package/assets/pixelcraft-logo-512.png +0 -0
  19. package/bin/pixelcraft.mjs +852 -0
  20. package/docs/ARCHITECTURE.md +105 -0
  21. package/docs/DESIGN-RATIONALE.md +191 -0
  22. package/docs/INSTALL.md +221 -0
  23. package/evals/README.md +37 -0
  24. package/evals/fixtures/3d-web-engineering.json +69 -0
  25. package/evals/fixtures/README.md +36 -0
  26. package/evals/fixtures/acceptance-checklist-rule03-gate.json +43 -0
  27. package/evals/fixtures/ai-ui-libraries.json +53 -0
  28. package/evals/fixtures/audio-visual-accessibility.json +69 -0
  29. package/evals/fixtures/auth-and-checkout-ui.json +53 -0
  30. package/evals/fixtures/brandkit-identity-governance.json +48 -0
  31. package/evals/fixtures/build-and-architecture.json +53 -0
  32. package/evals/fixtures/canvas-and-node-editors.json +53 -0
  33. package/evals/fixtures/chat-ai-exfiltration-ime-hitl-gate.json +43 -0
  34. package/evals/fixtures/completion-gate-scan-until-clean.json +44 -0
  35. package/evals/fixtures/component-systems.json +53 -0
  36. package/evals/fixtures/component-testing.json +53 -0
  37. package/evals/fixtures/constrained-voice-and-tv.json +43 -0
  38. package/evals/fixtures/creative-code-rendering.json +69 -0
  39. package/evals/fixtures/creative-reference-evidence.json +67 -0
  40. package/evals/fixtures/data-app-python-marimo.json +49 -0
  41. package/evals/fixtures/desktop-cpp-juce-audio.json +49 -0
  42. package/evals/fixtures/desktop-csharp-avalonia.json +49 -0
  43. package/evals/fixtures/desktop-native-workspace.json +48 -0
  44. package/evals/fixtures/desktop-python-anti-tkinter.json +49 -0
  45. package/evals/fixtures/direction-prototype-complexity.json +29 -0
  46. package/evals/fixtures/document-prepress-pdfx4-tounicode.json +43 -0
  47. package/evals/fixtures/document-rust-typst-invoice.json +49 -0
  48. package/evals/fixtures/document-typst-and-print-css.json +43 -0
  49. package/evals/fixtures/email-mjml-dark-mode.json +49 -0
  50. package/evals/fixtures/email-outlook-and-plaintext.json +43 -0
  51. package/evals/fixtures/enterprise-data-ui.json +53 -0
  52. package/evals/fixtures/extended-tui-toolkits.json +53 -0
  53. package/evals/fixtures/extensions-mv3-and-vscode.json +43 -0
  54. package/evals/fixtures/file-upload-media-ui.json +53 -0
  55. package/evals/fixtures/finish-gate-anti-slop.json +30 -0
  56. package/evals/fixtures/forms-accessibility-negative.json +29 -0
  57. package/evals/fixtures/forms-validation.json +53 -0
  58. package/evals/fixtures/game-go-ebitengine.json +49 -0
  59. package/evals/fixtures/game-godot-gdscript.json +49 -0
  60. package/evals/fixtures/game-ui-hud-and-engines.json +43 -0
  61. package/evals/fixtures/handoff-fidelity-tolerance.json +29 -0
  62. package/evals/fixtures/i18n-engineering.json +53 -0
  63. package/evals/fixtures/local-first-sync.json +53 -0
  64. package/evals/fixtures/lynxjs.json +53 -0
  65. package/evals/fixtures/maizzle-email.json +53 -0
  66. package/evals/fixtures/maps-geospatial.json +53 -0
  67. package/evals/fixtures/media-og-and-video-export.json +43 -0
  68. package/evals/fixtures/media-players.json +53 -0
  69. package/evals/fixtures/mobile-compose-16kb-foldable-store-gate.json +44 -0
  70. package/evals/fixtures/mobile-elixir-liveview-native.json +49 -0
  71. package/evals/fixtures/mobile-flutter-dynamic-type.json +49 -0
  72. package/evals/fixtures/mobile-harmonyos-arkui.json +49 -0
  73. package/evals/fixtures/mobile-jetpack-compose.json +49 -0
  74. package/evals/fixtures/mobile-swiftui-ios.json +49 -0
  75. package/evals/fixtures/motion-engineering.json +69 -0
  76. package/evals/fixtures/pdfjs-and-pptx.json +53 -0
  77. package/evals/fixtures/plan-brownfield-evidence.json +28 -0
  78. package/evals/fixtures/plan-discovery-interview.json +31 -0
  79. package/evals/fixtures/plan-grill-me-brainstorm-gate.json +49 -0
  80. package/evals/fixtures/reactive-data-apps.json +53 -0
  81. package/evals/fixtures/review-evidence-audit.json +43 -0
  82. package/evals/fixtures/rich-text-and-code-editors.json +53 -0
  83. package/evals/fixtures/scrollytelling-resilience.json +70 -0
  84. package/evals/fixtures/spatial-xr-comfort-and-platforms.json +43 -0
  85. package/evals/fixtures/state-architecture.json +53 -0
  86. package/evals/fixtures/styling-ecosystem.json +53 -0
  87. package/evals/fixtures/token-tooling.json +53 -0
  88. package/evals/fixtures/tui-go-bubbletea.json +49 -0
  89. package/evals/fixtures/tui-rust-ratatui-grapheme-paste-teardown.json +44 -0
  90. package/evals/fixtures/tui-rust-ratatui.json +49 -0
  91. package/evals/fixtures/ux-state-matrix-and-i18n.json +43 -0
  92. package/evals/fixtures/visual-qa-task-evidence.json +29 -0
  93. package/evals/fixtures/web-3d-engines.json +53 -0
  94. package/evals/fixtures/web-php-laravel-filament.json +49 -0
  95. package/evals/fixtures/web-ruby-viewcomponent-phlex.json +49 -0
  96. package/evals/fixtures/workflow-checkpoints.json +30 -0
  97. package/evals/pixelcraft-accessibility.md +74 -0
  98. package/evals/pixelcraft-brandkit.md +58 -0
  99. package/evals/pixelcraft-chat-ui.md +55 -0
  100. package/evals/pixelcraft-constrained.md +55 -0
  101. package/evals/pixelcraft-craft.md +76 -0
  102. package/evals/pixelcraft-data-apps.md +55 -0
  103. package/evals/pixelcraft-dataviz.md +59 -0
  104. package/evals/pixelcraft-desktop.md +55 -0
  105. package/evals/pixelcraft-direction.md +77 -0
  106. package/evals/pixelcraft-document.md +55 -0
  107. package/evals/pixelcraft-email.md +55 -0
  108. package/evals/pixelcraft-extensions.md +55 -0
  109. package/evals/pixelcraft-game-ui.md +59 -0
  110. package/evals/pixelcraft-handoff.md +57 -0
  111. package/evals/pixelcraft-media.md +55 -0
  112. package/evals/pixelcraft-mobile.md +59 -0
  113. package/evals/pixelcraft-patterns.md +73 -0
  114. package/evals/pixelcraft-plan.md +127 -0
  115. package/evals/pixelcraft-review.md +63 -0
  116. package/evals/pixelcraft-spatial.md +55 -0
  117. package/evals/pixelcraft-tokens.md +57 -0
  118. package/evals/pixelcraft-tui.md +55 -0
  119. package/evals/pixelcraft-ux.md +59 -0
  120. package/evals/pixelcraft-visual-qa.md +86 -0
  121. package/evals/pixelcraft-web.md +89 -0
  122. package/evals/pixelcraft.md +70 -0
  123. package/gemini-extension.json +6 -0
  124. package/install.ps1 +341 -0
  125. package/install.sh +512 -0
  126. package/package.json +91 -4
  127. package/plugin.json +29 -0
  128. package/scripts/build-adapters.mjs +288 -0
  129. package/scripts/build-release-archives.mjs +61 -0
  130. package/scripts/build-skill-zips.mjs +94 -0
  131. package/scripts/run-evals.mjs +397 -0
  132. package/scripts/sync-docs.mjs +381 -0
  133. package/scripts/test-build-adapters.mjs +61 -0
  134. package/scripts/test-cross-platform-qa.mjs +359 -0
  135. package/scripts/test-distribution.mjs +203 -0
  136. package/scripts/test-export-tokens.mjs +361 -0
  137. package/scripts/test-finish-gate.mjs +271 -0
  138. package/scripts/test-installers.mjs +216 -0
  139. package/scripts/test-release-archives.mjs +42 -0
  140. package/scripts/test-shoot.mjs +87 -0
  141. package/scripts/test-slop-scan.mjs +416 -0
  142. package/scripts/test-style-inventory.mjs +234 -0
  143. package/scripts/test-sync-docs.mjs +140 -0
  144. package/scripts/test-validate-skills.mjs +195 -0
  145. package/scripts/validate-skills.mjs +658 -0
  146. package/skills/pixelcraft/SKILL.md +155 -0
  147. package/skills/pixelcraft/references/design-brief.md +75 -0
  148. package/skills/pixelcraft/references/floor.md +90 -0
  149. package/skills/pixelcraft/references/report-template.md +49 -0
  150. package/skills/pixelcraft/references/stack-detection.md +226 -0
  151. package/skills/pixelcraft/references/surface-acceptance.md +52 -0
  152. package/skills/pixelcraft/references/workflow-checkpoints.md +71 -0
  153. package/skills/pixelcraft-accessibility/SKILL.md +54 -0
  154. package/skills/pixelcraft-accessibility/references/apg-patterns.md +64 -0
  155. package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
  156. package/skills/pixelcraft-accessibility/references/platforms.md +86 -0
  157. package/skills/pixelcraft-accessibility/references/verification.md +64 -0
  158. package/skills/pixelcraft-accessibility/references/wcag22-checks.md +99 -0
  159. package/skills/pixelcraft-brandkit/SKILL.md +127 -0
  160. package/skills/pixelcraft-brandkit/references/asset-pipeline.md +165 -0
  161. package/skills/pixelcraft-brandkit/references/brand-governance.md +82 -0
  162. package/skills/pixelcraft-brandkit/references/layouts.md +88 -0
  163. package/skills/pixelcraft-brandkit/references/logo-concepting.md +83 -0
  164. package/skills/pixelcraft-brandkit/references/logo-methods.md +97 -0
  165. package/skills/pixelcraft-brandkit/references/pixel-art-logos.md +82 -0
  166. package/skills/pixelcraft-brandkit/references/prompt-template.md +87 -0
  167. package/skills/pixelcraft-brandkit/references/qa-checklist.md +93 -0
  168. package/skills/pixelcraft-brandkit/references/visual-modes.md +123 -0
  169. package/skills/pixelcraft-chat-ui/SKILL.md +57 -0
  170. package/skills/pixelcraft-chat-ui/references/agentic-workspace.md +66 -0
  171. package/skills/pixelcraft-chat-ui/references/ai-ui-libraries.md +259 -0
  172. package/skills/pixelcraft-chat-ui/references/conversation-design.md +84 -0
  173. package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +77 -0
  174. package/skills/pixelcraft-chat-ui/references/slack-discord.md +80 -0
  175. package/skills/pixelcraft-constrained/SKILL.md +52 -0
  176. package/skills/pixelcraft-constrained/references/specialized-hardware.md +90 -0
  177. package/skills/pixelcraft-constrained/references/tv-wearables.md +134 -0
  178. package/skills/pixelcraft-constrained/references/voice-ui.md +104 -0
  179. package/skills/pixelcraft-craft/SKILL.md +58 -0
  180. package/skills/pixelcraft-craft/references/color.md +125 -0
  181. package/skills/pixelcraft-craft/references/imagery-icons.md +37 -0
  182. package/skills/pixelcraft-craft/references/layout-quality.md +65 -0
  183. package/skills/pixelcraft-craft/references/layout.md +73 -0
  184. package/skills/pixelcraft-craft/references/motion.md +163 -0
  185. package/skills/pixelcraft-craft/references/typography.md +110 -0
  186. package/skills/pixelcraft-data-apps/SKILL.md +86 -0
  187. package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
  188. package/skills/pixelcraft-data-apps/references/dash.md +109 -0
  189. package/skills/pixelcraft-data-apps/references/evidence.md +90 -0
  190. package/skills/pixelcraft-data-apps/references/gradio.md +103 -0
  191. package/skills/pixelcraft-data-apps/references/julia-genie.md +89 -0
  192. package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +91 -0
  193. package/skills/pixelcraft-data-apps/references/nicegui.md +102 -0
  194. package/skills/pixelcraft-data-apps/references/observable-framework.md +105 -0
  195. package/skills/pixelcraft-data-apps/references/panel.md +99 -0
  196. package/skills/pixelcraft-data-apps/references/r-shiny.md +124 -0
  197. package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
  198. package/skills/pixelcraft-data-apps/references/reflex.md +116 -0
  199. package/skills/pixelcraft-data-apps/references/shiny.md +110 -0
  200. package/skills/pixelcraft-data-apps/references/streamlit.md +113 -0
  201. package/skills/pixelcraft-dataviz/SKILL.md +60 -0
  202. package/skills/pixelcraft-dataviz/references/chart-choice.md +55 -0
  203. package/skills/pixelcraft-dataviz/references/color-accessibility.md +112 -0
  204. package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +107 -0
  205. package/skills/pixelcraft-dataviz/references/libraries.md +176 -0
  206. package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
  207. package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +92 -0
  208. package/skills/pixelcraft-desktop/SKILL.md +93 -0
  209. package/skills/pixelcraft-desktop/references/appkit.md +92 -0
  210. package/skills/pixelcraft-desktop/references/avalonia.md +95 -0
  211. package/skills/pixelcraft-desktop/references/cpp-gui.md +129 -0
  212. package/skills/pixelcraft-desktop/references/electron.md +96 -0
  213. package/skills/pixelcraft-desktop/references/go-gui.md +83 -0
  214. package/skills/pixelcraft-desktop/references/gtk.md +97 -0
  215. package/skills/pixelcraft-desktop/references/javafx-swing.md +81 -0
  216. package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +88 -0
  217. package/skills/pixelcraft-desktop/references/rust-gui.md +83 -0
  218. package/skills/pixelcraft-desktop/references/tauri.md +110 -0
  219. package/skills/pixelcraft-desktop/references/uno-platform.md +71 -0
  220. package/skills/pixelcraft-desktop/references/winui-wpf.md +98 -0
  221. package/skills/pixelcraft-desktop/references/working-context.md +84 -0
  222. package/skills/pixelcraft-direction/SKILL.md +120 -0
  223. package/skills/pixelcraft-direction/references/composition-library.md +84 -0
  224. package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
  225. package/skills/pixelcraft-direction/references/direction-card.md +64 -0
  226. package/skills/pixelcraft-direction/references/direction-scoring.md +76 -0
  227. package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
  228. package/skills/pixelcraft-direction/references/movements.md +71 -0
  229. package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
  230. package/skills/pixelcraft-direction/references/repetition-history.md +75 -0
  231. package/skills/pixelcraft-direction/references/slop-fingerprints.md +83 -0
  232. package/skills/pixelcraft-direction/references/wildcards.md +47 -0
  233. package/skills/pixelcraft-document/SKILL.md +58 -0
  234. package/skills/pixelcraft-document/references/archetypes.md +106 -0
  235. package/skills/pixelcraft-document/references/pdf-tools.md +314 -0
  236. package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
  237. package/skills/pixelcraft-document/references/print-css.md +187 -0
  238. package/skills/pixelcraft-document/references/slides.md +198 -0
  239. package/skills/pixelcraft-email/SKILL.md +80 -0
  240. package/skills/pixelcraft-email/references/client-quirks.md +113 -0
  241. package/skills/pixelcraft-email/references/html-tables.md +114 -0
  242. package/skills/pixelcraft-email/references/maizzle.md +54 -0
  243. package/skills/pixelcraft-email/references/mjml.md +54 -0
  244. package/skills/pixelcraft-email/references/react-email.md +95 -0
  245. package/skills/pixelcraft-extensions/SKILL.md +56 -0
  246. package/skills/pixelcraft-extensions/references/browser-extensions.md +105 -0
  247. package/skills/pixelcraft-extensions/references/figma-office.md +106 -0
  248. package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
  249. package/skills/pixelcraft-extensions/references/raycast.md +98 -0
  250. package/skills/pixelcraft-extensions/references/vscode-webviews.md +100 -0
  251. package/skills/pixelcraft-game-ui/SKILL.md +80 -0
  252. package/skills/pixelcraft-game-ui/references/bevy.md +90 -0
  253. package/skills/pixelcraft-game-ui/references/godot.md +130 -0
  254. package/skills/pixelcraft-game-ui/references/hud-principles.md +67 -0
  255. package/skills/pixelcraft-game-ui/references/love2d.md +77 -0
  256. package/skills/pixelcraft-game-ui/references/monogame.md +68 -0
  257. package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
  258. package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +107 -0
  259. package/skills/pixelcraft-game-ui/references/unreal-umg.md +80 -0
  260. package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
  261. package/skills/pixelcraft-handoff/SKILL.md +50 -0
  262. package/skills/pixelcraft-handoff/references/design-translation.md +134 -0
  263. package/skills/pixelcraft-handoff/references/fidelity-tolerance.md +78 -0
  264. package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
  265. package/skills/pixelcraft-media/SKILL.md +49 -0
  266. package/skills/pixelcraft-media/references/banners-video.md +130 -0
  267. package/skills/pixelcraft-media/references/og-generation.md +154 -0
  268. package/skills/pixelcraft-media/references/social-cards.md +71 -0
  269. package/skills/pixelcraft-mobile/SKILL.md +86 -0
  270. package/skills/pixelcraft-mobile/references/dotnet-maui.md +91 -0
  271. package/skills/pixelcraft-mobile/references/flet.md +80 -0
  272. package/skills/pixelcraft-mobile/references/flutter.md +113 -0
  273. package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
  274. package/skills/pixelcraft-mobile/references/ionic-capacitor.md +87 -0
  275. package/skills/pixelcraft-mobile/references/jetpack-compose.md +129 -0
  276. package/skills/pixelcraft-mobile/references/kivy.md +82 -0
  277. package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +86 -0
  278. package/skills/pixelcraft-mobile/references/lynxjs.md +110 -0
  279. package/skills/pixelcraft-mobile/references/nativescript-and-skip.md +91 -0
  280. package/skills/pixelcraft-mobile/references/react-native-expo.md +106 -0
  281. package/skills/pixelcraft-mobile/references/swiftui.md +200 -0
  282. package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
  283. package/skills/pixelcraft-mobile/references/task-state-composition.md +85 -0
  284. package/skills/pixelcraft-mobile/references/uikit.md +92 -0
  285. package/skills/pixelcraft-patterns/SKILL.md +75 -0
  286. package/skills/pixelcraft-patterns/references/accessibility-resilience.md +29 -0
  287. package/skills/pixelcraft-patterns/references/ai-and-offline-patterns.md +54 -0
  288. package/skills/pixelcraft-patterns/references/auth-onboarding.md +44 -0
  289. package/skills/pixelcraft-patterns/references/billing-paywalls.md +40 -0
  290. package/skills/pixelcraft-patterns/references/command-workspace.md +56 -0
  291. package/skills/pixelcraft-patterns/references/commerce.md +47 -0
  292. package/skills/pixelcraft-patterns/references/communication.md +45 -0
  293. package/skills/pixelcraft-patterns/references/creative-tools.md +42 -0
  294. package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
  295. package/skills/pixelcraft-patterns/references/dashboard-admin.md +35 -0
  296. package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
  297. package/skills/pixelcraft-patterns/references/marketing.md +44 -0
  298. package/skills/pixelcraft-patterns/references/multi-tenant-rbac.md +47 -0
  299. package/skills/pixelcraft-patterns/references/narrative-systems.md +42 -0
  300. package/skills/pixelcraft-patterns/references/notifications-activity.md +57 -0
  301. package/skills/pixelcraft-patterns/references/pattern-selection.md +80 -0
  302. package/skills/pixelcraft-patterns/references/scheduling-kanban.md +47 -0
  303. package/skills/pixelcraft-patterns/references/scroll-implementation.md +37 -0
  304. package/skills/pixelcraft-patterns/references/search-filtering.md +42 -0
  305. package/skills/pixelcraft-patterns/references/settings.md +51 -0
  306. package/skills/pixelcraft-patterns/references/tables-crud.md +43 -0
  307. package/skills/pixelcraft-plan/SKILL.md +103 -0
  308. package/skills/pixelcraft-plan/references/design-input.md +69 -0
  309. package/skills/pixelcraft-plan/references/discovery-interview.md +110 -0
  310. package/skills/pixelcraft-plan/references/grill-me-protocol.md +63 -0
  311. package/skills/pixelcraft-plan/references/plan-template.md +134 -0
  312. package/skills/pixelcraft-plan/references/repo-discovery.md +49 -0
  313. package/skills/pixelcraft-plan/references/stack-freshness.md +67 -0
  314. package/skills/pixelcraft-plan/references/stack-selection.md +98 -0
  315. package/skills/pixelcraft-review/SKILL.md +86 -0
  316. package/skills/pixelcraft-review/references/audit-report.md +69 -0
  317. package/skills/pixelcraft-review/references/critique-protocol.md +89 -0
  318. package/skills/pixelcraft-review/references/heuristics.md +63 -0
  319. package/skills/pixelcraft-review/references/personas.md +53 -0
  320. package/skills/pixelcraft-review/references/polish.md +78 -0
  321. package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
  322. package/skills/pixelcraft-review/scripts/fixtures/brand-critique-waivers.json +14 -0
  323. package/skills/pixelcraft-review/scripts/fixtures/brand-critique.css +18 -0
  324. package/skills/pixelcraft-review/scripts/fixtures/clean.html +43 -0
  325. package/skills/pixelcraft-review/scripts/fixtures/focus-after-block.css +4 -0
  326. package/skills/pixelcraft-review/scripts/fixtures/focus-at-rules.css +17 -0
  327. package/skills/pixelcraft-review/scripts/fixtures/focus-comments.css +10 -0
  328. package/skills/pixelcraft-review/scripts/fixtures/focus-html-quote-leak.html +12 -0
  329. package/skills/pixelcraft-review/scripts/fixtures/focus-invalid-replacements.css +27 -0
  330. package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
  331. package/skills/pixelcraft-review/scripts/fixtures/focus-nested-rules.css +19 -0
  332. package/skills/pixelcraft-review/scripts/fixtures/focus-not-visible-skip.css +8 -0
  333. package/skills/pixelcraft-review/scripts/fixtures/focus-outline-shorthands.css +11 -0
  334. package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-and-border.css +15 -0
  335. package/skills/pixelcraft-review/scripts/fixtures/focus-unknown-last-wins.css +19 -0
  336. package/skills/pixelcraft-review/scripts/fixtures/focus-valid-replacements-extended.css +29 -0
  337. package/skills/pixelcraft-review/scripts/fixtures/focus-visible-no-replacement.css +3 -0
  338. package/skills/pixelcraft-review/scripts/fixtures/focus-visible-valid-replacements.css +9 -0
  339. package/skills/pixelcraft-review/scripts/fixtures/slop.html +28 -0
  340. package/skills/pixelcraft-review/scripts/slop-scan.mjs +1233 -0
  341. package/skills/pixelcraft-spatial/SKILL.md +51 -0
  342. package/skills/pixelcraft-spatial/references/comfort-accessibility.md +39 -0
  343. package/skills/pixelcraft-spatial/references/platforms.md +147 -0
  344. package/skills/pixelcraft-tokens/SKILL.md +60 -0
  345. package/skills/pixelcraft-tokens/assets/tokens.example.json +71 -0
  346. package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +47 -0
  347. package/skills/pixelcraft-tokens/references/adoption.md +55 -0
  348. package/skills/pixelcraft-tokens/references/format.md +84 -0
  349. package/skills/pixelcraft-tokens/references/governance.md +80 -0
  350. package/skills/pixelcraft-tokens/references/state-tokens.md +62 -0
  351. package/skills/pixelcraft-tokens/references/theme-presets.md +122 -0
  352. package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
  353. package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +847 -0
  354. package/skills/pixelcraft-tui/SKILL.md +76 -0
  355. package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +79 -0
  356. package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
  357. package/skills/pixelcraft-tui/references/ink.md +109 -0
  358. package/skills/pixelcraft-tui/references/ratatui.md +102 -0
  359. package/skills/pixelcraft-tui/references/rich.md +82 -0
  360. package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
  361. package/skills/pixelcraft-tui/references/textual.md +108 -0
  362. package/skills/pixelcraft-ux/SKILL.md +56 -0
  363. package/skills/pixelcraft-ux/references/cognitive-walkthrough.md +70 -0
  364. package/skills/pixelcraft-ux/references/feedback-performance.md +50 -0
  365. package/skills/pixelcraft-ux/references/flows-ia.md +44 -0
  366. package/skills/pixelcraft-ux/references/forms.md +151 -0
  367. package/skills/pixelcraft-ux/references/i18n.md +221 -0
  368. package/skills/pixelcraft-ux/references/laws.md +39 -0
  369. package/skills/pixelcraft-ux/references/locale-test-matrix.md +60 -0
  370. package/skills/pixelcraft-ux/references/state-matrix.md +53 -0
  371. package/skills/pixelcraft-ux/references/usability-testing.md +84 -0
  372. package/skills/pixelcraft-ux/references/ux-writing.md +44 -0
  373. package/skills/pixelcraft-visual-qa/SKILL.md +96 -0
  374. package/skills/pixelcraft-visual-qa/references/baseline-governance.md +70 -0
  375. package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +59 -0
  376. package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
  377. package/skills/pixelcraft-visual-qa/references/capture-email.md +38 -0
  378. package/skills/pixelcraft-visual-qa/references/capture-mobile.md +50 -0
  379. package/skills/pixelcraft-visual-qa/references/capture-terminal.md +35 -0
  380. package/skills/pixelcraft-visual-qa/references/critique-rubric.md +71 -0
  381. package/skills/pixelcraft-visual-qa/references/finish-gate.md +35 -0
  382. package/skills/pixelcraft-visual-qa/references/measured-craft.md +30 -0
  383. package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
  384. package/skills/pixelcraft-visual-qa/references/performance-budgets.md +78 -0
  385. package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -0
  386. package/skills/pixelcraft-visual-qa/references/task-verification.md +81 -0
  387. package/skills/pixelcraft-visual-qa/scripts/check-contrast.mjs +442 -0
  388. package/skills/pixelcraft-visual-qa/scripts/check-email.mjs +397 -0
  389. package/skills/pixelcraft-visual-qa/scripts/check-pdf.mjs +189 -0
  390. package/skills/pixelcraft-visual-qa/scripts/check-tui.mjs +321 -0
  391. package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +174 -0
  392. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-aria-modal.html +19 -0
  393. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-audit.html +34 -0
  394. package/skills/pixelcraft-visual-qa/scripts/fixtures/shoot-modal.html +17 -0
  395. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-deferred.js +1 -0
  396. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory-edge.html +52 -0
  397. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.html +80 -0
  398. package/skills/pixelcraft-visual-qa/scripts/fixtures/style-inventory.js +8 -0
  399. package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +668 -0
  400. package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +1226 -0
  401. package/skills/pixelcraft-web/SKILL.md +132 -0
  402. package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
  403. package/skills/pixelcraft-web/references/adaptive-layout.md +69 -0
  404. package/skills/pixelcraft-web/references/angular.md +108 -0
  405. package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
  406. package/skills/pixelcraft-web/references/astro.md +113 -0
  407. package/skills/pixelcraft-web/references/audio-reactive.md +61 -0
  408. package/skills/pixelcraft-web/references/auth-and-checkout-ui.md +115 -0
  409. package/skills/pixelcraft-web/references/build-and-architecture.md +215 -0
  410. package/skills/pixelcraft-web/references/canvas-and-node-editors.md +157 -0
  411. package/skills/pixelcraft-web/references/clojurescript.md +88 -0
  412. package/skills/pixelcraft-web/references/component-systems.md +102 -0
  413. package/skills/pixelcraft-web/references/component-testing.md +170 -0
  414. package/skills/pixelcraft-web/references/creative-effects.md +59 -0
  415. package/skills/pixelcraft-web/references/creative-runtime.md +34 -0
  416. package/skills/pixelcraft-web/references/elm.md +53 -0
  417. package/skills/pixelcraft-web/references/enterprise-data-ui.md +138 -0
  418. package/skills/pixelcraft-web/references/file-upload-media-ui.md +82 -0
  419. package/skills/pixelcraft-web/references/forms-validation.md +123 -0
  420. package/skills/pixelcraft-web/references/fsharp-fable.md +54 -0
  421. package/skills/pixelcraft-web/references/gsap.md +102 -0
  422. package/skills/pixelcraft-web/references/html-css.md +220 -0
  423. package/skills/pixelcraft-web/references/htmx-alpine.md +103 -0
  424. package/skills/pixelcraft-web/references/i18n-engineering.md +106 -0
  425. package/skills/pixelcraft-web/references/interaction-and-search-primitives.md +196 -0
  426. package/skills/pixelcraft-web/references/java-web.md +61 -0
  427. package/skills/pixelcraft-web/references/kotlin-web.md +57 -0
  428. package/skills/pixelcraft-web/references/leptos-yew.md +97 -0
  429. package/skills/pixelcraft-web/references/lit-web-components.md +63 -0
  430. package/skills/pixelcraft-web/references/local-first-sync.md +105 -0
  431. package/skills/pixelcraft-web/references/media-players.md +104 -0
  432. package/skills/pixelcraft-web/references/motion-react.md +96 -0
  433. package/skills/pixelcraft-web/references/motion-recipes.md +82 -0
  434. package/skills/pixelcraft-web/references/preact-fresh-hono.md +111 -0
  435. package/skills/pixelcraft-web/references/pwa.md +230 -0
  436. package/skills/pixelcraft-web/references/qwik.md +94 -0
  437. package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
  438. package/skills/pixelcraft-web/references/react-next.md +168 -0
  439. package/skills/pixelcraft-web/references/rendering-choice.md +63 -0
  440. package/skills/pixelcraft-web/references/rendering-performance.md +80 -0
  441. package/skills/pixelcraft-web/references/rich-text-and-code-editors.md +220 -0
  442. package/skills/pixelcraft-web/references/rive-lottie.md +73 -0
  443. package/skills/pixelcraft-web/references/scala-laminar.md +53 -0
  444. package/skills/pixelcraft-web/references/scene-architecture.md +132 -0
  445. package/skills/pixelcraft-web/references/server-rendered.md +114 -0
  446. package/skills/pixelcraft-web/references/shader-workflow.md +77 -0
  447. package/skills/pixelcraft-web/references/smooth-scroll.md +58 -0
  448. package/skills/pixelcraft-web/references/solid.md +111 -0
  449. package/skills/pixelcraft-web/references/state-architecture.md +107 -0
  450. package/skills/pixelcraft-web/references/styling-ecosystem.md +273 -0
  451. package/skills/pixelcraft-web/references/svelte.md +111 -0
  452. package/skills/pixelcraft-web/references/tailwind.md +99 -0
  453. package/skills/pixelcraft-web/references/video-media.md +69 -0
  454. package/skills/pixelcraft-web/references/vue-nuxt.md +86 -0
  455. package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
@@ -0,0 +1,114 @@
1
+ # Server-rendered web: Rails, Laravel/Filament, Symfony UX, WordPress, Django/FastAPI/FastHTML, Phoenix, Blazor, Go, Dart Jaspr
2
+
3
+ The common discipline: the server owns initial semantic HTML, routing, validation, authorization, and most state. Progressive enhancement must not break URLs, forms, back/forward, refresh, or no-/limited-JS behavior.
4
+
5
+ ## Token mapping
6
+
7
+ Import generated CSS variables in the base layout/asset pipeline. Do not duplicate token values across framework-specific CSS build systems. In component ecosystems (Livewire/Flux/Filament, Symfony Twig Components, WordPress `theme.json`, Blazor, LiveView, ViewComponent, Phlex, Cotton, `templ`, Gomponents, Jaspr), pass semantic class names/state rather than raw visual constants.
8
+
9
+ ## Rails 8 + Hotwire (Turbo 8, Stimulus, ViewComponent & Phlex)
10
+
11
+ - **Turbo 8 page refreshes**: enable morphing refreshes (`<meta name="turbo-refresh-method" content="morph">` and `<meta name="turbo-refresh-scroll" content="preserve">`) so form updates and broadcasts preserve scroll and input focus without hand-coding fine-grained Turbo Streams for every DOM node. Mark media players or stateful widgets `data-turbo-permanent` with a stable `id`.
12
+ - **ViewComponent**: encapsulate reusable UI in Ruby classes with typed **`renders_one`** / **`renders_many`** slots, preview every state variant in **`ViewComponent::Preview`** + **Lookbook**, and assert rendered HTML/ARIA semantics directly via `render_inline(AlertComponent.new(...))`.
13
+ - **Phlex**: author pure-Ruby HTML/SVG views (`class InvoiceCard < Phlex::HTML`) with compile-safe keyword arguments, explicit `whitespace`, streaming support, and zero ERB partial-local leaks.
14
+ - **Stimulus lifecycle**: bind listeners/observers in `connect()` and always tear them down in **`disconnect()`** (Turbo caches pages and reconnects controllers on back/forward). Honor `prefers-reduced-motion` in CSS.
15
+ - **Do**: `<a href="/invoices/4" data-turbo-frame="_top">View invoice</a>`, expose ViewComponent slots/Lookbook previews or Phlex components for every design-system primitive, and tear down observers in Stimulus `disconnect()`.
16
+ - **Don't**: swap a frame containing duplicate IDs, stuff complex conditionals into unencapsulated ERB partials, drop focus when removing a trigger, or leak Stimulus `window` listeners across Turbo cache restores.
17
+ - **Verify**: `bin/rails test`, `bin/rails test:system` (Capybara/Playwright for `rendered` evidence).
18
+
19
+ ## Laravel Blade + Livewire 3 / 4, Filament, & Flux UI
20
+
21
+ - **Livewire navigation & security**: use `wire:navigate` with **`@persist('audio-player')`** for persistent chrome, cache derived lookups with **`#[Computed]`**, protect immutable IDs/foreign keys with **`#[Locked]`**, enforce Laravel Policies/Gates inside action methods (never `mount()` alone), key loops with `wire:key`, and guard buttons with `wire:loading.attr="disabled"`.
22
+ - **Laravel Filament** (TALL-stack admin, portals, and operational apps): build CRUD and workflows with declarative **`Resource`**, **`Schema`/`Form`**, **`Table`**, **`Action`**, and **`Notification`** classes; enforce authorization Policies per resource/action/bulk action; configure brand tokens cleanly through `Panel::colors(...)`, font setup, and a scoped custom Vite panel theme instead of brittle CSS overrides.
23
+ - **Livewire Flux UI**: use Flux's accessible primitives (`<flux:modal>`, `<flux:select>`, `<flux:command>`, `<flux:toast>`) backed by Tailwind semantic tokens rather than hand-rolling Alpine modals inside Livewire views.
24
+ - **Do**: keep Filament tables server-paginated/searchable with explicit empty-state actions (`emptyStateActions`) and use `#[Locked]` + Policy checks on every Livewire mutation.
25
+ - **Don't**: trust client-writable Livewire public properties without authorization, fight Filament's layout with `!important` overrides, or render validation errors only in a disappearing toast.
26
+ - **Verify**: `php artisan test` (Pest/PHPUnit + Filament Livewire tests), Laravel Dusk / Playwright (`rendered`).
27
+
28
+ ## Symfony UX (Turbo, Live Components, Twig Components, Stimulus, Autocomplete)
29
+
30
+ - **Twig Components (`#[AsTwigComponent]`)**: encapsulate design-system primitives as typed PHP + Twig components (`<twig:Alert variant="danger">`) with strict prop defaults and slots.
31
+ - **Live Components (`#[AsLiveComponent]`)**: use for interactive server-driven filters, forms, and inline edits; mark mutable properties **`#[LiveProp(writable: true)]`** *only* when user-editable and validate/authorize inside **`#[LiveAction]`** methods.
32
+ - **UX Turbo, Stimulus & Autocomplete**: use Turbo Drive/Frames/Streams (`data-turbo-permanent` for media), tear down Stimulus controllers in `disconnect()`, and wire **UX Autocomplete** (`autocomplete: true` on Symfony Form types) for async searchable selects instead of loading 5,000 `<option>` tags into HTML.
33
+ - **Do**: keep `#[LiveProp]` read-only by default, return semantic Symfony Form validation errors inline, and preserve full-page SSR routes behind Turbo Frames.
34
+ - **Don't**: expose internal entity IDs/roles as `writable: true` `LiveProp`s or attach uncleaned Stimulus listeners across Turbo navigations.
35
+ - **Verify**: `php bin/phpunit` (Symfony Panther / Playwright for `rendered` evidence).
36
+
37
+ ## WordPress Gutenberg Blocks & Interactivity API
38
+
39
+ - **Block contract (`block.json`)**: declare block metadata, `supports` (`color`, `spacing`, `typography`, `align`), editor assets, and server-side **`render.php`** (`render` field) so dynamic blocks output clean, crawlable HTML on first paint.
40
+ - **`@wordpress/interactivity`**: use declarative directives (**`data-wp-interactive`**, **`data-wp-context`**, **`data-wp-on--click`**, **`data-wp-bind--aria-expanded`**, **`data-wp-class--is-open`**) paired with `store(...)` for frontend interactivity (tabs, filters, disclosures, instant search) instead of hydrating full React trees or legacy jQuery scripts on public pages.
41
+ - **`theme.json` tokens**: map DTCG semantic tokens into `theme.json` (`settings.color.palette`, `settings.typography.fontFamilies`, `settings.spacing.spacingSizes`) and reference `var(--wp--preset--*)` in CSS so block-editor controls and frontend rendering stay in sync.
42
+ - **Do**: emit valid initial SSR markup in `render.php` with `wp_interactivity_data_wp_context(...)` and escape output via `esc_html`/`esc_attr`/`wp_kses_post`.
43
+ - **Don't**: ship a full React runtime to the public frontend just for an accordion/filter bar, or bypass `theme.json` with global `!important` resets.
44
+ - **Verify**: `npm run build` (`@wordpress/scripts`), `wp-env` + Playwright (`rendered`).
45
+
46
+ ## Inertia.js v2 (React / Vue / Svelte over Laravel, Rails, Phoenix)
47
+
48
+ Choose **Inertia.js v2** when the server owns routing, controllers, auth, and database queries while the frontend needs rich React/Vue/Svelte interactivity without maintaining a separate REST/GraphQL API layer:
49
+
50
+ - **Deferred props (`Inertia::defer(...)` + `<Deferred data="metrics" fallback={...}>`)**: render the main page immediately and stream slow secondary data asynchronously without blocking TTFB.
51
+ - **Prefetching & viewport lazy loads**: use `<Link href="/invoices" prefetch>` (hover/mount prefetch) and **`<WhenVisible data="comments" fallback={...}>`** for below-the-fold data; use `usePoll()` for controlled live refresh.
52
+ - **Forms**: use `useForm()` (or `<Form>` in Inertia v2) so server validation errors (`errors.<field>`), `processing` state, scroll preservation, and browser history work seamlessly.
53
+ - **Do**: keep authorization and data shaping in controllers and return minimal serializable props (never leak raw ORM models).
54
+ - **Don't**: recreate a client-side router or duplicate server validation/auth logic inside Inertia page components.
55
+
56
+ ## Python Web: Django (`django-htmx` / Cotton / Ninja / Unfold / Wagtail), FastAPI + Jinja2, & FastHTML
57
+
58
+ - **Django + `django-htmx` / Cotton**: use base template inheritance for the shell, **`django-cotton`** (`<c-card>`) or `django-template-partials` for reusable semantic components, and **`django-htmx`** (`if request.htmx:`) to return focused fragments on partial requests while returning the full page on direct loads/refreshes (always set `Vary: HX-Request`). Include `hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'`, render `form.field.errors` adjacent to `<label>`, and preserve bound values on HTTP 422/400 re-renders.
59
+ - **Django Ninja, Unfold, & Wagtail**: pair **Django Ninja** (typed Pydantic schemas) for island/API endpoints; adopt **Django Unfold** (`UNFOLD` semantic theme config, KPI/navigation helpers) when shipping a modern accessible Django Admin instead of hacking raw admin CSS; build editorial CMS pages in **Wagtail** using structured **`StreamField`** blocks mapped to design-system templates rather than freeform rich-text HTML blobs.
60
+ - **FastAPI + Jinja2 + htmx**: render SSR pages with `templates.TemplateResponse(request, "invoices.html", {...})`, return HTTP 422 HTML field-error fragments on Pydantic `ValidationError` for htmx requests, enforce explicit CSRF tokens on form/htmx mutations (FastAPI does not enable CSRF middleware by default), and set `Vary: HX-Request`.
61
+ - **FastHTML** (`fasthtml.common` + Starlette/ASGI + htmx): compose semantic FT components (`Main`, `Form`, `Label`, `Input`, `Button`) backed by static token CSS (`hdrs=(Link(rel='stylesheet', href='/tokens.css'),)`). Never pass untrusted user input to `NotStr(...)` (XSS risk).
62
+ - **Do**: serve the exact same URL as full HTML on refresh and as a fragment on `HX-Request` (with `Vary: HX-Request`) and preserve posted input on HTTP 422 errors.
63
+ - **Don't**: cache htmx fragments under full-page cache keys, omit CSRF protection in FastAPI form/htmx handlers, or dump unstyled `{{ form.as_p }}` / `NotStr(user_input)`.
64
+ - **Verify**: `python manage.py check`, `pytest` (`TestClient`), Playwright (`rendered`).
65
+
66
+ ## Phoenix + LiveView 1.0+
67
+
68
+ - **Memory & async discipline**: render large or growing collections with **`stream/3`** + `phx-update="stream"` (so LiveView does not retain thousands of structs in process RAM) and load slow data non-blockingly via **`assign_async/3`** paired with `<.async_result :let={data} assign={@invoices}>` (`:loading`, `:failed`, ok states).
69
+ - **Zero-round-trip UI transitions**: use **`Phoenix.LiveView.JS`** commands (`JS.show`, `JS.hide`, `JS.toggle_class`, `JS.focus`) for modals, drawers, and disclosures so local interaction is instant and respects `prefers-reduced-motion`.
70
+ - **Forms & uploads**: use `to_form/1`, `phx-change`/`phx-submit` with `phx-debounce` and `phx-disable-with`, and explicit `live_file_input` progress/cancel/error UI. Keep dead-view (initial HTTP GET) HTML complete and semantic before the WebSocket connects.
71
+ - **Do**: clean up external observers/charts in JS Hook `destroyed()` and preserve focus across patches.
72
+ - **Don't**: assign giant lists directly to socket assigns (`assign(socket, :rows, huge_list)`) or ignore socket reconnect/offline states.
73
+ - **Verify**: `mix format --check-formatted`, `mix test` (LiveView tests), Wallaby/Playwright (`rendered`).
74
+
75
+ ## Blazor (.NET 9 / 10) & Component Ecosystems
76
+
77
+ - **Render modes & streaming**: keep content-heavy routes **Static SSR** by default, apply **`[StreamRendering]`** for immediate loading skeletons, use **Enhanced Forms** (`<EditForm Enhance ...>` + `[SupplyParameterFromForm]`), and opt into `@rendermode InteractiveServer`, `InteractiveWebAssembly`, or `InteractiveAuto` only on components requiring live stateful interaction.
78
+ - **Component suites (choose ONE per app)**:
79
+ - **FluentUI Blazor** (`Microsoft.FluentUI.AspNetCore.Components`): built on Fluent Web Components with strong WCAG/keyboard/RTL parity and `<FluentDesignTheme>` live light/dark/accent tokens—strong default for accessible business/enterprise apps.
80
+ - **MudBlazor**: Material-based C#-first library; mount `<MudThemeProvider Theme="_theme" />`, `<MudPopoverProvider />`, `<MudDialogProvider />`, and `<MudSnackbarProvider />` once in `MainLayout.razor` and map semantic tokens into `MudTheme`.
81
+ - **Radzen Blazor**: data-dense enterprise `RadzenDataGrid`/scheduler/chart suite—bind server-side `LoadData` paging/sorting/filtering for large datasets and customize theme CSS tokens cleanly.
82
+ - **Accessibility & reconnects**: pair `<InputText id="email" ... />` with `<label for="email">` and `<ValidationMessage>`; design explicit SignalR circuit-reconnecting/failed UX and dispose `IJSObjectReference` in `DisposeAsync()`.
83
+ - **Do**: pick one suite (FluentUI, MudBlazor, or Radzen), mount its overlay providers once in `MainLayout`, and dispose JS interop handles.
84
+ - **Don't**: mix MudBlazor and FluentUI overlay providers on the same layout, or force `InteractiveServer` globally on static content routes.
85
+ - **Verify**: `dotnet build`, `dotnet test` (bUnit), Playwright (`rendered`).
86
+
87
+ ## Go `templ`, Gomponents, `html/template`, & htmx
88
+
89
+ - **`templ`**: compile-time type-checked HTML components (`templ generate`) with automatic contextual escaping and `templ.SafeURL` for user-supplied links.
90
+ - **Gomponents** (`maragudk/gomponents`): pure-Go functional HTML composition (`html.Div`, `html.Form`, `g.Text`) with zero code-generation step and automatic HTML escaping—pairs cleanly with **Echo**, **Chi**, or **Fiber** plus htmx (`hx-boost`, `hx-swap="morph"`) for partial fragments.
91
+ - **Forms & errors**: return an HTTP 422 field-error component containing preserved posted values, adjacent field messages, and a focusable summary; set `Vary: HX-Request` on fragment endpoints; never print raw Go validation structs as user copy.
92
+ - **Do**: escape text with `templ` / `g.Text` and pass `http.ResponseWriter` cleanly through middleware (CSRF, auth, `Vary: HX-Request`).
93
+ - **Don't**: concatenate raw HTML strings with `fmt.Sprintf` or pass untrusted strings to `g.Raw(...)` / `templ.Raw(...)`.
94
+ - **Verify**: `templ generate`, `go vet ./...`, `go test ./...`, Playwright (`rendered`).
95
+
96
+ ## Dart Jaspr (SSR & Islands)
97
+
98
+ Choose **Jaspr** when a Dart/Flutter team needs true semantic HTML/CSS web sites, SEO-crawlable SSR, or static pages without shipping Flutter Web's CanvasKit canvas runtime:
99
+
100
+ - Author server-rendered shells (`@document`) with semantic HTML components (`div`, `nav`, `main`, `form`, `button`) and mark only interactive islands with **`@client`** so client JS stays minimal.
101
+ - Map DTCG semantic CSS custom properties into global stylesheets (or Jaspr typed CSS) rather than duplicating Flutter `ThemeData` inline styles on every node.
102
+ - **Do**: keep static/content routes server-rendered (`static` or `server` mode) and hydrate small `@client` islands.
103
+ - **Don't**: embed Flutter Web's canvas inside a Jaspr marketing/docs page for text content, or ship unstyled interactive controls without keyboard/ARIA semantics.
104
+ - **Verify**: `dart analyze`, `dart test`, `jaspr build`, Playwright (`rendered`).
105
+
106
+ ## Cross-stack traps
107
+
108
+ - fragment swaps duplicating IDs/landmarks or destroying keyboard focus;
109
+ - caching partial responses without `Vary: HX-Request` / `Vary: X-Inertia`;
110
+ - hidden divergence between enhanced (Turbo/htmx/Livewire/Interactivity API/Enhanced Forms) and no-JS behavior;
111
+ - validation rendered only in toast/console or dropping posted input on error;
112
+ - authorization checked only on initial GET render, not inside Livewire/Live Component/Filament/LiveView/Turbo/Inertia POST mutations;
113
+ - timezone/locale rendering mismatch between server and browser;
114
+ - pagination/filter state absent from URLs and lost on back/share/refresh.
@@ -0,0 +1,77 @@
1
+ # Shader workflow (GLSL, WGSL, and TSL)
2
+
3
+ ## Before writing a shader
4
+
5
+ - State the visual/material behavior in plain language and identify its semantic role.
6
+ - Choose **GLSL ES 3.0** (`#version 300 es`) for WebGL 2, **WGSL** for raw WebGPU, or **TSL (`three/tsl`)** when using Three.js `WebGPURenderer` so one node graph compiles to both WGSL and GLSL (`scene-architecture.md`).
7
+ - Define input textures, coordinate space, uniforms, color space (linear math → sRGB output), alpha behavior, precision (`precision highp float;` on mobile GPUs to avoid UV/time banding), and a **`uReduceMotion`** uniform (`0.0` or `1.0`) so reduced-motion mode freezes evolution cleanly without recompiling shaders.
8
+ - Build a static UV diagnostic frame first, then layer clamped time/pointer/audio uniforms.
9
+
10
+ ## Starter patterns (GLSL / WGSL / TSL)
11
+
12
+ ```glsl
13
+ // GLSL ES 3.0 fragment starter: explicit highp precision, aspect-corrected UVs, uReduceMotion gate
14
+ #version 300 es
15
+ precision highp float;
16
+
17
+ uniform vec2 uResolution;
18
+ uniform float uTime;
19
+ uniform float uReduceMotion; // 1.0 when prefers-reduced-motion: reduce
20
+
21
+ out vec4 fragColor;
22
+
23
+ void main() {
24
+ vec2 uv = gl_FragCoord.xy / uResolution;
25
+ vec2 centered = (gl_FragCoord.xy - 0.5 * uResolution) / min(uResolution.x, uResolution.y);
26
+ float phase = mix(uTime * 0.35, 0.0, uReduceMotion);
27
+ float band = 0.5 + 0.5 * sin(length(centered) * 6.0 - phase);
28
+ vec3 col = mix(vec3(0.08, 0.11, 0.16), vec3(0.20, 0.42, 0.62), band * (1.0 - uv.y * 0.3));
29
+ fragColor = vec4(col, 1.0);
30
+ }
31
+ ```
32
+
33
+ ```wgsl
34
+ // WGSL fragment starter: uniform buffer with reduced-motion gate
35
+ struct Uniforms {
36
+ resolution: vec2<f32>,
37
+ time: f32,
38
+ reduceMotion: f32,
39
+ };
40
+ @group(0) @binding(0) var<uniform> u: Uniforms;
41
+
42
+ @fragment
43
+ fn fs_main(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
44
+ let centered = (pos.xy - 0.5 * u.resolution) / min(u.resolution.x, u.resolution.y);
45
+ let phase = mix(u.time * 0.35, 0.0, u.reduceMotion);
46
+ let band = 0.5 + 0.5 * sin(length(centered) * 6.0 - phase);
47
+ return vec4<f32>(mix(vec3<f32>(0.08, 0.11, 0.16), vec3<f32>(0.20, 0.42, 0.62), band), 1.0);
48
+ }
49
+ ```
50
+
51
+ ```ts
52
+ // Three.js TSL starter (compiles to WGSL on WebGPU and GLSL on WebGL2)
53
+ import { color, float, length, mix, sin, time, uniform, uv } from 'three/tsl';
54
+
55
+ const uReduce = uniform(window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 1 : 0);
56
+ const phase = mix(time.mul(0.35), float(0), uReduce);
57
+ const band = sin(length(uv().sub(0.5)).mul(6).sub(phase)).mul(0.5).add(0.5);
58
+ material.colorNode = mix(color(0x141c29), color(0x336b9e), band);
59
+ ```
60
+
61
+ ## Debugging sequence
62
+
63
+ 1. Confirm shader compiles cleanly (check `gl.getShaderInfoLog` / `device.pushErrorScope('validation')`).
64
+ 2. Render a diagnostic UV gradient to verify aspect ratio and DPR scaling.
65
+ 3. Verify sRGB/linear color space, tone mapping, premultiplied alpha, and texture flip-Y orientation.
66
+ 4. Add one pass at a time while checking GPU frame time and memory.
67
+ 5. Test context loss, resize, texture load failure, `uReduceMotion = 1`, and static fallback (`rendered`).
68
+
69
+ ## Rules
70
+
71
+ - Bound loop counts and texture reads; avoid deep nested loops or wide blur kernels on mobile GPUs.
72
+ - Use derivative-based antialiasing (`fwidth`) for crisp procedural edges.
73
+ - Never introduce high-frequency flashing or strobing (>3 Hz, WCAG 2.3.1).
74
+ - Seed procedural noise deterministically for reproducible visual QA.
75
+ - Never paste proprietary shaders; derive original effects from the surface brief.
76
+
77
+ References: WebGL Fundamentals (https://webglfundamentals.org/), WGSL spec (https://www.w3.org/TR/WGSL/), and Three.js TSL (https://threejs.org/examples/?q=tsl).
@@ -0,0 +1,58 @@
1
+ # Smooth scrolling: Lenis and GSAP ScrollSmoother
2
+
3
+ Smooth scrolling is optional. It alters input feel and browser behavior, so add it only when the brief explicitly calls for inertial scroll choreography and normal native scroll remains intact. Never force smooth-scroll hijacking on operational dashboards, tables, or forms.
4
+
5
+ ## Selection checks
6
+
7
+ - Confirm there is no existing smooth-scroll library or custom scroll container.
8
+ - Check keyboard (`Space`/`PageDown`/arrows), wheel, touch momentum, scrollbar dragging, `#anchor` jumps, history restoration, focus-into-view, nested scroll regions, and `prefers-reduced-motion`.
9
+ - Never combine Lenis with GSAP `ScrollSmoother`, Locomotive, or another scroll controller.
10
+ - Disable smooth scroll on `prefers-reduced-motion: reduce`, low-power/constrained surfaces, and preserve native touch inertia on mobile.
11
+
12
+ ## Lenis (`lenis`, `lenis/react`) + GSAP ScrollTrigger
13
+
14
+ - **Package rename**: use **`lenis`** (not legacy `@studio-freight/lenis`), import its required stylesheet **`import 'lenis/dist/lenis.css'`**, and in React use **`lenis/react`** (`<ReactLenis root options={{ autoRaf: false }} ref={lenisRef}>` / `useLenis`).
15
+ - **Single-clock rule (`autoRaf: false`)**: when driving Lenis from `gsap.ticker`, explicitly pass **`autoRaf: false`** so Lenis v1.1+ does not run a competing internal `requestAnimationFrame` loop.
16
+ - **Nested scrollable panels**: mark scrollable modals, drawers, code blocks, and select menus with **`data-lenis-prevent`** (or `data-lenis-prevent-wheel` / `data-lenis-prevent-touch`) so wheel/touch scrolling inside overlays is not hijacked by the page scroller.
17
+ - **CSS hygiene**: remove `html { scroll-behavior: smooth; }` when Lenis is active so native smooth scroll does not fight Lenis interpolation; use `overflow-x: clip` (never `overflow-x: hidden`) on `body` so `position: sticky` keeps working.
18
+
19
+ ```ts
20
+ // Single-clock Lenis + ScrollTrigger sync (skip when reduced motion is preferred)
21
+ import Lenis from 'lenis';
22
+ import 'lenis/dist/lenis.css';
23
+ import gsap from 'gsap';
24
+ import { ScrollTrigger } from 'gsap/ScrollTrigger';
25
+
26
+ gsap.registerPlugin(ScrollTrigger);
27
+
28
+ let cleanup = () => {};
29
+ if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
30
+ const lenis = new Lenis({ autoRaf: false, duration: 1.05, smoothWheel: true });
31
+ lenis.on('scroll', ScrollTrigger.update);
32
+ const tick = (time: number) => lenis.raf(time * 1000);
33
+ gsap.ticker.add(tick);
34
+ gsap.ticker.lagSmoothing(0);
35
+ cleanup = () => {
36
+ gsap.ticker.remove(tick);
37
+ lenis.destroy();
38
+ };
39
+ }
40
+ ```
41
+
42
+ ## GSAP `ScrollSmoother` (free in GSAP 3.13+)
43
+
44
+ If the route is already heavily GSAP/ScrollTrigger-driven and needs built-in `data-speed` / `data-lag` parallax without a second vendor, **`ScrollSmoother`** (free in GSAP 3.13+) is a direct alternative to Lenis:
45
+
46
+ - Wrap scrollable content in `#smooth-wrapper > #smooth-content` while keeping `position: fixed` headers, modals, and drawers **outside** `#smooth-content` (transforms on `#smooth-content` trap fixed descendants).
47
+ - Keep `smoothTouch: 0` (or `false`) so mobile touch scrolling stays native, skip creation under `(prefers-reduced-motion: reduce)`, and call `smoother.kill()` on teardown.
48
+
49
+ ## Progressive fallback
50
+
51
+ The page must remain scrollable when JavaScript, Lenis, or ScrollSmoother fails. Never hide the browser scrollbar or suppress wheel/touch input, and test `<a href="#section">` anchors, `Tab` focus into offscreen controls, and nested `data-lenis-prevent` containers in a real browser (`rendered`).
52
+
53
+ ## Official references
54
+
55
+ - Lenis documentation: https://lenis.darkroom.engineering/
56
+ - Lenis repository: https://github.com/darkroomengineering/lenis
57
+ - GSAP ScrollSmoother: https://gsap.com/docs/v3/Plugins/ScrollSmoother/
58
+ - GSAP ScrollTrigger: https://gsap.com/docs/v3/Plugins/ScrollTrigger/
@@ -0,0 +1,111 @@
1
+ # Solid / SolidStart
2
+
3
+ ## Token mapping
4
+
5
+ Import generated CSS variables once at entry/root and consume semantic roles in CSS or style props:
6
+
7
+ ```ts
8
+ import './tokens.css';
9
+ ```
10
+
11
+ Fine-grained reactivity does not require fine-grained token duplication. Use typed constants only for names/roles, not copied raw colors.
12
+
13
+ ## Layout and responsive idioms
14
+
15
+ Use CSS-first layout. `<Show>`, `<For>`, `<Index>`, `<Switch>`/`<Match>`, `<ErrorBoundary>`, and `<Suspense>` control state rendering; they do not design layout. Solid's lack of VDOM means components run once and DOM bindings update at fine-grained signal level—never destructure `props` at the top of a component, or reactivity silently breaks. Use **`splitProps`** and **`mergeProps`** when forwarding or defaulting props.
16
+
17
+ ## Typography/custom fonts
18
+
19
+ Load fonts in HTML entry/root route (`src/entry-server.tsx` in SolidStart) with explicit fallback behavior. Keep text as real DOM text; do not replace typography with canvas or SVG except for genuinely graphical content.
20
+
21
+ ## Motion/reduced motion
22
+
23
+ Use CSS transitions/animations where possible. JS animation should be created inside lifecycle-aware code (`onMount`/`createEffect`) with cleanup in `onCleanup`, honoring `matchMedia('(prefers-reduced-motion: reduce)')`. Derive values with **`createMemo`** rather than mirroring signals via `createEffect`.
24
+
25
+ ## Accessibility specifics
26
+
27
+ Use native elements or Solid-native headless primitives (**Kobalte**, **Corvu**, **Ark UI**; see `component-systems.md`). Use `createUniqueId()` for SSR-safe `<label for>` and `aria-describedby` IDs. Choose **`<For>`** for arrays of objects with stable reference identity (rows/cards that reorder) and **`<Index>`** for arrays of primitives or editable input values (keyed by index, passing an accessor `item()` so typing does not recreate the `<input>` and drop focus).
28
+
29
+ ## States idiom & SolidStart 1.x
30
+
31
+ Use `<ErrorBoundary fallback={(err, reset) => ...}>` around `<Suspense>` so rejected async queries render recoverable errors instead of crashing the route. In **SolidStart 1.x** (`@solidjs/router` + Vinxi):
32
+
33
+ - Define cached read loaders with **`query(async (...) => { 'use server'; ... }, 'key')`** and consume them with **`createAsync(() => getInvoices())`** (preloaded via route `preload`).
34
+ - Define progressive mutations with **`action(async (formData: FormData) => { 'use server'; ... }, 'key')`**, attach directly to `<form action={saveInvoice} method="post">`, and inspect pending/error/optimistic state with **`useSubmission(saveInvoice)`** (or `useSubmissions` for concurrent item actions).
35
+ - Isolate browser-only widgets (WebGL canvases, rich editors) with **`clientOnly(() => import('./CanvasEditor'))`** from `@solidjs/start` so server rendering never imports browser globals.
36
+
37
+ ```tsx
38
+ import { query, action, createAsync, useSubmission } from '@solidjs/router';
39
+ import { ErrorBoundary, For, Show, Suspense, createMemo, mergeProps, splitProps } from 'solid-js';
40
+
41
+ const getInvoices = query(async () => {
42
+ 'use server';
43
+ return db.invoices.list();
44
+ }, 'invoices');
45
+
46
+ const archiveInvoice = action(async (formData: FormData) => {
47
+ 'use server';
48
+ const id = String(formData.get('id') ?? '');
49
+ if (!id) return { error: 'Missing invoice ID.' };
50
+ await db.invoices.archive(id);
51
+ return { ok: true };
52
+ }, 'archive-invoice');
53
+
54
+ export function InvoicePanel(rawProps: { filter?: string; class?: string }) {
55
+ const merged = mergeProps({ filter: '' }, rawProps);
56
+ const [local, rest] = splitProps(merged, ['filter']);
57
+ const invoices = createAsync(() => getInvoices());
58
+ const submission = useSubmission(archiveInvoice);
59
+ const visible = createMemo(() =>
60
+ (invoices() ?? []).filter((inv) => inv.code.includes(local.filter))
61
+ );
62
+
63
+ return (
64
+ <section {...rest}>
65
+ <ErrorBoundary fallback={(err, reset) => <button onClick={reset}>Retry: {err.message}</button>}>
66
+ <Suspense fallback={<p role="status" aria-busy="true">Loading invoices…</p>}>
67
+ <Show when={visible().length > 0} fallback={<p>No matching invoices.</p>}>
68
+ <For each={visible()}>
69
+ {(inv) => (
70
+ <form action={archiveInvoice} method="post">
71
+ <input type="hidden" name="id" value={inv.id} />
72
+ <button type="submit" disabled={submission.pending}>Archive {inv.code}</button>
73
+ </form>
74
+ )}
75
+ </For>
76
+ </Show>
77
+ </Suspense>
78
+ </ErrorBoundary>
79
+ </section>
80
+ );
81
+ }
82
+ ```
83
+
84
+ ## Forms idiom
85
+
86
+ Use native `<form action={myAction} method="post">` in SolidStart or Modular Forms (`@modular-forms/solid`) for complex client/server validation (`forms-validation.md`). Solid accepts standard HTML `for` on `<label>` (producing real label association). Preserve user input on failed server validation and expose `submission.error` / returned validation data next to the control.
87
+
88
+ ## Do/don't pairs
89
+
90
+ | Do | Don't |
91
+ |---|---|
92
+ | `<A href="/invoice/42">View invoice</A>` | Click-only `<div>` navigation |
93
+ | `splitProps`/`mergeProps` and `props.title` access inside JSX/memos | `function Card({ title })` destructuring that kills reactivity |
94
+ | `<For>` for object lists; `<Index>` for primitive/editable input lists | `<For>` over primitive strings inside `<input>` (recreates DOM and loses focus on every keystroke) |
95
+ | `createMemo` for derived values; `query`/`createAsync` + `action`/`useSubmission` in SolidStart | Mirroring derived state in `createEffect` or manual `onMount` fetch waterfalls |
96
+ | `clientOnly(() => import(...))` for browser-only modules and `onCleanup` for listeners | Importing `window`-dependent canvases directly in SSR routes or leaking listeners |
97
+
98
+ ## Known traps
99
+
100
+ Destructuring `props` and silently losing reactivity, using `<For>` on primitive input arrays (dropping focus), missing `<ErrorBoundary>` around `<Suspense>`/`createAsync`, browser-only imports crashing SolidStart SSR without `clientOnly()`, overusing `createEffect` where `createMemo` belongs, forgetting `'use server'` inside `query`/`action` handlers.
101
+
102
+ ## Verification commands
103
+
104
+ ```sh
105
+ npm run lint
106
+ npm run test -- --run
107
+ npm run build
108
+ npx playwright test
109
+ ```
110
+
111
+ Rendered browser inspection is required for hierarchy, focus, hydration, and motion evidence (`rendered`); builds and typechecks are `static`.
@@ -0,0 +1,107 @@
1
+ # State management and frontend data architecture
2
+
3
+ Do not put every piece of application state into one global store. Classify state by **ownership, lifetime, shareability, and failure mode**, then choose the smallest tool that fits each layer.
4
+
5
+ ## Five-layer state classification
6
+
7
+ | Layer | Examples | Primary tools | Anti-pattern to avoid |
8
+ |---|---|---|---|
9
+ | **Local UI state** | Open popover, hover index, accordion, ephemeral draft | Framework state (`useState`, signals, runes) | Lifting transient widget state into a global store |
10
+ | **URL / navigation state** | Active filters, sort, pagination, selected tab/item, modal deep-link | `nuqs` (v2), TanStack Router search params, native `URLSearchParams` | Storing shareable filter/tab state only in memory so reload resets it |
11
+ | **Server / async cache state** | REST/RPC/GraphQL entities, pagination, background refetch, mutations | TanStack Query (v5), **TanStack DB**, SWR, RTK Query; typed RPC: **tRPC v11**, **oRPC**, **Hono RPC (`hc`)**; GraphQL: Apollo Client, Relay, urql | Copying fetched API payloads into Redux/Zustand/Pinia and manually managing loading/stale flags |
12
+ | **Cross-tree client & workflow state** | Active tool, workspace panels, multi-step checkout, upload/retry machines | React: Zustand v5, Jotai, Redux Toolkit, Legend-State, TanStack Store; Vue: **Pinia**; Angular: **NgRx SignalStore**; workflows: **XState v5**, RxJS | Tangled boolean flags (`isLoading && !isError && isRetrying`) allowing impossible states |
13
+ | **Local persistent / offline state** | Drafts, offline queues, large client datasets, user prefs | Dexie.js (`IndexedDB`), **`idb` / `idb-keyval`** (tiny Promise wrappers over IndexedDB), OPFS (blobs), `localStorage` (small prefs) | Storing megabytes or structured queryable records in synchronous `localStorage` or unmaintained `localForage` |
14
+
15
+ ## Server-state, typed RPC, and GraphQL clients
16
+
17
+ - **React 19 native action hooks (`useActionState`, `useOptimistic`)**: use for component-scoped mutation lifecycles and transient optimistic UI overrides during form/action submission. They have **no global cache, deduplication, or background refetching**—they complement rather than replace TanStack Query (server cache) or Zustand (cross-tree client UI store).
18
+ - **REST & typed RPC**: use **TanStack Query v5** (React/Vue/Solid/Svelte/Angular) for structured caching, stale-while-revalidate, dependent queries, and optimistic mutations; pair with **tRPC v11** (native `queryOptions` / `mutationOptions` integration with TanStack Query), **oRPC** (OpenAPI-first Standard Schema typed RPC), or **Hono RPC (`hc<AppType>`)** for end-to-end TypeScript safety without codegen. Use **TanStack DB** when you need reactive client-side normalized collections, live cross-collection joins, and instant optimistic mutations backed by TanStack Query or sync engines (`local-first-sync.md`).
19
+ - **GraphQL**: use **Apollo Client** for normalized cache + local reactive variables; **Relay** when strict fragment colocation and compiler-enforced data masking justify the build step; **urql** for lightweight extensible document/graph caching.
20
+ - **Optimistic mutation contract**: always `cancelQueries` before mutating cache so in-flight refetches cannot overwrite optimistic data, snapshot previous data for `onError` rollback, and `invalidateQueries` in `onSettled`:
21
+
22
+ ```ts
23
+ // TanStack Query v5 optimistic update with rollback
24
+ const mutation = useMutation({
25
+ mutationFn: updateItem,
26
+ onMutate: async (nextItem) => {
27
+ await queryClient.cancelQueries({ queryKey: ['items'] });
28
+ const previous = queryClient.getQueryData<Item[]>(['items']);
29
+ queryClient.setQueryData<Item[]>(['items'], (old = []) => [...old, nextItem]);
30
+ return { previous };
31
+ },
32
+ onError: (_err, _vars, ctx) => {
33
+ queryClient.setQueryData(['items'], ctx?.previous);
34
+ },
35
+ onSettled: () => queryClient.invalidateQueries({ queryKey: ['items'] }),
36
+ });
37
+ ```
38
+
39
+ ## Client UI state and SSR isolation
40
+
41
+ - **React**: **Zustand v5** (select narrow slices with `useShallow` or primitive selectors), **Jotai** (atomic bottom-up derived graphs), **Redux Toolkit** (strict action logs/middleware), **Legend-State** (fine-grained signal-like observable state with optional sync persistence), **TanStack Store** (framework-agnostic minimal reactive store), or MobX/Valtio.
42
+ - **Vue / Nuxt**: **Pinia** (`defineStore('filters', () => { ... })` setup stores) registered per SSR app instance; pair with Nuxt `useState()` for simple request-scoped primitives (`vue-nuxt.md`).
43
+ - **Angular**: **NgRx SignalStore (`@ngrx/signals`)** (`signalStore(withState, withComputed, withMethods)`) for modular signal-first feature state (`angular.md`).
44
+ - **Svelte 5**: rune classes in `.svelte.ts` instantiated in root layout and shared via `setContext`/`getContext` (`svelte.md`).
45
+ - **SSR / Next.js critical rule**: never share a module-level singleton store across concurrent server requests, and never read/write client stores from React Server Components. Instantiate stores per-request via a client Context provider (`createStore` from `zustand/vanilla` initialized inside `useState(() => createAppStore())`).
46
+
47
+ ## Complex workflows (XState v5) and RxJS
48
+
49
+ - Use **XState v5** when a flow has explicit finite states, guards, cancellation, retries, or parallel regions. Use `setup({ types, actors: { ...: fromPromise(...) } }).createMachine(...)` (not v4's two-argument `createMachine`) and read snapshots in React with `useSelector(actorRef, selector)` + `actorRef.send(event)`.
50
+ - Use **RxJS** only when composing complex asynchronous event streams (cancellation via `switchMap`, backpressure, WebSocket multiplexing) where simple promises/effects become race-prone.
51
+
52
+ ## URL-as-State (`nuqs` v2 / typed router params) & network race cancellation
53
+
54
+ - **URL-as-State completeness**: serialize search queries (`?q=`), active filters, sort column/direction (`?sort=created_at:desc`), pagination/cursor, active tab, and shareable inspector/drawer IDs (`?invoice=inv_1042`) into URL query/path so page reload, browser Back/Forward, and shared links reproduce the exact view without trapped memory state.
55
+ - Wrap App Router / SPA roots in the matching `<NuqsAdapter>` and choose `history: 'replace'` (throttled) for high-frequency typing/sliders vs `history: 'push'` for discrete facet, tab, pagination, or drawer navigation steps.
56
+ - **Query cancellation (`AbortController`)**: forward TanStack Query's `signal` (`queryFn: ({ signal }) => fetch(url, { signal })`) or an explicit `AbortController` on rapid search/filter/tenant transitions so a slow 800 ms response for an earlier filter never overwrites a fast 90 ms response for the latest filter.
57
+
58
+ ```tsx
59
+ const [view, setView] = useQueryStates(
60
+ {
61
+ q: parseAsString.withDefault(''),
62
+ sort: parseAsStringLiteral(['newest', 'amount'] as const).withDefault('newest'),
63
+ page: parseAsInteger.withDefault(1),
64
+ drawerId: parseAsString,
65
+ },
66
+ { history: 'replace' }
67
+ );
68
+ ```
69
+
70
+ ## Multi-tab auth & tenant synchronization (`BroadcastChannel` + `storage`)
71
+
72
+ Users routinely keep 5–10 SaaS tabs open. If Tab B signs out, refreshes tokens, or switches active workspace/organization (`org_acme` → `org_globex`), background Tab A must react immediately—otherwise Tab A will display stale UI or fire mutations into the wrong tenant:
73
+
74
+ - Scope every server-cache key by tenant (`['org', activeOrgId, 'projects', filters]`) rather than global `['projects']`.
75
+ - Broadcast `SIGN_OUT`, `SESSION_REFRESHED`, and `ORG_CHANGED` over `BroadcastChannel` (with `window.addEventListener('storage', ...)` fallback where needed) so sibling tabs clear/re-scope caches immediately or prompt before overwriting unsaved drafts:
76
+
77
+ ```ts
78
+ type AuthSyncMessage =
79
+ | { type: 'SIGN_OUT' }
80
+ | { type: 'ORG_CHANGED'; orgId: string };
81
+
82
+ export function connectMultiTabSync(onEvent: (msg: AuthSyncMessage) => void) {
83
+ if (typeof BroadcastChannel === 'undefined') return () => {};
84
+ const channel = new BroadcastChannel('app:auth-tenant-sync');
85
+ channel.onmessage = (e: MessageEvent<AuthSyncMessage>) => onEvent(e.data);
86
+ return {
87
+ post: (msg: AuthSyncMessage) => channel.postMessage(msg),
88
+ close: () => channel.close(),
89
+ };
90
+ }
91
+ ```
92
+
93
+ ## Local persistence (Dexie / `idb` / `idb-keyval`)
94
+
95
+ - Use **IndexedDB** via **Dexie.js** (`useLiveQuery` in React) for structured queryable offline datasets and multi-megabyte caches, or **`idb` / `idb-keyval`** for lightweight typed Promise key-value storage (avoid unmaintained `localForage`). Reserve `localStorage` for tiny non-sensitive preferences (`< 50 KB`) and never store auth secrets there.
96
+ - In Dexie `.stores()`, declare **only indexed columns** (non-indexed fields are still stored automatically). **Never modify a shipped `db.version(N)` block that has an `.upgrade(tx => ...)` callback**—always append `db.version(N + 1)` for schema migrations.
97
+
98
+ ## Do/don't pairs
99
+
100
+ | Do | Don't |
101
+ |---|---|
102
+ | Keep API entities in TanStack Query / tRPC v11 / oRPC / Apollo (keyed by `orgId` + `signal`) and UI toggles in Zustand / Pinia / SignalStore | Mirror fetched server data into a global store or omit `AbortSignal` on rapid filter fetches |
103
+ | Instantiate Zustand / Svelte rune / Pinia stores per request in SSR frameworks | Export a global singleton store mutated during SSR requests |
104
+ | Propagate sign-out and workspace/tenant switches across tabs via `BroadcastChannel` | Let background tabs stay logged in after sign-out or write mutations to a stale tenant |
105
+ | Use XState v5 `setup().createMachine()` + `useSelector` for multi-step retry/cancel flows | Stack 6 booleans (`loading`, `retrying`, `failed`, `cancelled`) that allow invalid states |
106
+ | Serialize search, filters, sort, pagination, tabs, and shareable drawer IDs in the URL (`useQueryStates`) | Store filter/drawer state only in memory or serialize sensitive tokens into `window.location.search` |
107
+ | Use Dexie (append `db.version(N + 1)` for migrations) or `idb`/`idb-keyval` for offline storage | Add unmaintained `localForage`, edit shipped Dexie `.version(N)` upgrades, or stuff MBs into `localStorage` |