@bovinphang/frontend-craft 2.6.0 → 2.8.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 (414) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +72 -1
  4. package/CHANGELOG.zh-CN.md +71 -1
  5. package/README.md +10 -6
  6. package/README.openclaw.md +100 -42
  7. package/README.openclaw.zh-CN.md +100 -42
  8. package/README.zh-CN.md +10 -6
  9. package/agents/fec-architect.md +70 -70
  10. package/agents/fec-code-reviewer.md +82 -82
  11. package/agents/fec-debugger.md +20 -20
  12. package/agents/fec-design-token-mapper.md +36 -36
  13. package/agents/fec-doc-updater.md +13 -13
  14. package/agents/fec-e2e-runner.md +45 -45
  15. package/agents/fec-figma-implementer.md +59 -59
  16. package/agents/fec-performance-optimizer.md +128 -128
  17. package/agents/fec-refactor-cleaner.md +14 -14
  18. package/agents/fec-security-reviewer.md +66 -67
  19. package/agents/fec-test-planner.md +27 -27
  20. package/agents/fec-typescript-reviewer.md +88 -88
  21. package/agents/fec-ui-checker.md +74 -74
  22. package/commands/fec-debug.md +19 -19
  23. package/commands/fec-doc-sync.md +11 -11
  24. package/commands/fec-init.md +37 -38
  25. package/commands/fec-plan.md +58 -58
  26. package/commands/fec-refactor-clean.md +11 -11
  27. package/commands/fec-review.md +41 -41
  28. package/commands/fec-scaffold.md +41 -41
  29. package/commands/fec-tdd.md +13 -13
  30. package/dist/bin/frontend-craft.js +29 -27
  31. package/docs/example-prompts.md +84 -69
  32. package/docs/ja-JP/README.md +56 -52
  33. package/docs/ko-KR/README.md +45 -41
  34. package/docs/project-structure.md +19 -7
  35. package/docs/superpowers/plans/2026-05-29-fec-debug.md +491 -0
  36. package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +340 -0
  37. package/docs/zh-CN/example-prompts.md +84 -69
  38. package/docs/zh-CN/project-structure.md +14 -5
  39. package/docs/zh-TW/README.md +33 -29
  40. package/localized/zh-CN/agents/fec-architect.md +125 -0
  41. package/localized/zh-CN/agents/fec-code-reviewer.md +152 -0
  42. package/localized/zh-CN/agents/fec-debugger.md +44 -0
  43. package/localized/zh-CN/agents/fec-design-token-mapper.md +75 -0
  44. package/localized/zh-CN/agents/fec-doc-updater.md +30 -0
  45. package/localized/zh-CN/agents/fec-e2e-runner.md +107 -0
  46. package/localized/zh-CN/agents/fec-figma-implementer.md +104 -0
  47. package/localized/zh-CN/agents/fec-performance-optimizer.md +293 -0
  48. package/localized/zh-CN/agents/fec-refactor-cleaner.md +32 -0
  49. package/localized/zh-CN/agents/fec-security-reviewer.md +116 -0
  50. package/localized/zh-CN/agents/fec-test-planner.md +50 -0
  51. package/localized/zh-CN/agents/fec-typescript-reviewer.md +142 -0
  52. package/localized/zh-CN/agents/fec-ui-checker.md +120 -0
  53. package/localized/zh-CN/commands/fec-debug.md +30 -0
  54. package/localized/zh-CN/commands/fec-doc-sync.md +19 -0
  55. package/localized/zh-CN/commands/fec-init.md +70 -0
  56. package/localized/zh-CN/commands/fec-plan.md +94 -0
  57. package/localized/zh-CN/commands/fec-refactor-clean.md +19 -0
  58. package/localized/zh-CN/commands/fec-review.md +66 -0
  59. package/localized/zh-CN/commands/fec-scaffold.md +205 -0
  60. package/localized/zh-CN/commands/fec-tdd.md +21 -0
  61. package/localized/zh-CN/skills/TEMPLATE.md +155 -0
  62. package/localized/zh-CN/skills/eval_queries.json +1013 -0
  63. package/localized/zh-CN/skills/fec-accessibility-check/SKILL.md +39 -0
  64. package/localized/zh-CN/skills/fec-accessibility-check/references/report-template.md +23 -0
  65. package/localized/zh-CN/skills/fec-accessibility-check/references/screen-reader-testing.md +33 -0
  66. package/localized/zh-CN/skills/fec-alchemy/SKILL.md +74 -0
  67. package/localized/zh-CN/skills/fec-alchemy/assets/absorption-plan-template.md +47 -0
  68. package/localized/zh-CN/skills/fec-alchemy/assets/intake-template.md +55 -0
  69. package/localized/zh-CN/skills/fec-alchemy/assets/review-checklist.md +31 -0
  70. package/localized/zh-CN/skills/fec-alchemy/references/methodology.md +94 -0
  71. package/localized/zh-CN/skills/fec-alchemy/references/originality-and-licensing.md +57 -0
  72. package/localized/zh-CN/skills/fec-api-integration/SKILL.md +78 -0
  73. package/localized/zh-CN/skills/fec-api-integration/references/integration-patterns.md +80 -0
  74. package/localized/zh-CN/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
  75. package/localized/zh-CN/skills/fec-browser-storage/SKILL.md +34 -0
  76. package/localized/zh-CN/skills/fec-browser-storage/references/storage-patterns.md +65 -0
  77. package/localized/zh-CN/skills/fec-canvas-threejs/SKILL.md +66 -0
  78. package/localized/zh-CN/skills/fec-canvas-threejs/references/rendering-patterns.md +67 -0
  79. package/localized/zh-CN/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +67 -0
  80. package/localized/zh-CN/skills/fec-code-review/SKILL.md +143 -0
  81. package/localized/zh-CN/skills/fec-code-review/references/report-template.md +29 -0
  82. package/localized/zh-CN/skills/fec-component-testing/SKILL.md +119 -0
  83. package/localized/zh-CN/skills/fec-data-fetching/SKILL.md +62 -0
  84. package/localized/zh-CN/skills/fec-data-fetching/references/query-patterns.md +103 -0
  85. package/localized/zh-CN/skills/fec-debug-framework/SKILL.md +157 -0
  86. package/localized/zh-CN/skills/fec-debug-framework/references/report-template.md +58 -0
  87. package/localized/zh-CN/skills/fec-dependency-upgrade/SKILL.md +34 -0
  88. package/localized/zh-CN/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +56 -0
  89. package/localized/zh-CN/skills/fec-doc-sync/SKILL.md +39 -0
  90. package/localized/zh-CN/skills/fec-drawio-studio/SKILL.md +73 -0
  91. package/localized/zh-CN/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  92. package/localized/zh-CN/skills/fec-drawio-studio/data/brand-icons.json +878 -0
  93. package/localized/zh-CN/skills/fec-drawio-studio/data/shape-index.json +83570 -0
  94. package/localized/zh-CN/skills/fec-drawio-studio/references/data-residency.md +27 -0
  95. package/localized/zh-CN/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
  96. package/localized/zh-CN/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
  97. package/localized/zh-CN/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
  98. package/localized/zh-CN/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
  99. package/localized/zh-CN/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
  100. package/localized/zh-CN/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
  101. package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
  102. package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
  103. package/localized/zh-CN/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
  104. package/localized/zh-CN/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
  105. package/localized/zh-CN/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  106. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  107. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  108. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  109. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  110. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  111. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  112. package/localized/zh-CN/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
  113. package/localized/zh-CN/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
  114. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
  115. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
  116. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
  117. package/localized/zh-CN/skills/fec-drawio-studio/styles/schema.json +112 -0
  118. package/localized/zh-CN/skills/fec-e2e-testing/SKILL.md +42 -0
  119. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
  120. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
  121. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
  122. package/localized/zh-CN/skills/fec-e2e-testing/references/playwright-patterns.md +95 -0
  123. package/localized/zh-CN/skills/fec-form-handling/SKILL.md +76 -0
  124. package/localized/zh-CN/skills/fec-form-handling/references/advanced-form-patterns.md +101 -0
  125. package/localized/zh-CN/skills/fec-image-generation/SKILL.md +80 -0
  126. package/localized/zh-CN/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
  127. package/localized/zh-CN/skills/fec-image-generation/references/artifact-routing.md +80 -0
  128. package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +74 -0
  129. package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
  130. package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
  131. package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
  132. package/localized/zh-CN/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
  133. package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
  134. package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
  135. package/localized/zh-CN/skills/fec-implement-from-design/SKILL.md +129 -0
  136. package/localized/zh-CN/skills/fec-implement-from-design/references/design-plan-template.md +36 -0
  137. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/SKILL.md +46 -0
  138. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
  139. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +41 -0
  140. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
  141. package/localized/zh-CN/skills/fec-legacy-web-standard/SKILL.md +35 -0
  142. package/localized/zh-CN/skills/fec-legacy-web-standard/references/legacy-patterns.md +85 -0
  143. package/localized/zh-CN/skills/fec-list-virtualization/SKILL.md +34 -0
  144. package/localized/zh-CN/skills/fec-list-virtualization/references/virtualization-patterns.md +80 -0
  145. package/localized/zh-CN/skills/fec-monorepo-project-standard/SKILL.md +142 -0
  146. package/localized/zh-CN/skills/fec-motion-interaction/SKILL.md +73 -0
  147. package/localized/zh-CN/skills/fec-motion-interaction/references/motion-patterns.md +112 -0
  148. package/localized/zh-CN/skills/fec-nextjs-project-standard/SKILL.md +123 -0
  149. package/localized/zh-CN/skills/fec-nuxt-project-standard/SKILL.md +122 -0
  150. package/localized/zh-CN/skills/fec-performance-optimization/SKILL.md +80 -0
  151. package/localized/zh-CN/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
  152. package/localized/zh-CN/skills/fec-performance-optimization/references/report-template.md +59 -0
  153. package/localized/zh-CN/skills/fec-pwa-implementation/SKILL.md +35 -0
  154. package/localized/zh-CN/skills/fec-pwa-implementation/references/manifest-and-icons.md +53 -0
  155. package/localized/zh-CN/skills/fec-pwa-implementation/references/service-worker-workbox.md +68 -0
  156. package/localized/zh-CN/skills/fec-react-project-standard/SKILL.md +91 -0
  157. package/localized/zh-CN/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
  158. package/localized/zh-CN/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
  159. package/localized/zh-CN/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
  160. package/localized/zh-CN/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
  161. package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +51 -0
  162. package/localized/zh-CN/skills/fec-refactor-clean/references/report-template.md +42 -0
  163. package/localized/zh-CN/skills/fec-responsive-layout/SKILL.md +34 -0
  164. package/localized/zh-CN/skills/fec-responsive-layout/references/responsive-layout-patterns.md +70 -0
  165. package/localized/zh-CN/skills/fec-route-protection/SKILL.md +135 -0
  166. package/localized/zh-CN/skills/fec-security-review/SKILL.md +38 -0
  167. package/localized/zh-CN/skills/fec-security-review/references/report-template.md +27 -0
  168. package/localized/zh-CN/skills/fec-security-review/references/security-checklist.md +64 -0
  169. package/localized/zh-CN/skills/fec-source-driven-development/SKILL.md +87 -0
  170. package/localized/zh-CN/skills/fec-state-management/SKILL.md +140 -0
  171. package/localized/zh-CN/skills/fec-state-management/references/state-patterns.md +109 -0
  172. package/localized/zh-CN/skills/fec-storybook-component-doc/SKILL.md +37 -0
  173. package/localized/zh-CN/skills/fec-storybook-component-doc/references/story-patterns.md +118 -0
  174. package/localized/zh-CN/skills/fec-svg-animation/SKILL.md +148 -0
  175. package/localized/zh-CN/skills/fec-tailwind-design-system/SKILL.md +34 -0
  176. package/localized/zh-CN/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +59 -0
  177. package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +52 -0
  178. package/localized/zh-CN/skills/fec-testing-strategy/SKILL.md +45 -0
  179. package/localized/zh-CN/skills/fec-typescript-project-standard/SKILL.md +54 -0
  180. package/{skills/fec-typescript-type-safety → localized/zh-CN/skills/fec-typescript-project-standard}/references/type-safety-patterns.md +1 -1
  181. package/{skills/fec-typescript-type-safety/SKILL.md → localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety.md} +5 -14
  182. package/localized/zh-CN/skills/fec-ui-design/SKILL.md +108 -0
  183. package/localized/zh-CN/skills/fec-ui-design/data/product-rules.json +231 -0
  184. package/localized/zh-CN/skills/fec-ui-design/data/stack-ui-rules.json +146 -0
  185. package/localized/zh-CN/skills/fec-ui-design/data/style-archetypes.json +373 -0
  186. package/localized/zh-CN/skills/fec-ui-design/data/ux-quality-rules.json +203 -0
  187. package/localized/zh-CN/skills/fec-ui-design/references/design-intelligence.md +97 -0
  188. package/localized/zh-CN/skills/fec-ui-design/references/master-page-overrides.md +30 -0
  189. package/localized/zh-CN/skills/fec-ui-design/references/pre-delivery-checklist.md +39 -0
  190. package/localized/zh-CN/skills/fec-ui-design/scripts/design-system.mjs +648 -0
  191. package/localized/zh-CN/skills/fec-validation-fix/SKILL.md +51 -0
  192. package/localized/zh-CN/skills/fec-validation-fix/references/report-template.md +43 -0
  193. package/localized/zh-CN/skills/fec-vite-project-standard/SKILL.md +83 -0
  194. package/localized/zh-CN/skills/fec-vue3-project-standard/SKILL.md +58 -0
  195. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +162 -0
  196. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
  197. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-project-structure.md +176 -0
  198. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
  199. package/localized/zh-CN/skills/fec-web-video-presentation/SKILL.md +61 -0
  200. package/localized/zh-CN/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
  201. package/localized/zh-CN/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
  202. package/localized/zh-CN/skills/fec-web-video-presentation/references/content-plan.md +38 -0
  203. package/localized/zh-CN/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
  204. package/localized/zh-CN/skills/fec-web-video-presentation/references/theme-system.md +36 -0
  205. package/localized/zh-CN/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
  206. package/localized/zh-CN/skills/fec-web-workers/SKILL.md +35 -0
  207. package/localized/zh-CN/skills/fec-web-workers/references/advanced-workers.md +54 -0
  208. package/localized/zh-CN/skills/fec-web-workers/references/basic-worker.md +67 -0
  209. package/localized/zh-CN/skills/metadata.json +1646 -0
  210. package/localized/zh-CN/skills/relations.json +755 -0
  211. package/localized/zh-CN/templates/claude/CLAUDE.md +106 -0
  212. package/localized/zh-CN/templates/claude/settings.json +62 -0
  213. package/localized/zh-CN/templates/codex/AGENTS.md +105 -0
  214. package/localized/zh-CN/templates/codex/config.toml +32 -0
  215. package/localized/zh-CN/templates/openclaw/AGENTS.md +101 -0
  216. package/localized/zh-CN/templates/openclaw/OPENCLAW-CONFIG.md +12 -0
  217. package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +54 -0
  218. package/localized/zh-CN/templates/shared/rules/fec-api-layer.md +99 -0
  219. package/localized/zh-CN/templates/shared/rules/fec-ci-cd.md +40 -0
  220. package/localized/zh-CN/templates/shared/rules/fec-code-comments.md +33 -0
  221. package/localized/zh-CN/templates/shared/rules/fec-design-system.md +72 -0
  222. package/localized/zh-CN/templates/shared/rules/fec-error-handling.md +56 -0
  223. package/localized/zh-CN/templates/shared/rules/fec-git-conventions.md +73 -0
  224. package/localized/zh-CN/templates/shared/rules/fec-i18n.md +64 -0
  225. package/localized/zh-CN/templates/shared/rules/fec-naming-conventions.md +120 -0
  226. package/localized/zh-CN/templates/shared/rules/fec-performance.md +101 -0
  227. package/localized/zh-CN/templates/shared/rules/fec-react.md +82 -0
  228. package/localized/zh-CN/templates/shared/rules/fec-refactoring.md +47 -0
  229. package/localized/zh-CN/templates/shared/rules/fec-rendering-patterns.md +40 -0
  230. package/localized/zh-CN/templates/shared/rules/fec-responsive-design.md +50 -0
  231. package/localized/zh-CN/templates/shared/rules/fec-source-driven-development.md +31 -0
  232. package/localized/zh-CN/templates/shared/rules/fec-state-management.md +60 -0
  233. package/localized/zh-CN/templates/shared/rules/fec-testing.md +98 -0
  234. package/localized/zh-CN/templates/shared/rules/fec-typescript.md +112 -0
  235. package/localized/zh-CN/templates/shared/rules/fec-vue.md +64 -0
  236. package/localized/zh-CN/templates/shared/rules/fec-working-modes.md +50 -0
  237. package/openclaw.plugin.json +1 -1
  238. package/package.json +4 -3
  239. package/skills/TEMPLATE.md +74 -74
  240. package/skills/eval_queries.json +717 -619
  241. package/skills/fec-accessibility-check/SKILL.md +21 -21
  242. package/skills/fec-accessibility-check/references/report-template.md +12 -12
  243. package/skills/fec-accessibility-check/references/screen-reader-testing.md +24 -24
  244. package/skills/fec-alchemy/SKILL.md +50 -50
  245. package/skills/fec-alchemy/assets/absorption-plan-template.md +32 -32
  246. package/skills/fec-alchemy/assets/intake-template.md +55 -55
  247. package/skills/fec-alchemy/assets/review-checklist.md +23 -23
  248. package/skills/fec-alchemy/references/methodology.md +66 -66
  249. package/skills/fec-alchemy/references/originality-and-licensing.md +42 -42
  250. package/skills/fec-api-integration/SKILL.md +61 -61
  251. package/skills/fec-api-integration/references/integration-patterns.md +30 -30
  252. package/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
  253. package/skills/fec-browser-storage/SKILL.md +16 -16
  254. package/skills/fec-browser-storage/references/storage-patterns.md +16 -16
  255. package/skills/fec-canvas-threejs/SKILL.md +21 -21
  256. package/skills/fec-canvas-threejs/references/rendering-patterns.md +10 -10
  257. package/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +37 -37
  258. package/skills/fec-code-review/SKILL.md +94 -94
  259. package/skills/fec-code-review/references/report-template.md +13 -13
  260. package/skills/fec-component-testing/SKILL.md +39 -39
  261. package/skills/fec-data-fetching/SKILL.md +16 -16
  262. package/skills/fec-data-fetching/references/query-patterns.md +27 -27
  263. package/skills/fec-debug-framework/SKILL.md +95 -95
  264. package/skills/fec-debug-framework/references/report-template.md +34 -34
  265. package/skills/fec-dependency-upgrade/SKILL.md +17 -17
  266. package/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +31 -31
  267. package/skills/fec-doc-sync/SKILL.md +23 -23
  268. package/skills/fec-drawio-studio/SKILL.md +73 -0
  269. package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  270. package/skills/fec-drawio-studio/data/brand-icons.json +878 -0
  271. package/skills/fec-drawio-studio/data/shape-index.json +83570 -0
  272. package/skills/fec-drawio-studio/references/data-residency.md +27 -0
  273. package/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
  274. package/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
  275. package/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
  276. package/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
  277. package/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
  278. package/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
  279. package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
  280. package/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
  281. package/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
  282. package/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
  283. package/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  284. package/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  285. package/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  286. package/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  287. package/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  288. package/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  289. package/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  290. package/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
  291. package/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
  292. package/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
  293. package/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
  294. package/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
  295. package/skills/fec-drawio-studio/styles/schema.json +112 -0
  296. package/skills/fec-e2e-testing/SKILL.md +24 -22
  297. package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
  298. package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
  299. package/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
  300. package/skills/fec-e2e-testing/references/playwright-patterns.md +6 -6
  301. package/skills/fec-form-handling/SKILL.md +21 -21
  302. package/skills/fec-form-handling/references/advanced-form-patterns.md +41 -41
  303. package/skills/fec-image-generation/SKILL.md +81 -0
  304. package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
  305. package/skills/fec-image-generation/references/artifact-routing.md +80 -0
  306. package/skills/fec-image-generation/references/diagram-workflows.md +74 -0
  307. package/skills/fec-image-generation/references/html-technical-diagrams.md +236 -0
  308. package/skills/fec-image-generation/references/png-qa-autofix.md +30 -0
  309. package/skills/fec-image-generation/scripts/export-diagram.mjs +364 -0
  310. package/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
  311. package/skills/fec-image-generation/scripts/png-qa.mjs +431 -0
  312. package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1397 -0
  313. package/skills/fec-implement-from-design/SKILL.md +81 -74
  314. package/skills/fec-implement-from-design/references/design-plan-template.md +16 -16
  315. package/skills/fec-legacy-to-modern-migration/SKILL.md +29 -173
  316. package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
  317. package/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +37 -37
  318. package/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
  319. package/skills/fec-legacy-web-standard/SKILL.md +17 -17
  320. package/skills/fec-legacy-web-standard/references/legacy-patterns.md +16 -16
  321. package/skills/fec-list-virtualization/SKILL.md +16 -16
  322. package/skills/fec-list-virtualization/references/virtualization-patterns.md +31 -31
  323. package/skills/fec-monorepo-project-standard/SKILL.md +52 -52
  324. package/skills/fec-motion-interaction/SKILL.md +51 -44
  325. package/skills/fec-motion-interaction/references/motion-patterns.md +11 -11
  326. package/skills/fec-nextjs-project-standard/SKILL.md +64 -58
  327. package/skills/fec-nuxt-project-standard/SKILL.md +57 -57
  328. package/skills/fec-performance-optimization/SKILL.md +54 -50
  329. package/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
  330. package/skills/fec-performance-optimization/references/report-template.md +34 -28
  331. package/skills/fec-pwa-implementation/SKILL.md +17 -17
  332. package/skills/fec-pwa-implementation/references/manifest-and-icons.md +12 -12
  333. package/skills/fec-pwa-implementation/references/service-worker-workbox.md +13 -13
  334. package/skills/fec-react-project-standard/SKILL.md +72 -64
  335. package/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
  336. package/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
  337. package/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
  338. package/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
  339. package/skills/fec-refactor-clean/SKILL.md +30 -30
  340. package/skills/fec-refactor-clean/references/report-template.md +23 -23
  341. package/skills/fec-responsive-layout/SKILL.md +17 -17
  342. package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +39 -28
  343. package/skills/fec-route-protection/SKILL.md +26 -26
  344. package/skills/fec-security-review/SKILL.md +20 -20
  345. package/skills/fec-security-review/references/report-template.md +12 -12
  346. package/skills/fec-security-review/references/security-checklist.md +27 -27
  347. package/skills/fec-source-driven-development/SKILL.md +66 -40
  348. package/skills/fec-state-management/SKILL.md +34 -34
  349. package/skills/fec-state-management/references/state-patterns.md +19 -19
  350. package/skills/fec-storybook-component-doc/SKILL.md +19 -19
  351. package/skills/fec-storybook-component-doc/references/story-patterns.md +12 -12
  352. package/skills/fec-svg-animation/SKILL.md +32 -32
  353. package/skills/fec-tailwind-design-system/SKILL.md +17 -17
  354. package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +36 -32
  355. package/skills/fec-tdd-workflow/SKILL.md +28 -28
  356. package/skills/fec-testing-strategy/SKILL.md +29 -29
  357. package/skills/fec-typescript-project-standard/SKILL.md +54 -0
  358. package/skills/fec-typescript-project-standard/references/type-safety-patterns.md +102 -0
  359. package/skills/fec-typescript-project-standard/references/type-safety.md +148 -0
  360. package/skills/fec-ui-design/SKILL.md +90 -72
  361. package/skills/fec-ui-design/data/style-archetypes.json +40 -0
  362. package/skills/fec-ui-design/data/ux-quality-rules.json +35 -0
  363. package/skills/fec-ui-design/references/design-intelligence.md +81 -21
  364. package/skills/fec-ui-design/references/master-page-overrides.md +15 -15
  365. package/skills/fec-ui-design/references/pre-delivery-checklist.md +38 -32
  366. package/skills/fec-ui-design/scripts/design-system.mjs +119 -1
  367. package/skills/fec-validation-fix/SKILL.md +26 -26
  368. package/skills/fec-validation-fix/references/report-template.md +25 -25
  369. package/skills/fec-vite-project-standard/SKILL.md +39 -39
  370. package/skills/fec-vue3-project-standard/SKILL.md +39 -30
  371. package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +163 -0
  372. package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
  373. package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +177 -0
  374. package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
  375. package/skills/fec-web-video-presentation/SKILL.md +61 -0
  376. package/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
  377. package/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
  378. package/skills/fec-web-video-presentation/references/content-plan.md +38 -0
  379. package/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
  380. package/skills/fec-web-video-presentation/references/theme-system.md +36 -0
  381. package/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
  382. package/skills/fec-web-workers/SKILL.md +16 -16
  383. package/skills/fec-web-workers/references/advanced-workers.md +13 -13
  384. package/skills/fec-web-workers/references/basic-worker.md +8 -8
  385. package/skills/metadata.json +402 -220
  386. package/skills/relations.json +120 -25
  387. package/templates/claude/CLAUDE.md +60 -60
  388. package/templates/codex/AGENTS.md +76 -76
  389. package/templates/codex/config.toml +4 -4
  390. package/templates/openclaw/AGENTS.md +68 -68
  391. package/templates/openclaw/OPENCLAW-CONFIG.md +8 -8
  392. package/templates/shared/rules/fec-agent-workflow.md +40 -40
  393. package/templates/shared/rules/fec-api-layer.md +52 -52
  394. package/templates/shared/rules/fec-ci-cd.md +29 -117
  395. package/templates/shared/rules/fec-code-comments.md +22 -22
  396. package/templates/shared/rules/fec-design-system.md +65 -241
  397. package/templates/shared/rules/fec-error-handling.md +41 -185
  398. package/templates/shared/rules/fec-git-conventions.md +42 -42
  399. package/templates/shared/rules/fec-i18n.md +48 -96
  400. package/templates/shared/rules/fec-naming-conventions.md +91 -91
  401. package/templates/shared/rules/fec-performance.md +78 -78
  402. package/templates/shared/rules/fec-react.md +58 -58
  403. package/templates/shared/rules/fec-refactoring.md +34 -30
  404. package/templates/shared/rules/fec-rendering-patterns.md +40 -183
  405. package/templates/shared/rules/fec-responsive-design.md +37 -214
  406. package/templates/shared/rules/fec-source-driven-development.md +22 -22
  407. package/templates/shared/rules/fec-state-management.md +45 -148
  408. package/templates/shared/rules/fec-testing.md +64 -64
  409. package/templates/shared/rules/fec-typescript.md +98 -341
  410. package/templates/shared/rules/fec-vue.md +42 -42
  411. package/templates/shared/rules/fec-working-modes.md +34 -34
  412. package/skills/fec-e2e-testing/references/e2e-advanced.md +0 -176
  413. package/skills/fec-react-project-standard/references/react-project-details.md +0 -642
  414. package/skills/fec-vue3-project-standard/references/vue3-project-details.md +0 -547
@@ -1,642 +0,0 @@
1
- # React 项目规范详解
2
-
3
- ## 项目结构(推荐参考)
4
-
5
- 以下为中大型 React 项目的业界最佳实践结构,按项目实际情况裁剪:
6
-
7
- ```text
8
- src/
9
- ├── app/ # 应用入口与全局配置
10
- │ ├── App.tsx # 根组件(Provider 组合)
11
- │ ├── routes.tsx # 路由配置
12
- │ └── providers.tsx # 全局 Provider 组装
13
- │
14
- ├── pages/ # 页面组件(与路由一一对应)
15
- │ ├── Dashboard/
16
- │ │ ├── DashboardPage.tsx
17
- │ │ ├── components/ # 页面私有组件
18
- │ │ └── hooks/ # 页面私有 hooks
19
- │ ├── UserList/
20
- │ └── Settings/
21
- │
22
- ├── layouts/ # 布局组件
23
- │ ├── MainLayout.tsx # 主布局(侧边栏 + 顶栏 + 内容区)
24
- │ ├── AuthLayout.tsx # 登录/注册页布局
25
- │ └── BlankLayout.tsx # 空白布局(错误页等)
26
- │
27
- ├── features/ # 功能模块(按业务领域划分)
28
- │ ├── auth/
29
- │ │ ├── components/ # 模块组件
30
- │ │ ├── hooks/ # 模块 hooks
31
- │ │ ├── api.ts # 模块 API 调用
32
- │ │ ├── types.ts # 模块类型定义
33
- │ │ ├── constants.ts # 模块常量
34
- │ │ └── index.ts # 模块公开导出
35
- │ └── order/
36
- │
37
- ├── components/ # 全局共享 UI 组件
38
- │ ├── Button/
39
- │ │ ├── Button.tsx
40
- │ │ ├── Button.styles.css
41
- │ │ └── __tests__/
42
- │ ├── Modal/
43
- │ ├── Form/
44
- │ └── ErrorBoundary/ # 对 react-error-boundary 等的薄封装(函数组件)
45
- │
46
- ├── hooks/ # 全局共享 hooks
47
- │ ├── useAuth.ts
48
- │ ├── useDebounce.ts
49
- │ └── useMediaQuery.ts
50
- │
51
- ├── services/ # API 基础层
52
- │ ├── request.ts # Axios/fetch 实例与拦截器
53
- │ └── endpoints/ # API 端点定义(如按领域拆分)
54
- │
55
- ├── stores/ # 全局状态管理
56
- │ ├── authStore.ts
57
- │ └── uiStore.ts
58
- │
59
- ├── locales/ # 国际化语言包
60
- │ ├── zh-CN.json # 中文
61
- │ ├── en-US.json # 英文
62
- │ └── index.ts # i18n 实例初始化(i18next / react-intl)
63
- │
64
- ├── assets/ # 静态资源
65
- │ ├── images/ # 图片(PNG、JPG、WebP)
66
- │ ├── icons/ # SVG 图标
67
- │ └── fonts/ # 自定义字体
68
- │
69
- ├── config/ # 应用配置
70
- │ ├── env.ts # 环境变量类型化封装
71
- │ └── features.ts # Feature Flags 管理
72
- │
73
- ├── types/ # 全局共享类型
74
- │ ├── api.ts # API 响应/请求通用类型
75
- │ ├── models.ts # 业务实体类型
76
- │ └── global.d.ts # 全局类型扩展(图片模块声明等)
77
- │
78
- ├── utils/ # 纯工具函数
79
- │ ├── format.ts # 日期、数字、货币格式化
80
- │ ├── validators.ts # 表单校验规则
81
- │ └── storage.ts # LocalStorage / SessionStorage 封装
82
- │
83
- ├── styles/ # 全局样式与主题
84
- │ ├── global.css # 全局基础样式(reset / normalize)
85
- │ ├── variables.css # CSS 变量(颜色、间距、字号)
86
- │ ├── breakpoints.ts # 响应式断点常量
87
- │ └── themes/ # 主题定义
88
- │ ├── light.css # 亮色主题变量
89
- │ ├── dark.css # 暗色主题变量
90
- │ └── index.ts # 主题切换逻辑
91
- │
92
- └── constants/ # 全局常量
93
- ├── routes.ts # 路由路径常量
94
- └── config.ts # 业务常量(分页大小、超时时间等)
95
- ```
96
-
97
- ### 关键原则
98
-
99
- - `pages/` 做路由映射和页面编排,不承载大块可复用业务逻辑
100
- - `layouts/` 负责页面骨架和布局容器,由路由配置引用
101
- - `features/` 按业务领域划分,模块内尽量自包含
102
- - `components/` 仅放跨页面、跨模块复用的通用组件
103
- - `hooks/` 仅放全局通用 hooks;业务 hooks 优先放回对应 feature 或 page
104
- - `locales/` 存放语言包 JSON 文件,组件中使用 `t('key')` 而非硬编码文案
105
- - `assets/` 存放静态资源,图标优先使用 SVG,图片优先使用 WebP/AVIF
106
- - `services/` 负责请求基础设施,不堆叠业务细节
107
- - `config/` 统一封装环境变量和特性开关,禁止组件中直接读取 `import.meta.env`
108
- - `styles/` 和主题变量统一管理,避免颜色和尺寸散落在业务代码中
109
- - 每个模块通过 `index.ts` 管控对外公开 API,避免深层路径导入
110
-
111
- ---
112
-
113
- ## 组件与模块分层
114
-
115
- 推荐分层:
116
-
117
- ```text
118
- 页面组件 (Pages) → 路由映射、布局组合、页面编排
119
- └── 容器/编排层 → 数据获取、状态组织、事件编排
120
- └── 业务组件 → 领域逻辑展示
121
- └── 通用组件 → 无业务耦合、可跨模块复用
122
- ```
123
-
124
- ### 什么时候放到 `pages/`
125
-
126
- 适合放:
127
-
128
- - 路由入口组件
129
- - 页面级布局组合
130
- - 页面私有的轻量编排逻辑
131
-
132
- 不适合放:
133
-
134
- - 大量领域逻辑
135
- - 可复用于多个页面的复杂业务块
136
- - 与某个业务域强绑定的 API / hooks / types
137
-
138
- ### 什么时候放到 `features/`
139
-
140
- 适合放:
141
-
142
- - 某个业务域的组件、hooks、api、types
143
- - 可被多个页面共享但带业务语义的逻辑
144
- - 一个完整业务单元的自包含实现
145
-
146
- ### 什么时候放到 `components/`
147
-
148
- 适合放:
149
-
150
- - 按钮、弹窗、表单项、表格壳子、空态、错误态等通用 UI
151
- - 与具体业务无关、可跨模块复用的组件
152
-
153
- ---
154
-
155
- ## 组件设计规范
156
-
157
- - 使用**函数组件**、Hooks 与 TypeScript;**不要**新增类组件(Error Boundary 用 `react-error-boundary` 等库,见下文)
158
- - **单文件规模**与拆分原则见 `templates/shared/rules/fec-react.md`「**组件文件规模**」(约 300 行内为佳,逾 500 行或复杂度过高拆子组件、Hooks、utils、类型)
159
- - 保持组件职责单一、可组合
160
- - 将可复用逻辑提取到 hooks
161
- - 在合适场景优先使用受控组件 API
162
- - props 定义清晰且类型明确
163
- - 优先复用现有设计系统组件
164
- - 保持可访问性与键盘交互
165
- - 避免过深的 JSX 嵌套和重复分支
166
- - 对可推导的值不要额外存 state
167
-
168
- ---
169
-
170
- ## 常用 UI 与状态模式
171
-
172
- 以下模式可与本 skill 其他章节(Hooks、状态管理、性能优化、错误处理)对照使用;**按业务复杂度与团队熟悉度选用**,避免为模式而模式。思路参考业界常见的 React 前端模式实践(如组件组合、复合组件、性能与无障碍等)。
173
-
174
- ### 组合优于继承
175
-
176
- - 用**小颗粒子组件** + `children` / 显式 props 拼装界面,而不是在 React 中搭建类继承层次。
177
- - 示例:`Card` + `CardHeader` + `CardBody`,由使用方组合,而不是一个巨型 `Card` 用大量布尔 props 分支。
178
-
179
- ### 复合组件(Compound Components)
180
-
181
- - 根组件通过 **Context** 向子组件提供内部状态(如当前 Tab、打开/关闭)。
182
- - 子组件在 `useContext` 为空时**抛错或断言**,明确「必须在 Provider 树内使用」。
183
- - API 表面保持可读:`<Tabs><TabList><Tab /></TabList></Tabs>`。
184
-
185
- ### Render Props / 函数子
186
-
187
- - 适用:封装**数据获取与三态**(loading / error / data),把**渲染决策**交给父级。
188
- - 与 **自定义 Hook** 二选一即可:多数场景 `useXxx()` + 普通组件更直观;仅在需要强约束「同层渲染逻辑」时保留 Render Props。
189
-
190
- ### Context + useReducer
191
-
192
- - 适合**中等复杂度、多子树共享**的客户端状态,且更新可归约为明确 `action`。
193
- - 避免把高频变化的大对象塞进顶层 Context;服务端数据仍优先 **React Query / SWR**。
194
- - 大型全局业务状态继续用仓库已选的 **Zustand / Redux Toolkit / Jotai**。
195
-
196
- ### 表单
197
-
198
- - 受控字段 + 校验错误对象是一类可行实现;中大型表单优先 **React Hook Form**(或 Formik)+ **Zod**(类型与校验与 `templates/shared/rules/fec-typescript.md` 一致)。
199
- - 避免单组件内巨型 `useState` 表单对象与重复校验逻辑,可拆字段子组件或抽 `useFormSchema`。
200
-
201
- ### Error Boundary
202
-
203
- - **不要**在业务代码中手写 React **类组件**形式的 Error Boundary;统一使用 **`react-error-boundary`**(或团队认可的同类库)在**模块边界**兜底渲染失败(与本章「错误处理」、`error-handling.md` 一致)。
204
- - 用 `FallbackComponent` 与 `resetErrorBoundary` 提供「重试」;**日志上报**放在库的 **`onError`**(等回调)中,生产代码避免长期依赖 `console.log`(见 TypeScript 规则)。
205
-
206
- ### 性能(与「性能优化」一节配合)
207
-
208
- - **useMemo**:昂贵派生、大列表排序/过滤;注意不可变数据,例如 `useMemo(() => [...list].sort(...), [list])`,避免直接 `sort` 可变原数组。
209
- - **useCallback**:传给 **`React.memo`** 子组件或作为其他 Hook 依赖的回调,在确有稳定引用需求时使用。
210
- - **React.memo**:纯展示、props 浅比较可接受的组件;不要全局套 memo。
211
- - **虚拟列表**:超长列表用 **TanStack Virtual**、**react-window** 等,只渲染视区内节点(路由级与组件级懒加载仍见「Suspense 与懒加载」)。
212
-
213
- ### 动画与过渡
214
-
215
- - 列表进出场可用 **Framer Motion** 的 `AnimatePresence` + `key`,或 CSS `transition`;注意减少布局抖动与 `prefers-reduced-motion`(与无障碍策略一致时)。
216
-
217
- ### 无障碍与焦点
218
-
219
- - 自定义下拉、标签页等:**`role` / `aria-*`**、**方向键 / Enter / Escape** 行为与焦点环可见。
220
- - 弹窗:打开时将焦点移入对话框,关闭时**恢复**触发元素焦点;可用 **`focus-trap-react`** 或类似方案,与 `fec-accessibility-check` skill 互补。
221
-
222
- ### Next.js 与服务端组件
223
-
224
- - **App Router、Server Components、服务端数据获取与缓存**见 **`fec-nextjs-project-standard`**;客户端交互模式仍以本章与 Hooks 规范为准。
225
-
226
- ---
227
-
228
- ## 组件目录建议
229
-
230
- 当组件复杂度较低时,可只保留一个文件。
231
- 当组件包含样式、子组件、hooks、测试时,推荐使用如下结构:
232
-
233
- ```text
234
- ComponentName/
235
- ├── ComponentName.tsx
236
- ├── ComponentName.types.ts
237
- ├── ComponentName.styles.css
238
- ├── hooks/
239
- │ └── useComponentLogic.ts
240
- ├── components/
241
- │ └── SubComponent.tsx
242
- └── __tests__/
243
- └── ComponentName.spec.tsx
244
- ```
245
-
246
- 说明:
247
-
248
- - 类型复杂时再拆 `ComponentName.types.ts`
249
- - 存在局部逻辑复用时再拆 `hooks/`
250
- - 子组件仅在当前组件内部使用时,放到当前目录 `components/`
251
- - 测试是否就近放置,应遵循仓库现有约定
252
-
253
- ---
254
-
255
- ## Hooks 设计模式
256
-
257
- ### 适合抽为自定义 Hook 的场景
258
-
259
- - 数据获取与三态管理
260
- - 表单状态逻辑
261
- - 分页、筛选、排序编排
262
- - 事件监听与副作用清理
263
- - 可在多个组件复用的交互逻辑
264
-
265
- ### 推荐原则
266
-
267
- - 统一使用 `use` 前缀命名
268
- - 返回对象而非数组,方便按需解构,增强可读性和扩展性
269
- - 状态和行为封装在一起
270
- - Hook 内部处理 `loading / error / data`
271
- - 对外暴露清晰的最小接口,不泄漏无关内部细节
272
-
273
- ### 示例
274
-
275
- ```tsx
276
- function useUserList(params: QueryParams) {
277
- const [data, setData] = useState<User[]>([]);
278
- const [loading, setLoading] = useState(false);
279
- const [error, setError] = useState<Error | null>(null);
280
-
281
- const fetch = useCallback(async () => {
282
- setLoading(true);
283
- setError(null);
284
- try {
285
- const res = await getUserList(params);
286
- setData(res.list);
287
- } catch (e) {
288
- setError(e as Error);
289
- } finally {
290
- setLoading(false);
291
- }
292
- }, [params]);
293
-
294
- useEffect(() => {
295
- fetch();
296
- }, [fetch]);
297
-
298
- return { data, loading, error, refetch: fetch };
299
- }
300
- ```
301
-
302
- ### Hook 使用原则
303
-
304
- - `useEffect` 必须有正确依赖和清理逻辑
305
- - `useMemo` / `useCallback` 不要滥用,只有在稳定引用确实重要时再加
306
- - 不在条件分支或循环中调用 hooks
307
- - 已引入 React Query / SWR 时,数据请求优先走这些库,而不是自己重复造一套缓存层
308
-
309
- ---
310
-
311
- ## 路由组织
312
-
313
- ### 推荐方式
314
-
315
- - 路由配置集中管理
316
- - 路径常量化
317
- - 页面组件按需懒加载
318
- - 权限控制放在 guard 层,而不是散落在页面组件内
319
- - 分页、筛选、排序等 URL 驱动状态优先与地址栏同步
320
-
321
- ### 示例
322
-
323
- ```tsx
324
- const routes: RouteObject[] = [
325
- {
326
- path: "/",
327
- element: <MainLayout />,
328
- children: [
329
- { index: true, element: <DashboardPage /> },
330
- { path: "users", element: <UserListPage /> },
331
- { path: "users/:id", element: <UserDetailPage /> },
332
- { path: "settings", element: <SettingsPage /> },
333
- ],
334
- },
335
- { path: "/login", element: <LoginPage /> },
336
- { path: "*", element: <NotFoundPage /> },
337
- ];
338
- ```
339
-
340
- ```tsx
341
- const UserListPage = lazy(() => import("@/pages/UserList/UserListPage"));
342
-
343
- function ProtectedRoute({ children }: { children: React.ReactNode }) {
344
- const { isAuthenticated } = useAuth();
345
- if (!isAuthenticated) return <Navigate to="/login" replace />;
346
- return <>{children}</>;
347
- }
348
- ```
349
-
350
- ---
351
-
352
- ## 状态管理选型
353
-
354
- | 状态类型 | 推荐方案 |
355
- | ------------------ | ------------------------------------------------- |
356
- | 组件内临时 UI 状态 | `useState` / `useReducer` |
357
- | 跨组件共享业务状态 | Zustand / Redux Toolkit / Jotai(按仓库实际选择) |
358
- | 服务端数据缓存 | React Query / SWR |
359
- | URL 驱动状态 | 路由参数 / `useSearchParams` |
360
- | 表单状态 | React Hook Form / Formik |
361
-
362
- ### 核心原则
363
-
364
- - 就近管理:状态尽量放在最近的公共祖先
365
- - 单一数据源:同一份数据不要维护多份
366
- - 派生优于同步:可计算值优先在渲染期计算
367
- - 服务端数据优先交给请求库管理,不手动塞进全局 store
368
- - 不要因为“以后可能会用到”就把局部状态提前升级为全局状态
369
-
370
- ---
371
-
372
- ## API 层规范
373
-
374
- ### 设计原则
375
-
376
- - 请求基础设施集中在 `services/`
377
- - 业务 API 按 feature 拆分,而不是全部堆在一个文件
378
- - 请求参数和响应结果都应有明确类型
379
- - 认证、错误格式化、通用拦截放在请求层统一处理
380
- - 页面和组件不要直接散落拼接请求细节
381
-
382
- ### 示例
383
-
384
- ```ts
385
- // services/request.ts
386
- const request = axios.create({
387
- baseURL: import.meta.env.VITE_API_BASE_URL,
388
- timeout: 10000,
389
- });
390
-
391
- request.interceptors.response.use(
392
- (res) => res.data,
393
- (error) => {
394
- if (error.response?.status === 401) {
395
- redirectToLogin();
396
- }
397
- return Promise.reject(normalizeError(error));
398
- },
399
- );
400
- ```
401
-
402
- ```ts
403
- // features/user/api.ts
404
- export function getUserList(
405
- params: UserQueryParams,
406
- ): Promise<PageResult<User>> {
407
- return request.get("/users", { params });
408
- }
409
-
410
- export function updateUser(id: string, data: UpdateUserDTO): Promise<User> {
411
- return request.put(`/users/${id}`, data);
412
- }
413
- ```
414
-
415
- ---
416
-
417
- ## 错误处理
418
-
419
- ### 必须覆盖的状态
420
-
421
- - Loading
422
- - Error
423
- - Empty
424
- - Data
425
-
426
- ### 推荐做法
427
-
428
- - 关键功能模块使用 Error Boundary 包裹,避免局部异常导致全页白屏
429
- - 异步请求失败时必须给用户可见反馈
430
- - 重要操作提供重试能力
431
- - 不要吞错,不写空 `catch`
432
-
433
- ### 示例(`react-error-boundary`,函数式 Fallback)
434
-
435
- ```tsx
436
- import { ErrorBoundary } from "react-error-boundary";
437
-
438
- function ModuleErrorFallback({
439
- resetErrorBoundary,
440
- }: {
441
- resetErrorBoundary: () => void;
442
- }) {
443
- return (
444
- <div>
445
- 模块加载失败
446
- <button type="button" onClick={resetErrorBoundary}>
447
- 重试
448
- </button>
449
- </div>
450
- );
451
- }
452
-
453
- export function UserDashboardSection() {
454
- return (
455
- <ErrorBoundary FallbackComponent={ModuleErrorFallback}>
456
- <UserDashboard />
457
- </ErrorBoundary>
458
- );
459
- }
460
- ```
461
-
462
- ---
463
-
464
- ## Suspense 与懒加载
465
-
466
- 适用场景:
467
-
468
- - 路由级页面
469
- - 图表、富文本编辑器、地图、重型表格等大体积组件
470
- - 初始化成本较高的模块
471
-
472
- 示例:
473
-
474
- ```tsx
475
- const HeavyChart = lazy(() => import("./components/HeavyChart"));
476
-
477
- function Dashboard() {
478
- return (
479
- <Suspense fallback={<ChartSkeleton />}>
480
- <HeavyChart data={chartData} />
481
- </Suspense>
482
- );
483
- }
484
- ```
485
-
486
- 建议:
487
-
488
- - 路由级优先 `lazy + Suspense`
489
- - `fallback` 优先使用 Skeleton 或更贴近内容的占位态,而不是纯 spinner
490
-
491
- ---
492
-
493
- ## 样式接入
494
-
495
- 本 skill 不强制具体样式方案,默认遵循仓库现状。
496
-
497
- 适配时注意:
498
-
499
- - Tailwind 项目继续使用 Tailwind
500
- - CSS Modules 项目保持命名与文件组织一致
501
- - styled-components 项目继续沿用其模式
502
- - 主题、颜色、字号、间距等优先复用仓库 token / CSS 变量
503
- - 避免在组件内硬编码大量视觉常量
504
- - 禁止内联样式(除动态值外)
505
- - 响应式处理需与项目断点约定一致
506
-
507
- ---
508
-
509
- ## 注释规范
510
-
511
- - **优先使用中文**:解释「为什么这样做」、业务约束、边界情况、非显而易见的权衡时,优先用中文撰写注释,便于团队与业务方阅读。
512
- - **与代码语言一致时的例外**:对接第三方协议字段名、HTTP 头、规范中的英文术语时,注释里可保留英文专有名词,必要时中英文并列说明。
513
- - **少而精**:能通过清晰命名与类型表达清楚的逻辑不写废话注释;复杂分支、临时兼容、性能取舍必须写清意图。
514
- - **公开 API**:模块或 hooks 的对外契约可用 JSDoc(`@param` / `@returns` / `@example`),说明用中文即可,除非仓库统一要求英文。
515
-
516
- ---
517
-
518
- ## TypeScript 规范
519
-
520
- 通用 TypeScript / JavaScript 约定(类型与接口、`any`/`unknown`、React Props、不可变更新、错误处理、Zod、模式与安全等)见插件模板 **`templates/shared/rules/fec-typescript.md`**(初始化到项目后为 `.claude/rules/fec-typescript.md`)。
521
-
522
- - **函数签名**:参数上的复杂联合、内联对象、冗长回调应优先抽成具名类型(见同文件「函数参数:复杂类型宜具名」)。
523
-
524
- ### React 项目补充约定
525
-
526
- - Props interface 命名: `ComponentNameProps`
527
- - 事件处理函数: `handle` 前缀(如 `handleClick`)
528
- - 回调 Props: `on` 前缀(如 `onChange`、`onSubmit`)
529
- - 组件优先写显式 props 与返回值类型(`JSX.Element` / `React.ReactElement`),避免依赖 `React.FC` 的隐式 `children` 等行为差异
530
- - 泛型组件使用 `<T>` 约束,保持调用处类型推导;回调与事件类型优先使用 DOM / React 自带类型(如 `React.ChangeEvent<HTMLInputElement>`)
531
-
532
- ```tsx
533
- interface TableProps<T extends Record<string, unknown>> {
534
- data: T[];
535
- columns: ColumnDef<T>[];
536
- onRowClick?: (row: T) => void;
537
- }
538
- ```
539
-
540
- ---
541
-
542
- ## 测试规范
543
-
544
- ### 应优先覆盖的内容
545
-
546
- - 核心交互行为(点击、输入、提交)
547
- - 条件渲染(loading / error / empty / data)
548
- - 关键 hooks 的返回值和副作用
549
- - API 调用 mock 与模块级集成测试
550
-
551
- ### 推荐风格
552
-
553
- - 测试用户行为,而不是实现细节
554
- - 优先使用 `screen.getByRole`、`getByLabelText`
555
- - 避免围绕内部 state 写脆弱测试
556
- - 只测关键行为,不机械追求覆盖率数字
557
-
558
- ### 示例
559
-
560
- ```tsx
561
- describe("UserForm", () => {
562
- it("should submit with valid data", async () => {
563
- const onSubmit = vi.fn();
564
- render(<UserForm onSubmit={onSubmit} />);
565
-
566
- await userEvent.type(screen.getByLabelText("用户名"), "test");
567
- await userEvent.click(screen.getByRole("button", { name: "提交" }));
568
-
569
- expect(onSubmit).toHaveBeenCalledWith({ username: "test" });
570
- });
571
-
572
- it("should show error on invalid input", async () => {
573
- render(<UserForm onSubmit={vi.fn()} />);
574
- await userEvent.click(screen.getByRole("button", { name: "提交" }));
575
- expect(screen.getByText("用户名不能为空")).toBeInTheDocument();
576
- });
577
- });
578
- ```
579
-
580
- ---
581
-
582
- ## 性能优化
583
-
584
- 在以下场景考虑性能优化:
585
-
586
- - 大列表 / 大表格
587
- - 高频重渲染组件
588
- - 大量 props 传递的复杂树
589
- - 重型第三方组件
590
- - 高频变化 context
591
-
592
- ### 推荐手段
593
-
594
- - 合理使用 `React.memo`
595
- - 只在必要时使用 `useMemo` / `useCallback`
596
- - 列表使用稳定 `key`
597
- - 大列表使用虚拟滚动
598
- - 路由级做 code splitting
599
- - 避免将高频变化值放进顶层 context
600
- - 避免在 render 中无意义创建大量新对象 / 新函数 / 新数组
601
-
602
- ---
603
-
604
- ## 常见反模式
605
-
606
- 避免:
607
-
608
- - prop drilling 过深却不考虑组合或局部封装
609
- - 对局部问题过度使用 context
610
- - 把数据请求、视图渲染、命令式 DOM 操作全塞进一个文件
611
- - 在 useEffect 中做可以在事件处理函数中完成的事
612
- - 用 `useEffect + setState` 模拟本可直接计算的派生值
613
- - 将所有状态都推进全局 store
614
- - 在 `components/` 中放业务耦合组件
615
- - 直接绕过模块出口,从 feature 深层路径导入
616
- - 没有明显收益却提前做复杂优化
617
- - **新增类组件**或手写类式 Error Boundary(应函数组件 + `react-error-boundary` 等)
618
-
619
- ---
620
-
621
- ## 输出检查清单
622
-
623
- 输出 React 代码或方案时,至少检查:
624
-
625
- - [ ] 是否先对齐了仓库现有约定
626
- - [ ] 页面 / feature / 通用组件边界是否清晰
627
- - [ ] 目录结构是否与模块复杂度匹配
628
- - [ ] Props 类型完整且明确
629
- - [ ] 解释性注释是否优先使用中文且点到要害
630
- - [ ] 可复用逻辑是否已提取为 hooks
631
- - [ ] loading / error / empty / data 状态是否齐全
632
- - [ ] API 层是否具备类型约束和统一错误处理
633
- - [ ] 是否避免滥用 `any`,外部/接口数据是否在边界收窄或校验
634
- - [ ] 状态管理是否符合就近原则
635
- - [ ] 路由级或重型模块是否考虑懒加载
636
- - [ ] 样式方案是否与仓库保持一致
637
- - [ ] 关键行为是否有测试覆盖
638
- - [ ] 关键模块已用 **`react-error-boundary`**(等)包裹,且未手写类组件式 Boundary
639
- - [ ] 超长列表是否评估虚拟化;弹窗/复合组件是否具备键盘与焦点约定
640
- - [ ] 是否引入了不必要的新依赖或新范式
641
-
642
- ---