@bovinphang/frontend-craft 2.7.0 → 2.9.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 (502) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +378 -305
  4. package/CHANGELOG.zh-CN.md +377 -304
  5. package/CONTRIBUTING.md +371 -361
  6. package/CONTRIBUTING.zh-CN.md +371 -361
  7. package/README.md +545 -493
  8. package/README.openclaw.md +359 -264
  9. package/README.openclaw.zh-CN.md +359 -264
  10. package/README.zh-CN.md +545 -493
  11. package/agents/fec-architect.md +70 -70
  12. package/agents/fec-code-reviewer.md +103 -82
  13. package/agents/fec-debugger.md +20 -20
  14. package/agents/fec-design-token-mapper.md +36 -36
  15. package/agents/fec-doc-updater.md +13 -13
  16. package/agents/fec-e2e-runner.md +45 -45
  17. package/agents/fec-figma-implementer.md +59 -59
  18. package/agents/fec-performance-optimizer.md +128 -128
  19. package/agents/fec-refactor-cleaner.md +17 -14
  20. package/agents/fec-refactoring-expert.md +81 -0
  21. package/agents/fec-security-reviewer.md +82 -67
  22. package/agents/fec-test-planner.md +27 -27
  23. package/agents/fec-typescript-reviewer.md +103 -87
  24. package/agents/fec-ui-checker.md +64 -64
  25. package/commands/fec-debug.md +19 -19
  26. package/commands/fec-doc-sync.md +11 -11
  27. package/commands/fec-init.md +37 -38
  28. package/commands/fec-plan.md +58 -58
  29. package/commands/fec-refactor-clean.md +11 -11
  30. package/commands/fec-refactor-plan.md +17 -0
  31. package/commands/fec-refactor.md +18 -0
  32. package/commands/fec-review.md +71 -41
  33. package/commands/fec-scaffold.md +41 -41
  34. package/commands/fec-smell.md +17 -0
  35. package/commands/fec-tdd.md +17 -13
  36. package/dist/bin/frontend-craft.js +190 -36
  37. package/dist/hooks/fec-run-tests.js +5 -1
  38. package/dist/hooks/fec-session-start.js +1 -1
  39. package/docs/example-prompts.md +157 -137
  40. package/docs/ja-JP/README.md +534 -493
  41. package/docs/ko-KR/README.md +534 -493
  42. package/docs/project-structure.md +151 -123
  43. package/docs/refactoring/README.md +50 -0
  44. package/docs/refactoring/catalog.md +105 -0
  45. package/docs/refactoring/smell-refactoring-matrix.md +41 -0
  46. package/docs/review-and-diagram-workflows.md +39 -0
  47. package/docs/runtimes/antigravity.md +18 -10
  48. package/docs/runtimes/augment.md +18 -10
  49. package/docs/runtimes/claude.md +191 -177
  50. package/docs/runtimes/claude.zh-CN.md +189 -175
  51. package/docs/runtimes/cline.md +18 -10
  52. package/docs/runtimes/codebuddy.md +18 -10
  53. package/docs/runtimes/codex.md +18 -10
  54. package/docs/runtimes/compatibility.md +27 -0
  55. package/docs/runtimes/copilot.md +18 -10
  56. package/docs/runtimes/cursor.md +18 -10
  57. package/docs/runtimes/gemini.md +18 -10
  58. package/docs/runtimes/kilo.md +18 -10
  59. package/docs/runtimes/openclaw.md +18 -10
  60. package/docs/runtimes/opencode.md +18 -10
  61. package/docs/runtimes/qoder.md +18 -19
  62. package/docs/runtimes/trae.md +18 -10
  63. package/docs/runtimes/windsurf.md +18 -10
  64. package/docs/superpowers/plans/2026-09-26-content-integrity.md +145 -0
  65. package/docs/superpowers/plans/2026-09-26-diagram-quality.md +170 -0
  66. package/docs/superpowers/specs/2026-09-26-diagram-quality-design.md +77 -0
  67. package/docs/superpowers/specs/2026-09-26-project-optimization-design.md +95 -0
  68. package/docs/zh-CN/example-prompts.md +157 -137
  69. package/docs/zh-CN/project-structure.md +148 -123
  70. package/docs/zh-CN/review-and-diagram-workflows.md +39 -0
  71. package/docs/zh-TW/README.md +534 -493
  72. package/localized/zh-CN/agents/fec-architect.md +125 -0
  73. package/localized/zh-CN/agents/fec-code-reviewer.md +171 -0
  74. package/localized/zh-CN/agents/fec-debugger.md +44 -0
  75. package/localized/zh-CN/agents/fec-design-token-mapper.md +75 -0
  76. package/localized/zh-CN/agents/fec-doc-updater.md +30 -0
  77. package/localized/zh-CN/agents/fec-e2e-runner.md +107 -0
  78. package/localized/zh-CN/agents/fec-figma-implementer.md +104 -0
  79. package/localized/zh-CN/agents/fec-performance-optimizer.md +293 -0
  80. package/localized/zh-CN/agents/fec-refactor-cleaner.md +35 -0
  81. package/localized/zh-CN/agents/fec-refactoring-expert.md +53 -0
  82. package/localized/zh-CN/agents/fec-security-reviewer.md +132 -0
  83. package/localized/zh-CN/agents/fec-test-planner.md +50 -0
  84. package/localized/zh-CN/agents/fec-typescript-reviewer.md +158 -0
  85. package/localized/zh-CN/agents/fec-ui-checker.md +120 -0
  86. package/localized/zh-CN/commands/fec-debug.md +30 -0
  87. package/localized/zh-CN/commands/fec-doc-sync.md +19 -0
  88. package/localized/zh-CN/commands/fec-init.md +70 -0
  89. package/localized/zh-CN/commands/fec-plan.md +94 -0
  90. package/localized/zh-CN/commands/fec-refactor-clean.md +19 -0
  91. package/localized/zh-CN/commands/fec-refactor-plan.md +15 -0
  92. package/localized/zh-CN/commands/fec-refactor.md +14 -0
  93. package/localized/zh-CN/commands/fec-review.md +97 -0
  94. package/localized/zh-CN/commands/fec-scaffold.md +205 -0
  95. package/localized/zh-CN/commands/fec-smell.md +13 -0
  96. package/localized/zh-CN/commands/fec-tdd.md +25 -0
  97. package/localized/zh-CN/skills/TEMPLATE.md +155 -0
  98. package/localized/zh-CN/skills/eval_queries.json +1257 -0
  99. package/localized/zh-CN/skills/fec-accessibility-check/SKILL.md +39 -0
  100. package/localized/zh-CN/skills/fec-accessibility-check/references/report-template.md +23 -0
  101. package/localized/zh-CN/skills/fec-accessibility-check/references/screen-reader-testing.md +33 -0
  102. package/localized/zh-CN/skills/fec-alchemy/SKILL.md +74 -0
  103. package/localized/zh-CN/skills/fec-alchemy/assets/absorption-plan-template.md +47 -0
  104. package/localized/zh-CN/skills/fec-alchemy/assets/intake-template.md +55 -0
  105. package/localized/zh-CN/skills/fec-alchemy/assets/review-checklist.md +31 -0
  106. package/localized/zh-CN/skills/fec-alchemy/references/methodology.md +94 -0
  107. package/localized/zh-CN/skills/fec-alchemy/references/originality-and-licensing.md +57 -0
  108. package/localized/zh-CN/skills/fec-api-integration/SKILL.md +78 -0
  109. package/localized/zh-CN/skills/fec-api-integration/references/integration-patterns.md +80 -0
  110. package/localized/zh-CN/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
  111. package/localized/zh-CN/skills/fec-browser-storage/SKILL.md +34 -0
  112. package/localized/zh-CN/skills/fec-browser-storage/references/storage-patterns.md +65 -0
  113. package/localized/zh-CN/skills/fec-canvas-threejs/SKILL.md +66 -0
  114. package/localized/zh-CN/skills/fec-canvas-threejs/references/rendering-patterns.md +67 -0
  115. package/localized/zh-CN/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +67 -0
  116. package/localized/zh-CN/skills/fec-code-review/SKILL.md +162 -0
  117. package/localized/zh-CN/skills/fec-code-review/references/report-template.md +39 -0
  118. package/localized/zh-CN/skills/fec-code-smells/SKILL.md +33 -0
  119. package/localized/zh-CN/skills/fec-code-smells/references/detection-guide.md +25 -0
  120. package/localized/zh-CN/skills/fec-code-smells/references/smell-catalog.md +817 -0
  121. package/localized/zh-CN/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
  122. package/localized/zh-CN/skills/fec-component-testing/SKILL.md +119 -0
  123. package/localized/zh-CN/skills/fec-data-fetching/SKILL.md +62 -0
  124. package/localized/zh-CN/skills/fec-data-fetching/references/query-patterns.md +103 -0
  125. package/localized/zh-CN/skills/fec-debug-framework/SKILL.md +157 -0
  126. package/localized/zh-CN/skills/fec-debug-framework/references/report-template.md +58 -0
  127. package/localized/zh-CN/skills/fec-dependency-upgrade/SKILL.md +34 -0
  128. package/localized/zh-CN/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +56 -0
  129. package/localized/zh-CN/skills/fec-doc-sync/SKILL.md +39 -0
  130. package/localized/zh-CN/skills/fec-drawio-studio/SKILL.md +73 -0
  131. package/localized/zh-CN/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
  132. package/localized/zh-CN/skills/fec-drawio-studio/data/brand-icons.json +878 -0
  133. package/localized/zh-CN/skills/fec-drawio-studio/data/shape-index.json +83570 -0
  134. package/localized/zh-CN/skills/fec-drawio-studio/references/data-residency.md +27 -0
  135. package/localized/zh-CN/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
  136. package/localized/zh-CN/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
  137. package/localized/zh-CN/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
  138. package/localized/zh-CN/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
  139. package/localized/zh-CN/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
  140. package/localized/zh-CN/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
  141. package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
  142. package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
  143. package/localized/zh-CN/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
  144. package/localized/zh-CN/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
  145. package/localized/zh-CN/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
  146. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
  147. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
  148. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
  149. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
  150. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
  151. package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
  152. package/localized/zh-CN/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
  153. package/localized/zh-CN/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
  154. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
  155. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
  156. package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
  157. package/localized/zh-CN/skills/fec-drawio-studio/styles/schema.json +112 -0
  158. package/localized/zh-CN/skills/fec-e2e-testing/SKILL.md +42 -0
  159. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
  160. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
  161. package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
  162. package/localized/zh-CN/skills/fec-e2e-testing/references/playwright-patterns.md +95 -0
  163. package/localized/zh-CN/skills/fec-form-handling/SKILL.md +76 -0
  164. package/localized/zh-CN/skills/fec-form-handling/references/advanced-form-patterns.md +101 -0
  165. package/localized/zh-CN/skills/fec-image-generation/SKILL.md +110 -0
  166. package/localized/zh-CN/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
  167. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
  168. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
  169. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
  170. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
  171. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
  172. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
  173. package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
  174. package/localized/zh-CN/skills/fec-image-generation/references/artifact-routing.md +80 -0
  175. package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +81 -0
  176. package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +243 -0
  177. package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +37 -0
  178. package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
  179. package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
  180. package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +332 -0
  181. package/localized/zh-CN/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
  182. package/localized/zh-CN/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
  183. package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +462 -0
  184. package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1537 -0
  185. package/localized/zh-CN/skills/fec-implement-from-design/SKILL.md +129 -0
  186. package/localized/zh-CN/skills/fec-implement-from-design/references/design-plan-template.md +36 -0
  187. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/SKILL.md +46 -0
  188. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
  189. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +41 -0
  190. package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
  191. package/localized/zh-CN/skills/fec-legacy-web-standard/SKILL.md +35 -0
  192. package/localized/zh-CN/skills/fec-legacy-web-standard/references/legacy-patterns.md +85 -0
  193. package/localized/zh-CN/skills/fec-list-virtualization/SKILL.md +34 -0
  194. package/localized/zh-CN/skills/fec-list-virtualization/references/virtualization-patterns.md +80 -0
  195. package/localized/zh-CN/skills/fec-monorepo-project-standard/SKILL.md +142 -0
  196. package/localized/zh-CN/skills/fec-motion-interaction/SKILL.md +73 -0
  197. package/localized/zh-CN/skills/fec-motion-interaction/references/motion-patterns.md +112 -0
  198. package/localized/zh-CN/skills/fec-nextjs-project-standard/SKILL.md +123 -0
  199. package/localized/zh-CN/skills/fec-nuxt-project-standard/SKILL.md +122 -0
  200. package/localized/zh-CN/skills/fec-performance-optimization/SKILL.md +80 -0
  201. package/localized/zh-CN/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
  202. package/localized/zh-CN/skills/fec-performance-optimization/references/report-template.md +59 -0
  203. package/localized/zh-CN/skills/fec-pwa-implementation/SKILL.md +35 -0
  204. package/localized/zh-CN/skills/fec-pwa-implementation/references/manifest-and-icons.md +53 -0
  205. package/localized/zh-CN/skills/fec-pwa-implementation/references/service-worker-workbox.md +68 -0
  206. package/localized/zh-CN/skills/fec-react-project-standard/SKILL.md +91 -0
  207. package/localized/zh-CN/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
  208. package/localized/zh-CN/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
  209. package/localized/zh-CN/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
  210. package/localized/zh-CN/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
  211. package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +54 -0
  212. package/localized/zh-CN/skills/fec-refactor-clean/references/report-template.md +42 -0
  213. package/localized/zh-CN/skills/fec-refactoring/SKILL.md +83 -0
  214. package/localized/zh-CN/skills/fec-refactoring/references/principles.md +43 -0
  215. package/localized/zh-CN/skills/fec-refactoring/references/refactoring-vs-feature-change.md +25 -0
  216. package/localized/zh-CN/skills/fec-refactoring/references/when-to-refactor.md +17 -0
  217. package/localized/zh-CN/skills/fec-refactoring/references/workflow.md +59 -0
  218. package/localized/zh-CN/skills/fec-refactoring-api/SKILL.md +25 -0
  219. package/localized/zh-CN/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
  220. package/localized/zh-CN/skills/fec-refactoring-catalog/SKILL.md +21 -0
  221. package/localized/zh-CN/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
  222. package/localized/zh-CN/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
  223. package/localized/zh-CN/skills/fec-refactoring-catalog/references/selection-guide.md +41 -0
  224. package/localized/zh-CN/skills/fec-refactoring-control/SKILL.md +25 -0
  225. package/localized/zh-CN/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
  226. package/localized/zh-CN/skills/fec-refactoring-data/SKILL.md +25 -0
  227. package/localized/zh-CN/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
  228. package/localized/zh-CN/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
  229. package/localized/zh-CN/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
  230. package/localized/zh-CN/skills/fec-refactoring-functions/SKILL.md +25 -0
  231. package/localized/zh-CN/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
  232. package/localized/zh-CN/skills/fec-refactoring-inheritance/SKILL.md +25 -0
  233. package/localized/zh-CN/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
  234. package/localized/zh-CN/skills/fec-refactoring-move-features/SKILL.md +25 -0
  235. package/localized/zh-CN/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
  236. package/localized/zh-CN/skills/fec-refactoring-validation/SKILL.md +52 -0
  237. package/localized/zh-CN/skills/fec-refactoring-validation/references/behavior-preservation.md +15 -0
  238. package/localized/zh-CN/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +25 -0
  239. package/localized/zh-CN/skills/fec-responsive-layout/SKILL.md +34 -0
  240. package/localized/zh-CN/skills/fec-responsive-layout/references/responsive-layout-patterns.md +70 -0
  241. package/localized/zh-CN/skills/fec-route-protection/SKILL.md +135 -0
  242. package/localized/zh-CN/skills/fec-security-review/SKILL.md +54 -0
  243. package/localized/zh-CN/skills/fec-security-review/references/report-template.md +37 -0
  244. package/localized/zh-CN/skills/fec-security-review/references/security-checklist.md +64 -0
  245. package/localized/zh-CN/skills/fec-source-driven-development/SKILL.md +87 -0
  246. package/localized/zh-CN/skills/fec-state-management/SKILL.md +140 -0
  247. package/localized/zh-CN/skills/fec-state-management/references/state-patterns.md +109 -0
  248. package/localized/zh-CN/skills/fec-storybook-component-doc/SKILL.md +37 -0
  249. package/localized/zh-CN/skills/fec-storybook-component-doc/references/story-patterns.md +118 -0
  250. package/localized/zh-CN/skills/fec-svg-animation/SKILL.md +148 -0
  251. package/localized/zh-CN/skills/fec-tailwind-design-system/SKILL.md +34 -0
  252. package/localized/zh-CN/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +59 -0
  253. package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +55 -0
  254. package/localized/zh-CN/skills/fec-testing-strategy/SKILL.md +45 -0
  255. package/localized/zh-CN/skills/fec-typescript-project-standard/SKILL.md +54 -0
  256. package/localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety-patterns.md +102 -0
  257. package/localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety.md +148 -0
  258. package/localized/zh-CN/skills/fec-ui-design/SKILL.md +108 -0
  259. package/localized/zh-CN/skills/fec-ui-design/data/product-rules.json +231 -0
  260. package/localized/zh-CN/skills/fec-ui-design/data/stack-ui-rules.json +146 -0
  261. package/localized/zh-CN/skills/fec-ui-design/data/style-archetypes.json +373 -0
  262. package/localized/zh-CN/skills/fec-ui-design/data/ux-quality-rules.json +203 -0
  263. package/localized/zh-CN/skills/fec-ui-design/references/design-intelligence.md +97 -0
  264. package/localized/zh-CN/skills/fec-ui-design/references/master-page-overrides.md +30 -0
  265. package/localized/zh-CN/skills/fec-ui-design/references/pre-delivery-checklist.md +39 -0
  266. package/localized/zh-CN/skills/fec-ui-design/scripts/design-system.mjs +648 -0
  267. package/localized/zh-CN/skills/fec-validation-fix/SKILL.md +51 -0
  268. package/localized/zh-CN/skills/fec-validation-fix/references/report-template.md +43 -0
  269. package/localized/zh-CN/skills/fec-vite-project-standard/SKILL.md +83 -0
  270. package/localized/zh-CN/skills/fec-vue3-project-standard/SKILL.md +58 -0
  271. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +162 -0
  272. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
  273. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-project-structure.md +176 -0
  274. package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
  275. package/localized/zh-CN/skills/fec-web-video-presentation/SKILL.md +61 -0
  276. package/localized/zh-CN/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
  277. package/localized/zh-CN/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
  278. package/localized/zh-CN/skills/fec-web-video-presentation/references/content-plan.md +38 -0
  279. package/localized/zh-CN/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
  280. package/localized/zh-CN/skills/fec-web-video-presentation/references/theme-system.md +36 -0
  281. package/localized/zh-CN/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
  282. package/localized/zh-CN/skills/fec-web-workers/SKILL.md +35 -0
  283. package/localized/zh-CN/skills/fec-web-workers/references/advanced-workers.md +54 -0
  284. package/localized/zh-CN/skills/fec-web-workers/references/basic-worker.md +67 -0
  285. package/localized/zh-CN/skills/metadata.json +2004 -0
  286. package/localized/zh-CN/skills/relations.json +1023 -0
  287. package/localized/zh-CN/templates/claude/CLAUDE.md +106 -0
  288. package/localized/zh-CN/templates/claude/settings.json +62 -0
  289. package/localized/zh-CN/templates/codex/AGENTS.md +105 -0
  290. package/localized/zh-CN/templates/codex/config.toml +32 -0
  291. package/localized/zh-CN/templates/openclaw/AGENTS.md +101 -0
  292. package/localized/zh-CN/templates/openclaw/OPENCLAW-CONFIG.md +12 -0
  293. package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +55 -0
  294. package/localized/zh-CN/templates/shared/rules/fec-api-layer.md +99 -0
  295. package/localized/zh-CN/templates/shared/rules/fec-ci-cd.md +40 -0
  296. package/localized/zh-CN/templates/shared/rules/fec-code-comments.md +33 -0
  297. package/localized/zh-CN/templates/shared/rules/fec-design-system.md +72 -0
  298. package/localized/zh-CN/templates/shared/rules/fec-error-handling.md +56 -0
  299. package/localized/zh-CN/templates/shared/rules/fec-git-conventions.md +73 -0
  300. package/localized/zh-CN/templates/shared/rules/fec-i18n.md +64 -0
  301. package/localized/zh-CN/templates/shared/rules/fec-naming-conventions.md +120 -0
  302. package/localized/zh-CN/templates/shared/rules/fec-performance.md +101 -0
  303. package/localized/zh-CN/templates/shared/rules/fec-react.md +82 -0
  304. package/localized/zh-CN/templates/shared/rules/fec-refactoring.md +47 -0
  305. package/localized/zh-CN/templates/shared/rules/fec-rendering-patterns.md +40 -0
  306. package/localized/zh-CN/templates/shared/rules/fec-responsive-design.md +50 -0
  307. package/localized/zh-CN/templates/shared/rules/fec-source-driven-development.md +31 -0
  308. package/localized/zh-CN/templates/shared/rules/fec-state-management.md +60 -0
  309. package/localized/zh-CN/templates/shared/rules/fec-testing.md +98 -0
  310. package/localized/zh-CN/templates/shared/rules/fec-typescript.md +112 -0
  311. package/localized/zh-CN/templates/shared/rules/fec-vue.md +64 -0
  312. package/localized/zh-CN/templates/shared/rules/fec-working-modes.md +50 -0
  313. package/openclaw.plugin.json +2 -3
  314. package/package.json +28 -17
  315. package/skills/TEMPLATE.md +74 -74
  316. package/skills/eval_queries.json +922 -678
  317. package/skills/fec-accessibility-check/SKILL.md +21 -21
  318. package/skills/fec-accessibility-check/references/report-template.md +12 -12
  319. package/skills/fec-accessibility-check/references/screen-reader-testing.md +24 -24
  320. package/skills/fec-alchemy/SKILL.md +50 -50
  321. package/skills/fec-alchemy/assets/absorption-plan-template.md +32 -32
  322. package/skills/fec-alchemy/assets/intake-template.md +55 -55
  323. package/skills/fec-alchemy/assets/review-checklist.md +23 -23
  324. package/skills/fec-alchemy/references/methodology.md +66 -66
  325. package/skills/fec-alchemy/references/originality-and-licensing.md +42 -42
  326. package/skills/fec-api-integration/SKILL.md +61 -61
  327. package/skills/fec-api-integration/references/integration-patterns.md +30 -30
  328. package/skills/fec-backend-requirements-handoff/SKILL.md +25 -25
  329. package/skills/fec-browser-storage/SKILL.md +16 -16
  330. package/skills/fec-browser-storage/references/storage-patterns.md +16 -16
  331. package/skills/fec-canvas-threejs/SKILL.md +21 -21
  332. package/skills/fec-canvas-threejs/references/rendering-patterns.md +10 -10
  333. package/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +37 -37
  334. package/skills/fec-code-review/SKILL.md +113 -94
  335. package/skills/fec-code-review/references/report-template.md +23 -13
  336. package/skills/fec-code-smells/SKILL.md +33 -0
  337. package/skills/fec-code-smells/references/detection-guide.md +25 -0
  338. package/skills/fec-code-smells/references/smell-catalog.md +861 -0
  339. package/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
  340. package/skills/fec-component-testing/SKILL.md +39 -39
  341. package/skills/fec-data-fetching/SKILL.md +16 -16
  342. package/skills/fec-data-fetching/references/query-patterns.md +27 -27
  343. package/skills/fec-debug-framework/SKILL.md +95 -95
  344. package/skills/fec-debug-framework/references/report-template.md +34 -34
  345. package/skills/fec-dependency-upgrade/SKILL.md +17 -17
  346. package/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +31 -31
  347. package/skills/fec-doc-sync/SKILL.md +23 -23
  348. package/skills/fec-drawio-studio/SKILL.md +42 -38
  349. package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +1 -1
  350. package/skills/fec-drawio-studio/data/shape-index.json +83570 -0
  351. package/skills/fec-drawio-studio/references/diagram-patterns.md +19 -0
  352. package/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
  353. package/skills/fec-drawio-studio/references/layout-and-export.md +18 -3
  354. package/skills/fec-drawio-studio/references/xml-and-mermaid.md +5 -1
  355. package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +62 -0
  356. package/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
  357. package/skills/fec-drawio-studio/scripts/shape-query.mjs +55 -15
  358. package/skills/fec-e2e-testing/SKILL.md +24 -24
  359. package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +20 -20
  360. package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +10 -10
  361. package/skills/fec-e2e-testing/references/e2e-visual-regression.md +17 -17
  362. package/skills/fec-e2e-testing/references/playwright-patterns.md +6 -6
  363. package/skills/fec-form-handling/SKILL.md +21 -21
  364. package/skills/fec-form-handling/references/advanced-form-patterns.md +41 -41
  365. package/skills/fec-image-generation/SKILL.md +84 -29
  366. package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
  367. package/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
  368. package/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
  369. package/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
  370. package/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
  371. package/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
  372. package/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
  373. package/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
  374. package/skills/fec-image-generation/references/diagram-workflows.md +41 -3
  375. package/skills/fec-image-generation/references/html-technical-diagrams.md +243 -0
  376. package/skills/fec-image-generation/references/png-qa-autofix.md +9 -2
  377. package/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
  378. package/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
  379. package/skills/fec-image-generation/scripts/export-diagram.mjs +332 -0
  380. package/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
  381. package/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
  382. package/skills/fec-image-generation/scripts/png-qa.mjs +35 -4
  383. package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1537 -0
  384. package/skills/fec-implement-from-design/SKILL.md +81 -81
  385. package/skills/fec-implement-from-design/references/design-plan-template.md +16 -16
  386. package/skills/fec-legacy-to-modern-migration/SKILL.md +29 -29
  387. package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +81 -81
  388. package/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +37 -37
  389. package/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +31 -31
  390. package/skills/fec-legacy-web-standard/SKILL.md +17 -17
  391. package/skills/fec-legacy-web-standard/references/legacy-patterns.md +16 -16
  392. package/skills/fec-list-virtualization/SKILL.md +16 -16
  393. package/skills/fec-list-virtualization/references/virtualization-patterns.md +31 -31
  394. package/skills/fec-monorepo-project-standard/SKILL.md +52 -52
  395. package/skills/fec-motion-interaction/SKILL.md +51 -51
  396. package/skills/fec-motion-interaction/references/motion-patterns.md +11 -11
  397. package/skills/fec-nextjs-project-standard/SKILL.md +64 -64
  398. package/skills/fec-nuxt-project-standard/SKILL.md +57 -57
  399. package/skills/fec-performance-optimization/SKILL.md +54 -54
  400. package/skills/fec-performance-optimization/references/framework-performance-patterns.md +23 -23
  401. package/skills/fec-performance-optimization/references/report-template.md +31 -31
  402. package/skills/fec-pwa-implementation/SKILL.md +17 -17
  403. package/skills/fec-pwa-implementation/references/manifest-and-icons.md +12 -12
  404. package/skills/fec-pwa-implementation/references/service-worker-workbox.md +13 -13
  405. package/skills/fec-react-project-standard/SKILL.md +72 -72
  406. package/skills/fec-react-project-standard/references/react-performance-patterns.md +28 -28
  407. package/skills/fec-react-project-standard/references/react-project-structure.md +112 -112
  408. package/skills/fec-react-project-standard/references/react-quality-patterns.md +72 -72
  409. package/skills/fec-react-project-standard/references/react-runtime-patterns.md +94 -94
  410. package/skills/fec-refactor-clean/SKILL.md +33 -30
  411. package/skills/fec-refactor-clean/references/report-template.md +23 -23
  412. package/skills/fec-refactoring/SKILL.md +83 -0
  413. package/skills/fec-refactoring/references/principles.md +60 -0
  414. package/skills/fec-refactoring/references/refactoring-vs-feature-change.md +27 -0
  415. package/skills/fec-refactoring/references/when-to-refactor.md +31 -0
  416. package/skills/fec-refactoring/references/workflow.md +90 -0
  417. package/skills/fec-refactoring-api/SKILL.md +25 -0
  418. package/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
  419. package/skills/fec-refactoring-catalog/SKILL.md +28 -0
  420. package/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
  421. package/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
  422. package/skills/fec-refactoring-catalog/references/selection-guide.md +47 -0
  423. package/skills/fec-refactoring-control/SKILL.md +25 -0
  424. package/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
  425. package/skills/fec-refactoring-data/SKILL.md +25 -0
  426. package/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
  427. package/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
  428. package/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
  429. package/skills/fec-refactoring-functions/SKILL.md +25 -0
  430. package/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
  431. package/skills/fec-refactoring-inheritance/SKILL.md +25 -0
  432. package/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
  433. package/skills/fec-refactoring-move-features/SKILL.md +25 -0
  434. package/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
  435. package/skills/fec-refactoring-validation/SKILL.md +59 -0
  436. package/skills/fec-refactoring-validation/references/behavior-preservation.md +53 -0
  437. package/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +42 -0
  438. package/skills/fec-responsive-layout/SKILL.md +17 -17
  439. package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +37 -37
  440. package/skills/fec-route-protection/SKILL.md +26 -26
  441. package/skills/fec-security-review/SKILL.md +36 -20
  442. package/skills/fec-security-review/references/report-template.md +22 -12
  443. package/skills/fec-security-review/references/security-checklist.md +27 -27
  444. package/skills/fec-source-driven-development/SKILL.md +59 -59
  445. package/skills/fec-state-management/SKILL.md +34 -34
  446. package/skills/fec-state-management/references/state-patterns.md +19 -19
  447. package/skills/fec-storybook-component-doc/SKILL.md +19 -19
  448. package/skills/fec-storybook-component-doc/references/story-patterns.md +12 -12
  449. package/skills/fec-svg-animation/SKILL.md +32 -32
  450. package/skills/fec-tailwind-design-system/SKILL.md +17 -17
  451. package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +36 -36
  452. package/skills/fec-tdd-workflow/SKILL.md +32 -28
  453. package/skills/fec-testing-strategy/SKILL.md +29 -29
  454. package/skills/fec-typescript-project-standard/SKILL.md +38 -38
  455. package/skills/fec-typescript-project-standard/references/type-safety-patterns.md +20 -20
  456. package/skills/fec-typescript-project-standard/references/type-safety.md +18 -18
  457. package/skills/fec-ui-design/SKILL.md +90 -90
  458. package/skills/fec-ui-design/references/design-intelligence.md +61 -61
  459. package/skills/fec-ui-design/references/master-page-overrides.md +15 -15
  460. package/skills/fec-ui-design/references/pre-delivery-checklist.md +38 -38
  461. package/skills/fec-validation-fix/SKILL.md +26 -26
  462. package/skills/fec-validation-fix/references/report-template.md +25 -25
  463. package/skills/fec-vite-project-standard/SKILL.md +39 -39
  464. package/skills/fec-vue3-project-standard/SKILL.md +38 -38
  465. package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +36 -36
  466. package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +8 -8
  467. package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +112 -112
  468. package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +74 -74
  469. package/skills/fec-web-video-presentation/SKILL.md +33 -33
  470. package/skills/fec-web-workers/SKILL.md +16 -16
  471. package/skills/fec-web-workers/references/advanced-workers.md +13 -13
  472. package/skills/fec-web-workers/references/basic-worker.md +8 -8
  473. package/skills/metadata.json +485 -116
  474. package/skills/relations.json +268 -0
  475. package/templates/claude/CLAUDE.md +60 -60
  476. package/templates/codex/AGENTS.md +76 -76
  477. package/templates/codex/config.toml +4 -4
  478. package/templates/openclaw/AGENTS.md +68 -68
  479. package/templates/openclaw/OPENCLAW-CONFIG.md +8 -8
  480. package/templates/shared/rules/fec-agent-workflow.md +41 -40
  481. package/templates/shared/rules/fec-api-layer.md +52 -52
  482. package/templates/shared/rules/fec-ci-cd.md +29 -29
  483. package/templates/shared/rules/fec-code-comments.md +22 -22
  484. package/templates/shared/rules/fec-design-system.md +53 -53
  485. package/templates/shared/rules/fec-error-handling.md +40 -40
  486. package/templates/shared/rules/fec-git-conventions.md +42 -42
  487. package/templates/shared/rules/fec-i18n.md +48 -48
  488. package/templates/shared/rules/fec-naming-conventions.md +91 -91
  489. package/templates/shared/rules/fec-performance.md +78 -78
  490. package/templates/shared/rules/fec-react.md +58 -58
  491. package/templates/shared/rules/fec-refactoring.md +34 -34
  492. package/templates/shared/rules/fec-rendering-patterns.md +36 -36
  493. package/templates/shared/rules/fec-responsive-design.md +37 -37
  494. package/templates/shared/rules/fec-source-driven-development.md +22 -22
  495. package/templates/shared/rules/fec-state-management.md +56 -56
  496. package/templates/shared/rules/fec-testing.md +64 -64
  497. package/templates/shared/rules/fec-typescript.md +75 -75
  498. package/templates/shared/rules/fec-vue.md +42 -42
  499. package/templates/shared/rules/fec-working-modes.md +34 -34
  500. package/docs/superpowers/plans/2026-05-29-fec-debug.md +0 -491
  501. package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +0 -340
  502. package/skills/fec-drawio-studio/data/shape-index.json.gz +0 -0
@@ -0,0 +1,131 @@
1
+ # React 质量模式
2
+
3
+ ## 样式接入
4
+
5
+ 本 skill 不强制具体样式方案,默认遵循仓库现状。
6
+
7
+ 适配时注意:
8
+
9
+ - Tailwind 项目继续使用 Tailwind
10
+ - CSS Modules 项目保持命名与文件组织一致
11
+ - styled-components 项目继续沿用其模式
12
+ - 主题、颜色、字号、间距等优先复用仓库 token / CSS 变量
13
+ - 避免在组件内硬编码大量视觉常量
14
+ - 禁止内联样式(除动态值外)
15
+ - 响应式处理需与项目断点约定一致
16
+
17
+ ---
18
+
19
+ ## 注释规范
20
+
21
+ - **优先使用中文**:解释「为什么这样做」、业务约束、边界情况、非显而易见的权衡时,优先用中文撰写注释,便于团队与业务方阅读。
22
+ - **与代码语言一致时的例外**:对接第三方协议字段名、HTTP 头、规范中的英文术语时,注释里可保留英文专有名词,必要时中英文并列说明。
23
+ - **少而精**:能通过清晰命名与类型表达清楚的逻辑不写废话注释;复杂分支、临时兼容、性能取舍必须写清意图。
24
+ - **公开 API**:模块或 hooks 的对外契约可用 JSDoc(`@param` / `@returns` / `@example`),说明用中文即可,除非仓库统一要求英文。
25
+
26
+ ---
27
+
28
+ ## TypeScript 规范
29
+
30
+ 通用 TypeScript 工程规则由 `fec-typescript-project-standard` 负责,包括 `tsconfig`、strictness、DTO / view model 边界、`unknown` 收窄、public API 类型、声明产物和类型测试。
31
+
32
+ React 规范只补充组件、Props、事件和 TSX 泛型写法;复杂类型建模或跨框架类型契约先分流到 `fec-typescript-project-standard`。
33
+
34
+ ### React 项目补充约定
35
+
36
+ - Props interface 命名: `ComponentNameProps`
37
+ - 事件处理函数: `handle` 前缀(如 `handleClick`)
38
+ - 回调 Props: `on` 前缀(如 `onChange`、`onSubmit`)
39
+ - 组件优先写显式 props 与返回值类型(`JSX.Element` / `React.ReactElement`),避免依赖 `React.FC` 的隐式 `children` 等行为差异
40
+ - 泛型组件使用 `<T>` 约束,保持调用处类型推导;回调与事件类型优先使用 DOM / React 自带类型(如 `React.ChangeEvent<HTMLInputElement>`)
41
+
42
+ ```tsx
43
+ interface TableProps<T extends Record<string, unknown>> {
44
+ data: T[];
45
+ columns: ColumnDef<T>[];
46
+ onRowClick?: (row: T) => void;
47
+ }
48
+ ```
49
+
50
+ ---
51
+
52
+ ## 测试规范
53
+
54
+ ### 应优先覆盖的内容
55
+
56
+ - 核心交互行为(点击、输入、提交)
57
+ - 条件渲染(loading / error / empty / data)
58
+ - 关键 hooks 的返回值和副作用
59
+ - API 调用 mock 与模块级集成测试
60
+
61
+ ### 推荐风格
62
+
63
+ - 测试用户行为,而不是实现细节
64
+ - 优先使用 `screen.getByRole`、`getByLabelText`
65
+ - 避免围绕内部 state 写脆弱测试
66
+ - 只测关键行为,不机械追求覆盖率数字
67
+
68
+ ### 示例
69
+
70
+ ```tsx
71
+ describe("UserForm", () => {
72
+ it("should submit with valid data", async () => {
73
+ const onSubmit = vi.fn();
74
+ render(<UserForm onSubmit={onSubmit} />);
75
+
76
+ await userEvent.type(screen.getByLabelText("用户名"), "test");
77
+ await userEvent.click(screen.getByRole("button", { name: "提交" }));
78
+
79
+ expect(onSubmit).toHaveBeenCalledWith({ username: "test" });
80
+ });
81
+
82
+ it("should show error on invalid input", async () => {
83
+ render(<UserForm onSubmit={vi.fn()} />);
84
+ await userEvent.click(screen.getByRole("button", { name: "提交" }));
85
+ expect(screen.getByText("用户名不能为空")).toBeInTheDocument();
86
+ });
87
+ });
88
+ ```
89
+
90
+ ---
91
+
92
+
93
+ ## 常见反模式
94
+
95
+ 避免:
96
+
97
+ - prop drilling 过深却不考虑组合或局部封装
98
+ - 对局部问题过度使用 context
99
+ - 把数据请求、视图渲染、命令式 DOM 操作全塞进一个文件
100
+ - 在 useEffect 中做可以在事件处理函数中完成的事
101
+ - 用 `useEffect + setState` 模拟本可直接计算的派生值
102
+ - 将所有状态都推进全局 store
103
+ - 在 `components/` 中放业务耦合组件
104
+ - 直接绕过模块出口,从 feature 深层路径导入
105
+ - 没有明显收益却提前做复杂优化
106
+ - **新增类组件**或手写类式 Error Boundary(应函数组件 + `react-error-boundary` 等)
107
+
108
+ ---
109
+
110
+ ## 输出检查清单
111
+
112
+ 输出 React 代码或方案时,至少检查:
113
+
114
+ - [ ] 是否先对齐了仓库现有约定
115
+ - [ ] 页面 / feature / 通用组件边界是否清晰
116
+ - [ ] 目录结构是否与模块复杂度匹配
117
+ - [ ] Props 类型完整且明确
118
+ - [ ] 解释性注释是否优先使用中文且点到要害
119
+ - [ ] 可复用逻辑是否已提取为 hooks
120
+ - [ ] loading / error / empty / data 状态是否齐全
121
+ - [ ] API 层是否具备类型约束和统一错误处理
122
+ - [ ] 复杂 DTO、外部数据收窄、公共类型或 `tsconfig` 问题是否已分流到 `fec-typescript-project-standard`
123
+ - [ ] 状态管理是否符合就近原则
124
+ - [ ] 路由级或重型模块是否考虑懒加载
125
+ - [ ] 样式方案是否与仓库保持一致
126
+ - [ ] 关键行为是否有测试覆盖
127
+ - [ ] 关键模块已用 **`react-error-boundary`**(等)包裹,且未手写类组件式 Boundary
128
+ - [ ] 超长列表是否评估虚拟化;弹窗/复合组件是否具备键盘与焦点约定
129
+ - [ ] 是否引入了不必要的新依赖或新范式
130
+
131
+ ---
@@ -0,0 +1,293 @@
1
+ # React 运行时模式
2
+
3
+ ## 常用 UI 与状态模式
4
+
5
+ 以下模式可与本 skill 其他章节(Hooks、状态管理、性能优化、错误处理)对照使用;**按业务复杂度与团队熟悉度选用**,避免为模式而模式。思路参考业界常见的 React 前端模式实践(如组件组合、复合组件、性能与无障碍等)。
6
+
7
+ ### 组合优于继承
8
+
9
+ - 用**小颗粒子组件** + `children` / 显式 props 拼装界面,而不是在 React 中搭建类继承层次。
10
+ - 示例:`Card` + `CardHeader` + `CardBody`,由使用方组合,而不是一个巨型 `Card` 用大量布尔 props 分支。
11
+
12
+ ### 复合组件(Compound Components)
13
+
14
+ - 根组件通过 **Context** 向子组件提供内部状态(如当前 Tab、打开/关闭)。
15
+ - 子组件在 `useContext` 为空时**抛错或断言**,明确「必须在 Provider 树内使用」。
16
+ - API 表面保持可读:`<Tabs><TabList><Tab /></TabList></Tabs>`。
17
+
18
+ ### Render Props / 函数子
19
+
20
+ - 适用:封装**数据获取与三态**(loading / error / data),把**渲染决策**交给父级。
21
+ - 与 **自定义 Hook** 二选一即可:多数场景 `useXxx()` + 普通组件更直观;仅在需要强约束「同层渲染逻辑」时保留 Render Props。
22
+
23
+ ### Context + useReducer
24
+
25
+ - 适合**中等复杂度、多子树共享**的客户端状态,且更新可归约为明确 `action`。
26
+ - 避免把高频变化的大对象塞进顶层 Context;服务端数据仍优先 **React Query / SWR**。
27
+ - 大型全局业务状态继续用仓库已选的 **Zustand / Redux Toolkit / Jotai**。
28
+
29
+ ### 表单
30
+
31
+ - 受控字段 + 校验错误对象是一类可行实现;中大型表单优先 **React Hook Form**(或 Formik)+ **Zod**,复杂表单值、DTO 和校验类型契约分流到 `fec-typescript-project-standard`。
32
+ - 避免单组件内巨型 `useState` 表单对象与重复校验逻辑,可拆字段子组件或抽 `useFormSchema`。
33
+
34
+ ### Error Boundary
35
+
36
+ - **不要**在业务代码中手写 React **类组件**形式的 Error Boundary;统一使用 **`react-error-boundary`**(或团队认可的同类库)在**模块边界**兜底渲染失败(与本章「错误处理」、`error-handling.md` 一致)。
37
+ - 用 `FallbackComponent` 与 `resetErrorBoundary` 提供「重试」;**日志上报**放在库的 **`onError`**(等回调)中,生产代码避免长期依赖 `console.log`(见 TypeScript 规则)。
38
+
39
+
40
+ ### 动画与过渡
41
+
42
+ - 列表进出场可用 **Framer Motion** 的 `AnimatePresence` + `key`,或 CSS `transition`;注意减少布局抖动与 `prefers-reduced-motion`(与无障碍策略一致时)。
43
+
44
+ ### 无障碍与焦点
45
+
46
+ - 自定义下拉、标签页等:**`role` / `aria-*`**、**方向键 / Enter / Escape** 行为与焦点环可见。
47
+ - 弹窗:打开时将焦点移入对话框,关闭时**恢复**触发元素焦点;可用 **`focus-trap-react`** 或类似方案,与 `fec-accessibility-check` skill 互补。
48
+
49
+ ### Next.js 与服务端组件
50
+
51
+ - **App Router、Server Components、服务端数据获取与缓存**见 **`fec-nextjs-project-standard`**;客户端交互模式仍以本章与 Hooks 规范为准。
52
+
53
+ ---
54
+
55
+
56
+ ## Hooks 设计模式
57
+
58
+ ### 适合抽为自定义 Hook 的场景
59
+
60
+ - 数据获取与三态管理
61
+ - 表单状态逻辑
62
+ - 分页、筛选、排序编排
63
+ - 事件监听与副作用清理
64
+ - 可在多个组件复用的交互逻辑
65
+
66
+ ### 推荐原则
67
+
68
+ - 统一使用 `use` 前缀命名
69
+ - 返回对象而非数组,方便按需解构,增强可读性和扩展性
70
+ - 状态和行为封装在一起
71
+ - Hook 内部处理 `loading / error / data`
72
+ - 对外暴露清晰的最小接口,不泄漏无关内部细节
73
+
74
+ ### 示例
75
+
76
+ ```tsx
77
+ function useUserList(params: QueryParams) {
78
+ const [data, setData] = useState<User[]>([]);
79
+ const [loading, setLoading] = useState(false);
80
+ const [error, setError] = useState<Error | null>(null);
81
+
82
+ const fetch = useCallback(async () => {
83
+ setLoading(true);
84
+ setError(null);
85
+ try {
86
+ const res = await getUserList(params);
87
+ setData(res.list);
88
+ } catch (e) {
89
+ setError(e as Error);
90
+ } finally {
91
+ setLoading(false);
92
+ }
93
+ }, [params]);
94
+
95
+ useEffect(() => {
96
+ fetch();
97
+ }, [fetch]);
98
+
99
+ return { data, loading, error, refetch: fetch };
100
+ }
101
+ ```
102
+
103
+ ### Hook 使用原则
104
+
105
+ - `useEffect` 必须有正确依赖和清理逻辑
106
+ - `useMemo` / `useCallback` 不要滥用,只有在稳定引用确实重要时再加
107
+ - 不在条件分支或循环中调用 hooks
108
+ - 已引入 React Query / SWR 时,数据请求优先走这些库,而不是自己重复造一套缓存层
109
+
110
+ ---
111
+
112
+ ## 路由组织
113
+
114
+ ### 推荐方式
115
+
116
+ - 路由配置集中管理
117
+ - 路径常量化
118
+ - 页面组件按需懒加载
119
+ - 权限控制放在 guard 层,而不是散落在页面组件内
120
+ - 分页、筛选、排序等 URL 驱动状态优先与地址栏同步
121
+
122
+ ### 示例
123
+
124
+ ```tsx
125
+ const routes: RouteObject[] = [
126
+ {
127
+ path: "/",
128
+ element: <MainLayout />,
129
+ children: [
130
+ { index: true, element: <DashboardPage /> },
131
+ { path: "users", element: <UserListPage /> },
132
+ { path: "users/:id", element: <UserDetailPage /> },
133
+ { path: "settings", element: <SettingsPage /> },
134
+ ],
135
+ },
136
+ { path: "/login", element: <LoginPage /> },
137
+ { path: "*", element: <NotFoundPage /> },
138
+ ];
139
+ ```
140
+
141
+ ```tsx
142
+ const UserListPage = lazy(() => import("@/pages/UserList/UserListPage"));
143
+
144
+ function ProtectedRoute({ children }: { children: React.ReactNode }) {
145
+ const { isAuthenticated } = useAuth();
146
+ if (!isAuthenticated) return <Navigate to="/login" replace />;
147
+ return <>{children}</>;
148
+ }
149
+ ```
150
+
151
+ ---
152
+
153
+ ## 状态管理选型
154
+
155
+ | 状态类型 | 推荐方案 |
156
+ | ------------------ | ------------------------------------------------- |
157
+ | 组件内临时 UI 状态 | `useState` / `useReducer` |
158
+ | 跨组件共享业务状态 | Zustand / Redux Toolkit / Jotai(按仓库实际选择) |
159
+ | 服务端数据缓存 | React Query / SWR |
160
+ | URL 驱动状态 | 路由参数 / `useSearchParams` |
161
+ | 表单状态 | React Hook Form / Formik |
162
+
163
+ ### 核心原则
164
+
165
+ - 就近管理:状态尽量放在最近的公共祖先
166
+ - 单一数据源:同一份数据不要维护多份
167
+ - 派生优于同步:可计算值优先在渲染期计算
168
+ - 服务端数据优先交给请求库管理,不手动塞进全局 store
169
+ - 不要因为“以后可能会用到”就把局部状态提前升级为全局状态
170
+
171
+ ---
172
+
173
+ ## API 层规范
174
+
175
+ ### 设计原则
176
+
177
+ - 请求基础设施集中在 `services/`
178
+ - 业务 API 按 feature 拆分,而不是全部堆在一个文件
179
+ - 请求参数和响应结果都应有明确类型
180
+ - 认证、错误格式化、通用拦截放在请求层统一处理
181
+ - 页面和组件不要直接散落拼接请求细节
182
+
183
+ ### 示例
184
+
185
+ ```ts
186
+ // services/request.ts
187
+ const request = axios.create({
188
+ baseURL: import.meta.env.VITE_API_BASE_URL,
189
+ timeout: 10000,
190
+ });
191
+
192
+ request.interceptors.response.use(
193
+ (res) => res.data,
194
+ (error) => {
195
+ if (error.response?.status === 401) {
196
+ redirectToLogin();
197
+ }
198
+ return Promise.reject(normalizeError(error));
199
+ },
200
+ );
201
+ ```
202
+
203
+ ```ts
204
+ // features/user/api.ts
205
+ export function getUserList(
206
+ params: UserQueryParams,
207
+ ): Promise<PageResult<User>> {
208
+ return request.get("/users", { params });
209
+ }
210
+
211
+ export function updateUser(id: string, data: UpdateUserDTO): Promise<User> {
212
+ return request.put(`/users/${id}`, data);
213
+ }
214
+ ```
215
+
216
+ ---
217
+
218
+ ## 错误处理
219
+
220
+ ### 必须覆盖的状态
221
+
222
+ - Loading
223
+ - Error
224
+ - Empty
225
+ - Data
226
+
227
+ ### 推荐做法
228
+
229
+ - 关键功能模块使用 Error Boundary 包裹,避免局部异常导致全页白屏
230
+ - 异步请求失败时必须给用户可见反馈
231
+ - 重要操作提供重试能力
232
+ - 不要吞错,不写空 `catch`
233
+
234
+ ### 示例(`react-error-boundary`,函数式 Fallback)
235
+
236
+ ```tsx
237
+ import { ErrorBoundary } from "react-error-boundary";
238
+
239
+ function ModuleErrorFallback({
240
+ resetErrorBoundary,
241
+ }: {
242
+ resetErrorBoundary: () => void;
243
+ }) {
244
+ return (
245
+ <div>
246
+ 模块加载失败
247
+ <button type="button" onClick={resetErrorBoundary}>
248
+ 重试
249
+ </button>
250
+ </div>
251
+ );
252
+ }
253
+
254
+ export function UserDashboardSection() {
255
+ return (
256
+ <ErrorBoundary FallbackComponent={ModuleErrorFallback}>
257
+ <UserDashboard />
258
+ </ErrorBoundary>
259
+ );
260
+ }
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Suspense 与懒加载
266
+
267
+ 适用场景:
268
+
269
+ - 路由级页面
270
+ - 图表、富文本编辑器、地图、重型表格等大体积组件
271
+ - 初始化成本较高的模块
272
+
273
+ 示例:
274
+
275
+ ```tsx
276
+ const HeavyChart = lazy(() => import("./components/HeavyChart"));
277
+
278
+ function Dashboard() {
279
+ return (
280
+ <Suspense fallback={<ChartSkeleton />}>
281
+ <HeavyChart data={chartData} />
282
+ </Suspense>
283
+ );
284
+ }
285
+ ```
286
+
287
+ 建议:
288
+
289
+ - 路由级优先 `lazy + Suspense`
290
+ - `fallback` 优先使用 Skeleton 或更贴近内容的占位态,而不是纯 spinner
291
+
292
+ ---
293
+
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: fec-refactor-clean
3
+ description: 用于安全移除前端死代码、未使用导出、陈旧组件、废弃路由、未使用依赖,或由 knip、depcheck、ts-prune、TypeScript、ESLint、人工审查发现的清理目标。不要用于会改变行为的功能重写;中文触发词包括 死代码、清理未使用、refactor clean、依赖清理、删除无用代码。
4
+ ---
5
+
6
+ # 重构清理
7
+
8
+ ## 用途
9
+
10
+ 在验证保护下识别并清理无用前端代码,减少技术债,同时避免误删动态引用、路由入口、配置文件和运行时约定。
11
+
12
+ ## 流程
13
+
14
+ 1. 先建立基线:运行或确认当前 lint、type-check、test、build 的状态。
15
+ 2. 收集候选项:
16
+ - 优先使用仓库已有工具,如 knip、depcheck、ts-prune、eslint、TypeScript。
17
+ - 没有工具时,用 `rg` 检查引用、导出、路由、注册点和文档入口。
18
+ 3. 按风险分类:
19
+ - SAFE:测试夹具、未引用工具函数、明确未导出的私有组件。
20
+ - CAUTION:共享组件、feature 入口、样式文件、Storybook stories。
21
+ - DANGER:路由、配置、package scripts、运行时模板、动态 import、插件元数据。
22
+ - UPGRADE:过期依赖、重复依赖、未使用依赖和安全告警先进入依赖升级或依赖清理评估,不与死代码删除混做。
23
+ 4. 只自动处理 SAFE 项;CAUTION 和 DANGER 需输出建议和证据,不直接删除。
24
+ 5. 每批清理后运行受影响验证命令。
25
+ 6. 若验证失败,停止扩大清理范围,先定位该批次。
26
+ 7. 清理结束后做行为等价复核:公开 API、路由、命令、模板、metadata、文档示例和报告输出仍可被引用。
27
+ 8. 对技术债排序:优先清理有验证保护、影响开发效率或阻塞升级的项目;低证据的大范围重写只输出建议。
28
+
29
+ ## 前端专项检查
30
+
31
+ - 检查 JSX/模板字符串、路由配置、barrel export、Storybook、测试、文档示例和动态组件注册。
32
+ - 样式文件需检查 className、CSS Modules、Tailwind safelist、全局选择器和主题变量。
33
+ - 依赖清理需检查构建插件、运行时模板、CLI scripts、monorepo 子包和 peer dependency。
34
+
35
+ ## 约束
36
+
37
+ - 不改变用户可见行为。
38
+ - 不删除无法证明无引用的公开 API、路由、模板或配置。
39
+ - 不用“一次大删除”替代可验证的小批次清理。
40
+ - 不把格式化、重命名或架构重写混入死代码清理。
41
+ - 不用“看起来没人用”作为证据;必须有搜索、工具输出、类型错误消失或测试保护。
42
+ - 不把依赖大版本升级伪装成清理;升级风险、release notes 和 lockfile 变更应分流到依赖升级工作流。
43
+
44
+ ## 详细参考
45
+
46
+ 撰写清理报告时,加载 [references/report-template.md](references/report-template.md)。
47
+
48
+ ## 预期输出
49
+
50
+ - 清理报告保存为 `reports/refactor-clean-YYYY-MM-DD-HHmmss.md`。
51
+ - 代码清理后相关验证命令通过,或明确说明阻塞原因。
52
+ ## 结构重构边界
53
+
54
+ 本工作流只负责已经证明无用/未使用的内容。如果代码仍在运行,问题属于过长函数、职责所有权、可变/派生数据、条件逻辑、API 形态或继承设计等结构重构,应分流到保持行为的结构重构,而不是以“清理”名义删除或重写。
@@ -0,0 +1,42 @@
1
+ # 重构清理报告模板
2
+
3
+ ```markdown
4
+ # 重构清理报告
5
+
6
+ > 生成时间: YYYY-MM-DD HH:mm
7
+ > 清理范围: 文件 / 模块 / 依赖 / 路由 / 样式
8
+
9
+ ## 基线验证
10
+
11
+ | 命令 | 清理前状态 | 清理后状态 | 备注 |
12
+ | --- | --- | --- | --- |
13
+ | `npm run lint` | 失败 / 通过 / 未运行 | 失败 / 通过 / 未运行 | ... |
14
+
15
+ ## 候选项与证据
16
+
17
+ | 候选项 | 证据 | 风险分类 |
18
+ | --- | --- | --- |
19
+ | `path/to/file.ts` | 工具输出 / rg 搜索 / 类型检查 | SAFE / CAUTION / DANGER / UPGRADE |
20
+
21
+ ## 已清理项
22
+
23
+ - 删除或修改的文件、导出、样式、依赖或配置
24
+ - 每项清理对应的证据
25
+
26
+ ## 跳过原因
27
+
28
+ - CAUTION / DANGER 项为什么没有自动处理
29
+ - 需要人工确认、运行时验证或专项流程的内容
30
+
31
+ ## 验证命令
32
+
33
+ - 执行的 lint、type-check、test、build 或手工验证
34
+ - 关键输出摘要
35
+
36
+ ## 剩余风险
37
+
38
+ - 动态引用、运行时模板、插件元数据或外部入口风险
39
+ - 建议后续清理或依赖升级项
40
+ ```
41
+
42
+ 清理完成后,将报告保存到 `reports/refactor-clean-YYYY-MM-DD-HHmmss.md`,并告知用户报告路径。
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: fec-refactoring
3
+ description: 用于在不改变可观察行为的前提下重组既有前端代码,包括职责提炼、模块搬移、条件逻辑简化、API 整理和数据组织。不要用于新增功能、改变行为的缺陷修复、依赖或框架迁移,以及已经证实的死代码清理。
4
+ ---
5
+
6
+ # 技能:保持行为的重构
7
+
8
+ ## 用途
9
+
10
+ 以小步、可验证、可回滚的方式重组仍在使用的前端代码,同时保持用户、调用方、测试、路由和集成能够观察到的行为不变。
11
+
12
+ ## 核心契约
13
+
14
+ 每次执行都遵守以下规则:
15
+
16
+ 1. **行为保持**:纯重构只改变内部结构,不主动改变可观察行为。
17
+ 2. **修改前基线**:编辑前先记录当前可用验证结果。
18
+ 3. **一次只做一个主要重构**:每一步只有一个主要结构意图。
19
+ 4. **每一步都验证**:完成一步后立即运行最小但有效的验证。
20
+ 5. **先回滚当前步骤,再讨论修复**:若当前步骤引入回归,先恢复到上一步,再缩小或重排方案。
21
+ 6. **重构与功能修改分离**:新增行为或改变行为的缺陷修复不属于纯重构。
22
+ 7. **优先最小安全重构**:有局部、可逆方案时,不直接扩大为架构重写。
23
+ 8. **遵守差异预算**:实际修改范围明显超出计划时必须停止并重新评估。
24
+
25
+ 纯重构采用 **GREEN → REFACTOR → GREEN**,不为了形式上的 TDD 人为制造失败行为测试。
26
+
27
+ ## 流程
28
+
29
+ 1. 分类请求,确认目标是结构调整且要求行为保持。
30
+ 2. 读取项目配置、受影响模块、公开导出、路由、状态边界、测试和当前 diff。
31
+ 3. 记录相关可观察契约:输入、输出、异常、副作用、UI 状态、事件、网络请求、状态迁移、路由和公开 API。
32
+ 4. 建立修改前基线;既有失败要单独记录,不能算到后续重构头上。
33
+ 5. 基于证据诊断结构问题,并检查可能的误判。
34
+ 6. 建立安全网:优先复用已有测试,风险较高且覆盖不足时再补当前行为的特征测试。
35
+ 7. 把方案拆成有顺序的小步,每步记录手法、原因、前置条件、风险、差异预算、验证和回滚边界。
36
+ 8. 每次只执行一个主要结构变换,不夹带无关清理、格式化和重新设计。
37
+ 9. 立即验证,并比较实际修改范围与差异预算。
38
+ 10. 若出现新回归,先回滚当前步骤,确认基线恢复,再缩小或调整顺序。
39
+ 11. 最后按需要运行类型检查、测试、构建、E2E、无障碍或其他专项门禁。
40
+ 12. 根据证据给出 PASS、PARTIAL 或 NOT PROVEN,不夸大验证强度。
41
+
42
+ ## 风险分级
43
+
44
+ | 风险 | 常见范围 | 默认动作 |
45
+ | --- | --- | --- |
46
+ | `SAFE` | 局部私有代码、契约稳定、容易回滚 | 可执行,并逐步验证 |
47
+ | `CAUTION` | 跨模块、共享状态、导入、Hook/Composable、生命周期 | 安全证据充分时执行,否则先规划 |
48
+ | `DANGER` | 公开 API、路由、持久化、网络契约、认证、SSR/水合、大范围状态或继承改造 | 默认先规划并停止等待明确授权 |
49
+
50
+ 风险由上下文决定,不能只凭手法名称判定安全级别。
51
+
52
+ ## 差异预算
53
+
54
+ 每个可执行步骤先写清:
55
+
56
+ ```text
57
+ 预期文件数:N
58
+ 预期函数/组件数:N
59
+ 预期公开 API 变化:0
60
+ 预期行为变化:0
61
+ ```
62
+
63
+ 如果实际 diff 明显超出预算,停止并重新评估,不能静默扩大成重新设计。
64
+
65
+ ## 参考资料
66
+
67
+ - 安全规则、证据模型和风险语言见 [principles.md](references/principles.md)。
68
+ - 状态机、基线、回滚和报告契约见 [workflow.md](references/workflow.md)。
69
+ - 判断何时重构或何时延后见 [when-to-refactor.md](references/when-to-refactor.md)。
70
+ - 区分重构、功能、缺陷、清理、迁移和评审见 [refactoring-vs-feature-change.md](references/refactoring-vs-feature-change.md)。
71
+
72
+ ## 约束
73
+
74
+ - 不修改测试来接受被重构意外改变的业务行为。
75
+ - 未有充分证据时,不把认证、权限、路由、持久化、协议或公开包契约变化标为 `SAFE`。
76
+ - 当前步骤出现新失败后,不继续叠加结构修改。
77
+ - 项目没有测试框架时,不自动安装新框架。
78
+ - 行数、复杂度、注释、一个 switch 或链式调用都不能单独证明存在坏味道。
79
+ - 默认不执行远程 Git 写入。
80
+
81
+ ## 预期输出
82
+
83
+ 输出带证据、风险、差异预算、逐步验证和必要回滚记录的重构方案或实现,并给出 PASS、PARTIAL 或 NOT PROVEN 的行为保持结论。
@@ -0,0 +1,43 @@
1
+ # 重构原则
2
+
3
+ ## 定义
4
+
5
+ 重构是在不主动改变可观察行为的前提下调整既有代码内部结构,目标是让后续修改更容易理解、定位、验证和回滚,而不是把新功能偷偷塞进结构修改。
6
+
7
+ ## 八条硬规则
8
+
9
+ 1. **行为保持**:开始重要修改前先明确相关可观察契约。
10
+ 2. **修改前基线**:把既有失败与当前步骤新引入的回归区分开。
11
+ 3. **一次一个主要重构**:每一步只承担一个结构意图。
12
+ 4. **每一步都验证**:完成一步立即运行最小有效反馈。
13
+ 5. **先回滚再修复**:当前步骤导致新回归时,先恢复,再缩小或重排。
14
+ 6. **功能修改分离**:新增结果、改变规则、改变错误行为都不属于纯重构。
15
+ 7. **最小安全重构优先**:优先局部、可逆、证据充分的变换。
16
+ 8. **遵守差异预算**:修改范围膨胀是停止信号,不是继续扩张的理由。
17
+
18
+ ## 可观察行为
19
+
20
+ 按实际范围检查:
21
+
22
+ - 返回值、异常和错误映射;
23
+ - 副作用及有业务意义的顺序;
24
+ - 请求、载荷、重试、取消和认证行为;
25
+ - 状态迁移、持久化、缓存身份和 memoization 依赖的对象身份;
26
+ - DOM、加载/错误/空状态、焦点、键盘和事件;
27
+ - props、emits、slots、Hook/Composable 契约、包导出、路由和 URL。
28
+
29
+ ## 证据模型
30
+
31
+ 优先使用调用点、依赖方向、数据所有权、变更位置、已有测试、公开契约、动态注册点、路由、i18n、Storybook、样式动态引用以及框架生命周期语义。度量值只负责提示“去哪里看”,不能单独下诊断结论。
32
+
33
+ ## 风险模型
34
+
35
+ - **SAFE**:局部私有范围、契约稳定、容易回滚并有对应验证。
36
+ - **CAUTION**:跨文件/组件、共享辅助模块、状态所有权、生命周期或动态引用,或者行为覆盖不完整。
37
+ - **DANGER**:公开 API、路由、存储结构、后端契约、认证权限、SSR/水合、关键计算、大范围继承或状态架构替换。
38
+
39
+ 同一手法在不同上下文风险可能完全不同,例如局部变量改名可以很安全,而序列化字段改名可能影响外部契约。
40
+
41
+ ## 风险修改前的特征测试
42
+
43
+ 重要行为覆盖不足时,可以先补描述当前实际行为的特征测试。它第一次运行可以直接为绿,因为目的只是锁定既有行为,不是创造新需求。
@@ -0,0 +1,25 @@
1
+ # 重构与相邻工作的边界
2
+
3
+ ## 纯重构
4
+
5
+ 目标是改善职责、命名、封装、位置、条件逻辑、API 形状或数据组织,并明确要求不改变调用方/用户可观察行为时,属于纯重构。验证模型是 **GREEN → REFACTOR → GREEN**。
6
+
7
+ ## 功能或改变行为的缺陷修复
8
+
9
+ 新增能力、改变业务规则、改变接受输入、改变可见输出、改变错误结果或主动改变副作用,都不是纯重构。应先用失败行为测试表达新期望,再实现。
10
+
11
+ ## 调试
12
+
13
+ 故障原因未知时,应先找到根因。后续修复可能包含重构,但不能用“重构一下”代替故障证据。
14
+
15
+ ## 死代码清理
16
+
17
+ 已证实未使用的代码、导出、依赖、路由等需要专门检查动态 import、配置、模板、Storybook、CSS、i18n 和生成内容,不能与活代码的大范围结构改写混做。
18
+
19
+ ## 迁移
20
+
21
+ 框架、依赖、路由、构建系统、状态库或整体架构迁移会主动跨越兼容边界,即使设计因此更好,也应按迁移规划处理。
22
+
23
+ ## 普通评审
24
+
25
+ 合并前评审可以指出结构问题,但默认先输出报告;若要诊断或执行重构,应作为明确的后续动作,而不是评审过程中静默改写源码。