universal-dev-standards 6.14.0-beta.9 → 6.14.1-beta.1

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 (721) hide show
  1. package/bin/uds.js +12 -1
  2. package/bundled/ai/options/commit-message/traditional-chinese.ai.yaml +69 -67
  3. package/bundled/ai/standards/commit-message.ai.yaml +12 -2
  4. package/bundled/ai/standards/mock-boundary.ai.yaml +138 -2
  5. package/bundled/ai/standards/secret-management-standards.ai.yaml +12 -1
  6. package/bundled/ai/standards/turn-completion-integrity.ai.yaml +6 -2
  7. package/bundled/core/commit-message-guide.md +22 -19
  8. package/bundled/core/mock-boundary.md +70 -2
  9. package/bundled/core/secret-management-standards.md +13 -1
  10. package/bundled/core/turn-completion-integrity.md +8 -2
  11. package/bundled/extensions/locales/zh-tw.md +19 -19
  12. package/bundled/hooks/check-dangerous-cmd.mjs +161 -26
  13. package/bundled/hooks/check-logging-standard.mjs +35 -6
  14. package/bundled/hooks/validate-commit-msg.mjs +317 -28
  15. package/bundled/locales/zh-CN/CHANGELOG.md +2323 -1099
  16. package/bundled/locales/zh-CN/CLAUDE.md +987 -101
  17. package/bundled/locales/zh-CN/README.md +3 -3
  18. package/bundled/locales/zh-CN/SECURITY.md +4 -3
  19. package/bundled/locales/zh-CN/STANDARDS-MAPPING.md +103 -6
  20. package/bundled/locales/zh-CN/adoption/ADOPTION-GUIDE.md +68 -97
  21. package/bundled/locales/zh-CN/adoption/DAILY-WORKFLOW-GUIDE.md +2 -1
  22. package/bundled/locales/zh-CN/adoption/STATIC-DYNAMIC-GUIDE.md +8 -9
  23. package/bundled/locales/zh-CN/adoption/checklists/enterprise.md +81 -80
  24. package/bundled/locales/zh-CN/adoption/checklists/minimal.md +18 -14
  25. package/bundled/locales/zh-CN/adoption/checklists/recommended.md +49 -46
  26. package/bundled/locales/zh-CN/ai/MAINTENANCE.md +44 -9
  27. package/bundled/locales/zh-CN/ai/options/commit-message/traditional-chinese.ai.yaml +63 -55
  28. package/bundled/locales/zh-CN/core/acceptance-criteria-traceability.md +61 -14
  29. package/bundled/locales/zh-CN/core/acceptance-test-driven-development.md +2 -1
  30. package/bundled/locales/zh-CN/core/accessibility-standards.md +871 -62
  31. package/bundled/locales/zh-CN/core/adr-standards.md +155 -32
  32. package/bundled/locales/zh-CN/core/agent-communication-protocol.md +2 -1
  33. package/bundled/locales/zh-CN/core/agent-dispatch.md +68 -33
  34. package/bundled/locales/zh-CN/core/ai-agreement-standards.md +23 -22
  35. package/bundled/locales/zh-CN/core/ai-command-behavior.md +2 -1
  36. package/bundled/locales/zh-CN/core/ai-friendly-architecture.md +311 -72
  37. package/bundled/locales/zh-CN/core/ai-instruction-standards.md +71 -49
  38. package/bundled/locales/zh-CN/core/ai-response-navigation.md +2 -1
  39. package/bundled/locales/zh-CN/core/alerting-standards.md +231 -36
  40. package/bundled/locales/zh-CN/core/anti-hallucination.md +116 -697
  41. package/bundled/locales/zh-CN/core/anti-sycophancy-prompting.md +34 -33
  42. package/bundled/locales/zh-CN/core/api-design-standards.md +144 -58
  43. package/bundled/locales/zh-CN/core/behavior-driven-development.md +2 -1
  44. package/bundled/locales/zh-CN/core/branch-completion.md +75 -20
  45. package/bundled/locales/zh-CN/core/capability-declaration.md +44 -94
  46. package/bundled/locales/zh-CN/core/change-batching-standards.md +2 -1
  47. package/bundled/locales/zh-CN/core/changelog-standards.md +485 -63
  48. package/bundled/locales/zh-CN/core/chaos-engineering-standards.md +141 -39
  49. package/bundled/locales/zh-CN/core/checkin-standards.md +176 -116
  50. package/bundled/locales/zh-CN/core/circuit-breaker.md +43 -77
  51. package/bundled/locales/zh-CN/core/code-review-checklist.md +37 -23
  52. package/bundled/locales/zh-CN/core/commit-message-guide.md +892 -69
  53. package/bundled/locales/zh-CN/core/containerization-standards.md +259 -57
  54. package/bundled/locales/zh-CN/core/context-aware-loading.md +103 -29
  55. package/bundled/locales/zh-CN/core/database-standards.md +115 -114
  56. package/bundled/locales/zh-CN/core/deprecation-standards.md +155 -40
  57. package/bundled/locales/zh-CN/core/design-document-standards.md +265 -55
  58. package/bundled/locales/zh-CN/core/developer-memory.md +150 -60
  59. package/bundled/locales/zh-CN/core/documentation-lifecycle.md +20 -16
  60. package/bundled/locales/zh-CN/core/documentation-structure.md +1284 -127
  61. package/bundled/locales/zh-CN/core/documentation-writing-standards.md +649 -259
  62. package/bundled/locales/zh-CN/core/dual-phase-output.md +37 -70
  63. package/bundled/locales/zh-CN/core/environment-standards.md +251 -73
  64. package/bundled/locales/zh-CN/core/error-code-standards.md +501 -60
  65. package/bundled/locales/zh-CN/core/estimation-standards.md +174 -41
  66. package/bundled/locales/zh-CN/core/execution-history.md +2 -1
  67. package/bundled/locales/zh-CN/core/failure-source-taxonomy.md +71 -84
  68. package/bundled/locales/zh-CN/core/feature-flag-standards.md +202 -57
  69. package/bundled/locales/zh-CN/core/forward-derivation-standards.md +613 -154
  70. package/bundled/locales/zh-CN/core/frontend-design-standards.md +361 -78
  71. package/bundled/locales/zh-CN/core/git-workflow.md +148 -262
  72. package/bundled/locales/zh-CN/core/git-worktree.md +59 -26
  73. package/bundled/locales/zh-CN/core/guides/file-placement-guide.md +132 -48
  74. package/bundled/locales/zh-CN/core/guides/performance-guide.md +61 -59
  75. package/bundled/locales/zh-CN/core/guides/security-guide.md +2 -0
  76. package/bundled/locales/zh-CN/core/health-check-standards.md +46 -104
  77. package/bundled/locales/zh-CN/core/immutability-first.md +83 -60
  78. package/bundled/locales/zh-CN/core/knowledge-transfer-standards.md +94 -31
  79. package/bundled/locales/zh-CN/core/mock-boundary.md +74 -6
  80. package/bundled/locales/zh-CN/core/mutation-testing.md +45 -6
  81. package/bundled/locales/zh-CN/core/observability-standards.md +281 -37
  82. package/bundled/locales/zh-CN/core/performance-standards.md +402 -42
  83. package/bundled/locales/zh-CN/core/pipeline-integration-standards.md +2 -1
  84. package/bundled/locales/zh-CN/core/postmortem-standards.md +358 -53
  85. package/bundled/locales/zh-CN/core/privacy-standards.md +148 -40
  86. package/bundled/locales/zh-CN/core/project-context-memory.md +182 -48
  87. package/bundled/locales/zh-CN/core/project-structure.md +550 -170
  88. package/bundled/locales/zh-CN/core/recovery-recipe-registry.md +54 -114
  89. package/bundled/locales/zh-CN/core/refactoring-standards.md +141 -556
  90. package/bundled/locales/zh-CN/core/requirement-engineering.md +7 -6
  91. package/bundled/locales/zh-CN/core/retrospective-standards.md +215 -22
  92. package/bundled/locales/zh-CN/core/retry-standards.md +46 -101
  93. package/bundled/locales/zh-CN/core/reverse-engineering-standards.md +370 -120
  94. package/bundled/locales/zh-CN/core/runbook-standards.md +294 -48
  95. package/bundled/locales/zh-CN/core/security-decision.md +45 -70
  96. package/bundled/locales/zh-CN/core/security-standards.md +169 -16
  97. package/bundled/locales/zh-CN/core/skill-standard-alignment-check.md +105 -71
  98. package/bundled/locales/zh-CN/core/slo-standards.md +296 -44
  99. package/bundled/locales/zh-CN/core/spec-driven-development.md +37 -6
  100. package/bundled/locales/zh-CN/core/standard-admission-criteria.md +25 -31
  101. package/bundled/locales/zh-CN/core/standard-lifecycle-management.md +49 -57
  102. package/bundled/locales/zh-CN/core/structured-task-definition.md +2 -1
  103. package/bundled/locales/zh-CN/core/supply-chain-security-standards.md +159 -32
  104. package/bundled/locales/zh-CN/core/systematic-debugging.md +87 -42
  105. package/bundled/locales/zh-CN/core/tech-debt-standards.md +202 -86
  106. package/bundled/locales/zh-CN/core/test-completeness-dimensions.md +262 -190
  107. package/bundled/locales/zh-CN/core/test-data-standards.md +252 -30
  108. package/bundled/locales/zh-CN/core/test-driven-development.md +21 -1022
  109. package/bundled/locales/zh-CN/core/test-governance.md +94 -43
  110. package/bundled/locales/zh-CN/core/testing-standards.md +83 -37
  111. package/bundled/locales/zh-CN/core/timeout-standards.md +45 -85
  112. package/bundled/locales/zh-CN/core/token-budget.md +44 -80
  113. package/bundled/locales/zh-CN/core/translation-lifecycle-standards.md +48 -36
  114. package/bundled/locales/zh-CN/core/turn-completion-integrity.md +8 -6
  115. package/bundled/locales/zh-CN/core/verification-evidence.md +44 -22
  116. package/bundled/locales/zh-CN/core/versioning.md +737 -73
  117. package/bundled/locales/zh-CN/core/virtual-organization-standards.md +30 -29
  118. package/bundled/locales/zh-CN/core/workflow-enforcement.md +9 -8
  119. package/bundled/locales/zh-CN/core/workflow-state-protocol.md +9 -8
  120. package/bundled/locales/zh-CN/docs/CHEATSHEET.md +2 -1
  121. package/bundled/locales/zh-CN/docs/CLI-FLOW.md +2 -1
  122. package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +19 -10
  123. package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +8 -6
  124. package/bundled/locales/zh-CN/docs/STANDARDS-REFERENCE.md +2 -1
  125. package/bundled/locales/zh-CN/docs/USAGE-MODES-COMPARISON.md +133 -132
  126. package/bundled/locales/zh-CN/docs/USER-MANUAL.md +11 -3
  127. package/bundled/locales/zh-CN/docs/WINDOWS-GUIDE.md +5 -2
  128. package/bundled/locales/zh-CN/docs/specs/system/memory-adoption-strategy.md +2 -0
  129. package/bundled/locales/zh-CN/docs/user/FAQ.md +2 -0
  130. package/bundled/locales/zh-CN/docs/user/GETTING-STARTED.md +2 -0
  131. package/bundled/locales/zh-CN/docs/user/GLOSSARY.md +2 -0
  132. package/bundled/locales/zh-CN/docs/user/README.md +4 -2
  133. package/bundled/locales/zh-CN/docs/user/TROUBLESHOOTING.md +2 -0
  134. package/bundled/locales/zh-CN/integrations/codex/AGENTS.md +136 -2
  135. package/bundled/locales/zh-CN/integrations/codex/README.md +62 -10
  136. package/bundled/locales/zh-CN/integrations/gemini-cli/GEMINI.md +59 -1
  137. package/bundled/locales/zh-CN/integrations/gemini-cli/README.md +9 -2
  138. package/bundled/locales/zh-CN/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +7 -1
  139. package/bundled/locales/zh-CN/integrations/github-copilot/README.md +8 -2
  140. package/bundled/locales/zh-CN/integrations/github-copilot/copilot-instructions.md +146 -12
  141. package/bundled/locales/zh-CN/integrations/github-copilot/skills-mapping.md +7 -1
  142. package/bundled/locales/zh-CN/integrations/google-antigravity/AGENTS.md +110 -3
  143. package/bundled/locales/zh-CN/integrations/google-antigravity/README.md +7 -1
  144. package/bundled/locales/zh-CN/integrations/opencode/AGENTS.md +140 -2
  145. package/bundled/locales/zh-CN/integrations/opencode/README.md +7 -1
  146. package/bundled/locales/zh-CN/integrations/opencode/skills-mapping.md +8 -2
  147. package/bundled/locales/zh-CN/integrations/openspec/AGENTS.md +46 -1
  148. package/bundled/locales/zh-CN/integrations/openspec/README.md +7 -1
  149. package/bundled/locales/zh-CN/integrations/spec-kit/AGENTS.md +20 -2
  150. package/bundled/locales/zh-CN/integrations/spec-kit/README.md +7 -1
  151. package/bundled/locales/zh-CN/options/changelog/auto-generated.md +2 -0
  152. package/bundled/locales/zh-CN/options/changelog/keep-a-changelog.md +2 -0
  153. package/bundled/locales/zh-CN/options/code-review/automated-review.md +2 -0
  154. package/bundled/locales/zh-CN/options/code-review/pair-programming.md +2 -0
  155. package/bundled/locales/zh-CN/options/commit-message/bilingual.md +139 -50
  156. package/bundled/locales/zh-CN/options/commit-message/english.md +159 -42
  157. package/bundled/locales/zh-CN/options/commit-message/traditional-chinese.md +156 -75
  158. package/bundled/locales/zh-CN/options/documentation/api-docs.md +3 -1
  159. package/bundled/locales/zh-CN/options/documentation/markdown-docs.md +2 -0
  160. package/bundled/locales/zh-CN/options/documentation/wiki-style.md +2 -0
  161. package/bundled/locales/zh-CN/options/git-workflow/gitflow.md +105 -77
  162. package/bundled/locales/zh-CN/options/git-workflow/github-flow.md +75 -57
  163. package/bundled/locales/zh-CN/options/git-workflow/merge-commit.md +155 -44
  164. package/bundled/locales/zh-CN/options/git-workflow/rebase-ff.md +168 -53
  165. package/bundled/locales/zh-CN/options/git-workflow/squash-merge.md +122 -37
  166. package/bundled/locales/zh-CN/options/git-workflow/trunk-based.md +108 -61
  167. package/bundled/locales/zh-CN/options/project-structure/dotnet.md +266 -47
  168. package/bundled/locales/zh-CN/options/project-structure/go.md +301 -43
  169. package/bundled/locales/zh-CN/options/project-structure/java.md +268 -48
  170. package/bundled/locales/zh-CN/options/project-structure/kotlin.md +2 -0
  171. package/bundled/locales/zh-CN/options/project-structure/nodejs.md +168 -51
  172. package/bundled/locales/zh-CN/options/project-structure/php.md +2 -0
  173. package/bundled/locales/zh-CN/options/project-structure/python.md +210 -52
  174. package/bundled/locales/zh-CN/options/project-structure/ruby.md +2 -0
  175. package/bundled/locales/zh-CN/options/project-structure/rust.md +2 -0
  176. package/bundled/locales/zh-CN/options/project-structure/swift.md +2 -0
  177. package/bundled/locales/zh-CN/options/testing/contract-testing.md +2 -0
  178. package/bundled/locales/zh-CN/options/testing/e2e-testing.md +227 -66
  179. package/bundled/locales/zh-CN/options/testing/industry-pyramid.md +2 -0
  180. package/bundled/locales/zh-CN/options/testing/integration-testing.md +185 -73
  181. package/bundled/locales/zh-CN/options/testing/istqb-framework.md +2 -0
  182. package/bundled/locales/zh-CN/options/testing/performance-testing.md +2 -0
  183. package/bundled/locales/zh-CN/options/testing/security-testing.md +2 -0
  184. package/bundled/locales/zh-CN/options/testing/system-testing.md +270 -96
  185. package/bundled/locales/zh-CN/options/testing/unit-testing.md +185 -71
  186. package/bundled/locales/zh-CN/skills/CONTRIBUTING.template.md +43 -42
  187. package/bundled/locales/zh-CN/skills/INTEGRATION-GUIDE.md +2 -1
  188. package/bundled/locales/zh-CN/skills/README.md +2 -1
  189. package/bundled/locales/zh-CN/skills/_shared/README.md +2 -1
  190. package/bundled/locales/zh-CN/skills/adr-assistant/guide.md +240 -4
  191. package/bundled/locales/zh-CN/skills/agents/README.md +180 -82
  192. package/bundled/locales/zh-CN/skills/agents/code-architect.md +3 -1
  193. package/bundled/locales/zh-CN/skills/agents/doc-writer.md +3 -1
  194. package/bundled/locales/zh-CN/skills/agents/reviewer.md +4 -2
  195. package/bundled/locales/zh-CN/skills/agents/spec-analyst.md +3 -1
  196. package/bundled/locales/zh-CN/skills/agents/test-specialist.md +3 -1
  197. package/bundled/locales/zh-CN/skills/ai-collaboration-standards/SKILL.md +91 -81
  198. package/bundled/locales/zh-CN/skills/ai-collaboration-standards/anti-hallucination.md +79 -59
  199. package/bundled/locales/zh-CN/skills/ai-collaboration-standards/certainty-labels.md +66 -40
  200. package/bundled/locales/zh-CN/skills/ai-friendly-architecture/SKILL.md +23 -36
  201. package/bundled/locales/zh-CN/skills/ai-instruction-standards/SKILL.md +217 -137
  202. package/bundled/locales/zh-CN/skills/api-design-assistant/SKILL.md +13 -2
  203. package/bundled/locales/zh-CN/skills/atdd-assistant/SKILL.md +16 -2
  204. package/bundled/locales/zh-CN/skills/atdd-assistant/acceptance-criteria-guide.md +2 -1
  205. package/bundled/locales/zh-CN/skills/atdd-assistant/atdd-workflow.md +98 -1
  206. package/bundled/locales/zh-CN/skills/atdd-assistant/guide.md +148 -132
  207. package/bundled/locales/zh-CN/skills/audit-assistant/SKILL.md +5 -2
  208. package/bundled/locales/zh-CN/skills/bdd-assistant/SKILL.md +16 -2
  209. package/bundled/locales/zh-CN/skills/bdd-assistant/bdd-workflow.md +2 -1
  210. package/bundled/locales/zh-CN/skills/bdd-assistant/gherkin-guide.md +2 -1
  211. package/bundled/locales/zh-CN/skills/bdd-assistant/guide.md +122 -121
  212. package/bundled/locales/zh-CN/skills/changelog-guide/SKILL.md +9 -2
  213. package/bundled/locales/zh-CN/skills/changelog-guide/guide.md +91 -88
  214. package/bundled/locales/zh-CN/skills/checkin-assistant/SKILL.md +12 -2
  215. package/bundled/locales/zh-CN/skills/checkin-assistant/guide.md +211 -210
  216. package/bundled/locales/zh-CN/skills/ci-cd-assistant/SKILL.md +14 -2
  217. package/bundled/locales/zh-CN/skills/code-review-assistant/SKILL.md +12 -2
  218. package/bundled/locales/zh-CN/skills/code-review-assistant/checkin-checklist.md +79 -78
  219. package/bundled/locales/zh-CN/skills/code-review-assistant/guide.md +119 -45
  220. package/bundled/locales/zh-CN/skills/code-review-assistant/review-checklist.md +89 -88
  221. package/bundled/locales/zh-CN/skills/commands/ac-coverage.md +43 -1
  222. package/bundled/locales/zh-CN/skills/commands/api-design.md +2 -1
  223. package/bundled/locales/zh-CN/skills/commands/atdd.md +71 -1
  224. package/bundled/locales/zh-CN/skills/commands/audit.md +2 -1
  225. package/bundled/locales/zh-CN/skills/commands/bdd.md +160 -62
  226. package/bundled/locales/zh-CN/skills/commands/changelog.md +36 -1
  227. package/bundled/locales/zh-CN/skills/commands/check.md +53 -1
  228. package/bundled/locales/zh-CN/skills/commands/checkin.md +45 -1
  229. package/bundled/locales/zh-CN/skills/commands/ci-cd.md +3 -2
  230. package/bundled/locales/zh-CN/skills/commands/code-review.md +41 -1
  231. package/bundled/locales/zh-CN/skills/commands/commit.md +56 -1
  232. package/bundled/locales/zh-CN/skills/commands/config.md +50 -1
  233. package/bundled/locales/zh-CN/skills/commands/coverage.md +43 -1
  234. package/bundled/locales/zh-CN/skills/commands/database.md +4 -3
  235. package/bundled/locales/zh-CN/skills/commands/derive-all.md +42 -1
  236. package/bundled/locales/zh-CN/skills/commands/derive-atdd.md +35 -1
  237. package/bundled/locales/zh-CN/skills/commands/derive-bdd.md +41 -1
  238. package/bundled/locales/zh-CN/skills/commands/derive-tdd.md +42 -1
  239. package/bundled/locales/zh-CN/skills/commands/derive.md +60 -4
  240. package/bundled/locales/zh-CN/skills/commands/dev-workflow.md +58 -8
  241. package/bundled/locales/zh-CN/skills/commands/discover.md +41 -1
  242. package/bundled/locales/zh-CN/skills/commands/docgen.md +37 -1
  243. package/bundled/locales/zh-CN/skills/commands/docs.md +136 -5
  244. package/bundled/locales/zh-CN/skills/commands/durable.md +4 -3
  245. package/bundled/locales/zh-CN/skills/commands/e2e.md +85 -1
  246. package/bundled/locales/zh-CN/skills/commands/guide.md +2 -1
  247. package/bundled/locales/zh-CN/skills/commands/incident.md +5 -4
  248. package/bundled/locales/zh-CN/skills/commands/init.md +57 -1
  249. package/bundled/locales/zh-CN/skills/commands/methodology.md +166 -77
  250. package/bundled/locales/zh-CN/skills/commands/metrics.md +3 -2
  251. package/bundled/locales/zh-CN/skills/commands/migrate.md +5 -4
  252. package/bundled/locales/zh-CN/skills/commands/observability.md +48 -3
  253. package/bundled/locales/zh-CN/skills/commands/pr.md +4 -3
  254. package/bundled/locales/zh-CN/skills/commands/refactor.md +76 -38
  255. package/bundled/locales/zh-CN/skills/commands/release.md +82 -1
  256. package/bundled/locales/zh-CN/skills/commands/requirement.md +40 -1
  257. package/bundled/locales/zh-CN/skills/commands/reverse-bdd.md +36 -1
  258. package/bundled/locales/zh-CN/skills/commands/reverse-sdd.md +44 -1
  259. package/bundled/locales/zh-CN/skills/commands/reverse-tdd.md +42 -1
  260. package/bundled/locales/zh-CN/skills/commands/reverse.md +43 -1
  261. package/bundled/locales/zh-CN/skills/commands/runbook.md +50 -3
  262. package/bundled/locales/zh-CN/skills/commands/scan.md +3 -2
  263. package/bundled/locales/zh-CN/skills/commands/sdd-retro.md +50 -1
  264. package/bundled/locales/zh-CN/skills/commands/sdd.md +182 -1
  265. package/bundled/locales/zh-CN/skills/commands/security.md +3 -2
  266. package/bundled/locales/zh-CN/skills/commands/slo.md +51 -3
  267. package/bundled/locales/zh-CN/skills/commands/tdd.md +74 -5
  268. package/bundled/locales/zh-CN/skills/commands/update.md +70 -8
  269. package/bundled/locales/zh-CN/skills/commit-standards/SKILL.md +4 -4
  270. package/bundled/locales/zh-CN/skills/commit-standards/conventional-commits.md +45 -44
  271. package/bundled/locales/zh-CN/skills/commit-standards/guide.md +172 -52
  272. package/bundled/locales/zh-CN/skills/commit-standards/language-options.md +50 -47
  273. package/bundled/locales/zh-CN/skills/contract-test-assistant/SKILL.md +2 -2
  274. package/bundled/locales/zh-CN/skills/contract-test-assistant/guide.md +76 -1
  275. package/bundled/locales/zh-CN/skills/database-assistant/SKILL.md +18 -5
  276. package/bundled/locales/zh-CN/skills/dev-methodology/SKILL.md +4 -2
  277. package/bundled/locales/zh-CN/skills/dev-methodology/create-methodology.md +2 -0
  278. package/bundled/locales/zh-CN/skills/dev-methodology/runtime.md +2 -0
  279. package/bundled/locales/zh-CN/skills/docs-generator/SKILL.md +16 -2
  280. package/bundled/locales/zh-CN/skills/docs-generator/guide.md +8 -7
  281. package/bundled/locales/zh-CN/skills/documentation-guide/SKILL.md +209 -184
  282. package/bundled/locales/zh-CN/skills/documentation-guide/documentation-structure.md +73 -72
  283. package/bundled/locales/zh-CN/skills/documentation-guide/readme-template.md +37 -36
  284. package/bundled/locales/zh-CN/skills/durable-execution-assistant/SKILL.md +28 -2
  285. package/bundled/locales/zh-CN/skills/e2e-assistant/SKILL.md +21 -6
  286. package/bundled/locales/zh-CN/skills/error-code-guide/SKILL.md +76 -95
  287. package/bundled/locales/zh-CN/skills/git-workflow-guide/SKILL.md +80 -87
  288. package/bundled/locales/zh-CN/skills/git-workflow-guide/branch-naming.md +44 -43
  289. package/bundled/locales/zh-CN/skills/git-workflow-guide/git-workflow.md +66 -65
  290. package/bundled/locales/zh-CN/skills/incident-response-assistant/SKILL.md +31 -13
  291. package/bundled/locales/zh-CN/skills/metrics-dashboard-assistant/SKILL.md +38 -2
  292. package/bundled/locales/zh-CN/skills/observability-assistant/SKILL.md +75 -1
  293. package/bundled/locales/zh-CN/skills/pr-automation-assistant/SKILL.md +32 -6
  294. package/bundled/locales/zh-CN/skills/project-discovery/SKILL.md +8 -2
  295. package/bundled/locales/zh-CN/skills/project-discovery/guide.md +158 -157
  296. package/bundled/locales/zh-CN/skills/project-structure-guide/SKILL.md +49 -46
  297. package/bundled/locales/zh-CN/skills/project-structure-guide/language-patterns.md +8 -7
  298. package/bundled/locales/zh-CN/skills/refactoring-assistant/SKILL.md +22 -2
  299. package/bundled/locales/zh-CN/skills/refactoring-assistant/guide.md +172 -171
  300. package/bundled/locales/zh-CN/skills/release-standards/SKILL.md +66 -23
  301. package/bundled/locales/zh-CN/skills/release-standards/changelog-format.md +42 -41
  302. package/bundled/locales/zh-CN/skills/release-standards/guide.md +51 -43
  303. package/bundled/locales/zh-CN/skills/release-standards/release-workflow.md +131 -95
  304. package/bundled/locales/zh-CN/skills/release-standards/semantic-versioning.md +62 -61
  305. package/bundled/locales/zh-CN/skills/requirement-assistant/SKILL.md +24 -15
  306. package/bundled/locales/zh-CN/skills/requirement-assistant/guide.md +88 -79
  307. package/bundled/locales/zh-CN/skills/requirement-assistant/requirement-checklist.md +128 -127
  308. package/bundled/locales/zh-CN/skills/requirement-assistant/requirement-writing.md +121 -120
  309. package/bundled/locales/zh-CN/skills/retrospective-assistant/guide.md +206 -2
  310. package/bundled/locales/zh-CN/skills/reverse-engineer/SKILL.md +2 -2
  311. package/bundled/locales/zh-CN/skills/reverse-engineer/bdd-extraction.md +2 -1
  312. package/bundled/locales/zh-CN/skills/reverse-engineer/guide.md +297 -173
  313. package/bundled/locales/zh-CN/skills/reverse-engineer/tdd-analysis.md +2 -1
  314. package/bundled/locales/zh-CN/skills/reverse-engineer/workflow.md +2 -1
  315. package/bundled/locales/zh-CN/skills/runbook-assistant/SKILL.md +9 -2
  316. package/bundled/locales/zh-CN/skills/security-assistant/SKILL.md +24 -6
  317. package/bundled/locales/zh-CN/skills/security-scan-assistant/SKILL.md +34 -10
  318. package/bundled/locales/zh-CN/skills/slo-assistant/SKILL.md +2 -1
  319. package/bundled/locales/zh-CN/skills/spec-derivation/SKILL.md +2 -2
  320. package/bundled/locales/zh-CN/skills/spec-driven-dev/guide.md +38 -6
  321. package/bundled/locales/zh-CN/skills/tdd-assistant/SKILL.md +16 -3
  322. package/bundled/locales/zh-CN/skills/tdd-assistant/guide.md +217 -156
  323. package/bundled/locales/zh-CN/skills/tdd-assistant/language-examples.md +727 -82
  324. package/bundled/locales/zh-CN/skills/tdd-assistant/tdd-workflow.md +396 -214
  325. package/bundled/locales/zh-CN/skills/test-coverage-assistant/SKILL.md +14 -5
  326. package/bundled/locales/zh-CN/skills/test-coverage-assistant/guide.md +25 -12
  327. package/bundled/locales/zh-CN/skills/testing-guide/testing-pyramid.md +99 -98
  328. package/bundled/locales/zh-CN/skills/testing-guide/testing-theory.md +3 -1
  329. package/bundled/locales/zh-CN/skills/tools/cline/README.md +2 -1
  330. package/bundled/locales/zh-CN/skills/tools/copilot/README.md +65 -18
  331. package/bundled/locales/zh-CN/skills/tools/copilot/copilot-instructions.md +2 -1
  332. package/bundled/locales/zh-CN/skills/tools/cursor/README.md +2 -1
  333. package/bundled/locales/zh-CN/skills/tools/windsurf/README.md +2 -1
  334. package/bundled/locales/zh-CN/skills/workflows/README.md +4 -2
  335. package/bundled/locales/zh-CN/templates/reverse-spec-template.md +50 -1
  336. package/bundled/locales/zh-TW/CHANGELOG.md +2323 -1128
  337. package/bundled/locales/zh-TW/CLAUDE.md +962 -76
  338. package/bundled/locales/zh-TW/README.md +3 -3
  339. package/bundled/locales/zh-TW/SECURITY.md +4 -3
  340. package/bundled/locales/zh-TW/STANDARDS-MAPPING.md +103 -6
  341. package/bundled/locales/zh-TW/adoption/ADOPTION-GUIDE.md +46 -93
  342. package/bundled/locales/zh-TW/adoption/DAILY-WORKFLOW-GUIDE.md +2 -1
  343. package/bundled/locales/zh-TW/adoption/STATIC-DYNAMIC-GUIDE.md +3 -1
  344. package/bundled/locales/zh-TW/adoption/checklists/enterprise.md +10 -9
  345. package/bundled/locales/zh-TW/adoption/checklists/minimal.md +6 -2
  346. package/bundled/locales/zh-TW/adoption/checklists/recommended.md +7 -4
  347. package/bundled/locales/zh-TW/ai/MAINTENANCE.md +34 -14
  348. package/bundled/locales/zh-TW/ai/options/commit-message/traditional-chinese.ai.yaml +48 -40
  349. package/bundled/locales/zh-TW/core/acceptance-criteria-traceability.md +56 -10
  350. package/bundled/locales/zh-TW/core/acceptance-test-driven-development.md +2 -1
  351. package/bundled/locales/zh-TW/core/accessibility-standards.md +895 -46
  352. package/bundled/locales/zh-TW/core/adr-standards.md +2 -1
  353. package/bundled/locales/zh-TW/core/agent-communication-protocol.md +2 -1
  354. package/bundled/locales/zh-TW/core/agent-dispatch.md +102 -33
  355. package/bundled/locales/zh-TW/core/ai-agreement-standards.md +58 -41
  356. package/bundled/locales/zh-TW/core/ai-command-behavior.md +2 -1
  357. package/bundled/locales/zh-TW/core/ai-friendly-architecture.md +306 -67
  358. package/bundled/locales/zh-TW/core/ai-instruction-standards.md +16 -13
  359. package/bundled/locales/zh-TW/core/ai-response-navigation.md +3 -3
  360. package/bundled/locales/zh-TW/core/alerting-standards.md +257 -35
  361. package/bundled/locales/zh-TW/core/anti-hallucination.md +169 -40
  362. package/bundled/locales/zh-TW/core/anti-sycophancy-prompting.md +2 -1
  363. package/bundled/locales/zh-TW/core/api-design-standards.md +2 -1
  364. package/bundled/locales/zh-TW/core/behavior-driven-development.md +3 -17
  365. package/bundled/locales/zh-TW/core/branch-completion.md +130 -34
  366. package/bundled/locales/zh-TW/core/capability-declaration.md +41 -79
  367. package/bundled/locales/zh-TW/core/change-batching-standards.md +2 -1
  368. package/bundled/locales/zh-TW/core/changelog-standards.md +14 -9
  369. package/bundled/locales/zh-TW/core/chaos-engineering-standards.md +138 -36
  370. package/bundled/locales/zh-TW/core/checkin-standards.md +84 -26
  371. package/bundled/locales/zh-TW/core/circuit-breaker.md +48 -87
  372. package/bundled/locales/zh-TW/core/code-review-checklist.md +19 -7
  373. package/bundled/locales/zh-TW/core/commit-message-guide.md +218 -87
  374. package/bundled/locales/zh-TW/core/containerization-standards.md +259 -57
  375. package/bundled/locales/zh-TW/core/context-aware-loading.md +121 -27
  376. package/bundled/locales/zh-TW/core/database-standards.md +2 -1
  377. package/bundled/locales/zh-TW/core/deprecation-standards.md +139 -37
  378. package/bundled/locales/zh-TW/core/design-document-standards.md +265 -55
  379. package/bundled/locales/zh-TW/core/developer-memory.md +102 -12
  380. package/bundled/locales/zh-TW/core/documentation-lifecycle.md +2 -1
  381. package/bundled/locales/zh-TW/core/documentation-structure.md +17 -8
  382. package/bundled/locales/zh-TW/core/dual-phase-output.md +28 -90
  383. package/bundled/locales/zh-TW/core/environment-standards.md +250 -72
  384. package/bundled/locales/zh-TW/core/error-code-standards.md +17 -6
  385. package/bundled/locales/zh-TW/core/estimation-standards.md +177 -44
  386. package/bundled/locales/zh-TW/core/execution-history.md +2 -1
  387. package/bundled/locales/zh-TW/core/failure-source-taxonomy.md +59 -117
  388. package/bundled/locales/zh-TW/core/feature-flag-standards.md +202 -57
  389. package/bundled/locales/zh-TW/core/forward-derivation-standards.md +592 -133
  390. package/bundled/locales/zh-TW/core/frontend-design-standards.md +120 -8
  391. package/bundled/locales/zh-TW/core/git-workflow.md +197 -37
  392. package/bundled/locales/zh-TW/core/git-worktree.md +79 -49
  393. package/bundled/locales/zh-TW/core/guides/anti-hallucination-guide.md +234 -487
  394. package/bundled/locales/zh-TW/core/guides/file-placement-guide.md +86 -2
  395. package/bundled/locales/zh-TW/core/guides/git-workflow-guide.md +411 -464
  396. package/bundled/locales/zh-TW/core/guides/performance-guide.md +2 -0
  397. package/bundled/locales/zh-TW/core/guides/refactoring-guide.md +237 -484
  398. package/bundled/locales/zh-TW/core/guides/security-guide.md +2 -0
  399. package/bundled/locales/zh-TW/core/health-check-standards.md +46 -104
  400. package/bundled/locales/zh-TW/core/immutability-first.md +45 -85
  401. package/bundled/locales/zh-TW/core/knowledge-graph-memory.md +2 -1
  402. package/bundled/locales/zh-TW/core/knowledge-transfer-standards.md +103 -40
  403. package/bundled/locales/zh-TW/core/mock-boundary.md +74 -6
  404. package/bundled/locales/zh-TW/core/observability-standards.md +284 -40
  405. package/bundled/locales/zh-TW/core/performance-standards.md +387 -86
  406. package/bundled/locales/zh-TW/core/pipeline-integration-standards.md +2 -1
  407. package/bundled/locales/zh-TW/core/postmortem-standards.md +367 -36
  408. package/bundled/locales/zh-TW/core/privacy-standards.md +153 -46
  409. package/bundled/locales/zh-TW/core/project-context-memory.md +210 -31
  410. package/bundled/locales/zh-TW/core/project-structure.md +240 -19
  411. package/bundled/locales/zh-TW/core/recovery-recipe-registry.md +54 -114
  412. package/bundled/locales/zh-TW/core/refactoring-standards.md +153 -48
  413. package/bundled/locales/zh-TW/core/requirement-engineering.md +8 -37
  414. package/bundled/locales/zh-TW/core/retrospective-standards.md +127 -7
  415. package/bundled/locales/zh-TW/core/retry-standards.md +41 -105
  416. package/bundled/locales/zh-TW/core/reverse-engineering-standards.md +5 -1
  417. package/bundled/locales/zh-TW/core/runbook-standards.md +296 -23
  418. package/bundled/locales/zh-TW/core/secret-management-standards.md +12 -4
  419. package/bundled/locales/zh-TW/core/security-decision.md +43 -84
  420. package/bundled/locales/zh-TW/core/security-standards.md +204 -25
  421. package/bundled/locales/zh-TW/core/self-review-protocol.md +2 -1
  422. package/bundled/locales/zh-TW/core/skill-standard-alignment-check.md +103 -69
  423. package/bundled/locales/zh-TW/core/slo-standards.md +301 -49
  424. package/bundled/locales/zh-TW/core/spec-driven-development.md +36 -7
  425. package/bundled/locales/zh-TW/core/standard-admission-criteria.md +22 -28
  426. package/bundled/locales/zh-TW/core/standard-lifecycle-management.md +40 -48
  427. package/bundled/locales/zh-TW/core/structured-task-definition.md +2 -1
  428. package/bundled/locales/zh-TW/core/supply-chain-security-standards.md +137 -10
  429. package/bundled/locales/zh-TW/core/systematic-debugging.md +94 -38
  430. package/bundled/locales/zh-TW/core/tech-debt-standards.md +170 -54
  431. package/bundled/locales/zh-TW/core/test-completeness-dimensions.md +101 -12
  432. package/bundled/locales/zh-TW/core/test-data-standards.md +245 -23
  433. package/bundled/locales/zh-TW/core/test-driven-development.md +4 -1
  434. package/bundled/locales/zh-TW/core/test-governance.md +92 -32
  435. package/bundled/locales/zh-TW/core/testing-standards.md +61 -14
  436. package/bundled/locales/zh-TW/core/timeout-standards.md +45 -85
  437. package/bundled/locales/zh-TW/core/token-budget.md +41 -112
  438. package/bundled/locales/zh-TW/core/translation-lifecycle-standards.md +28 -16
  439. package/bundled/locales/zh-TW/core/turn-completion-integrity.md +8 -6
  440. package/bundled/locales/zh-TW/core/verification-evidence.md +2 -1
  441. package/bundled/locales/zh-TW/core/versioning.md +6 -2
  442. package/bundled/locales/zh-TW/core/virtual-organization-standards.md +42 -36
  443. package/bundled/locales/zh-TW/core/workflow-enforcement.md +2 -1
  444. package/bundled/locales/zh-TW/core/workflow-state-protocol.md +2 -1
  445. package/bundled/locales/zh-TW/docs/CHEATSHEET.md +2 -1
  446. package/bundled/locales/zh-TW/docs/CLI-FLOW.md +2 -1
  447. package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +12 -3
  448. package/bundled/locales/zh-TW/docs/DEV-WORKFLOW-MAPPING.md +2 -1
  449. package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +8 -6
  450. package/bundled/locales/zh-TW/docs/STANDARDS-REFERENCE.md +2 -1
  451. package/bundled/locales/zh-TW/docs/USAGE-MODES-COMPARISON.md +2 -1
  452. package/bundled/locales/zh-TW/docs/USER-MANUAL.md +9 -1
  453. package/bundled/locales/zh-TW/docs/WINDOWS-GUIDE.md +4 -1
  454. package/bundled/locales/zh-TW/docs/specs/system/memory-adoption-strategy.md +2 -0
  455. package/bundled/locales/zh-TW/docs/user/FAQ.md +2 -0
  456. package/bundled/locales/zh-TW/docs/user/GETTING-STARTED.md +2 -0
  457. package/bundled/locales/zh-TW/docs/user/GLOSSARY.md +2 -0
  458. package/bundled/locales/zh-TW/docs/user/README.md +2 -0
  459. package/bundled/locales/zh-TW/docs/user/TROUBLESHOOTING.md +2 -0
  460. package/bundled/locales/zh-TW/integrations/claude-code/README.md +2 -1
  461. package/bundled/locales/zh-TW/integrations/codex/AGENTS.md +136 -2
  462. package/bundled/locales/zh-TW/integrations/codex/README.md +7 -1
  463. package/bundled/locales/zh-TW/integrations/gemini-cli/GEMINI.md +59 -1
  464. package/bundled/locales/zh-TW/integrations/gemini-cli/README.md +8 -1
  465. package/bundled/locales/zh-TW/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +7 -1
  466. package/bundled/locales/zh-TW/integrations/github-copilot/README.md +9 -3
  467. package/bundled/locales/zh-TW/integrations/github-copilot/copilot-instructions.md +146 -12
  468. package/bundled/locales/zh-TW/integrations/github-copilot/skills-mapping.md +7 -1
  469. package/bundled/locales/zh-TW/integrations/google-antigravity/AGENTS.md +110 -3
  470. package/bundled/locales/zh-TW/integrations/google-antigravity/README.md +7 -1
  471. package/bundled/locales/zh-TW/integrations/opencode/AGENTS.md +140 -2
  472. package/bundled/locales/zh-TW/integrations/opencode/README.md +7 -1
  473. package/bundled/locales/zh-TW/integrations/opencode/skills-mapping.md +8 -2
  474. package/bundled/locales/zh-TW/integrations/openspec/AGENTS.md +46 -1
  475. package/bundled/locales/zh-TW/integrations/openspec/README.md +7 -1
  476. package/bundled/locales/zh-TW/integrations/spec-kit/AGENTS.md +20 -2
  477. package/bundled/locales/zh-TW/integrations/spec-kit/README.md +7 -1
  478. package/bundled/locales/zh-TW/methodologies/guides/tdd-guide.md +584 -475
  479. package/bundled/locales/zh-TW/options/changelog/auto-generated.md +2 -0
  480. package/bundled/locales/zh-TW/options/changelog/keep-a-changelog.md +2 -0
  481. package/bundled/locales/zh-TW/options/code-review/automated-review.md +2 -0
  482. package/bundled/locales/zh-TW/options/code-review/pair-programming.md +2 -0
  483. package/bundled/locales/zh-TW/options/commit-message/bilingual.md +93 -5
  484. package/bundled/locales/zh-TW/options/commit-message/english.md +118 -1
  485. package/bundled/locales/zh-TW/options/commit-message/traditional-chinese.md +82 -1
  486. package/bundled/locales/zh-TW/options/documentation/api-docs.md +2 -0
  487. package/bundled/locales/zh-TW/options/documentation/markdown-docs.md +2 -0
  488. package/bundled/locales/zh-TW/options/documentation/wiki-style.md +2 -0
  489. package/bundled/locales/zh-TW/options/git-workflow/gitflow.md +99 -71
  490. package/bundled/locales/zh-TW/options/git-workflow/github-flow.md +68 -50
  491. package/bundled/locales/zh-TW/options/git-workflow/merge-commit.md +131 -20
  492. package/bundled/locales/zh-TW/options/git-workflow/rebase-ff.md +142 -27
  493. package/bundled/locales/zh-TW/options/git-workflow/squash-merge.md +100 -15
  494. package/bundled/locales/zh-TW/options/git-workflow/trunk-based.md +103 -56
  495. package/bundled/locales/zh-TW/options/project-structure/dotnet.md +233 -14
  496. package/bundled/locales/zh-TW/options/project-structure/go.md +270 -12
  497. package/bundled/locales/zh-TW/options/project-structure/java.md +235 -15
  498. package/bundled/locales/zh-TW/options/project-structure/kotlin.md +2 -0
  499. package/bundled/locales/zh-TW/options/project-structure/nodejs.md +136 -19
  500. package/bundled/locales/zh-TW/options/project-structure/php.md +2 -0
  501. package/bundled/locales/zh-TW/options/project-structure/python.md +177 -19
  502. package/bundled/locales/zh-TW/options/project-structure/ruby.md +2 -0
  503. package/bundled/locales/zh-TW/options/project-structure/rust.md +2 -0
  504. package/bundled/locales/zh-TW/options/project-structure/swift.md +2 -0
  505. package/bundled/locales/zh-TW/options/testing/contract-testing.md +2 -0
  506. package/bundled/locales/zh-TW/options/testing/e2e-testing.md +182 -21
  507. package/bundled/locales/zh-TW/options/testing/industry-pyramid.md +2 -0
  508. package/bundled/locales/zh-TW/options/testing/integration-testing.md +134 -22
  509. package/bundled/locales/zh-TW/options/testing/istqb-framework.md +2 -0
  510. package/bundled/locales/zh-TW/options/testing/performance-testing.md +2 -0
  511. package/bundled/locales/zh-TW/options/testing/security-testing.md +2 -0
  512. package/bundled/locales/zh-TW/options/testing/system-testing.md +175 -1
  513. package/bundled/locales/zh-TW/options/testing/unit-testing.md +123 -9
  514. package/bundled/locales/zh-TW/skills/CONTRIBUTING.template.md +3 -2
  515. package/bundled/locales/zh-TW/skills/INTEGRATION-GUIDE.md +2 -1
  516. package/bundled/locales/zh-TW/skills/README.md +2 -1
  517. package/bundled/locales/zh-TW/skills/_shared/README.md +2 -1
  518. package/bundled/locales/zh-TW/skills/ac-coverage/SKILL.md +15 -4
  519. package/bundled/locales/zh-TW/skills/adr-assistant/guide.md +123 -3
  520. package/bundled/locales/zh-TW/skills/agents/README.md +99 -1
  521. package/bundled/locales/zh-TW/skills/agents/code-architect.md +2 -0
  522. package/bundled/locales/zh-TW/skills/agents/doc-writer.md +2 -0
  523. package/bundled/locales/zh-TW/skills/agents/reviewer.md +3 -1
  524. package/bundled/locales/zh-TW/skills/agents/spec-analyst.md +2 -0
  525. package/bundled/locales/zh-TW/skills/agents/test-specialist.md +2 -0
  526. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +48 -37
  527. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/anti-hallucination.md +22 -2
  528. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/certainty-labels.md +29 -3
  529. package/bundled/locales/zh-TW/skills/ai-friendly-architecture/SKILL.md +23 -36
  530. package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +12 -36
  531. package/bundled/locales/zh-TW/skills/api-design-assistant/SKILL.md +21 -5
  532. package/bundled/locales/zh-TW/skills/atdd-assistant/SKILL.md +40 -15
  533. package/bundled/locales/zh-TW/skills/atdd-assistant/acceptance-criteria-guide.md +2 -1
  534. package/bundled/locales/zh-TW/skills/atdd-assistant/atdd-workflow.md +98 -1
  535. package/bundled/locales/zh-TW/skills/atdd-assistant/guide.md +24 -8
  536. package/bundled/locales/zh-TW/skills/audit-assistant/SKILL.md +8 -2
  537. package/bundled/locales/zh-TW/skills/bdd-assistant/SKILL.md +29 -6
  538. package/bundled/locales/zh-TW/skills/bdd-assistant/bdd-workflow.md +2 -1
  539. package/bundled/locales/zh-TW/skills/bdd-assistant/gherkin-guide.md +2 -1
  540. package/bundled/locales/zh-TW/skills/bdd-assistant/guide.md +9 -8
  541. package/bundled/locales/zh-TW/skills/changelog-guide/SKILL.md +12 -3
  542. package/bundled/locales/zh-TW/skills/changelog-guide/guide.md +11 -7
  543. package/bundled/locales/zh-TW/skills/checkin-assistant/SKILL.md +19 -3
  544. package/bundled/locales/zh-TW/skills/checkin-assistant/guide.md +5 -3
  545. package/bundled/locales/zh-TW/skills/ci-cd-assistant/SKILL.md +35 -16
  546. package/bundled/locales/zh-TW/skills/code-review-assistant/SKILL.md +19 -2
  547. package/bundled/locales/zh-TW/skills/code-review-assistant/checkin-checklist.md +2 -1
  548. package/bundled/locales/zh-TW/skills/code-review-assistant/guide.md +81 -6
  549. package/bundled/locales/zh-TW/skills/code-review-assistant/review-checklist.md +2 -1
  550. package/bundled/locales/zh-TW/skills/commands/ac-coverage.md +47 -2
  551. package/bundled/locales/zh-TW/skills/commands/api-design.md +3 -2
  552. package/bundled/locales/zh-TW/skills/commands/atdd.md +80 -10
  553. package/bundled/locales/zh-TW/skills/commands/audit.md +3 -2
  554. package/bundled/locales/zh-TW/skills/commands/bdd.md +114 -16
  555. package/bundled/locales/zh-TW/skills/commands/changelog.md +45 -9
  556. package/bundled/locales/zh-TW/skills/commands/check.md +74 -21
  557. package/bundled/locales/zh-TW/skills/commands/checkin.md +56 -11
  558. package/bundled/locales/zh-TW/skills/commands/ci-cd.md +2 -1
  559. package/bundled/locales/zh-TW/skills/commands/code-review.md +43 -2
  560. package/bundled/locales/zh-TW/skills/commands/commit.md +58 -4
  561. package/bundled/locales/zh-TW/skills/commands/config.md +52 -4
  562. package/bundled/locales/zh-TW/skills/commands/coverage.md +45 -4
  563. package/bundled/locales/zh-TW/skills/commands/database.md +3 -2
  564. package/bundled/locales/zh-TW/skills/commands/derive-all.md +44 -2
  565. package/bundled/locales/zh-TW/skills/commands/derive-atdd.md +37 -2
  566. package/bundled/locales/zh-TW/skills/commands/derive-bdd.md +44 -3
  567. package/bundled/locales/zh-TW/skills/commands/derive-tdd.md +45 -3
  568. package/bundled/locales/zh-TW/skills/commands/derive.md +62 -5
  569. package/bundled/locales/zh-TW/skills/commands/dev-workflow.md +60 -9
  570. package/bundled/locales/zh-TW/skills/commands/discover.md +43 -2
  571. package/bundled/locales/zh-TW/skills/commands/docgen.md +39 -2
  572. package/bundled/locales/zh-TW/skills/commands/docs.md +139 -7
  573. package/bundled/locales/zh-TW/skills/commands/durable.md +3 -2
  574. package/bundled/locales/zh-TW/skills/commands/e2e.md +86 -3
  575. package/bundled/locales/zh-TW/skills/commands/guide.md +4 -2
  576. package/bundled/locales/zh-TW/skills/commands/incident.md +3 -2
  577. package/bundled/locales/zh-TW/skills/commands/init.md +72 -15
  578. package/bundled/locales/zh-TW/skills/commands/methodology.md +117 -28
  579. package/bundled/locales/zh-TW/skills/commands/metrics.md +2 -1
  580. package/bundled/locales/zh-TW/skills/commands/migrate.md +2 -1
  581. package/bundled/locales/zh-TW/skills/commands/observability.md +45 -2
  582. package/bundled/locales/zh-TW/skills/commands/pr.md +2 -1
  583. package/bundled/locales/zh-TW/skills/commands/refactor.md +54 -13
  584. package/bundled/locales/zh-TW/skills/commands/release.md +83 -2
  585. package/bundled/locales/zh-TW/skills/commands/requirement.md +41 -2
  586. package/bundled/locales/zh-TW/skills/commands/reverse-bdd.md +37 -2
  587. package/bundled/locales/zh-TW/skills/commands/reverse-sdd.md +45 -2
  588. package/bundled/locales/zh-TW/skills/commands/reverse-tdd.md +43 -2
  589. package/bundled/locales/zh-TW/skills/commands/reverse.md +44 -2
  590. package/bundled/locales/zh-TW/skills/commands/runbook.md +47 -2
  591. package/bundled/locales/zh-TW/skills/commands/scan.md +3 -2
  592. package/bundled/locales/zh-TW/skills/commands/sdd-retro.md +52 -3
  593. package/bundled/locales/zh-TW/skills/commands/sdd.md +209 -28
  594. package/bundled/locales/zh-TW/skills/commands/security.md +3 -2
  595. package/bundled/locales/zh-TW/skills/commands/slo.md +48 -2
  596. package/bundled/locales/zh-TW/skills/commands/tdd.md +71 -2
  597. package/bundled/locales/zh-TW/skills/commands/update.md +64 -2
  598. package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +2 -2
  599. package/bundled/locales/zh-TW/skills/commit-standards/conventional-commits.md +2 -1
  600. package/bundled/locales/zh-TW/skills/commit-standards/guide.md +137 -17
  601. package/bundled/locales/zh-TW/skills/commit-standards/language-options.md +21 -18
  602. package/bundled/locales/zh-TW/skills/contract-test-assistant/SKILL.md +2 -2
  603. package/bundled/locales/zh-TW/skills/contract-test-assistant/guide.md +81 -1
  604. package/bundled/locales/zh-TW/skills/database-assistant/SKILL.md +21 -5
  605. package/bundled/locales/zh-TW/skills/deploy-assistant/SKILL.md +2 -1
  606. package/bundled/locales/zh-TW/skills/dev-methodology/SKILL.md +4 -1
  607. package/bundled/locales/zh-TW/skills/dev-methodology/create-methodology.md +2 -0
  608. package/bundled/locales/zh-TW/skills/dev-methodology/runtime.md +2 -0
  609. package/bundled/locales/zh-TW/skills/docs-generator/SKILL.md +19 -2
  610. package/bundled/locales/zh-TW/skills/docs-generator/guide.md +4 -3
  611. package/bundled/locales/zh-TW/skills/documentation-guide/SKILL.md +67 -42
  612. package/bundled/locales/zh-TW/skills/documentation-guide/documentation-structure.md +2 -1
  613. package/bundled/locales/zh-TW/skills/documentation-guide/readme-template.md +2 -1
  614. package/bundled/locales/zh-TW/skills/durable-execution-assistant/SKILL.md +32 -3
  615. package/bundled/locales/zh-TW/skills/e2e-assistant/SKILL.md +25 -7
  616. package/bundled/locales/zh-TW/skills/error-code-guide/SKILL.md +17 -34
  617. package/bundled/locales/zh-TW/skills/git-workflow-guide/SKILL.md +33 -38
  618. package/bundled/locales/zh-TW/skills/git-workflow-guide/branch-naming.md +2 -1
  619. package/bundled/locales/zh-TW/skills/git-workflow-guide/git-workflow.md +2 -1
  620. package/bundled/locales/zh-TW/skills/incident-response-assistant/SKILL.md +35 -14
  621. package/bundled/locales/zh-TW/skills/journey-test-assistant/SKILL.md +2 -14
  622. package/bundled/locales/zh-TW/skills/knowledge-graph/SKILL.md +6 -2
  623. package/bundled/locales/zh-TW/skills/metrics-dashboard-assistant/SKILL.md +42 -3
  624. package/bundled/locales/zh-TW/skills/observability-assistant/SKILL.md +85 -18
  625. package/bundled/locales/zh-TW/skills/pr-automation-assistant/SKILL.md +27 -3
  626. package/bundled/locales/zh-TW/skills/project-discovery/SKILL.md +11 -3
  627. package/bundled/locales/zh-TW/skills/project-discovery/guide.md +5 -3
  628. package/bundled/locales/zh-TW/skills/project-discovery/workflow.md +2 -1
  629. package/bundled/locales/zh-TW/skills/project-structure-guide/SKILL.md +19 -16
  630. package/bundled/locales/zh-TW/skills/project-structure-guide/language-patterns.md +2 -1
  631. package/bundled/locales/zh-TW/skills/refactoring-assistant/SKILL.md +26 -3
  632. package/bundled/locales/zh-TW/skills/refactoring-assistant/guide.md +4 -2
  633. package/bundled/locales/zh-TW/skills/release-standards/SKILL.md +91 -45
  634. package/bundled/locales/zh-TW/skills/release-standards/changelog-format.md +4 -3
  635. package/bundled/locales/zh-TW/skills/release-standards/guide.md +14 -5
  636. package/bundled/locales/zh-TW/skills/release-standards/release-workflow.md +5 -1
  637. package/bundled/locales/zh-TW/skills/release-standards/semantic-versioning.md +2 -1
  638. package/bundled/locales/zh-TW/skills/requirement-assistant/SKILL.md +15 -6
  639. package/bundled/locales/zh-TW/skills/requirement-assistant/guide.md +18 -8
  640. package/bundled/locales/zh-TW/skills/requirement-assistant/requirement-checklist.md +2 -1
  641. package/bundled/locales/zh-TW/skills/requirement-assistant/requirement-writing.md +2 -1
  642. package/bundled/locales/zh-TW/skills/retrospective-assistant/guide.md +200 -6
  643. package/bundled/locales/zh-TW/skills/reverse-engineer/bdd-extraction.md +2 -1
  644. package/bundled/locales/zh-TW/skills/reverse-engineer/guide.md +161 -36
  645. package/bundled/locales/zh-TW/skills/reverse-engineer/tdd-analysis.md +2 -1
  646. package/bundled/locales/zh-TW/skills/reverse-engineer/workflow.md +2 -1
  647. package/bundled/locales/zh-TW/skills/runbook-assistant/SKILL.md +9 -1
  648. package/bundled/locales/zh-TW/skills/security-assistant/SKILL.md +25 -5
  649. package/bundled/locales/zh-TW/skills/security-scan-assistant/SKILL.md +34 -8
  650. package/bundled/locales/zh-TW/skills/skill-builder/SKILL.md +3 -21
  651. package/bundled/locales/zh-TW/skills/slo-assistant/SKILL.md +3 -1
  652. package/bundled/locales/zh-TW/skills/spec-derivation/SKILL.md +2 -1
  653. package/bundled/locales/zh-TW/skills/spec-driven-dev/guide.md +35 -2
  654. package/bundled/locales/zh-TW/skills/sweep/SKILL.md +2 -1
  655. package/bundled/locales/zh-TW/skills/tdd-assistant/SKILL.md +10 -2
  656. package/bundled/locales/zh-TW/skills/tdd-assistant/guide.md +68 -9
  657. package/bundled/locales/zh-TW/skills/tdd-assistant/language-examples.md +693 -47
  658. package/bundled/locales/zh-TW/skills/tdd-assistant/tdd-workflow.md +183 -1
  659. package/bundled/locales/zh-TW/skills/test-coverage-assistant/SKILL.md +15 -5
  660. package/bundled/locales/zh-TW/skills/test-coverage-assistant/guide.md +26 -13
  661. package/bundled/locales/zh-TW/skills/testing-guide/testing-pyramid.md +2 -1
  662. package/bundled/locales/zh-TW/skills/testing-guide/testing-theory.md +3 -1
  663. package/bundled/locales/zh-TW/skills/tools/cline/README.md +2 -1
  664. package/bundled/locales/zh-TW/skills/tools/copilot/README.md +65 -18
  665. package/bundled/locales/zh-TW/skills/tools/copilot/copilot-instructions.md +2 -1
  666. package/bundled/locales/zh-TW/skills/tools/cursor/README.md +2 -1
  667. package/bundled/locales/zh-TW/skills/tools/windsurf/README.md +2 -1
  668. package/bundled/locales/zh-TW/skills/workflows/README.md +11 -9
  669. package/bundled/locales/zh-TW/templates/reverse-spec-template.md +50 -1
  670. package/bundled/skills/.claude-plugin/plugin.json +71 -0
  671. package/bundled/skills/commit-standards/SKILL.md +2 -2
  672. package/bundled/skills/commit-standards/guide.md +3 -2
  673. package/bundled/skills/commit-standards/language-options.md +19 -17
  674. package/package.json +2 -2
  675. package/src/commands/audit.js +28 -1
  676. package/src/commands/check.js +72 -3
  677. package/src/commands/compile.js +37 -4
  678. package/src/commands/config.js +49 -24
  679. package/src/commands/init.js +78 -30
  680. package/src/commands/open-work.js +6 -2
  681. package/src/commands/release-messages.js +228 -0
  682. package/src/commands/release.js +127 -68
  683. package/src/commands/run-intent.js +11 -0
  684. package/src/commands/spec.js +4 -2
  685. package/src/commands/update.js +227 -47
  686. package/src/compilers/claude-code-compiler.js +9 -1
  687. package/src/config/ai-agent-paths.js +14 -1
  688. package/src/core/installed-formats.js +15 -0
  689. package/src/core/open-work-config.js +20 -1
  690. package/src/core/project-config.js +55 -0
  691. package/src/i18n/messages.js +106 -2
  692. package/src/installers/hooks-installer.js +1 -1
  693. package/src/installers/manifest-installer.js +1 -1
  694. package/src/installers/skills-installer.js +1 -1
  695. package/src/installers/standards-installer.js +3 -1
  696. package/src/mcp/server.js +9 -3
  697. package/src/prompts/init.js +26 -22
  698. package/src/reconciler/actual-state-scanner.js +2 -8
  699. package/src/reconciler/backup-locations.js +5 -0
  700. package/src/reconciler/backup-manager.js +19 -11
  701. package/src/reconciler/desired-state-calculator.js +89 -57
  702. package/src/reconciler/plan-executor.js +101 -8
  703. package/src/reconciler/recorded-versions.js +49 -0
  704. package/src/reconciler/relative-path.js +23 -0
  705. package/src/uninstallers/hook-uninstaller.js +9 -1
  706. package/src/uninstallers/skills-uninstaller.js +22 -3
  707. package/src/utils/available-standards-report.js +25 -4
  708. package/src/utils/available-standards.js +13 -3
  709. package/src/utils/build-manifest.js +1 -1
  710. package/src/utils/commit-message-judge.js +60 -13
  711. package/src/utils/friction-detector.js +23 -11
  712. package/src/utils/git-hooks.js +106 -4
  713. package/src/utils/integration-generator.js +95 -67
  714. package/src/utils/legacy-hook-migration.js +121 -2
  715. package/src/utils/open-work-tracking.mjs +105 -16
  716. package/src/utils/sdd-header.js +16 -4
  717. package/src/utils/skills-installer.js +2 -1
  718. package/src/utils/spinner.js +14 -4
  719. package/src/utils/standard-validator.js +3 -2
  720. package/standards-registry.json +10 -8
  721. package/bundled/locales/zh-TW/core/guides/testing-guide.md +0 -2280
@@ -1,8 +1,9 @@
1
1
  ---
2
- source: ../../core/test-driven-development.md
2
+ source: ../../../../methodologies/guides/tdd-guide.md
3
3
  source_version: 1.2.0
4
4
  translation_version: 1.2.0
5
- last_synced: 2026-01-25
5
+ last_synced: 2026-10-16
6
+ source_hash: 15f328d37322
6
7
  status: current
7
8
  ---
8
9
 
@@ -13,7 +14,7 @@ status: current
13
14
  **適用範圍**: 所有採用測試驅動開發的專案
14
15
  **範圍**: universal
15
16
 
16
- > **語言**: [English](../../../../core/test-driven-development.md) | 繁體中文
17
+ > **語言**: [English](../../../../methodologies/guides/tdd-guide.md) | 繁體中文
17
18
 
18
19
  ---
19
20
 
@@ -34,7 +35,7 @@ status: current
34
35
 
35
36
  > **分類**: 傳統開發方法論 (1999-2011)
36
37
 
37
- TDD 是**傳統測試驅動開發家族**的一部分,源自極限編程 (XP) 和敏捷實踐。它不同於 **AI 時代 SDD (規格驅動開發)** 方法論。
38
+ TDD 是源自極限編程 (XP) 與敏捷實踐的**傳統測試驅動開發家族**之一部分。它有別於 **AI 時代的 SDD (規格驅動開發)** 方法論。
38
39
 
39
40
  ### 歷史背景
40
41
 
@@ -51,27 +52,27 @@ TDD 可以**在 SDD 實作階段內**使用,但不是 SDD 方法論本身的
51
52
 
52
53
  ```
53
54
  ┌──────────────────────────────────────────────────────────────┐
54
- │ 方法論關係 │
55
+ │ Methodology Relationship │
55
56
  ├──────────────────────────────────────────────────────────────┤
56
57
  │ │
57
- │ SDD 工作流程: │
58
- │ 討論 → 提案 → 審查 → [實作] → 驗證 │
58
+ │ SDD Workflow: │
59
+ │ Discuss → Proposal → Review → [Implementation] → Verify │
59
60
  │ ↑ │
60
- │ TDD 可在此處使用 │
61
- │ (選擇性,非必需) │
61
+ │ TDD can be used here │
62
+ │ (optional, not required) │
62
63
  │ │
63
- │ 傳統雙循環 TDD (GOOS): │
64
- │ BDD (外層) → TDD (內層) │
64
+ │ Traditional Double-Loop TDD (GOOS): │
65
+ │ BDD (Outer) → TDD (Inner) │
65
66
  │ │
66
- │ SDD 透過正向推導生成測試工件, │
67
- │ TDD 然後可用作起點。 │
67
+ │ SDD generates test artifacts through Forward Derivation, │
68
+ │ which TDD can then use as starting point. │
68
69
  │ │
69
70
  └──────────────────────────────────────────────────────────────┘
70
71
  ```
71
72
 
72
73
  ### 何時使用 TDD
73
74
 
74
- | 上下文 | 建議 |
75
+ | 情境 | 建議 |
75
76
  |---------|----------------|
76
77
  | **SDD 專案** | 在實作階段使用 TDD (選擇性) |
77
78
  | **舊系統專案** | 對新功能和錯誤修復使用 TDD |
@@ -84,22 +85,22 @@ TDD 可以**在 SDD 實作階段內**使用,但不是 SDD 方法論本身的
84
85
 
85
86
  ## 目錄
86
87
 
87
- 1. [TDD 核心循環](#tdd-核心循環)
88
- 2. [TDD 原則](#tdd-原則)
89
- 3. [適用場景指南](#適用場景指南)
88
+ 1. [TDD 核心循環](#tdd-core-cycle)
89
+ 2. [TDD 原則](#tdd-principles)
90
+ 3. [適用場景指南](#applicability-guide)
90
91
  4. [TDD vs BDD vs ATDD](#tdd-vs-bdd-vs-atdd)
91
- 5. [與 SDD 整合](#與-sdd-整合)
92
- 6. [TDD 工作流程](#tdd-工作流程)
93
- 7. [測試設計指南](#測試設計指南)
94
- 8. [重構策略](#重構策略)
95
- 9. [TDD 中的測試替身](#tdd-中的測試替身)
96
- 10. [反模式與修復](#反模式與修復)
97
- 11. [語言/框架實踐](#語言框架實踐)
98
- 12. [度量與評估](#度量與評估)
99
- 13. [相關標準](#相關標準)
100
- 14. [參考資料](#參考資料)
101
- 15. [版本歷史](#版本歷史)
102
- 16. [授權](#授權)
92
+ 5. [與 SDD 整合](#integration-with-sdd)
93
+ 6. [TDD 工作流程](#tdd-workflow)
94
+ 7. [測試設計指南](#test-design-guidelines)
95
+ 8. [重構策略](#refactoring-strategies)
96
+ 9. [TDD 中的測試替身](#test-doubles-in-tdd)
97
+ 10. [反模式與修復](#anti-patterns-and-remediation)
98
+ 11. [語言/框架實踐](#languageframework-practices)
99
+ 12. [度量與評估](#metrics-and-assessment)
100
+ 13. [相關標準](#related-standards)
101
+ 14. [參考資料](#references)
102
+ 15. [版本歷史](#version-history)
103
+ 16. [授權](#license)
103
104
 
104
105
  ---
105
106
 
@@ -111,31 +112,31 @@ TDD 遵循一個簡單但強大的迭代循環:
111
112
 
112
113
  ```
113
114
  ┌─────────────────────────────────────────────────────────────────────────────┐
114
- │ TDD 核心循環 │
115
+ │ TDD Core Cycle │
115
116
  ├─────────────────────────────────────────────────────────────────────────────┤
116
117
  │ │
117
118
  │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
118
- │ │ 🔴 紅 │────────▶│ 🟢 綠 │────────▶│🔵 重構 │ │
119
+ │ │ 🔴 RED │────────▶│ 🟢 GREEN│────────▶│🔵 REFACTOR│ │
119
120
  │ └─────────┘ └─────────┘ └─────────┘ │
120
121
  │ ▲ │ │
121
122
  │ │ │ │
122
123
  │ └────────────────────────────────────────┘ │
123
124
  │ │
124
- │ 🔴 紅色階段 (1-5 分鐘) │
125
- │ ├─ 撰寫一個描述預期行為的失敗測試 │
126
- │ ├─ 測試應該因為「正確的原因」而失敗 │
127
- │ └─ 驗證測試確實失敗 │
125
+ │ 🔴 RED Phase (1-5 minutes) │
126
+ │ ├─ Write a failing test that describes expected behavior │
127
+ │ ├─ Test should fail for the RIGHT reason │
128
+ │ └─ Verify the test actually fails │
128
129
  │ │
129
- │ 🟢 綠色階段 (1-10 分鐘) │
130
- │ ├─ 撰寫「最少」的程式碼讓測試通過 │
131
- │ ├─ 「先假裝,再實現」是可以接受的 │
132
- │ └─ 不要過度設計;只要讓它能運作 │
130
+ │ 🟢 GREEN Phase (1-10 minutes) │
131
+ │ ├─ Write the MINIMUM code to make the test pass │
132
+ │ ├─ "Fake it till you make it" is acceptable │
133
+ │ └─ Don't over-engineer; just make it work │
133
134
  │ │
134
- │ 🔵 重構階段 (5-15 分鐘) │
135
- │ ├─ 在保持測試綠色的同時改善程式碼品質 │
136
- │ ├─ 消除重複 (DRY) │
137
- │ ├─ 改善命名、結構、可讀性 │
138
- │ └─ 每次重構步驟後執行測試 │
135
+ │ 🔵 REFACTOR Phase (5-15 minutes) │
136
+ │ ├─ Improve code quality while keeping tests green │
137
+ │ ├─ Remove duplication (DRY) │
138
+ │ ├─ Improve naming, structure, readability │
139
+ │ └─ Run tests after each refactoring step │
139
140
  │ │
140
141
  └─────────────────────────────────────────────────────────────────────────────┘
141
142
  ```
@@ -143,16 +144,16 @@ TDD 遵循一個簡單但強大的迭代循環:
143
144
  ### 循環時間建議
144
145
 
145
146
  | 階段 | 建議時間 | 警示訊號 |
146
- |------|---------|---------|
147
- | 🔴 紅 | 1-5 分鐘 | 若超過 10 分鐘,測試範圍太大 |
148
- | 🟢 綠 | 1-10 分鐘 | 若超過 15 分鐘,需要分解問題 |
149
- | 🔵 重構 | 5-15 分鐘 | 若跳過,技術債會累積 |
147
+ |-------|-----------------|---------------|
148
+ | 🔴 RED | 1-5 分鐘 | 若 >10 分鐘,測試範圍太大 |
149
+ | 🟢 GREEN | 1-10 分鐘 | 若 >15 分鐘,需要拆解問題 |
150
+ | 🔵 REFACTOR | 5-15 分鐘 | 若跳過,技術債會累積 |
150
151
 
151
152
  ### 口訣
152
153
 
153
- > **紅 → 綠 → 重構 → 重複**
154
+ > **Red → Green → Refactor → Repeat**
154
155
 
155
- 每次迭代都應該很小。如果你發現自己在任何階段花費太長時間,測試可能太有野心了。
156
+ 每次迭代都應該很小。如果你發現自己在任何階段花費太長時間,該測試可能設定得過於龐大。
156
157
 
157
158
  ---
158
159
 
@@ -163,43 +164,43 @@ TDD 遵循一個簡單但強大的迭代循環:
163
164
  高品質的測試遵循 FIRST 原則:
164
165
 
165
166
  | 原則 | 說明 | 實踐指南 |
166
- |------|------|---------|
167
- | **F**ast (快速) | 測試應該快速執行 | 單元測試每個 < 100ms;總測試套件 < 10s |
168
- | **I**ndependent (獨立) | 測試之間不互相依賴 | 無共享狀態;每個測試設置自己的資料 |
169
- | **R**epeatable (可重複) | 每次執行結果相同 | 無隨機性;無時間依賴;無外部 I/O |
170
- | **S**elf-validating (自我驗證) | 有明確的通過/失敗結果 | 不需手動檢查;明確的斷言 |
171
- | **T**imely (及時) | 在生產程式碼之前撰寫 | 這是 TDD 的本質 |
167
+ |-----------|-------------|---------------------|
168
+ | **F**ast | 測試應該快速執行 | 單元測試每個 < 100ms;總測試套件 < 10s |
169
+ | **I**ndependent | 測試之間不互相依賴 | 無共用狀態;每個測試自行設定其資料 |
170
+ | **R**epeatable | 每次執行結果相同 | 無隨機性;無時間依賴;無外部 I/O |
171
+ | **S**elf-validating | 明確的通過/失敗結果 | 不需手動檢查;明確的斷言 |
172
+ | **T**imely | 在生產程式碼之前撰寫 | 這是 TDD 的本質 |
172
173
 
173
- ### Uncle Bob 的 TDD 三規則
174
+ ### Uncle Bob 的 TDD 三項規則
174
175
 
175
176
  Robert C. Martin (Uncle Bob) 用三條嚴格的規則定義 TDD:
176
177
 
177
178
  1. **規則一(紅色規則)**:除非是為了讓失敗的單元測試通過,否則不允許撰寫任何生產程式碼。
178
179
 
179
- 2. **規則二(測試規則)**:不允許撰寫超過足以失敗的單元測試;編譯失敗也算失敗。
180
+ 2. **規則二(測試規則)**:不允許撰寫超過足以失敗程度的單元測試;編譯失敗也算失敗。
180
181
 
181
- 3. **規則三(綠色規則)**:不允許撰寫超過足以讓當前失敗測試通過的生產程式碼。
182
+ 3. **規則三(綠色規則)**:不允許撰寫超過足以讓單一失敗單元測試通過程度的生產程式碼。
182
183
 
183
184
  ### 測試的單一職責
184
185
 
185
186
  每個測試應該驗證「一個」行為:
186
187
 
187
188
  ```
188
- ✅ 好:test_calculate_total_with_discount_applies_percentage()
189
- ❌ 差:test_calculate_total_and_tax_and_discount_and_shipping()
189
+ ✅ Good: test_calculate_total_with_discount_applies_percentage()
190
+ ❌ Bad: test_calculate_total_and_tax_and_discount_and_shipping()
190
191
  ```
191
192
 
192
193
  ### 測試即文件
193
194
 
194
- 良好撰寫的測試可作為可執行的文件:
195
+ 撰寫良好的測試可作為可執行的文件:
195
196
 
196
197
  ```
197
- ✅ 好的測試名稱:
198
+ ✅ Good test names:
198
199
  - should_return_empty_list_when_no_users_found
199
200
  - should_throw_validation_error_when_email_is_invalid
200
201
  - should_calculate_discount_when_order_exceeds_threshold
201
202
 
202
- ❌ 差的測試名稱:
203
+ ❌ Bad test names:
203
204
  - test1
204
205
  - testCalculate
205
206
  - itWorks
@@ -209,95 +210,95 @@ Robert C. Martin (Uncle Bob) 用三條嚴格的規則定義 TDD:
209
210
 
210
211
  ## 適用場景指南
211
212
 
212
- ### TDD 場景適用性
213
+ ### 依情境劃分的 TDD 適用性
213
214
 
214
- | 場景 | 評分 | 說明 |
215
+ | 情境 | 評級 | 附註 |
215
216
  |------|------|------|
216
- | **新功能開發** | ⭐⭐⭐⭐⭐ | TDD 最佳使用場景;設計從測試中浮現 |
217
- | **Bug 修復** | ⭐⭐⭐⭐⭐ | 先撰寫失敗測試重現 bug |
218
- | **API 設計** | ⭐⭐⭐⭐⭐ | 測試即 API 使用文件 |
219
- | **核心業務邏輯** | ⭐⭐⭐⭐⭐ | 高價值程式碼必須有測試保護 |
220
- | **演算法實現** | ⭐⭐⭐⭐ | 邊界情況多;TDD 幫助思考 |
221
- | **重構現有程式碼** | ⭐⭐⭐⭐ | 先補測試,再安全重構 |
222
- | **UI 組件** | ⭐⭐⭐ | 部分適用;可結合 BDD |
223
- | **探索性原型** | ⭐⭐ | TDD 可能拖慢不確定的探索 |
224
- | **一次性腳本** | ⭐ | 成本效益比低 |
217
+ | **新功能開發** | ⭐⭐⭐⭐⭐ | TDD 最佳使用案例;設計從測試中浮現 |
218
+ | **Bug 修復** | ⭐⭐⭐⭐⭐ | 先撰寫失敗測試以重現 bug |
219
+ | **API 設計** | ⭐⭐⭐⭐⭐ | 測試可作為 API 使用文件 |
220
+ | **核心業務邏輯** | ⭐⭐⭐⭐⭐ | 高價值程式碼必須具備測試保護 |
221
+ | **演算法實作** | ⭐⭐⭐⭐ | 邊界情況繁多;TDD 有助於全面思考 |
222
+ | **重構既有程式碼** | ⭐⭐⭐⭐ | 先補足測試,再安全地重構 |
223
+ | **UI 元件** | ⭐⭐⭐ | 部分適用;可與 BDD 結合 |
224
+ | **探索性原型** | ⭐⭐ | TDD 可能會拖慢充滿不確定性的探索 |
225
+ | **一次性指令碼** | ⭐ | 成本效益比低 |
225
226
  | **第三方整合** | ⭐⭐ | 難以 Mock;改用整合測試 |
226
227
 
227
228
  ### 依專案類型的 TDD
228
229
 
229
230
  | 專案類型 | TDD | BDD | ATDD | 建議 |
230
- |---------|-----|-----|------|------|
231
- | **新創 MVP** | ⚠️ 選擇性 | ✅ 推薦 | ❌ | 快速迭代優先 |
232
- | **企業應用** | ✅ 推薦 | ✅ 推薦 | ✅ 推薦 | 品質與可維護性關鍵 |
233
- | **開源專案** | ✅ 推薦 | ⚠️ 選擇性 | ❌ | 貢獻者需要測試文件 |
234
- | **遺留系統改造** | ✅ 必要 | ⚠️ 選擇性 | ❌ | 使用 Golden Master 策略(見下方) |
235
- | **微服務** | ✅ 推薦 | ✅ 推薦 | ✅ 推薦 | 契約測試重要 |
231
+ |----------|-----|-----|------|------|
232
+ | **新創 MVP** | ⚠️ 選擇性 | ✅ 建議 | ❌ | 優先考量快速迭代 |
233
+ | **企業級應用程式** | ✅ 建議 | ✅ 建議 | ✅ 建議 | 品質與可維護性極為關鍵 |
234
+ | **開源專案** | ✅ 建議 | ⚠️ 選擇性 | ❌ | 貢獻者需要測試文件 |
235
+ | **老舊系統改造** | ✅ 必須 | ⚠️ 選擇性 | ❌ | 使用 Golden Master 策略(見下方) |
236
+ | **微服務** | ✅ 建議 | ✅ 建議 | ✅ 建議 | 合約測試至關重要 |
236
237
  | **資料管線** | ⚠️ 選擇性 | ❌ | ❌ | 以整合測試為主 |
237
- | **機器學習** | 🔶 視情況 | ❌ | ❌ | 見下方 ML 測試邊界 |
238
+ | **機器學習** | 🔶 視情況 | ❌ | ❌ | 請參閱下方的 ML 測試邊界 |
238
239
 
239
240
  ### 機器學習 (ML) 測試邊界
240
241
 
241
- **重要**:ML 專案需要區分「模型效果」和「資料工程」:
242
+ **重要提示**:ML 專案需要區分「模型效能」與「資料工程」:
242
243
 
243
244
  | 面向 | TDD 適用性 | 說明 |
244
245
  |------|-----------|------|
245
- | **模型準確率** | ❌ 不適用 | 結果不確定性高;難以預先定義期望值 |
246
- | **特徵處理** | ✅ 必須 | 避免 Garbage In, Garbage Out |
247
- | **資料清洗** | ✅ 必須 | 資料品質直接影響模型效果 |
248
- | **資料轉換** | ✅ 必須 | 確保轉換邏輯正確 |
246
+ | **模型準確度** | ❌ 不適用 | 結果具非確定性;難以預先定義預期結果 |
247
+ | **特徵工程** | ✅ 必須 | 避免 Garbage In, Garbage Out |
248
+ | **資料清理** | ✅ 必須 | 資料品質會直接影響模型效能 |
249
+ | **資料轉換** | ✅ 必須 | 確保轉換邏輯正確無誤 |
249
250
  | **管線整合** | ⚠️ 選擇性 | 以整合測試為主 |
250
251
 
251
- ### 遺留系統策略:Golden Master Testing(黃金大師測試)
252
+ ### 老舊系統策略:Golden Master 測試
252
253
 
253
- **問題**:在沒有測試的遺留系統中,「補測試」本身就有破壞現有邏輯的風險。
254
+ **問題**:在沒有測試的老舊系統中,「新增測試」本身就伴隨著破壞既有邏輯的風險。
254
255
 
255
- **Golden Master Testing 工作流程**:
256
+ **Golden Master 測試工作流程**:
256
257
 
257
258
  ```
258
259
  ┌─────────────────────────────────────────────────────────────────┐
259
- │ Golden Master Testing 工作流程 │
260
+ │ Golden Master Testing Workflow │
260
261
  ├─────────────────────────────────────────────────────────────────┤
261
262
  │ │
262
- │ 1️⃣ 錄製階段(不修改程式碼) │
263
- │ ├─ 對系統執行大量輸入 │
264
- │ ├─ 記錄所有輸出作為「黃金基準」 │
265
- │ └─ 使用自動化工具或 AI 生成測試案例 │
263
+ │ 1️⃣ RECORD Phase (Don't modify code) │
264
+ │ ├─ Execute system with many inputs │
265
+ │ ├─ Record all outputs as "golden baseline" │
266
+ │ └─ Use automation tools or AI to generate test cases │
266
267
  │ │
267
- │ 2️⃣ 驗證階段 │
268
- │ ├─ 建立 Snapshot/Approval 測試 │
269
- │ └─ 確保重構前後輸出一致 │
268
+ │ 2️⃣ VERIFY Phase │
269
+ │ ├─ Create Snapshot/Approval tests │
270
+ │ └─ Ensure pre/post refactoring outputs match │
270
271
  │ │
271
- │ 3️⃣ 重構階段 │
272
- │ ├─ 在 Golden Master 保護下安全重構 │
273
- │ ├─ 每次修改後執行 Golden Master 測試 │
274
- │ └─ 逐步將 Golden Master 轉換為正式的單元測試 │
272
+ │ 3️⃣ REFACTOR Phase │
273
+ │ ├─ Safely refactor under Golden Master protection │
274
+ │ ├─ Run Golden Master tests after each modification │
275
+ │ └─ Gradually convert Golden Masters to proper unit tests │
275
276
  │ │
276
- │ 4️⃣ 演進階段 │
277
- │ └─ 新功能使用標準 TDD │
277
+ │ 4️⃣ EVOLVE Phase │
278
+ │ └─ New features use standard TDD │
278
279
  │ │
279
280
  └─────────────────────────────────────────────────────────────────┘
280
281
  ```
281
282
 
282
283
  **工具支援**:
283
- - ApprovalTests(多語言支援)
284
- - Jest Snapshot Testing
285
- - Python: pytest-snapshot
286
- - AI 輔助測試輸入生成
284
+ - ApprovalTests(支援多種語言)
285
+ - Jest 快照測試(Jest Snapshot Testing)
286
+ - Python:pytest-snapshot
287
+ - AI 輔助的測試輸入生成
287
288
 
288
289
  ### 決策樹
289
290
 
290
291
  ```
291
- 需求來源?
292
- ├─ 技術需求(效能、重構)→ TDD
293
- ├─ 業務需求
294
- │ ├─ 有明確驗收標準?
295
- │ │ ├─ 是 → ATDD → BDD → TDD
296
- │ │ └─ 否 → BDD → TDD
297
- │ └─ 複雜業務流程?
298
- │ ├─ 是 → BDD(場景描述)→ TDD
299
- │ └─ 否 → TDD
300
- └─ 探索性/原型 → 暫時跳過 TDD
292
+ Requirement Source?
293
+ ├─ Technical (performance, refactoring) → TDD
294
+ ├─ Business Requirement
295
+ │ ├─ Has clear acceptance criteria?
296
+ │ │ ├─ Yes → ATDD → BDD → TDD
297
+ │ │ └─ No → BDD → TDD
298
+ │ └─ Complex business flow?
299
+ │ ├─ Yes → BDD (scenario description) → TDD
300
+ │ └─ No → TDD
301
+ └─ Exploratory/Prototype → Skip TDD temporarily
301
302
  ```
302
303
 
303
304
  ---
@@ -308,101 +309,114 @@ Robert C. Martin (Uncle Bob) 用三條嚴格的規則定義 TDD:
308
309
 
309
310
  | 面向 | TDD | BDD | ATDD |
310
311
  |------|-----|-----|------|
311
- | **焦點** | 程式碼單元 | 行為 | 驗收標準 |
312
+ | **焦點** | 程式碼單元 | 行為 | 驗收條件 |
312
313
  | **語言** | 程式碼 | 自然語言 (Gherkin) | 業務語言 |
313
- | **參與者** | 開發者 | 開發者 + BA + QA | 全團隊 + 利益相關者 |
314
- | **測試層級** | 單元/整合 | 功能/場景 | 系統/驗收 |
315
- | **工具** | xUnit 框架 | Cucumber, Behave, SpecFlow | FitNesse, Concordion |
316
- | **時機** | 編碼期間 | 編碼之前 | 開發開始之前 |
314
+ | **參與者** | 開發人員 | 開發人員 + 業務分析師 (BA) + 品質工程師 (QA) | 全體團隊 + 利害關係人 |
315
+ | **測試層級** | 單元/整合 | 功能/場景 | 系統/驗收 |
316
+ | **工具** | xUnit 框架 | Cucumber、Behave、SpecFlow | FitNesse、Concordion |
317
+ | **時機** | 編寫程式碼期間 | 編寫程式碼之前 | 開發開始之前 |
317
318
 
318
- ### 整合金字塔
319
+ ### 雙循環 TDD (GOOS 模式)
319
320
 
320
321
  ```
321
322
  ┌─────────────────────────────────────────────────────────────────┐
322
- │ 完整的測試驅動開發堆疊 │
323
+ │ Double-Loop TDD (Freeman & Pryce, 2009) │
323
324
  ├─────────────────────────────────────────────────────────────────┤
324
325
  │ │
325
- │ 需求層 ATDD - 驗收測試驅動開發 │
326
- │ (接收業務驗收標準) │
327
- │ ↓ │
328
- │ 規格層 SDD - 規格驅動開發 │
329
- │ (正式規格、驗收條件) │
330
- │ ↓ │
331
- │ 功能層 BDD - 行為驅動開發 │
332
- │ (場景 → Step Definitions) │
333
- │ ↓ │
334
- │ 開發層 TDD - 測試驅動開發 │
335
- │ (單元測試 → 程式碼) │
336
- │ ↓ │
337
- │ 整合層 整合與系統測試 │
326
+ │ ┌─────────────────────────────────────────────────────────┐ │
327
+ │ │ BDD (Outer Loop) - Hours to Days │ │
328
+ │ │ ├─ Feature/Acceptance level │ │
329
+ │ │ ├─ User/Business perspective │ │
330
+ │ │ └─ Given-When-Then scenarios │ │
331
+ │ │ ↓ │ │
332
+ │ │ ┌─────────────────────────────────────────────────┐ │ │
333
+ │ │ │ TDD (Inner Loop) - Minutes │ │ │
334
+ │ │ │ ├─ Unit/Component level │ │ │
335
+ │ │ │ ├─ Code/Implementation perspective │ │ │
336
+ │ │ │ └─ Red → Green → Refactor │ │ │
337
+ │ │ └─────────────────────────────────────────────────┘ │ │
338
+ │ └─────────────────────────────────────────────────────────┘ │
338
339
  │ │
339
- │ 關鍵:ATDD → SDD → BDD → TDD → 整合測試(自上而下) │
340
+ │ Key: BDD → TDD (Double-Loop from GOOS) │
341
+ │ │
342
+ │ Note: ATDD is an optional collaboration method for defining │
343
+ │ acceptance criteria, not a required step in this sequence. │
344
+ │ SDD (2025) is a separate AI-era methodology. │
340
345
  │ │
341
346
  └─────────────────────────────────────────────────────────────────┘
342
347
  ```
343
348
 
349
+ ### 傳統與 AI 時代方法論
350
+
351
+ | 類別 | 方法論 | 焦點 |
352
+ |------|--------|------|
353
+ | **傳統 (1999-2011)** | TDD、BDD、ATDD | 測試驅動設計 |
354
+ | **AI 時代 (2025+)** | SDD | 規格驅動生成 |
355
+
356
+ > **附註**:SDD 可在其實作階段使用 TDD,但兩者是獨立的方法論。詳情請參閱 [規格驅動開發](../../core/spec-driven-development.md)。
357
+
344
358
  ### BDD Gherkin 語法概覽
345
359
 
346
360
  ```gherkin
347
- Feature: 使用者登入
348
- 作為一個註冊使用者
349
- 我想要登入我的帳號
350
- 以便我可以存取我的個人化內容
351
-
352
- Scenario: 使用有效憑證成功登入
353
- Given 我在登入頁面
354
- And 我有一個註冊帳號,電子郵件為 "user@example.com"
355
- When 我輸入電子郵件 "user@example.com"
356
- And 我輸入密碼 "correctpassword"
357
- And 我點擊登入按鈕
358
- Then 我應該被重新導向到儀表板
359
- And 我應該看到包含我名字的歡迎訊息
360
-
361
- Scenario: 使用無效密碼登入失敗
362
- Given 我在登入頁面
363
- When 我輸入電子郵件 "user@example.com"
364
- And 我輸入密碼 "wrongpassword"
365
- And 我點擊登入按鈕
366
- Then 我應該看到錯誤訊息 "無效的憑證"
367
- And 我應該保持在登入頁面
361
+ Feature: User Login
362
+ As a registered user
363
+ I want to log into my account
364
+ So that I can access my personalized content
365
+
366
+ Scenario: Successful login with valid credentials
367
+ Given I am on the login page
368
+ And I have a registered account with email "user@example.com"
369
+ When I enter email "user@example.com"
370
+ And I enter password "correctpassword"
371
+ And I click the login button
372
+ Then I should be redirected to the dashboard
373
+ And I should see a welcome message with my name
374
+
375
+ Scenario: Failed login with invalid password
376
+ Given I am on the login page
377
+ When I enter email "user@example.com"
378
+ And I enter password "wrongpassword"
379
+ And I click the login button
380
+ Then I should see an error message "Invalid credentials"
381
+ And I should remain on the login page
368
382
  ```
369
383
 
370
- ### ATDD 驗收標準格式
384
+ ### ATDD 驗收條件格式
371
385
 
372
386
  ```markdown
373
- ## 功能:購物車結帳
387
+ ## Feature: Shopping Cart Checkout
374
388
 
375
- ### 驗收標準:
389
+ ### Acceptance Criteria:
376
390
 
377
- **AC-1:計算訂單總額**
378
- - GIVEN 購物車中有價格為 [$10, $20, $15] 的商品
379
- - WHEN 使用者進行結帳
380
- - THEN 總額應為 $45
391
+ **AC-1: Calculate Order Total**
392
+ - GIVEN items in cart with prices [$10, $20, $15]
393
+ - WHEN user proceeds to checkout
394
+ - THEN total should be $45
381
395
 
382
- **AC-2:套用折扣碼**
383
- - GIVEN 購物車總額為 $100
384
- - AND 有效的折扣碼 "SAVE20" 為 20% 折扣
385
- - WHEN 使用者套用折扣碼
386
- - THEN 總額應為 $80
396
+ **AC-2: Apply Discount Code**
397
+ - GIVEN cart total is $100
398
+ - AND valid discount code "SAVE20" for 20% off
399
+ - WHEN user applies discount code
400
+ - THEN total should be $80
387
401
 
388
- **AC-3:驗證最低訂單金額**
389
- - GIVEN 購物車總額低於 $25
390
- - WHEN 使用者嘗試結帳
391
- - THEN 系統應顯示「最低訂單金額為 $25」錯誤
402
+ **AC-3: Validate Minimum Order**
403
+ - GIVEN cart total is below $25
404
+ - WHEN user attempts checkout
405
+ - THEN system should show "Minimum order is $25" error
392
406
  ```
393
407
 
394
- ### 選擇正確的方法
408
+ ### 選擇適當的做法
395
409
 
396
- | 使用案例 | 主要方法 | 輔助方法 |
397
- |---------|---------|---------|
398
- | 演算法實現 | TDD | - |
410
+ | 使用案例 | 主要做法 | 輔助做法 |
411
+ |----------|----------|----------|
412
+ | 演算法實作 | TDD | - |
399
413
  | 使用者驗證流程 | BDD | TDD |
400
- | 支付處理 | ATDD | BDD + TDD |
401
- | API 端點 | TDD | BDD 用於整合 |
402
- | UI 組件 | BDD | TDD 用於邏輯 |
414
+ | 付款處理 | ATDD | BDD + TDD |
415
+ | API 端點 | TDD | BDD(用於整合) |
416
+ | UI 元件 | BDD | TDD(用於邏輯) |
403
417
  | 業務規則驗證 | ATDD | TDD |
404
- | 效能優化 | TDD | - |
405
- | 外部服務整合 | TDD | BDD 用於契約 |
418
+ | 效能最佳化 | TDD | - |
419
+ | 外部服務整合 | TDD | BDD(用於合約) |
406
420
 
407
421
  ---
408
422
 
@@ -417,66 +431,66 @@ Feature: 使用者登入
417
431
 
418
432
  ```
419
433
  ┌─────────────────────────────────────────────────────────────────────────────┐
420
- │ SDD + TDD 整合工作流程 │
434
+ │ SDD + TDD 整合工作流程 │
421
435
  ├─────────────────────────────────────────────────────────────────────────────┤
422
436
  │ │
423
- │ 1️⃣ SDD:提案階段 │
424
- │ ├─ 撰寫 Spec:定義功能、驗收標準、邊界情況 │
425
- │ ├─ 包含驗收標準(轉換為 ATDD 場景) │
426
- │ └─ 取得利益相關者批准 │
437
+ │ 1️⃣ SDD: PROPOSAL 階段 │
438
+ │ ├─ 撰寫 Spec:定義功能、驗收條件、邊界情況 │
439
+ │ ├─ 包含驗收條件(轉換為 ATDD 場景) │
440
+ │ └─ 取得利益相關者核准 │
427
441
  │ (Spec ID: SPEC-001) │
428
442
  │ │
429
- │ 2️⃣ TDD:紅色階段 │
430
- │ ├─ 基於 Spec 的驗收標準撰寫測試 │
443
+ │ 2️⃣ TDD: RED 階段 │
444
+ │ ├─ 根據 Spec 的驗收條件撰寫測試 │
431
445
  │ ├─ 撰寫描述預期行為的失敗測試 │
432
- │ ├─ 測試實現 Spec:一個標準 = 多個測試 │
433
- │ └─ 在測試文件註解中參考 SPEC-001 │
446
+ │ ├─ 測試實作 Spec:一個條件 = 多個測試 │
447
+ │ └─ 在測試檔案註釋中引用 SPEC-001 │
434
448
  │ │
435
- │ 3️⃣ TDD:綠色 + 重構階段 │
436
- │ ├─ 迭代開發,一次實現一個小功能 │
437
- │ ├─ 測試通過後重構 │
438
- │ └─ 保持所有 Spec 驗收標準測試通過 │
449
+ │ 3️⃣ TDD: GREEN + REFACTOR 階段 │
450
+ │ ├─ 迭代開發,一次實作一個小功能 │
451
+ │ ├─ 測試通過後進行重構 │
452
+ │ └─ 保持所有 Spec 驗收條件測試處於通過狀態 │
439
453
  │ │
440
- │ 4️⃣ SDD:驗證階段 │
441
- │ ├─ 確認實現與 Spec 相符 │
454
+ │ 4️⃣ SDD: VERIFICATION 階段 │
455
+ │ ├─ 確認實作符合 Spec │
442
456
  │ ├─ 驗收測試套件通過 │
443
- │ └─ 所有驗收標準已實現 ✓ │
457
+ │ └─ 所有驗收條件均已實作 ✓ │
444
458
  │ │
445
- │ 5️⃣ 提交 PR 和撰寫提交訊息 │
459
+ │ 5️⃣ 提交 PR 並撰寫 Commit 訊息 │
446
460
  │ ├─ Commit: "feat(auth): implement login" │
447
- │ ├─ Body: "Implements SPEC-001 with OAuth2" │
448
- │ ├─ Refs: SPEC-001 │
461
+ │ ├─ 內文: "Implements SPEC-001 with OAuth2" │
462
+ │ ├─ 引用: SPEC-001 │
449
463
  │ └─ 包含測試覆蓋率報告 │
450
464
  │ │
451
- │ 6️⃣ SDD:歸檔階段 │
452
- │ └─ 歸檔 Spec,連結到 PR/提交 │
465
+ │ 6️⃣ SDD: ARCHIVE 階段 │
466
+ │ └─ 封存 Spec,連結至 PR/commits │
453
467
  │ │
454
468
  └─────────────────────────────────────────────────────────────────────────────┘
455
469
  ```
456
470
 
457
- ### 將 Spec 驗收標準對應到 TDD 測試
471
+ ### 將 Spec 驗收條件對應至 TDD 測試
458
472
 
459
- | Spec 驗收標準 | TDD 測試 |
460
- |--------------|----------|
461
- | 「使用者可以用有效憑證登入」 | `test_login_with_valid_credentials_succeeds()` |
462
- | 「無效密碼顯示錯誤」 | `test_login_with_invalid_password_shows_error()` |
463
- | 「3 次失敗嘗試後帳號鎖定」 | `test_account_locks_after_three_failed_attempts()` |
464
- | 「鎖定的帳號無法登入」 | `test_locked_account_cannot_login()` |
473
+ | Spec 驗收條件 | TDD 測試 |
474
+ |---------------|----------|
475
+ | "User can login with valid credentials" | `test_login_with_valid_credentials_succeeds()` |
476
+ | "Invalid password shows error" | `test_login_with_invalid_password_shows_error()` |
477
+ | "Account locked after 3 failed attempts" | `test_account_locks_after_three_failed_attempts()` |
478
+ | "Locked account cannot login" | `test_locked_account_cannot_login()` |
465
479
 
466
- ### 在測試中參考 Spec
480
+ ### 在測試中引用 Spec
467
481
 
468
482
  ```typescript
469
483
  /**
470
- * SPEC-001:使用者驗證 的測試
484
+ * Tests for SPEC-001: User Authentication
471
485
  * @see specs/SPEC-001-user-authentication.md
472
486
  */
473
- describe('使用者驗證 (SPEC-001)', () => {
474
- // AC-1:使用者可以用有效憑證登入
487
+ describe('User Authentication (SPEC-001)', () => {
488
+ // AC-1: User can login with valid credentials
475
489
  test('should login successfully with valid credentials', async () => {
476
490
  // ...
477
491
  });
478
492
 
479
- // AC-2:無效密碼顯示錯誤
493
+ // AC-2: Invalid password shows error
480
494
  test('should show error message for invalid password', async () => {
481
495
  // ...
482
496
  });
@@ -491,71 +505,71 @@ describe('使用者驗證 (SPEC-001)', () => {
491
505
 
492
506
  ```
493
507
  ┌─────────────────────────────────────────────────────────────────┐
494
- │ 個人 TDD 工作階段流程 │
508
+ │ 個人 TDD 工作階段流程 │
495
509
  ├─────────────────────────────────────────────────────────────────┤
496
510
  │ │
497
- │ 1. 理解需求 │
498
- │ ├─ 閱讀 spec/使用者故事 │
499
- │ └─ 識別驗收標準 │
511
+ │ 1. 理解需求 │
512
+ │ ├─ 閱讀規格/使用者故事 │
513
+ │ └─ 識別驗收條件 │
500
514
  │ │
501
- │ 2. 列出測試案例(紙上或 TODO 註解) │
502
- │ ├─ 快樂路徑場景 │
503
- │ ├─ 邊界情況 │
504
- │ ├─ 錯誤場景 │
505
- │ └─ 邊界條件 │
515
+ │ 2. 列出測試案例(在紙上或 TODO 註釋中) │
516
+ │ ├─ 正常路徑(Happy path)場景 │
517
+ │ ├─ 邊界情況 │
518
+ │ ├─ 錯誤場景 │
519
+ │ └─ 邊界條件 │
506
520
  │ │
507
- │ 3. 選擇最簡單的測試案例 │
508
- │ └─ 從最基本的快樂路徑開始 │
521
+ │ 3. 挑選最簡單的測試案例 │
522
+ │ └─ 從最基本的正常路徑開始 │
509
523
  │ │
510
- │ 4. 紅色:撰寫測試 │
511
- │ ├─ 使用清晰的 Arrange-Act-Assert 撰寫測試 │
512
- │ ├─ 使用描述性的測試名稱 │
513
- │ └─ 執行測試,驗證它失敗 │
524
+ │ 4. RED:撰寫測試 │
525
+ │ ├─ 撰寫具有清晰 Arrange-Act-Assert 的測試 │
526
+ │ ├─ 使用具描述性的測試名稱 │
527
+ │ └─ 執行測試,驗證其失敗 │
514
528
  │ │
515
- │ 5. 綠色:讓它通過 │
516
- │ ├─ 撰寫最少的程式碼讓測試通過 │
517
- │ ├─ 「假裝」是可以接受的 │
518
- │ └─ 執行測試,驗證它通過 │
529
+ │ 5. GREEN:讓測試通過 │
530
+ │ ├─ 撰寫最少量的程式碼使其通過 │
531
+ │ ├─ 「先假裝,再實現」是可以接受的 │
532
+ │ └─ 執行測試,驗證其通過 │
519
533
  │ │
520
- │ 6. 重構:清理 │
521
- │ ├─ 消除重複 │
522
- │ ├─ 改善命名 │
523
- │ ├─ 提取方法/函式 │
524
- │ └─ 每次變更後執行所有測試 │
534
+ │ 6. REFACTOR:清理程式碼 │
535
+ │ ├─ 消除重複 │
536
+ │ ├─ 改善命名 │
537
+ │ ├─ 擷取方法/函式 │
538
+ │ └─ 每次變更後執行所有測試 │
525
539
  │ │
526
- │ 7. 從步驟 3 重複,直到所有測試完成 │
540
+ │ 7. 從步驟 3 重複,直到所有測試完成 │
527
541
  │ │
528
542
  └─────────────────────────────────────────────────────────────────┘
529
543
  ```
530
544
 
531
545
  ### 團隊層級 TDD
532
546
 
533
- #### 使用 TDD 的結對程式設計
547
+ #### 結對編程與 TDD
534
548
 
535
- **乒乓模式**:
549
+ **乒乓模式(Ping-Pong Pattern)**:
536
550
  1. 開發者 A 撰寫一個失敗的測試
537
- 2. 開發者 B 撰寫程式碼讓測試通過
551
+ 2. 開發者 B 撰寫程式碼使測試通過
538
552
  3. 開發者 B 撰寫下一個失敗的測試
539
- 4. 開發者 A 撰寫程式碼讓測試通過
540
- 5. 任一開發者可以隨時重構
541
- 6. 重複
553
+ 4. 開發者 A 撰寫程式碼使測試通過
554
+ 5. 任一開發者均可在任何時間進行重構
555
+ 6. 重複此過程
542
556
 
543
- **駕駛員-領航員模式**:
544
- 1. 領航員思考設計和測試案例
545
- 2. 駕駛員撰寫測試和程式碼
546
- 3. 每 15-30 分鐘交換角色
557
+ **駕駛與領航員模式(Driver-Navigator Pattern)**:
558
+ 1. 領航員(Navigator)思考設計與測試案例
559
+ 2. 駕駛(Driver)撰寫測試與程式碼
560
+ 3. 每 15-30 分鐘輪換角色
547
561
 
548
- #### 使用 TDD 的群體程式設計
562
+ #### 群體編程(Mob Programming)與 TDD
549
563
 
550
- - 一個駕駛員(打字),多個領航員(指導)
551
- - 每 5-10 分鐘輪換駕駛員
552
- - 集體決定測試案例和實現
553
- - 透過多元視角獲得更高品質
564
+ - 一位駕駛(鍵盤輸入),多位領航員(引導方向)
565
+ - 每 5-10 分鐘輪換一次駕駛
566
+ - 共同決定測試案例與實作方式
567
+ - 透過多元觀點獲得更高品質
554
568
 
555
569
  ### CI/CD 整合
556
570
 
557
571
  ```yaml
558
- # TDD 的 GitHub Actions 工作流程範例
572
+ # Example GitHub Actions workflow for TDD
559
573
  name: TDD CI Pipeline
560
574
 
561
575
  on: [push, pull_request]
@@ -595,15 +609,15 @@ jobs:
595
609
 
596
610
  ```typescript
597
611
  test('should calculate total with discount', () => {
598
- // Arrange - 設置測試資料和依賴
612
+ // Arrange - Set up test data and dependencies
599
613
  const cart = new ShoppingCart();
600
614
  cart.addItem({ name: 'Widget', price: 100 });
601
- cart.setDiscountCode('SAVE20'); // 20% 折扣
615
+ cart.setDiscountCode('SAVE20'); // 20% discount
602
616
 
603
- // Act - 執行被測試的行為
617
+ // Act - Execute the behavior being tested
604
618
  const total = cart.calculateTotal();
605
619
 
606
- // Assert - 驗證結果
620
+ // Assert - Verify the result
607
621
  expect(total).toBe(80);
608
622
  });
609
623
  ```
@@ -629,35 +643,35 @@ test('given a cart with items, when discount applied, then total is reduced', ()
629
643
 
630
644
  | 模式 | 範例 |
631
645
  |------|------|
632
- | `should_[行為]_when_[條件]` | `should_return_error_when_email_invalid` |
633
- | `[方法]_[場景]_[預期]` | `calculateTotal_withDiscount_returnsReducedPrice` |
634
- | `test_[方法]_[場景]_[預期]` | `test_login_invalidPassword_throwsError` |
635
- | `it_[做某事]` | `it_calculates_total_correctly` |
646
+ | `should_[behavior]_when_[condition]` | `should_return_error_when_email_invalid` |
647
+ | `[method]_[scenario]_[expected]` | `calculateTotal_withDiscount_returnsReducedPrice` |
648
+ | `test_[method]_[scenario]_[expected]` | `test_login_invalidPassword_throwsError` |
649
+ | `it_[does something]` | `it_calculates_total_correctly` |
636
650
 
637
651
  ### 測試資料最佳實踐
638
652
 
639
653
  ```typescript
640
- // ✅ 好:清晰、有意義的測試資料
654
+ // ✅ Good: Clear, meaningful test data
641
655
  const validUser = {
642
656
  email: 'john.doe@example.com',
643
657
  password: 'SecureP@ss123',
644
658
  role: 'admin'
645
659
  };
646
660
 
647
- // ❌ 差:沒有上下文的魔術字串
661
+ // ❌ Bad: Magic strings without context
648
662
  const user = {
649
663
  email: 'a@b.c',
650
664
  password: '123',
651
665
  role: 'x'
652
666
  };
653
667
 
654
- // ✅ 好:使用測試資料建構器
668
+ // ✅ Good: Use test data builders
655
669
  const user = UserBuilder.create()
656
670
  .withEmail('john.doe@example.com')
657
671
  .withRole('admin')
658
672
  .build();
659
673
 
660
- // ✅ 好:使用常數表示邊界值
674
+ // ✅ Good: Use constants for boundary values
661
675
  const MAX_PASSWORD_LENGTH = 128;
662
676
  const MIN_PASSWORD_LENGTH = 8;
663
677
 
@@ -669,134 +683,227 @@ test('should reject password exceeding max length', () => {
669
683
 
670
684
  ### 測試邊界情況
671
685
 
672
- 確保測試涵蓋 [測試完整性維度](../../core/test-completeness-dimensions.md) 定義的所有八個維度。這些維度包括:快樂路徑、邊界條件、錯誤處理、授權、狀態變化、驗證、整合,以及 AI 生成品質(適用時)。
686
+ 確保測試涵蓋 [測試完整性維度](../../core/test-completeness-dimensions.md) 中定義的所有八個維度。其中包括正常路徑(happy path)、邊界條件、錯誤處理、授權、狀態變更、驗證、整合以及 AI 生成品質(適用時)。
673
687
 
674
- 請使用該文件中的檢查清單來驗證每個功能的覆蓋率。
688
+ 使用該文件中的檢查清單來驗證各功能的覆蓋率。
675
689
 
676
690
  ---
677
691
 
678
692
  ## 重構策略
679
693
 
680
- ### 何時重構
694
+ ### 何時進行重構
681
695
 
682
- 當你看到以下情況時進行重構:
696
+ 當你看到程式碼壞味道(code smell)時就進行重構。使用下方的完整目錄來識別問題與對應的解決方案。
683
697
 
684
- - **重複**:相同的程式碼出現在多個地方
685
- - **過長方法**:函式做太多事
686
- - **命名不佳**:不清楚的變數/函式名稱
687
- - **複雜條件**:巢狀的 if/else 鏈
688
- - **功能嫉妒**:方法過度使用另一個類別的資料
689
- - **資料團塊**:相同的資料群組一起出現
698
+ ### 程式碼壞味道目錄
690
699
 
691
- ### 安全重構檢查清單
700
+ 根據 Martin Fowler 的《重構》(第 2 版),程式碼壞味道分為五大類:
692
701
 
693
- ```
694
- 重構前:
695
- □ 所有測試都通過(綠色)
696
- □ 有足夠的測試覆蓋
697
- □ 你理解程式碼在做什麼
702
+ #### 1. 膨脹劑(Bloaters)
698
703
 
699
- 重構中:
700
- □ 一次只做「一個」小變更
701
- □ 「每次」變更後執行測試
702
- □ 如果測試失敗,立即復原
703
- □ 重構時不要新增功能
704
+ 程式碼過於龐大而難以處理。
704
705
 
705
- 重構後:
706
- □ 所有測試仍然通過
707
- □ 程式碼更乾淨/簡單
708
- □ 沒有新增功能
709
- ```
706
+ | 壞味道 | 說明 | 重構手法 |
707
+ |-------|-------------|-------------|
708
+ | **過長函式(Long Method)** | 函式超過 20 行,做太多事情 | 提煉函式(Extract Method)、以查詢取代暫存變數(Replace Temp with Query)、引入參數物件(Introduce Parameter Object) |
709
+ | **過大類別(Large Class)** | 類別承擔過多職責 | 提煉類別(Extract Class)、提煉子類別(Extract Subclass)、提煉介面(Extract Interface) |
710
+ | **基本型別偏執(Primitive Obsession)** | 對簡單任務使用基本型別而非小型物件 | 以物件取代基本型別(Replace Primitive with Object)、以類別取代型別碼(Replace Type Code with Class)、引入參數物件(Introduce Parameter Object) |
711
+ | **過長參數列(Long Parameter List)** | 超過 3 個參數 | 引入參數物件(Introduce Parameter Object)、保持物件完整(Preserve Whole Object)、以函式呼叫取代參數(Replace Parameter with Method Call) |
712
+ | **資料泥團(Data Clumps)** | 相同的一組資料在多處一同出現 | 提煉類別(Extract Class)、引入參數物件(Introduce Parameter Object)、保持物件完整(Preserve Whole Object) |
710
713
 
711
- ### 常見重構技術
714
+ #### 2. 物件導向濫用者(Object-Orientation Abusers)
712
715
 
713
- | 技術 | 使用時機 | 範例 |
714
- |------|---------|------|
715
- | **提取方法** | 過長方法、重複程式碼 | 提取 10 行到 `calculateDiscount()` |
716
- | **重新命名** | 不清楚的名稱 | `calc()` → `calculateOrderTotal()` |
717
- | **內聯** | 過度抽象 | 移除不必要的包裝函式 |
718
- | **提取變數** | 複雜表達式 | `const isEligible = age >= 18 && hasLicense` |
719
- | **用多型取代條件** | 複雜的 switch/if 鏈 | 使用策略模式 |
720
- | **引入參數物件** | 太多參數 | `(x, y, width, height)` → `Rectangle rect` |
716
+ 對物件導向原則不完整或不正確的應用。
721
717
 
722
- ### 程式碼異味目錄
718
+ | 壞味道 | 說明 | 重構手法 |
719
+ |-------|-------------|-------------|
720
+ | **Switch 語句(Switch Statements)** | 依據型別而生的複雜 switch/if-else 鏈 | 以多型取代條件邏輯(Replace Conditional with Polymorphism)、以策略取代型別碼(Replace Type Code with Strategy)、以狀態取代型別碼(Replace Type Code with State) |
721
+ | **暫時性欄位(Temporary Field)** | 僅在特定情況下設定的欄位 | 提煉類別(Extract Class)、引入空物件(Introduce Null Object)、引入特例(Introduce Special Case) |
722
+ | **拒絕繼承(Refused Bequest)** | 子類別未使用繼承的函式 | 下移函式(Push Down Method)、下移欄位(Push Down Field)、以委託取代繼承(Replace Inheritance with Delegation) |
723
+ | **介面不同的替代類別(Alternative Classes with Different Interfaces)** | 做相同事情但函式簽章不同的類別 | 重新命名函式(Rename Method)、搬移函式(Move Method)、提煉超類別(Extract Superclass) |
724
+ | **平行繼承體系(Parallel Inheritance Hierarchies)** | 建立子類別時必須在另一個體系中也建立一個子類別 | 搬移函式(Move Method)、搬移欄位(Move Field) |
723
725
 
724
- 根據 Martin Fowler 的《Refactoring》(第二版),程式碼異味分為五大類別:
726
+ #### 3. 變更預防者(Change Preventers)
725
727
 
726
- #### 1. 膨脹型(Bloaters)
728
+ 讓變更比必要更困難的程式碼。
727
729
 
728
- | 異味 | 說明 | 重構方式 |
729
- |------|------|---------|
730
- | **Long Method(過長方法)** | 方法超過 20 行,做太多事 | Extract Method、Replace Temp with Query、Introduce Parameter Object、Preserve Whole Object、Replace Method with Method Object |
731
- | **Large Class(過大類別)** | 類別有太多職責 | Extract Class、Extract Subclass、Extract Interface、Duplicate Observed Data |
732
- | **Primitive Obsession(基本型別偏執)** | 過度使用基本型別而非小物件 | Replace Data Value with Object、Replace Type Code with Class/Subclass/Strategy、Extract Class、Introduce Parameter Object |
733
- | **Long Parameter List(過長參數列表)** | 方法有太多參數(>3-4 個) | Replace Parameter with Method Call、Preserve Whole Object、Introduce Parameter Object |
734
- | **Data Clumps(資料泥團)** | 相同的資料群組一起出現 | Extract Class、Introduce Parameter Object、Preserve Whole Object |
730
+ | 壞味道 | 說明 | 重構手法 |
731
+ |-------|-------------|-------------|
732
+ | **發散式變化(Divergent Change)** | 一個類別因許多不同原因而改變 | 提煉類別(Extract Class)、拆分階段(Split Phase) |
733
+ | **散彈式手術(Shotgun Surgery)** | 一個變更需要修改許多類別 | 搬移函式(Move Method)、搬移欄位(Move Field)、內聯函式(Inline Function)、內聯類別(Inline Class) |
734
+ | **平行繼承體系(Parallel Inheritance Hierarchies)** | (見上) | 搬移函式(Move Method)、搬移欄位(Move Field) |
735
735
 
736
- #### 2. 物件導向濫用者(OO Abusers)
736
+ #### 4. 可贅除物(Dispensables)
737
737
 
738
- | 異味 | 說明 | 重構方式 |
739
- |------|------|---------|
740
- | **Switch Statements(Switch 語句)** | 複雜的 switch/case 或 if/else 鏈 | Replace Type Code with Subclasses、Replace Conditional with Polymorphism、Replace Parameter with Explicit Methods、Introduce Null Object |
741
- | **Temporary Field(暫時欄位)** | 只在某些情況下有值的欄位 | Extract Class、Introduce Null Object |
742
- | **Refused Bequest(被拒絕的遺產)** | 子類別不使用繼承的方法/資料 | Replace Inheritance with Delegation、Push Down Method/Field |
743
- | **Alternative Classes with Different Interfaces(介面不同的替代類別)** | 做相同事情但有不同介面的類別 | Rename Method、Move Method、Extract Superclass |
744
- | **Parallel Inheritance Hierarchies(平行繼承階層)** | 每次建立一個類別的子類別就需要建立另一個類別的子類別 | Move Method、Move Field 合併階層 |
738
+ 可以被移除的不必要程式碼。
745
739
 
746
- #### 3. 變更阻礙者(Change Preventers)
740
+ | 壞味道 | 說明 | 重構手法 |
741
+ |-------|-------------|-------------|
742
+ | **註解(Comments)** | 掩蓋糟糕程式碼的過多註解 | 提煉函式(Extract Method)、重新命名函式(Rename Method)、引入斷言(Introduce Assertion) |
743
+ | **重複程式碼(Duplicate Code)** | 多處出現相同或相似的程式碼 | 提煉函式(Extract Method)、上推函式(Pull Up Method)、提煉類別(Extract Class)、搬移陳述句(Slide Statements) |
744
+ | **死碼(Dead Code)** | 未使用的程式碼(變數、函式、類別) | 移除死碼(Remove Dead Code) |
745
+ | **冗贅類別(Lazy Class)** | 做的太少不足以證明其存在價值的類別 | 內聯類別(Inline Class)、折疊體系(Collapse Hierarchy) |
746
+ | **誇誇其談未來性(Speculative Generality)** | 「以備將來之需」的未使用抽象 | 折疊體系(Collapse Hierarchy)、內聯函式(Inline Function)、內聯類別(Inline Class)、移除死碼(Remove Dead Code) |
747
+ | **純資料類別(Data Class)** | 僅有欄位與 getter/setter 的類別 | 搬移函式(Move Method)、封裝欄位(Encapsulate Field)、封裝集合(Encapsulate Collection) |
747
748
 
748
- | 異味 | 說明 | 重構方式 |
749
- |------|------|---------|
750
- | **Divergent Change(發散式變更)** | 一個類別因不同原因經常被修改 | Extract Class 分離不同的關注點 |
751
- | **Shotgun Surgery(散彈槍手術)** | 一個變更需要修改多個類別 | Move Method、Move Field、Inline Class 合併相關行為 |
752
- | **Parallel Inheritance Hierarchies(平行繼承階層)** | 每次建立一個類別的子類別就需要建立另一個 | Move Method、Move Field |
749
+ #### 5. 耦合者(Couplers)
753
750
 
754
- #### 4. 可有可無者(Dispensables)
751
+ 類別之間存在過度耦合的程式碼。
755
752
 
756
- | 異味 | 說明 | 重構方式 |
757
- |------|------|---------|
758
- | **Lazy Class(懶惰類別)** | 做太少事的類別 | Inline Class、Collapse Hierarchy |
759
- | **Data Class(資料類別)** | 只有欄位和 getter/setter 的類別 | Move Method、Encapsulate Field、Encapsulate Collection |
760
- | **Duplicate Code(重複程式碼)** | 相同程式碼在多處出現 | Extract Method、Extract Class、Pull Up Method、Form Template Method |
761
- | **Dead Code(死碼)** | 未使用的程式碼 | 刪除未使用的程式碼 |
762
- | **Speculative Generality(推測式通用性)** | 為「未來可能需要」建立的未使用抽象 | Collapse Hierarchy、Inline Class、Remove Parameter、Rename Method |
763
- | **Comments(註解)** | 用於解釋難懂程式碼的過多註解 | Extract Method、Rename Method、Introduce Assertion(讓程式碼自我說明) |
753
+ | 壞味道 | 說明 | 重構手法 |
754
+ |-------|-------------|-------------|
755
+ | **依戀情結(Feature Envy)** | 函式使用另一個類別的資料多於自己的資料 | 搬移函式(Move Method)、提煉函式(Extract Method) |
756
+ | **狎暱關係(Inappropriate Intimacy)** | 類別過度緊密耦合,存取彼此的私有部分 | 搬移函式(Move Method)、搬移欄位(Move Field)、隱藏委託(Hide Delegate)、以繼承取代委託(Replace Delegation with Inheritance) |
757
+ | **訊息鏈(Message Chains)** | `a.getB().getC().getD().getValue()` | 隱藏委託(Hide Delegate)、提煉函式(Extract Method)、搬移函式(Move Method) |
758
+ | **中間人(Middle Man)** | 類別只是一味委託給另一個類別 | 移除中間人(Remove Middle Man)、內聯函式(Inline Function)、以委託取代超類別(Replace Superclass with Delegate) |
764
759
 
765
- #### 5. 耦合者(Couplers)
760
+ ### 程式碼壞味道偵測檢查清單
761
+
762
+ 用於識別常見壞味道的快速檢查清單:
763
+
764
+ ```
765
+ 函式/方法層級:
766
+ □ 函式 > 20 行? → 提煉函式(Extract Method)
767
+ □ > 3 個參數? → 引入參數物件(Introduce Parameter Object)
768
+ □ 巢狀過深(> 3 層)? → 提煉函式(Extract Method)、以保護子句取代巢狀條件式(Replace Nested Conditional with Guard Clauses)
769
+ □ 多個 return 陳述句? → 考慮重構
770
+
771
+ 類別層級:
772
+ □ 類別 > 200 行? → 提煉類別(Extract Class)
773
+ □ > 10 個函式? → 考慮拆分職責
774
+ □ 上帝類別(God class,無所不做)? → 提煉類別(Extract Class)
775
+ □ 純資料類別(僅有欄位)? → 移入行為
776
+
777
+ 程式碼模式:
778
+ □ 依型別切換(Switch on type)? → 以多型取代(Replace with Polymorphism)
779
+ □ 複製貼上的程式碼? → 提煉函式/類別(Extract Method/Class)
780
+ □ 未使用的程式碼? → 刪除它
781
+ □ 魔術數字? → 以具名常數取代(Replace with Named Constant)
782
+ ```
766
783
 
767
- | 異味 | 說明 | 重構方式 |
768
- |------|------|---------|
769
- | **Feature Envy(功能嫉妒)** | 方法過度使用另一個類別的資料 | Move Method、Extract Method |
770
- | **Inappropriate Intimacy(不當親密)** | 類別過度存取彼此的內部 | Move Method、Move Field、Change Bidirectional to Unidirectional、Extract Class、Hide Delegate |
771
- | **Message Chains(訊息鏈)** | 一連串的 getThis().getThat().getOther() | Hide Delegate、Extract Method、Move Method |
772
- | **Middle Man(中間人)** | 類別的大部分方法只是委派給另一個類別 | Remove Middle Man、Inline Method、Replace Delegation with Inheritance |
773
- | **Incomplete Library Class(不完整的函式庫類別)** | 函式庫類別缺少你需要的功能 | Introduce Foreign Method、Introduce Local Extension |
784
+ ### 安全重構檢查清單
785
+
786
+ ```
787
+ 重構前:
788
+ □ 所有測試皆通過(綠色)
789
+ □ 存在足夠的測試覆蓋率
790
+ □ 你理解程式碼在做什麼
774
791
 
775
- #### 快速診斷表
792
+ 重構期間:
793
+ □ 一次只做一個微小變更
794
+ □ 每次變更後都執行測試
795
+ □ 若測試失敗,立即還原
796
+ □ 重構時不要加入新功能
776
797
 
798
+ 重構後:
799
+ □ 所有測試仍然通過
800
+ □ 程式碼更整潔/更簡單
801
+ □ 未加入任何新功能
777
802
  ```
778
- ┌─────────────────────────────────────────────────────────────────┐
779
- │ 程式碼異味快速診斷 │
780
- ├─────────────────────────────────────────────────────────────────┤
781
- │ │
782
- │ 症狀 可能的異味 │
783
- │ ───────────────────────────────────────────── │
784
- │ 方法太長(>20 行) Long Method │
785
- │ 類別太大(>200 行) Large Class │
786
- │ 太多參數(>4 個) Long Parameter List │
787
- │ 重複程式碼 Duplicate Code │
788
- │ 複雜的 if/else 或 switch Switch Statements │
789
- │ 過度使用基本型別 Primitive Obsession │
790
- │ 一個變更影響多處 Shotgun Surgery │
791
- │ 一個類別因多種原因變更 Divergent Change │
792
- │ 方法使用別的類別資料 Feature Envy │
793
- │ 長串的方法呼叫 Message Chains │
794
- │ 類別只委派給另一個類別 Middle Man │
795
- │ 只有 getter/setter 的類別 Data Class │
796
- │ 未使用的程式碼或類別 Dead Code / Lazy Class │
797
- │ 解釋程式碼的大量註解 Comments │
798
- │ │
799
- └─────────────────────────────────────────────────────────────────┘
803
+
804
+ ### 重構技巧目錄
805
+
806
+ 基於 Martin Fowler 的《重構:改善既有程式碼的設計》(第 2 版,2018)。
807
+
808
+ #### 重新組織函式(Composing Methods)
809
+
810
+ | 技巧 | 何時使用 | 範例 |
811
+ |-----------|-------------|---------|
812
+ | **提煉函式(Extract Method)** | 過長函式、重複程式碼 | 將 10 行提煉為 `calculateDiscount()` |
813
+ | **內聯函式(Inline Method)** | 函式本體與其名稱一樣清晰 | 移除微不足道的委託 |
814
+ | **提煉變數(Extract Variable)** | 複雜運算式 | `const isEligible = age >= 18 && hasLicense` |
815
+ | **內聯變數(Inline Variable)** | 變數未增加任何資訊 | 移除 `const x = obj.value; return x;` |
816
+ | **以查詢取代暫存變數(Replace Temp with Query)** | 暫存變數被多次使用 | 轉為函式以供重複使用 |
817
+ | **拆分變數(Split Variable)** | 變數因不同目的被多次賦值 | 建立各自獨立的變數 |
818
+ | **移除對參數的賦值(Remove Assignments to Parameters)** | 令人困惑的參數修改 | 改用區域變數 |
819
+ | **以函式物件取代函式(Replace Method with Method Object)** | 帶有許多區域變數的過長函式 | 提煉至新類別 |
820
+
821
+ #### 在物件之間搬移特性(Moving Features Between Objects)
822
+
823
+ | 技巧 | 何時使用 | 範例 |
824
+ |-----------|-------------|---------|
825
+ | **搬移函式(Move Method)** | 函式使用另一個類別的特性更多 | 搬移至其所依戀的類別 |
826
+ | **搬移欄位(Move Field)** | 欄位被另一個類別使用更多 | 搬移至使用它最多的類別 |
827
+ | **提煉類別(Extract Class)** | 類別做太多事 | 拆分為兩個類別 |
828
+ | **內聯類別(Inline Class)** | 類別做太少事 | 合併至另一個類別 |
829
+ | **隱藏委託(Hide Delegate)** | 用戶端透過委託鏈進行呼叫 | 加入中介函式 |
830
+ | **移除中間人(Remove Middle Man)** | 過多的委託 | 直接公開委託物件 |
831
+
832
+ #### 組織資料(Organizing Data)
833
+
834
+ | 技巧 | 何時使用 | 範例 |
835
+ |-----------|-------------|---------|
836
+ | **以物件取代基本型別(Replace Primitive with Object)** | 帶有行為的基本型別 | `string phoneNumber` → `PhoneNumber` 類別 |
837
+ | **以物件取代資料值(Replace Data Value with Object)** | 資料項目需要額外行為 | 將價格作為帶有幣別的物件 |
838
+ | **以常數取代魔術數字(Replace Magic Number with Constant)** | 程式碼中的魔術數字 | `const MAX_RETRIES = 3` |
839
+ | **封裝欄位(Encapsulate Field)** | 公開欄位 | 加入 getter/setter 函式 |
840
+ | **封裝集合(Encapsulate Collection)** | Getter 直接回傳集合 | 回傳防禦性複本 |
841
+ | **以類別取代型別碼(Replace Type Code with Class)** | 型別碼影響行為 | 改用類別/列舉 |
842
+ | **以子類別取代型別碼(Replace Type Code with Subclasses)** | 型別碼對行為產生不同影響 | 建立子類別體系 |
843
+ | **以狀態/策略取代型別碼(Replace Type Code with State/Strategy)** | 型別碼在執行時期改變 | 使用 State/Strategy 模式 |
844
+
845
+ #### 簡化條件運算式(Simplifying Conditional Expressions)
846
+
847
+ | 技巧 | 何時使用 | 範例 |
848
+ |-----------|-------------|---------|
849
+ | **分解條件式(Decompose Conditional)** | 複雜條件式 | 將條件與分支提煉為函式 |
850
+ | **合併條件運算式(Consolidate Conditional Expression)** | 多個條件具有相同結果 | 使用邏輯運算子合併 |
851
+ | **合併重複的條件片段(Consolidate Duplicate Conditional Fragments)** | 所有分支中皆有相同程式碼 | 移至條件式之外 |
852
+ | **以保護子句取代巢狀條件式(Replace Nested Conditional with Guard Clauses)** | 深度巢狀 | 針對特殊情況提早回傳 |
853
+ | **以多型取代條件邏輯(Replace Conditional with Polymorphism)** | 依型別切換(Switch on type) | 使用多型 |
854
+ | **引入空物件(Introduce Null Object)** | 頻繁的 null 檢查 | 建立 Null Object 類別 |
855
+ | **引入斷言(Introduce Assertion)** | 關於狀態的假設 | 加入明確的斷言 |
856
+
857
+ #### 簡化函式呼叫(Making Method Calls Simpler)
858
+
859
+ | 技巧 | 何時使用 | 範例 |
860
+ |-----------|-------------|---------|
861
+ | **重新命名函式(Rename Method)** | 不清晰的名稱 | `calc()` → `calculateOrderTotal()` |
862
+ | **加入參數(Add Parameter)** | 函式需要更多資料 | 加入必要參數 |
863
+ | **移除參數(Remove Parameter)** | 參數不再使用 | 移除未使用的參數 |
864
+ | **將查詢與修改分離(Separate Query from Modifier)** | 函式同時回傳值並進行修改 | 拆分為兩個函式 |
865
+ | **參數化函式(Parameterize Method)** | 僅有字面值差異的相似函式 | 透過參數進行合併 |
866
+ | **引入參數物件(Introduce Parameter Object)** | 多個參數總是一同傳遞 | `(x, y, w, h)` → `Rectangle` |
867
+ | **保持物件完整(Preserve Whole Object)** | 從物件傳遞多個數值 | 改為傳遞該物件 |
868
+ | **以函式呼叫取代參數(Replace Parameter with Method Call)** | 參數可被計算取得 | 在內部呼叫函式 |
869
+ | **以工廠函式取代建構式(Replace Constructor with Factory Method)** | 複雜的建構邏輯 | 使用工廠函式 |
870
+
871
+ #### 處理概括關係(Dealing with Generalization)
872
+
873
+ | 技巧 | 何時使用 | 範例 |
874
+ |-----------|-------------|---------|
875
+ | **上推欄位(Pull Up Field)** | 子類別中的相同欄位 | 移至超類別 |
876
+ | **上推函式(Pull Up Method)** | 子類別中的相同函式 | 移至超類別 |
877
+ | **下移欄位(Push Down Field)** | 僅被部分子類別使用的欄位 | 移至相關子類別 |
878
+ | **下移函式(Push Down Method)** | 僅被部分子類別使用的函式 | 移至相關子類別 |
879
+ | **提煉超類別(Extract Superclass)** | 相似類別 | 建立共享的超類別 |
880
+ | **提煉介面(Extract Interface)** | 多個類別具有相同的函式子集 | 建立介面 |
881
+ | **折疊體系(Collapse Hierarchy)** | 超類別/子類別差異不夠大 | 合併類別 |
882
+ | **以委託取代繼承(Replace Inheritance with Delegation)** | 子類別不想要所有繼承的函式 | 改用組合(composition) |
883
+ | **以繼承取代委託(Replace Delegation with Inheritance)** | 過多的轉發 | 改為繼承 |
884
+
885
+ #### 快速參考:最常見的重構
886
+
887
+ ```
888
+ 每日重構(5-15 分鐘):
889
+ ├── 重新命名(變數、函式、類別)
890
+ ├── 提煉函式
891
+ ├── 內聯變數
892
+ ├── 以常數取代魔術數字
893
+ └── 提煉變數
894
+
895
+ 每週重構(30 分鐘 - 2 小時):
896
+ ├── 提煉類別
897
+ ├── 搬移函式/欄位
898
+ ├── 以多型取代條件邏輯
899
+ ├── 引入參數物件
900
+ └── 以物件取代基本型別
901
+
902
+ 策略性重構(數天 - 數週):
903
+ ├── 以委託取代繼承
904
+ ├── 提煉超類別/介面
905
+ ├── 引入空物件
906
+ └── 以狀態/策略取代型別碼
800
907
  ```
801
908
 
802
909
  ---
@@ -806,26 +913,26 @@ test('should reject password exceeding max length', () => {
806
913
  ### 測試替身類型
807
914
 
808
915
  | 類型 | 目的 | 使用時機 |
809
- |------|------|---------|
810
- | **Dummy** | 填充參數列表 | 必要參數但測試中未使用 |
811
- | **Stub** | 回傳預定義的值 | 模擬特定場景 |
916
+ |------|---------|-------------|
917
+ | **Dummy** | 填補參數列表 | 測試中不需要使用但必填的參數 |
918
+ | **Stub** | 回傳預先定義的值 | 模擬特定情境 |
812
919
  | **Spy** | 記錄互動 | 驗證方法是否被呼叫 |
813
- | **Mock** | 驗證互動 + 回傳值 | 測試行為和協作 |
814
- | **Fake** | 簡化的實作 | 記憶體內資料庫 |
920
+ | **Mock** | 驗證互動 + 回傳值 | 測試行為與協作 |
921
+ | **Fake** | 簡化的可用實作 | 記憶體內部資料庫 |
815
922
 
816
923
  ### 依測試層級的測試替身使用
817
924
 
818
- | 層級 | 建議的替身 |
819
- |------|-----------|
820
- | **單元測試** | 所有外部依賴使用 Mock、Stub |
821
- | **整合測試** | DB 使用 Fake,外部 API 使用 Stub |
822
- | **系統測試** | 真實元件,只有外部服務使用 Fake |
823
- | **E2E 測試** | 全部使用真實 |
925
+ | 層級 | 建議替身 |
926
+ |-------|---------------------|
927
+ | **單元測試** | 對所有外部相依使用 Mock、Stub |
928
+ | **整合測試** | 對資料庫使用 Fake,對外部 API 使用 Stub |
929
+ | **系統測試** | 真實元件,僅對外部服務使用 Fake |
930
+ | **E2E 測試** | 全部使用真實元件 |
824
931
 
825
- ### 範例:使用 Mock 和 Stub
932
+ ### 範例:使用 Mock 與 Stub
826
933
 
827
934
  ```typescript
828
- // Stub 範例 - 預定義的回傳值
935
+ // Stub 範例 - 預先定義的回傳值
829
936
  const paymentGateway = {
830
937
  processPayment: jest.fn().mockResolvedValue({ success: true, transactionId: 'TXN123' })
831
938
  };
@@ -840,7 +947,7 @@ test('should send confirmation email after successful payment', async () => {
840
947
 
841
948
  await order.checkout({ amount: 100, email: 'user@example.com' });
842
949
 
843
- // 驗證 mock 是否使用正確的參數被呼叫
950
+ // 驗證 mock 是否以正確的引數被呼叫
844
951
  expect(emailService.sendConfirmation).toHaveBeenCalledWith(
845
952
  'user@example.com',
846
953
  expect.objectContaining({ transactionId: 'TXN123' })
@@ -851,15 +958,15 @@ test('should send confirmation email after successful payment', async () => {
851
958
  ### 避免過度 Mock
852
959
 
853
960
  ```
854
- ❌ 過度 mock(測試實作細節):
961
+ ❌ 過度 Mock(測試實作細節):
855
962
  - Mock 私有方法
856
- - Mock 每一個依賴
963
+ - Mock 每一個相依套件
857
964
  - 驗證每一個內部方法呼叫
858
965
 
859
- ✅ 適當的 mock:
966
+ ✅ 適當的 Mock:
860
967
  - Mock 外部服務(API、資料庫)
861
- - Mock 慢速操作(檔案 I/O、網路)
862
- - Mock 非確定性操作(時間、隨機)
968
+ - Mock 耗時操作(檔案 I/O、網路)
969
+ - Mock 不確定性操作(時間、隨機)
863
970
  ```
864
971
 
865
972
  ---
@@ -868,65 +975,65 @@ test('should send confirmation email after successful payment', async () => {
868
975
 
869
976
  ### 程式碼層級反模式
870
977
 
871
- | 反模式 | 說明 | 影響 | 修復方式 |
872
- |--------|------|------|---------|
873
- | **測試實作細節** | 測試私有方法或內部狀態 | 脆弱的測試,重構會破壞測試 | 只測試公開行為 |
874
- | **過度 Mock** | Mock 所有東西,失去真實性 | 虛假的信心,bug 進入生產環境 | 平衡 mock 和真實元件 |
875
- | **測試相依性** | 測試依賴執行順序 | 隨機失敗,難以隔離 | 每個測試設置自己的狀態 |
876
- | **魔術數字/字串** | 沒有意義的硬編碼值 | 可讀性差,維護噩夢 | 使用命名常數、建構器 |
877
- | **缺少斷言** | 測試沒有適當的斷言 | 假陽性 | 每個測試需要明確的斷言 |
878
- | **不穩定測試** | 有時通過,有時失敗 | 對測試套件信任度降低 | 消除時間/順序依賴 |
879
- | **過大的 Arrange 區塊** | 每個測試都有複雜設置 | 難以理解、維護 | 提取設置到建構器/fixtures |
880
- | **測試中的條件邏輯** | 測試程式碼中的 if/else | 一個測試中有多個測試 | 分割成獨立的測試 |
881
- | **測試程式碼重複** | 許多測試中相同的設置 | 維護負擔 | 提取共享設置 |
882
- | **過於特定的斷言** | 斷言每一個欄位 | 脆弱的測試 | 只斷言相關欄位 |
883
- | **忽略測試失敗** | 跳過或註解掉失敗的測試 | 隱藏的 bug | 修復或移除失敗的測試 |
884
- | **測試第三方程式碼** | 測試程式庫/框架行為 | 浪費努力 | 信任第三方,測試你的程式碼 |
885
- | **一個巨大的測試** | 單一測試涵蓋所有 | 難以診斷失敗 | 分割成聚焦的測試 |
886
- | **沒有測試名稱** | `test1`、`test2` | 無法理解 | 使用描述性名稱 |
887
- | **捕獲所有例外** | 測試中的 `catch (Exception e)` | 隱藏的失敗 | 捕獲特定例外 |
978
+ | 反模式 | 說明 | 影響 | 修復 |
979
+ |--------------|-------------|--------|-------------|
980
+ | **測試實作細節** | 測試私有方法或內部狀態 | 脆性測試,重構會破壞測試 | 僅測試公開行為 |
981
+ | **過度 Mock** | Mock 所有東西,失去真實性 | 虛假信心,正式環境出現 bug | 在 Mock 與真實元件間取得平衡 |
982
+ | **測試相互依賴** | 測試依賴執行順序 | 隨機失敗,難以隔離 | 每個測試設置自己的狀態 |
983
+ | **魔術數字/字串** | 未賦予意義的寫死數值 | 可讀性差,維護惡夢 | 使用具名常數、Builder |
984
+ | **缺少斷言** | 測試缺乏適當的斷言 | 偽陽性(假警報) | 每個測試都需要明確的斷言 |
985
+ | **不穩定測試 (Flaky Tests)** | 有時通過,有時失敗 | 侵蝕對測試套件的信任 | 消除時間/順序相依性 |
986
+ | **過大的 Arrange 區段** | 每個測試都有複雜的設置 | 難以理解、維護 | 將設置抽取至 Builder/Fixture |
987
+ | **測試中的條件邏輯** | 測試程式碼中出現 if/else | 多個測試混在同一個測試裡 | 拆分為獨立的測試 |
988
+ | **測試程式碼重複** | 許多測試中有一樣的設置 | 維護負擔 | 抽取共用設置 |
989
+ | **過度具體的斷言** | 斷言每一個欄位 | 脆性測試 | 僅斷言相關欄位 |
990
+ | **忽略測試失敗** | 跳過或註解掉失敗的測試 | 隱藏 bug | 修復或移除失敗的測試 |
991
+ | **測試第三方程式碼** | 測試函式庫/框架行為 | 浪費精力 | 信任第三方,測試自己的程式碼 |
992
+ | **單一龐大測試** | 單一測試涵蓋所有東西 | 難以診斷失敗原因 | 拆分為專注的小測試 |
993
+ | **無意義的測試名稱** | `test1`、`test2` | 無法理解 | 使用具描述性的名稱 |
994
+ | **捕捉所有例外** | 測試中使用 `catch (Exception e)` | 隱藏失敗 | 捕捉特定例外 |
888
995
 
889
996
  ### 流程層級反模式
890
997
 
891
- | 反模式 | 說明 | 影響 | 修復方式 |
892
- |--------|------|------|---------|
893
- | **跳過紅色階段** | 在測試之前寫程式碼 | 失去 TDD 設計優點 | 紀律:始終先寫失敗的測試 |
894
- | **跳過重構階段** | 從不清理 | 技術債累積 | 安排重構時間 |
895
- | **開發後測試 (TAD)** | 程式碼完成後才寫測試 | 不是 TDD,錯過設計回饋 | 真正的 TDD:測試優先 |
896
- | **一次寫所有測試** | 同時寫所有測試 | 不堪負荷,覆蓋率差 | 一次一個測試 |
897
- | **100% 覆蓋率迷思** | 追求覆蓋率指標 | 無意義的測試 | 專注於行為覆蓋 |
898
- | **不審查測試** | PR 中不審查測試 | 測試品質差 | 在程式碼審查中包含測試 |
899
- | **延遲執行測試** | 不常執行測試 | 回饋延遲 | 持續執行測試 |
900
- | **忽略慢速測試** | 讓測試套件變慢 | 開發者跳過測試 | 優化或並行化 |
901
- | **TDD 狂熱** | 到處強制使用 TDD | 團隊挫敗 | 務實地應用 TDD |
902
- | **不維護測試** | 讓測試腐敗 | 假陽性/假陰性 | 將測試視為生產程式碼 |
998
+ | 反模式 | 說明 | 影響 | 修復 |
999
+ |--------------|-------------|--------|-------------|
1000
+ | **跳過紅色階段** | 在寫測試之前先寫程式碼 | 失去 TDD 設計效益 | 紀律:始終先撰寫失敗的測試 |
1001
+ | **跳過重構階段** | 從不清理程式碼 | 技術債累積 | 排定重構時間 |
1002
+ | **後測開發 (TAD)** | 程式碼完成後才寫測試 | 非 TDD,錯失設計回饋 | 真正的 TDD:測試優先 |
1003
+ | **大霹靂測試撰寫** | 一次寫完所有測試 | 難以招架,覆蓋率不佳 | 一次一個測試 |
1004
+ | **100% 覆蓋率執念** | 盲目追求覆蓋率指標 | 毫無意義的測試 | 聚焦於行為覆蓋率 |
1005
+ | **缺乏測試審查** | PR 中未審查測試 | 測試品質差 | 在程式碼審查中納入測試 |
1006
+ | **延遲執行測試** | 不常執行測試 | 回饋太晚 | 持續執行測試 |
1007
+ | **忽略緩慢測試** | 任由測試套件變慢 | 開發者跳過測試 | 最佳化或平行化 |
1008
+ | **TDD 狂熱** | 在所有地方強推 TDD | 團隊感到沮喪 | 務實應用 TDD |
1009
+ | **缺乏測試維護** | 任由測試腐爛 | 偽陽性/偽陰性 | 將測試視為正式環境程式碼 |
903
1010
 
904
1011
  ### 診斷與修復步驟
905
1012
 
906
1013
  ```
907
1014
  ┌─────────────────────────────────────────────────────────────────┐
908
- │ 反模式診斷工作流程 │
1015
+ │ 反模式診斷工作流程 │
909
1016
  ├─────────────────────────────────────────────────────────────────┤
910
1017
  │ │
911
- │ 症狀:重構時測試經常失敗 │
912
- │ ├─ 可能原因:測試實作細節 │
913
- │ └─ 修復:審查測試,確保只測試行為 │
1018
+ │ 症狀:重構時測試經常損壞 │
1019
+ │ ├─ 可能原因:測試實作細節 │
1020
+ │ └─ 修復:審查測試,確保僅測試行為 │
914
1021
  │ │
915
- │ 症狀:測試通過但 bug 進入生產環境 │
916
- │ ├─ 可能原因:過度 mock,缺少邊界情況 │
917
- │ └─ 修復:新增整合測試,審查覆蓋差距 │
1022
+ │ 症狀:測試通過但 bug 流入正式環境 │
1023
+ │ ├─ 可能原因:過度 Mock、缺少邊界情況 │
1024
+ │ └─ 修復:加入整合測試,審查覆蓋率缺口 │
918
1025
  │ │
919
- │ 症狀:測試隨機失敗 │
920
- │ ├─ 可能原因:測試相依性,時間問題 │
921
- │ └─ 修復:隔離測試,mock 時間相關操作 │
1026
+ │ 症狀:測試隨機失敗 │
1027
+ │ ├─ 可能原因:測試相互依賴、時序問題 │
1028
+ │ └─ 修復:隔離測試,Mock 與時間相依的操作 │
922
1029
  │ │
923
- │ 症狀:測試套件執行時間太長 │
924
- │ ├─ 可能原因:整合測試太多,慢速 I/O │
925
- │ └─ 修復:增加單元測試比例,並行化 │
1030
+ │ 症狀:測試套件耗時過長 │
1031
+ │ ├─ 可能原因:太多整合測試、緩慢的 I/O │
1032
+ │ └─ 修復:提高單元測試比例、平行化執行 │
926
1033
  │ │
927
- │ 症狀:團隊迴避寫測試 │
928
- │ ├─ 可能原因:測試太複雜,工具不佳 │
929
- │ └─ 修復:簡化測試設置,改善測試工具 │
1034
+ │ 症狀:團隊排斥寫測試 │
1035
+ │ ├─ 可能原因:測試過於複雜、工具支援差 │
1036
+ │ └─ 修復:簡化測試設置,改善測試公用程式 │
930
1037
  │ │
931
1038
  └─────────────────────────────────────────────────────────────────┘
932
1039
  ```
@@ -935,13 +1042,13 @@ test('should send confirmation email after successful payment', async () => {
935
1042
 
936
1043
  ## 語言/框架實踐
937
1044
 
938
- 詳細的語言特定 TDD 範例,請參閱 TDD Assistant skill:
939
- - [語言範例](../skills/tdd-assistant/language-examples.md)
1045
+ 有關特定語言的詳細 TDD 範例,請參閱 TDD Assistant 技能:
1046
+ - [Language Examples](../skills/tdd-assistant/language-examples.md)
940
1047
 
941
- ### 依語言快速參考
1048
+ ### 依語言速查手冊
942
1049
 
943
- | 語言 | 測試框架 | Mock 程式庫 | BDD 工具 |
944
- |------|---------|------------|---------|
1050
+ | 語言 | 測試框架 | Mock 函式庫 | BDD 工具 |
1051
+ |----------|---------------|--------------|----------|
945
1052
  | **JavaScript/TypeScript** | Jest, Vitest | jest.mock, vitest.mock | Cucumber.js |
946
1053
  | **Python** | pytest, unittest | unittest.mock, pytest-mock | Behave |
947
1054
  | **C#** | xUnit, NUnit, MSTest | Moq, NSubstitute | SpecFlow |
@@ -951,36 +1058,36 @@ test('should send confirmation email after successful payment', async () => {
951
1058
 
952
1059
  ### 框架選擇指南
953
1060
 
954
- | 考量 | 建議 |
955
- |------|------|
956
- | **新專案** | 使用 IDE 支援最好的框架 |
957
- | **團隊經驗** | 使用團隊最熟悉的 |
958
- | **現有程式碼庫** | 匹配現有測試框架 |
959
- | **需要 BDD** | 選擇有 BDD 整合的框架 |
960
- | **速度關鍵** | 考慮並行執行支援 |
1061
+ | 考量因素 | 建議 |
1062
+ |---------------|----------------|
1063
+ | **新專案** | 使用 IDE 支援最佳的框架 |
1064
+ | **團隊經驗** | 使用團隊最熟悉的工具 |
1065
+ | **現有程式碼庫** | 與現有測試框架一致 |
1066
+ | **需要 BDD** | 選擇具備 BDD 整合支援的框架 |
1067
+ | **速度關鍵** | 考量平行執行支援能力 |
961
1068
 
962
1069
  ---
963
1070
 
964
- ## 度量與評估
1071
+ ## 指標與評估
965
1072
 
966
1073
  ### TDD 成熟度模型
967
1074
 
968
- | 層級 | 名稱 | 特徵 |
969
- |------|------|------|
970
- | **Level 0** | 無 TDD | 程式碼之後寫測試(如果有的話) |
971
- | **Level 1** | 測試優先 | 有時在程式碼之前寫測試 |
972
- | **Level 2** | TDD 實踐者 | 一致的紅-綠-重構循環 |
973
- | **Level 3** | TDD 專家 | 有效的測試替身,乾淨的測試 |
974
- | **Level 4** | TDD 大師 | TDD 驅動設計,指導他人 |
1075
+ | 等級 | 名稱 | 特徵 |
1076
+ |-------|------|-----------------|
1077
+ | **等級 0** | 無 TDD | 測試在寫完程式碼後才寫,甚至完全不寫 |
1078
+ | **等級 1** | 測試優先 (Test-First) | 有時在寫程式碼之前先寫測試 |
1079
+ | **等級 2** | TDD 實踐者 | 一貫遵循紅-綠-重構循環 |
1080
+ | **等級 3** | TDD 專家 | 有效運用測試替身,測試乾淨俐落 |
1081
+ | **等級 4** | TDD 大師 | TDD 驅動設計,指導他人 |
975
1082
 
976
1083
  ### 關鍵指標
977
1084
 
978
- | 指標 | 目標 | 警示閾值 |
979
- |------|------|---------|
1085
+ | 指標 | 目標 | 警示門檻 |
1086
+ |--------|--------|-------------------|
980
1087
  | **程式碼覆蓋率** | > 80% | < 60% |
981
- | **測試對程式碼比** | 1:1 到 2:1 | < 0.5:1 |
982
- | **測試執行時間** | < 30 秒(單元) | > 2 分鐘 |
983
- | **不穩定測試率** | 0% | > 1% |
1088
+ | **測試與程式碼比例** | 1:1 至 2:1 | < 0.5:1 |
1089
+ | **測試執行時間** | < 30 秒(單元測試) | > 2 分鐘 |
1090
+ | **不穩定測試比例** | 0% | > 1% |
984
1091
  | **測試維護成本** | < 15% 開發時間 | > 30% |
985
1092
  | **缺陷逃逸率** | 下降中 | 上升中 |
986
1093
 
@@ -989,14 +1096,14 @@ test('should send confirmation email after successful payment', async () => {
989
1096
  ```
990
1097
  團隊 TDD 評估:
991
1098
 
992
- □ 在生產程式碼之前寫測試
1099
+ □ 測試在生產程式碼之前撰寫
993
1100
  □ 遵循紅-綠-重構循環
994
1101
  □ 測試名稱清楚描述行為
995
- □ 測試是獨立且可重複的
1102
+ □ 測試具備獨立性與可重複性
996
1103
  □ 測試套件執行快速(< 2 分鐘)
997
- □ 沒有不穩定的測試
1104
+ □ 無不穩定測試
998
1105
  □ 足夠的覆蓋率(> 80%)
999
- □ 程式碼審查中審查測試
1106
+ □ 程式碼審查中包含測試審查
1000
1107
  □ 定期進行重構
1001
1108
  □ CI/CD 自動執行測試
1002
1109
  ```
@@ -1005,12 +1112,13 @@ test('should send confirmation email after successful payment', async () => {
1005
1112
 
1006
1113
  ## 相關標準
1007
1114
 
1008
- - [重構標準](../../core/refactoring-standards.md) - 完整重構指南(遺留程式碼策略、大規模模式、度量指標)
1009
- - [測試標準](../../core/testing-standards.md) - 核心測試標準(UT/IT/ST/E2E)(或使用 `/testing-guide` 技能)
1010
- - [測試完整性維度](../../core/test-completeness-dimensions.md) - 8 維度框架
1011
- - [規格驅動開發](../../core/spec-driven-development.md) - SDD 工作流程
1012
- - [程式碼入庫標準](../../core/checkin-standards.md) - 入庫要求
1013
- - [程式碼審查檢查清單](../../core/code-review-checklist.md) - 審查指南
1115
+ - [Testing Standards](../../core/testing-standards.md) - 核心測試標準 (UT/IT/ST/E2E)(或使用 `/testing-guide` 技能)
1116
+ - [Test Completeness Dimensions](../../core/test-completeness-dimensions.md) - 八維度框架
1117
+ - [Behavior-Driven Development](../../core/behavior-driven-development.md) - 採用 Given-When-Then 格式的 BDD 工作流程
1118
+ - [Acceptance Test-Driven Development](../../core/acceptance-test-driven-development.md) - 包含規格工作坊的 ATDD 工作流程
1119
+ - [Spec-Driven Development](../../core/spec-driven-development.md) - SDD 工作流程
1120
+ - [Code Check-in Standards](../../core/checkin-standards.md) - 簽入要求
1121
+ - [Code Review Checklist](../../core/code-review-checklist.md) - 審查指南
1014
1122
 
1015
1123
  ---
1016
1124
 
@@ -1027,29 +1135,30 @@ test('should send confirmation email after successful payment', async () => {
1027
1135
 
1028
1136
  - [IEEE 29119 - 軟體測試標準](https://www.iso.org/standard/81291.html)
1029
1137
  - [SWEBOK v4.0 - 第 5 章:軟體建構](https://www.computer.org/education/bodies-of-knowledge/software-engineering)
1030
- - [ISTQB 認證測試員基礎級](https://www.istqb.org/)
1138
+ - [ISTQB Certified Tester Foundation Level](https://www.istqb.org/)
1031
1139
 
1032
1140
  ### 線上資源
1033
1141
 
1034
1142
  - [TDD by Example - Martin Fowler](https://martinfowler.com/bliki/TestDrivenDevelopment.html)
1035
1143
  - [The Three Rules of TDD - Uncle Bob](http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd)
1036
1144
  - [Test Pyramid - Martin Fowler](https://martinfowler.com/bliki/TestPyramid.html)
1145
+ - [Double-Loop TDD - Samman Coaching](https://sammancoaching.org/learning_hours/bdd/double_loop_tdd.html) - 解說 BDD 外循環 / TDD 內循環模式
1037
1146
  - [Approval Tests](https://approvaltests.com/)
1038
1147
 
1039
1148
  ---
1040
1149
 
1041
1150
  ## 版本歷史
1042
1151
 
1043
- | 版本 | 日期 | 變更內容 |
1044
- |------|------|----------|
1045
- | 1.2.0 | 2026-01-25 | 新增:方法論分類章節,明確 TDD 與 SDD 的關係、歷史背景、使用上下文 |
1046
- | 1.1.0 | 2026-01-12 | 新增:完整程式碼異味目錄(22+ 種異味,分為 5 大類別),基於 Martin Fowler《Refactoring》第二版 |
1152
+ | 版本 | 日期 | 變更 |
1153
+ |---------|------|---------|
1154
+ | 1.2.0 | 2026-01-25 | 新增:方法論分類章節(傳統開發方法論定位、與 SDD 的關係) |
1155
+ | 1.1.0 | 2026-01-12 | 新增:完整程式碼壞味道目錄(基於 Martin Fowler《Refactoring》第 2 版,分為 5 大類共 22+ 種壞味道)、程式碼壞味道偵測檢查清單 |
1047
1156
  | 1.0.0 | 2026-01-07 | 初始 TDD 標準定義 |
1048
1157
 
1049
1158
  ---
1050
1159
 
1051
1160
  ## 授權
1052
1161
 
1053
- 本標準依據 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授權釋出。
1162
+ 本標準依據 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 釋出。
1054
1163
 
1055
1164
  **來源**: [universal-dev-standards](https://github.com/AsiaOstrich/universal-dev-standards)