universal-dev-standards 3.5.1-beta.1 → 3.5.1-beta.11

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 (433) hide show
  1. package/bin/uds.js +2 -0
  2. package/bundled/core/ai-instruction-standards.md +205 -0
  3. package/bundled/core/anti-hallucination.md +684 -0
  4. package/bundled/core/changelog-standards.md +556 -0
  5. package/bundled/core/checkin-standards.md +935 -0
  6. package/bundled/core/code-review-checklist.md +684 -0
  7. package/bundled/core/commit-message-guide.md +915 -0
  8. package/bundled/core/documentation-structure.md +1117 -0
  9. package/bundled/core/documentation-writing-standards.md +487 -0
  10. package/bundled/core/error-code-standards.md +382 -0
  11. package/bundled/core/git-workflow.md +859 -0
  12. package/bundled/core/logging-standards.md +323 -0
  13. package/bundled/core/project-structure.md +354 -0
  14. package/bundled/core/refactoring-standards.md +636 -0
  15. package/bundled/core/spec-driven-development.md +207 -0
  16. package/bundled/core/test-completeness-dimensions.md +536 -0
  17. package/bundled/core/test-driven-development.md +995 -0
  18. package/bundled/core/testing-standards.md +3061 -0
  19. package/bundled/core/versioning.md +902 -0
  20. package/bundled/locales/README.md +88 -0
  21. package/bundled/locales/zh-CN/CHANGELOG.md +705 -0
  22. package/bundled/locales/zh-CN/CLAUDE.md +213 -0
  23. package/bundled/locales/zh-CN/MAINTENANCE.md +689 -0
  24. package/bundled/locales/zh-CN/README.md +707 -0
  25. package/bundled/locales/zh-CN/STANDARDS-MAPPING.md +177 -0
  26. package/bundled/locales/zh-CN/adoption/ADOPTION-GUIDE.md +392 -0
  27. package/bundled/locales/zh-CN/adoption/STATIC-DYNAMIC-GUIDE.md +302 -0
  28. package/bundled/locales/zh-CN/adoption/checklists/enterprise.md +332 -0
  29. package/bundled/locales/zh-CN/adoption/checklists/minimal.md +141 -0
  30. package/bundled/locales/zh-CN/adoption/checklists/recommended.md +272 -0
  31. package/bundled/locales/zh-CN/ai/MAINTENANCE.md +739 -0
  32. package/bundled/locales/zh-CN/ai/options/changelog/auto-generated.ai.yaml +76 -0
  33. package/bundled/locales/zh-CN/ai/options/changelog/keep-a-changelog.ai.yaml +99 -0
  34. package/bundled/locales/zh-CN/ai/options/code-review/automated-review.ai.yaml +120 -0
  35. package/bundled/locales/zh-CN/ai/options/code-review/pair-programming.ai.yaml +109 -0
  36. package/bundled/locales/zh-CN/ai/options/code-review/pr-review.ai.yaml +104 -0
  37. package/bundled/locales/zh-CN/ai/options/commit-message/bilingual.ai.yaml +105 -0
  38. package/bundled/locales/zh-CN/ai/options/commit-message/english.ai.yaml +79 -0
  39. package/bundled/locales/zh-CN/ai/options/commit-message/traditional-chinese.ai.yaml +100 -0
  40. package/bundled/locales/zh-CN/ai/options/documentation/api-docs.ai.yaml +140 -0
  41. package/bundled/locales/zh-CN/ai/options/documentation/markdown-docs.ai.yaml +89 -0
  42. package/bundled/locales/zh-CN/ai/options/documentation/wiki-style.ai.yaml +119 -0
  43. package/bundled/locales/zh-CN/ai/options/git-workflow/gitflow.ai.yaml +133 -0
  44. package/bundled/locales/zh-CN/ai/options/git-workflow/github-flow.ai.yaml +73 -0
  45. package/bundled/locales/zh-CN/ai/options/git-workflow/merge-commit.ai.yaml +88 -0
  46. package/bundled/locales/zh-CN/ai/options/git-workflow/rebase-ff.ai.yaml +113 -0
  47. package/bundled/locales/zh-CN/ai/options/git-workflow/squash-merge.ai.yaml +85 -0
  48. package/bundled/locales/zh-CN/ai/options/git-workflow/trunk-based.ai.yaml +117 -0
  49. package/bundled/locales/zh-CN/ai/options/project-structure/dotnet.ai.yaml +108 -0
  50. package/bundled/locales/zh-CN/ai/options/project-structure/go.ai.yaml +115 -0
  51. package/bundled/locales/zh-CN/ai/options/project-structure/java.ai.yaml +113 -0
  52. package/bundled/locales/zh-CN/ai/options/project-structure/kotlin.ai.yaml +123 -0
  53. package/bundled/locales/zh-CN/ai/options/project-structure/nodejs.ai.yaml +101 -0
  54. package/bundled/locales/zh-CN/ai/options/project-structure/php.ai.yaml +147 -0
  55. package/bundled/locales/zh-CN/ai/options/project-structure/python.ai.yaml +116 -0
  56. package/bundled/locales/zh-CN/ai/options/project-structure/ruby.ai.yaml +140 -0
  57. package/bundled/locales/zh-CN/ai/options/project-structure/rust.ai.yaml +117 -0
  58. package/bundled/locales/zh-CN/ai/options/project-structure/swift.ai.yaml +143 -0
  59. package/bundled/locales/zh-CN/ai/options/testing/contract-testing.ai.yaml +254 -0
  60. package/bundled/locales/zh-CN/ai/options/testing/e2e-testing.ai.yaml +116 -0
  61. package/bundled/locales/zh-CN/ai/options/testing/industry-pyramid.ai.yaml +144 -0
  62. package/bundled/locales/zh-CN/ai/options/testing/integration-testing.ai.yaml +90 -0
  63. package/bundled/locales/zh-CN/ai/options/testing/istqb-framework.ai.yaml +108 -0
  64. package/bundled/locales/zh-CN/ai/options/testing/performance-testing.ai.yaml +272 -0
  65. package/bundled/locales/zh-CN/ai/options/testing/security-testing.ai.yaml +160 -0
  66. package/bundled/locales/zh-CN/ai/options/testing/system-testing.ai.yaml +101 -0
  67. package/bundled/locales/zh-CN/ai/options/testing/unit-testing.ai.yaml +82 -0
  68. package/bundled/locales/zh-CN/ai/standards/anti-hallucination.ai.yaml +145 -0
  69. package/bundled/locales/zh-CN/ai/standards/changelog.ai.yaml +146 -0
  70. package/bundled/locales/zh-CN/ai/standards/checkin-standards.ai.yaml +170 -0
  71. package/bundled/locales/zh-CN/ai/standards/code-review.ai.yaml +148 -0
  72. package/bundled/locales/zh-CN/ai/standards/commit-message.ai.yaml +175 -0
  73. package/bundled/locales/zh-CN/ai/standards/documentation-structure.ai.yaml +124 -0
  74. package/bundled/locales/zh-CN/ai/standards/documentation-writing-standards.ai.yaml +190 -0
  75. package/bundled/locales/zh-CN/ai/standards/error-codes.ai.yaml +139 -0
  76. package/bundled/locales/zh-CN/ai/standards/git-workflow.ai.yaml +95 -0
  77. package/bundled/locales/zh-CN/ai/standards/logging.ai.yaml +128 -0
  78. package/bundled/locales/zh-CN/ai/standards/project-structure.ai.yaml +134 -0
  79. package/bundled/locales/zh-CN/ai/standards/spec-driven-development.ai.yaml +169 -0
  80. package/bundled/locales/zh-CN/ai/standards/test-completeness-dimensions.ai.yaml +220 -0
  81. package/bundled/locales/zh-CN/ai/standards/testing.ai.yaml +137 -0
  82. package/bundled/locales/zh-CN/ai/standards/versioning.ai.yaml +211 -0
  83. package/bundled/locales/zh-CN/core/ai-instruction-standards.md +213 -0
  84. package/bundled/locales/zh-CN/core/anti-hallucination.md +691 -0
  85. package/bundled/locales/zh-CN/core/changelog-standards.md +147 -0
  86. package/bundled/locales/zh-CN/core/checkin-standards.md +943 -0
  87. package/bundled/locales/zh-CN/core/code-review-guide.md +693 -0
  88. package/bundled/locales/zh-CN/core/commit-message-guide.md +129 -0
  89. package/bundled/locales/zh-CN/core/documentation-structure.md +173 -0
  90. package/bundled/locales/zh-CN/core/documentation-writing-standards.md +495 -0
  91. package/bundled/locales/zh-CN/core/error-code-standards.md +180 -0
  92. package/bundled/locales/zh-CN/core/git-workflow.md +193 -0
  93. package/bundled/locales/zh-CN/core/logging-standards.md +174 -0
  94. package/bundled/locales/zh-CN/core/project-structure.md +184 -0
  95. package/bundled/locales/zh-CN/core/refactoring-standards.md +642 -0
  96. package/bundled/locales/zh-CN/core/spec-driven-development.md +215 -0
  97. package/bundled/locales/zh-CN/core/test-completeness-dimensions.md +544 -0
  98. package/bundled/locales/zh-CN/core/test-driven-development.md +1002 -0
  99. package/bundled/locales/zh-CN/core/testing-standards.md +170 -0
  100. package/bundled/locales/zh-CN/core/versioning.md +177 -0
  101. package/bundled/locales/zh-CN/docs/AI-AGENT-ROADMAP.md +303 -0
  102. package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +990 -0
  103. package/bundled/locales/zh-CN/docs/OPERATION-WORKFLOW.md +1064 -0
  104. package/bundled/locales/zh-CN/docs/USAGE-MODES-COMPARISON.md +333 -0
  105. package/bundled/locales/zh-CN/docs/WINDOWS-GUIDE.md +215 -0
  106. package/bundled/locales/zh-CN/integrations/codex/AGENTS.md +115 -0
  107. package/bundled/locales/zh-CN/integrations/codex/README.md +67 -0
  108. package/bundled/locales/zh-CN/integrations/gemini-cli/GEMINI.md +102 -0
  109. package/bundled/locales/zh-CN/integrations/gemini-cli/README.md +140 -0
  110. package/bundled/locales/zh-CN/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +269 -0
  111. package/bundled/locales/zh-CN/integrations/github-copilot/README.md +167 -0
  112. package/bundled/locales/zh-CN/integrations/github-copilot/copilot-instructions.md +263 -0
  113. package/bundled/locales/zh-CN/integrations/github-copilot/skills-mapping.md +192 -0
  114. package/bundled/locales/zh-CN/integrations/google-antigravity/INSTRUCTIONS.md +61 -0
  115. package/bundled/locales/zh-CN/integrations/google-antigravity/README.md +84 -0
  116. package/bundled/locales/zh-CN/integrations/opencode/AGENTS.md +111 -0
  117. package/bundled/locales/zh-CN/integrations/opencode/README.md +176 -0
  118. package/bundled/locales/zh-CN/integrations/opencode/skills-mapping.md +396 -0
  119. package/bundled/locales/zh-CN/integrations/openspec/AGENTS.md +301 -0
  120. package/bundled/locales/zh-CN/integrations/openspec/README.md +43 -0
  121. package/bundled/locales/zh-CN/integrations/spec-kit/AGENTS.md +184 -0
  122. package/bundled/locales/zh-CN/integrations/spec-kit/README.md +43 -0
  123. package/bundled/locales/zh-CN/options/commit-message/bilingual.md +161 -0
  124. package/bundled/locales/zh-CN/options/commit-message/english.md +137 -0
  125. package/bundled/locales/zh-CN/options/commit-message/traditional-chinese.md +162 -0
  126. package/bundled/locales/zh-CN/options/git-workflow/gitflow.md +147 -0
  127. package/bundled/locales/zh-CN/options/git-workflow/github-flow.md +124 -0
  128. package/bundled/locales/zh-CN/options/git-workflow/merge-commit.md +124 -0
  129. package/bundled/locales/zh-CN/options/git-workflow/rebase-ff.md +160 -0
  130. package/bundled/locales/zh-CN/options/git-workflow/squash-merge.md +117 -0
  131. package/bundled/locales/zh-CN/options/git-workflow/trunk-based.md +125 -0
  132. package/bundled/locales/zh-CN/options/project-structure/dotnet.md +183 -0
  133. package/bundled/locales/zh-CN/options/project-structure/go.md +226 -0
  134. package/bundled/locales/zh-CN/options/project-structure/java.md +213 -0
  135. package/bundled/locales/zh-CN/options/project-structure/nodejs.md +185 -0
  136. package/bundled/locales/zh-CN/options/project-structure/python.md +229 -0
  137. package/bundled/locales/zh-CN/options/testing/e2e-testing.md +207 -0
  138. package/bundled/locales/zh-CN/options/testing/integration-testing.md +230 -0
  139. package/bundled/locales/zh-CN/options/testing/system-testing.md +183 -0
  140. package/bundled/locales/zh-CN/options/testing/unit-testing.md +165 -0
  141. package/bundled/locales/zh-CN/skills/INTEGRATION-GUIDE.md +218 -0
  142. package/bundled/locales/zh-CN/skills/README.md +134 -0
  143. package/bundled/locales/zh-CN/skills/_shared/README.md +68 -0
  144. package/bundled/locales/zh-CN/skills/claude-code/CONTRIBUTING.template.md +151 -0
  145. package/bundled/locales/zh-CN/skills/claude-code/README.md +174 -0
  146. package/bundled/locales/zh-CN/skills/claude-code/ai-collaboration-standards/SKILL.md +175 -0
  147. package/bundled/locales/zh-CN/skills/claude-code/ai-collaboration-standards/anti-hallucination.md +223 -0
  148. package/bundled/locales/zh-CN/skills/claude-code/ai-collaboration-standards/certainty-labels.md +132 -0
  149. package/bundled/locales/zh-CN/skills/claude-code/changelog-guide/SKILL.md +237 -0
  150. package/bundled/locales/zh-CN/skills/claude-code/checkin-assistant/SKILL.md +407 -0
  151. package/bundled/locales/zh-CN/skills/claude-code/code-review-assistant/SKILL.md +154 -0
  152. package/bundled/locales/zh-CN/skills/claude-code/code-review-assistant/checkin-checklist.md +257 -0
  153. package/bundled/locales/zh-CN/skills/claude-code/code-review-assistant/review-checklist.md +246 -0
  154. package/bundled/locales/zh-CN/skills/claude-code/commands/bdd.md +142 -0
  155. package/bundled/locales/zh-CN/skills/claude-code/commands/methodology.md +274 -0
  156. package/bundled/locales/zh-CN/skills/claude-code/commit-standards/SKILL.md +191 -0
  157. package/bundled/locales/zh-CN/skills/claude-code/commit-standards/conventional-commits.md +264 -0
  158. package/bundled/locales/zh-CN/skills/claude-code/commit-standards/language-options.md +172 -0
  159. package/bundled/locales/zh-CN/skills/claude-code/documentation-guide/SKILL.md +421 -0
  160. package/bundled/locales/zh-CN/skills/claude-code/documentation-guide/documentation-structure.md +357 -0
  161. package/bundled/locales/zh-CN/skills/claude-code/documentation-guide/readme-template.md +412 -0
  162. package/bundled/locales/zh-CN/skills/claude-code/error-code-guide/SKILL.md +269 -0
  163. package/bundled/locales/zh-CN/skills/claude-code/git-workflow-guide/SKILL.md +218 -0
  164. package/bundled/locales/zh-CN/skills/claude-code/git-workflow-guide/branch-naming.md +220 -0
  165. package/bundled/locales/zh-CN/skills/claude-code/git-workflow-guide/git-workflow.md +321 -0
  166. package/bundled/locales/zh-CN/skills/claude-code/logging-guide/SKILL.md +285 -0
  167. package/bundled/locales/zh-CN/skills/claude-code/methodology-system/SKILL.md +131 -0
  168. package/bundled/locales/zh-CN/skills/claude-code/methodology-system/create-methodology.md +350 -0
  169. package/bundled/locales/zh-CN/skills/claude-code/methodology-system/runtime.md +279 -0
  170. package/bundled/locales/zh-CN/skills/claude-code/project-structure-guide/SKILL.md +143 -0
  171. package/bundled/locales/zh-CN/skills/claude-code/project-structure-guide/language-patterns.md +271 -0
  172. package/bundled/locales/zh-CN/skills/claude-code/refactoring-assistant/SKILL.md +162 -0
  173. package/bundled/locales/zh-CN/skills/claude-code/release-standards/SKILL.md +191 -0
  174. package/bundled/locales/zh-CN/skills/claude-code/release-standards/changelog-format.md +247 -0
  175. package/bundled/locales/zh-CN/skills/claude-code/release-standards/release-workflow.md +345 -0
  176. package/bundled/locales/zh-CN/skills/claude-code/release-standards/semantic-versioning.md +250 -0
  177. package/bundled/locales/zh-CN/skills/claude-code/requirement-assistant/SKILL.md +227 -0
  178. package/bundled/locales/zh-CN/skills/claude-code/requirement-assistant/requirement-checklist.md +325 -0
  179. package/bundled/locales/zh-CN/skills/claude-code/requirement-assistant/requirement-writing.md +399 -0
  180. package/bundled/locales/zh-CN/skills/claude-code/spec-driven-dev/SKILL.md +243 -0
  181. package/bundled/locales/zh-CN/skills/claude-code/tdd-assistant/SKILL.md +332 -0
  182. package/bundled/locales/zh-CN/skills/claude-code/tdd-assistant/language-examples.md +639 -0
  183. package/bundled/locales/zh-CN/skills/claude-code/tdd-assistant/tdd-workflow.md +486 -0
  184. package/bundled/locales/zh-CN/skills/claude-code/test-coverage-assistant/SKILL.md +282 -0
  185. package/bundled/locales/zh-CN/skills/claude-code/testing-guide/SKILL.md +234 -0
  186. package/bundled/locales/zh-CN/skills/claude-code/testing-guide/testing-pyramid.md +448 -0
  187. package/bundled/locales/zh-CN/skills/cline/README.md +58 -0
  188. package/bundled/locales/zh-CN/skills/copilot/README.md +61 -0
  189. package/bundled/locales/zh-CN/skills/copilot/copilot-instructions.md +79 -0
  190. package/bundled/locales/zh-CN/skills/cursor/README.md +58 -0
  191. package/bundled/locales/zh-CN/skills/windsurf/README.md +59 -0
  192. package/bundled/locales/zh-TW/CHANGELOG.md +707 -0
  193. package/bundled/locales/zh-TW/CLAUDE.md +213 -0
  194. package/bundled/locales/zh-TW/MAINTENANCE.md +683 -0
  195. package/bundled/locales/zh-TW/README.md +687 -0
  196. package/bundled/locales/zh-TW/STANDARDS-MAPPING.md +177 -0
  197. package/bundled/locales/zh-TW/adoption/ADOPTION-GUIDE.md +392 -0
  198. package/bundled/locales/zh-TW/adoption/STATIC-DYNAMIC-GUIDE.md +299 -0
  199. package/bundled/locales/zh-TW/adoption/checklists/enterprise.md +332 -0
  200. package/bundled/locales/zh-TW/adoption/checklists/minimal.md +141 -0
  201. package/bundled/locales/zh-TW/adoption/checklists/recommended.md +272 -0
  202. package/bundled/locales/zh-TW/ai/MAINTENANCE.md +754 -0
  203. package/bundled/locales/zh-TW/ai/options/changelog/auto-generated.ai.yaml +76 -0
  204. package/bundled/locales/zh-TW/ai/options/changelog/keep-a-changelog.ai.yaml +99 -0
  205. package/bundled/locales/zh-TW/ai/options/code-review/automated-review.ai.yaml +120 -0
  206. package/bundled/locales/zh-TW/ai/options/code-review/pair-programming.ai.yaml +109 -0
  207. package/bundled/locales/zh-TW/ai/options/code-review/pr-review.ai.yaml +104 -0
  208. package/bundled/locales/zh-TW/ai/options/commit-message/bilingual.ai.yaml +105 -0
  209. package/bundled/locales/zh-TW/ai/options/commit-message/english.ai.yaml +79 -0
  210. package/bundled/locales/zh-TW/ai/options/commit-message/traditional-chinese.ai.yaml +100 -0
  211. package/bundled/locales/zh-TW/ai/options/documentation/api-docs.ai.yaml +140 -0
  212. package/bundled/locales/zh-TW/ai/options/documentation/markdown-docs.ai.yaml +89 -0
  213. package/bundled/locales/zh-TW/ai/options/documentation/wiki-style.ai.yaml +119 -0
  214. package/bundled/locales/zh-TW/ai/options/git-workflow/gitflow.ai.yaml +133 -0
  215. package/bundled/locales/zh-TW/ai/options/git-workflow/github-flow.ai.yaml +73 -0
  216. package/bundled/locales/zh-TW/ai/options/git-workflow/merge-commit.ai.yaml +88 -0
  217. package/bundled/locales/zh-TW/ai/options/git-workflow/rebase-ff.ai.yaml +113 -0
  218. package/bundled/locales/zh-TW/ai/options/git-workflow/squash-merge.ai.yaml +85 -0
  219. package/bundled/locales/zh-TW/ai/options/git-workflow/trunk-based.ai.yaml +117 -0
  220. package/bundled/locales/zh-TW/ai/options/project-structure/dotnet.ai.yaml +108 -0
  221. package/bundled/locales/zh-TW/ai/options/project-structure/go.ai.yaml +115 -0
  222. package/bundled/locales/zh-TW/ai/options/project-structure/java.ai.yaml +113 -0
  223. package/bundled/locales/zh-TW/ai/options/project-structure/kotlin.ai.yaml +123 -0
  224. package/bundled/locales/zh-TW/ai/options/project-structure/nodejs.ai.yaml +101 -0
  225. package/bundled/locales/zh-TW/ai/options/project-structure/php.ai.yaml +147 -0
  226. package/bundled/locales/zh-TW/ai/options/project-structure/python.ai.yaml +116 -0
  227. package/bundled/locales/zh-TW/ai/options/project-structure/ruby.ai.yaml +140 -0
  228. package/bundled/locales/zh-TW/ai/options/project-structure/rust.ai.yaml +117 -0
  229. package/bundled/locales/zh-TW/ai/options/project-structure/swift.ai.yaml +143 -0
  230. package/bundled/locales/zh-TW/ai/options/testing/contract-testing.ai.yaml +254 -0
  231. package/bundled/locales/zh-TW/ai/options/testing/e2e-testing.ai.yaml +116 -0
  232. package/bundled/locales/zh-TW/ai/options/testing/industry-pyramid.ai.yaml +144 -0
  233. package/bundled/locales/zh-TW/ai/options/testing/integration-testing.ai.yaml +90 -0
  234. package/bundled/locales/zh-TW/ai/options/testing/istqb-framework.ai.yaml +108 -0
  235. package/bundled/locales/zh-TW/ai/options/testing/performance-testing.ai.yaml +272 -0
  236. package/bundled/locales/zh-TW/ai/options/testing/security-testing.ai.yaml +160 -0
  237. package/bundled/locales/zh-TW/ai/options/testing/system-testing.ai.yaml +101 -0
  238. package/bundled/locales/zh-TW/ai/options/testing/unit-testing.ai.yaml +82 -0
  239. package/bundled/locales/zh-TW/ai/standards/anti-hallucination.ai.yaml +145 -0
  240. package/bundled/locales/zh-TW/ai/standards/changelog.ai.yaml +146 -0
  241. package/bundled/locales/zh-TW/ai/standards/checkin-standards.ai.yaml +170 -0
  242. package/bundled/locales/zh-TW/ai/standards/code-review.ai.yaml +148 -0
  243. package/bundled/locales/zh-TW/ai/standards/commit-message.ai.yaml +175 -0
  244. package/bundled/locales/zh-TW/ai/standards/documentation-structure.ai.yaml +124 -0
  245. package/bundled/locales/zh-TW/ai/standards/documentation-writing-standards.ai.yaml +190 -0
  246. package/bundled/locales/zh-TW/ai/standards/error-codes.ai.yaml +139 -0
  247. package/bundled/locales/zh-TW/ai/standards/git-workflow.ai.yaml +95 -0
  248. package/bundled/locales/zh-TW/ai/standards/logging.ai.yaml +128 -0
  249. package/bundled/locales/zh-TW/ai/standards/project-structure.ai.yaml +134 -0
  250. package/bundled/locales/zh-TW/ai/standards/spec-driven-development.ai.yaml +169 -0
  251. package/bundled/locales/zh-TW/ai/standards/test-completeness-dimensions.ai.yaml +220 -0
  252. package/bundled/locales/zh-TW/ai/standards/testing.ai.yaml +137 -0
  253. package/bundled/locales/zh-TW/ai/standards/versioning.ai.yaml +211 -0
  254. package/bundled/locales/zh-TW/core/ai-instruction-standards.md +213 -0
  255. package/bundled/locales/zh-TW/core/anti-hallucination.md +691 -0
  256. package/bundled/locales/zh-TW/core/changelog-standards.md +564 -0
  257. package/bundled/locales/zh-TW/core/checkin-standards.md +943 -0
  258. package/bundled/locales/zh-TW/core/code-review-checklist.md +693 -0
  259. package/bundled/locales/zh-TW/core/commit-message-guide.md +809 -0
  260. package/bundled/locales/zh-TW/core/documentation-structure.md +1125 -0
  261. package/bundled/locales/zh-TW/core/documentation-writing-standards.md +495 -0
  262. package/bundled/locales/zh-TW/core/error-code-standards.md +384 -0
  263. package/bundled/locales/zh-TW/core/git-workflow.md +860 -0
  264. package/bundled/locales/zh-TW/core/logging-standards.md +325 -0
  265. package/bundled/locales/zh-TW/core/project-structure.md +362 -0
  266. package/bundled/locales/zh-TW/core/refactoring-standards.md +642 -0
  267. package/bundled/locales/zh-TW/core/spec-driven-development.md +215 -0
  268. package/bundled/locales/zh-TW/core/test-completeness-dimensions.md +544 -0
  269. package/bundled/locales/zh-TW/core/test-driven-development.md +1004 -0
  270. package/bundled/locales/zh-TW/core/testing-standards.md +2158 -0
  271. package/bundled/locales/zh-TW/core/versioning.md +909 -0
  272. package/bundled/locales/zh-TW/docs/AI-AGENT-ROADMAP.md +303 -0
  273. package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +990 -0
  274. package/bundled/locales/zh-TW/docs/OPERATION-WORKFLOW.md +1064 -0
  275. package/bundled/locales/zh-TW/docs/USAGE-MODES-COMPARISON.md +333 -0
  276. package/bundled/locales/zh-TW/docs/WINDOWS-GUIDE.md +215 -0
  277. package/bundled/locales/zh-TW/integrations/codex/AGENTS.md +115 -0
  278. package/bundled/locales/zh-TW/integrations/codex/README.md +113 -0
  279. package/bundled/locales/zh-TW/integrations/gemini-cli/GEMINI.md +102 -0
  280. package/bundled/locales/zh-TW/integrations/gemini-cli/README.md +140 -0
  281. package/bundled/locales/zh-TW/integrations/github-copilot/COPILOT-CHAT-REFERENCE.md +269 -0
  282. package/bundled/locales/zh-TW/integrations/github-copilot/README.md +167 -0
  283. package/bundled/locales/zh-TW/integrations/github-copilot/copilot-instructions.md +263 -0
  284. package/bundled/locales/zh-TW/integrations/github-copilot/skills-mapping.md +192 -0
  285. package/bundled/locales/zh-TW/integrations/google-antigravity/INSTRUCTIONS.md +61 -0
  286. package/bundled/locales/zh-TW/integrations/google-antigravity/README.md +84 -0
  287. package/bundled/locales/zh-TW/integrations/opencode/AGENTS.md +111 -0
  288. package/bundled/locales/zh-TW/integrations/opencode/README.md +176 -0
  289. package/bundled/locales/zh-TW/integrations/opencode/skills-mapping.md +396 -0
  290. package/bundled/locales/zh-TW/integrations/openspec/AGENTS.md +301 -0
  291. package/bundled/locales/zh-TW/integrations/openspec/README.md +43 -0
  292. package/bundled/locales/zh-TW/integrations/spec-kit/AGENTS.md +184 -0
  293. package/bundled/locales/zh-TW/integrations/spec-kit/README.md +43 -0
  294. package/bundled/locales/zh-TW/options/commit-message/bilingual.md +161 -0
  295. package/bundled/locales/zh-TW/options/commit-message/english.md +137 -0
  296. package/bundled/locales/zh-TW/options/commit-message/traditional-chinese.md +162 -0
  297. package/bundled/locales/zh-TW/options/git-workflow/gitflow.md +147 -0
  298. package/bundled/locales/zh-TW/options/git-workflow/github-flow.md +124 -0
  299. package/bundled/locales/zh-TW/options/git-workflow/merge-commit.md +124 -0
  300. package/bundled/locales/zh-TW/options/git-workflow/rebase-ff.md +160 -0
  301. package/bundled/locales/zh-TW/options/git-workflow/squash-merge.md +117 -0
  302. package/bundled/locales/zh-TW/options/git-workflow/trunk-based.md +125 -0
  303. package/bundled/locales/zh-TW/options/project-structure/dotnet.md +183 -0
  304. package/bundled/locales/zh-TW/options/project-structure/go.md +226 -0
  305. package/bundled/locales/zh-TW/options/project-structure/java.md +213 -0
  306. package/bundled/locales/zh-TW/options/project-structure/nodejs.md +185 -0
  307. package/bundled/locales/zh-TW/options/project-structure/python.md +229 -0
  308. package/bundled/locales/zh-TW/options/testing/e2e-testing.md +207 -0
  309. package/bundled/locales/zh-TW/options/testing/integration-testing.md +230 -0
  310. package/bundled/locales/zh-TW/options/testing/system-testing.md +183 -0
  311. package/bundled/locales/zh-TW/options/testing/unit-testing.md +165 -0
  312. package/bundled/locales/zh-TW/skills/INTEGRATION-GUIDE.md +218 -0
  313. package/bundled/locales/zh-TW/skills/README.md +132 -0
  314. package/bundled/locales/zh-TW/skills/_shared/README.md +68 -0
  315. package/bundled/locales/zh-TW/skills/claude-code/CONTRIBUTING.template.md +151 -0
  316. package/bundled/locales/zh-TW/skills/claude-code/README.md +174 -0
  317. package/bundled/locales/zh-TW/skills/claude-code/ai-collaboration-standards/SKILL.md +175 -0
  318. package/bundled/locales/zh-TW/skills/claude-code/ai-collaboration-standards/anti-hallucination.md +223 -0
  319. package/bundled/locales/zh-TW/skills/claude-code/ai-collaboration-standards/certainty-labels.md +132 -0
  320. package/bundled/locales/zh-TW/skills/claude-code/changelog-guide/SKILL.md +237 -0
  321. package/bundled/locales/zh-TW/skills/claude-code/checkin-assistant/SKILL.md +407 -0
  322. package/bundled/locales/zh-TW/skills/claude-code/code-review-assistant/SKILL.md +154 -0
  323. package/bundled/locales/zh-TW/skills/claude-code/code-review-assistant/checkin-checklist.md +257 -0
  324. package/bundled/locales/zh-TW/skills/claude-code/code-review-assistant/review-checklist.md +246 -0
  325. package/bundled/locales/zh-TW/skills/claude-code/commands/bdd.md +142 -0
  326. package/bundled/locales/zh-TW/skills/claude-code/commands/methodology.md +274 -0
  327. package/bundled/locales/zh-TW/skills/claude-code/commit-standards/SKILL.md +191 -0
  328. package/bundled/locales/zh-TW/skills/claude-code/commit-standards/conventional-commits.md +264 -0
  329. package/bundled/locales/zh-TW/skills/claude-code/commit-standards/language-options.md +172 -0
  330. package/bundled/locales/zh-TW/skills/claude-code/documentation-guide/SKILL.md +421 -0
  331. package/bundled/locales/zh-TW/skills/claude-code/documentation-guide/documentation-structure.md +357 -0
  332. package/bundled/locales/zh-TW/skills/claude-code/documentation-guide/readme-template.md +412 -0
  333. package/bundled/locales/zh-TW/skills/claude-code/error-code-guide/SKILL.md +269 -0
  334. package/bundled/locales/zh-TW/skills/claude-code/git-workflow-guide/SKILL.md +218 -0
  335. package/bundled/locales/zh-TW/skills/claude-code/git-workflow-guide/branch-naming.md +220 -0
  336. package/bundled/locales/zh-TW/skills/claude-code/git-workflow-guide/git-workflow.md +321 -0
  337. package/bundled/locales/zh-TW/skills/claude-code/logging-guide/SKILL.md +285 -0
  338. package/bundled/locales/zh-TW/skills/claude-code/methodology-system/SKILL.md +131 -0
  339. package/bundled/locales/zh-TW/skills/claude-code/methodology-system/create-methodology.md +350 -0
  340. package/bundled/locales/zh-TW/skills/claude-code/methodology-system/runtime.md +279 -0
  341. package/bundled/locales/zh-TW/skills/claude-code/project-structure-guide/SKILL.md +143 -0
  342. package/bundled/locales/zh-TW/skills/claude-code/project-structure-guide/language-patterns.md +271 -0
  343. package/bundled/locales/zh-TW/skills/claude-code/refactoring-assistant/SKILL.md +162 -0
  344. package/bundled/locales/zh-TW/skills/claude-code/release-standards/SKILL.md +191 -0
  345. package/bundled/locales/zh-TW/skills/claude-code/release-standards/changelog-format.md +247 -0
  346. package/bundled/locales/zh-TW/skills/claude-code/release-standards/release-workflow.md +345 -0
  347. package/bundled/locales/zh-TW/skills/claude-code/release-standards/semantic-versioning.md +250 -0
  348. package/bundled/locales/zh-TW/skills/claude-code/requirement-assistant/SKILL.md +227 -0
  349. package/bundled/locales/zh-TW/skills/claude-code/requirement-assistant/requirement-checklist.md +325 -0
  350. package/bundled/locales/zh-TW/skills/claude-code/requirement-assistant/requirement-writing.md +399 -0
  351. package/bundled/locales/zh-TW/skills/claude-code/spec-driven-dev/SKILL.md +243 -0
  352. package/bundled/locales/zh-TW/skills/claude-code/tdd-assistant/SKILL.md +332 -0
  353. package/bundled/locales/zh-TW/skills/claude-code/tdd-assistant/language-examples.md +639 -0
  354. package/bundled/locales/zh-TW/skills/claude-code/tdd-assistant/tdd-workflow.md +486 -0
  355. package/bundled/locales/zh-TW/skills/claude-code/test-coverage-assistant/SKILL.md +282 -0
  356. package/bundled/locales/zh-TW/skills/claude-code/testing-guide/SKILL.md +234 -0
  357. package/bundled/locales/zh-TW/skills/claude-code/testing-guide/testing-pyramid.md +448 -0
  358. package/bundled/locales/zh-TW/skills/cline/README.md +58 -0
  359. package/bundled/locales/zh-TW/skills/copilot/README.md +61 -0
  360. package/bundled/locales/zh-TW/skills/copilot/copilot-instructions.md +79 -0
  361. package/bundled/locales/zh-TW/skills/cursor/README.md +58 -0
  362. package/bundled/locales/zh-TW/skills/windsurf/README.md +59 -0
  363. package/bundled/skills/claude-code/CONTRIBUTING.template.md +141 -0
  364. package/bundled/skills/claude-code/README.md +196 -0
  365. package/bundled/skills/claude-code/ai/standards/checkin.ai.yaml +21 -0
  366. package/bundled/skills/claude-code/ai/standards/commit.ai.yaml +20 -0
  367. package/bundled/skills/claude-code/ai/standards/refactoring.ai.yaml +34 -0
  368. package/bundled/skills/claude-code/ai/standards/testing.ai.yaml +41 -0
  369. package/bundled/skills/claude-code/ai-collaboration-standards/SKILL.md +175 -0
  370. package/bundled/skills/claude-code/ai-collaboration-standards/anti-hallucination.md +215 -0
  371. package/bundled/skills/claude-code/ai-collaboration-standards/certainty-labels.md +124 -0
  372. package/bundled/skills/claude-code/changelog-guide/SKILL.md +232 -0
  373. package/bundled/skills/claude-code/checkin-assistant/SKILL.md +402 -0
  374. package/bundled/skills/claude-code/code-review-assistant/SKILL.md +220 -0
  375. package/bundled/skills/claude-code/code-review-assistant/checkin-checklist.md +249 -0
  376. package/bundled/skills/claude-code/code-review-assistant/review-checklist.md +238 -0
  377. package/bundled/skills/claude-code/commands/README.md +78 -0
  378. package/bundled/skills/claude-code/commands/bdd.md +142 -0
  379. package/bundled/skills/claude-code/commands/changelog.md +57 -0
  380. package/bundled/skills/claude-code/commands/check.md +91 -0
  381. package/bundled/skills/claude-code/commands/commit.md +48 -0
  382. package/bundled/skills/claude-code/commands/config.md +97 -0
  383. package/bundled/skills/claude-code/commands/coverage.md +58 -0
  384. package/bundled/skills/claude-code/commands/docs.md +75 -0
  385. package/bundled/skills/claude-code/commands/init.md +88 -0
  386. package/bundled/skills/claude-code/commands/methodology.md +268 -0
  387. package/bundled/skills/claude-code/commands/release.md +50 -0
  388. package/bundled/skills/claude-code/commands/requirement.md +54 -0
  389. package/bundled/skills/claude-code/commands/review.md +50 -0
  390. package/bundled/skills/claude-code/commands/spec.md +69 -0
  391. package/bundled/skills/claude-code/commands/tdd.md +86 -0
  392. package/bundled/skills/claude-code/commands/update.md +122 -0
  393. package/bundled/skills/claude-code/commit-standards/SKILL.md +249 -0
  394. package/bundled/skills/claude-code/commit-standards/conventional-commits.md +256 -0
  395. package/bundled/skills/claude-code/commit-standards/language-options.md +164 -0
  396. package/bundled/skills/claude-code/documentation-guide/SKILL.md +416 -0
  397. package/bundled/skills/claude-code/documentation-guide/documentation-structure.md +349 -0
  398. package/bundled/skills/claude-code/documentation-guide/readme-template.md +404 -0
  399. package/bundled/skills/claude-code/error-code-guide/SKILL.md +264 -0
  400. package/bundled/skills/claude-code/git-workflow-guide/SKILL.md +226 -0
  401. package/bundled/skills/claude-code/git-workflow-guide/branch-naming.md +212 -0
  402. package/bundled/skills/claude-code/git-workflow-guide/git-workflow.md +313 -0
  403. package/bundled/skills/claude-code/logging-guide/SKILL.md +280 -0
  404. package/bundled/skills/claude-code/methodology-system/SKILL.md +215 -0
  405. package/bundled/skills/claude-code/methodology-system/create-methodology.md +450 -0
  406. package/bundled/skills/claude-code/methodology-system/runtime.md +271 -0
  407. package/bundled/skills/claude-code/project-structure-guide/SKILL.md +143 -0
  408. package/bundled/skills/claude-code/project-structure-guide/language-patterns.md +263 -0
  409. package/bundled/skills/claude-code/refactoring-assistant/SKILL.md +205 -0
  410. package/bundled/skills/claude-code/release-standards/SKILL.md +191 -0
  411. package/bundled/skills/claude-code/release-standards/changelog-format.md +239 -0
  412. package/bundled/skills/claude-code/release-standards/release-workflow.md +337 -0
  413. package/bundled/skills/claude-code/release-standards/semantic-versioning.md +242 -0
  414. package/bundled/skills/claude-code/requirement-assistant/SKILL.md +222 -0
  415. package/bundled/skills/claude-code/requirement-assistant/requirement-checklist.md +317 -0
  416. package/bundled/skills/claude-code/requirement-assistant/requirement-writing.md +391 -0
  417. package/bundled/skills/claude-code/spec-driven-dev/SKILL.md +238 -0
  418. package/bundled/skills/claude-code/tdd-assistant/SKILL.md +384 -0
  419. package/bundled/skills/claude-code/tdd-assistant/language-examples.md +1276 -0
  420. package/bundled/skills/claude-code/tdd-assistant/tdd-workflow.md +659 -0
  421. package/bundled/skills/claude-code/test-coverage-assistant/SKILL.md +277 -0
  422. package/bundled/skills/claude-code/testing-guide/SKILL.md +317 -0
  423. package/bundled/skills/claude-code/testing-guide/testing-pyramid.md +440 -0
  424. package/package.json +4 -2
  425. package/src/commands/check.js +38 -6
  426. package/src/commands/init.js +20 -6
  427. package/src/commands/list.js +7 -2
  428. package/src/commands/skills.js +0 -2
  429. package/src/commands/update.js +271 -0
  430. package/src/i18n/messages.js +161 -11
  431. package/src/utils/copier.js +63 -10
  432. package/src/utils/skills-installer.js +47 -11
  433. package/standards-registry.json +6 -3
@@ -0,0 +1,642 @@
1
+ ---
2
+ source: ../../../core/refactoring-standards.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-01-12
6
+ status: current
7
+ ---
8
+
9
+ # 重構標準
10
+
11
+ > **語言**: [English](../../../core/refactoring-standards.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-01-12
15
+ **適用範圍**: 所有進行程式碼改善的軟體專案
16
+
17
+ ---
18
+
19
+ ## 目的
20
+
21
+ 本標準定義程式碼重構的完整指引,涵蓋從日常 TDD 重構循環到大型遺留系統現代化的所有場景。確保重構工作安全、可衡量,並與業務目標一致。
22
+
23
+ **主要優點**:
24
+ - 系統化的程式碼品質改善方法
25
+ - 降低重構過程中引入錯誤的風險
26
+ - 清晰的重構 vs 重寫決策框架
27
+ - 可衡量的成果與投資報酬率追蹤
28
+
29
+ ---
30
+
31
+ ## 目錄
32
+
33
+ 1. [重構 vs 重寫決策矩陣](#重構-vs-重寫決策矩陣)
34
+ 2. [依規模的重構策略](#依規模的重構策略)
35
+ 3. [遺留程式碼策略](#遺留程式碼策略)
36
+ 4. [大型重構模式](#大型重構模式)
37
+ 5. [資料庫重構](#資料庫重構)
38
+ 6. [安全重構工作流程](#安全重構工作流程)
39
+ 7. [重構度量指標](#重構度量指標)
40
+ 8. [團隊協作](#團隊協作)
41
+ 9. [技術債管理](#技術債管理)
42
+ 10. [相關標準](#相關標準)
43
+ 11. [參考資料](#參考資料)
44
+ 12. [版本歷程](#版本歷程)
45
+
46
+ ---
47
+
48
+ ## 重構 vs 重寫決策矩陣
49
+
50
+ 在開始任何大型重構工作之前,評估重構或重寫哪個更合適。
51
+
52
+ ### 決策流程圖
53
+
54
+ ```
55
+ ┌─────────────────────────────────────────────────────────────────┐
56
+ │ 重構 vs 重寫決策樹 │
57
+ ├─────────────────────────────────────────────────────────────────┤
58
+ │ │
59
+ │ 程式碼目前在生產環境運行嗎? │
60
+ │ ├─ 否 → 考慮重寫(風險較低) │
61
+ │ └─ 是 ↓ │
62
+ │ │
63
+ │ 你了解程式碼在做什麼嗎? │
64
+ │ ├─ 否 → 先寫特徵測試,再決定 │
65
+ │ └─ 是 ↓ │
66
+ │ │
67
+ │ 測試覆蓋率足夠嗎(>60%)? │
68
+ │ ├─ 否 → 先補測試,再決定 │
69
+ │ └─ 是 ↓ │
70
+ │ │
71
+ │ 核心架構可以保留嗎? │
72
+ │ ├─ 否 → Strangler Fig(漸進替換) │
73
+ │ └─ 是 → 漸進式重構 ✓ │
74
+ │ │
75
+ └─────────────────────────────────────────────────────────────────┘
76
+ ```
77
+
78
+ ### 比較矩陣
79
+
80
+ | 因素 | 傾向重構 | 傾向重寫 |
81
+ |------|---------|---------|
82
+ | **程式碼規模** | 大型、複雜 | 小型、獨立 |
83
+ | **測試覆蓋率** | 良好(>60%)| 差或沒有 |
84
+ | **業務連續性** | 關鍵 | 可容忍停機 |
85
+ | **團隊知識** | 團隊理解程式碼 | 無組織知識 |
86
+ | **核心架構** | 健全,只是混亂 | 根本性缺陷 |
87
+ | **時間壓力** | 緊迫期限 | 彈性時間 |
88
+ | **風險容忍度** | 低 | 較高 |
89
+
90
+ ### 警告:第二系統效應
91
+
92
+ > 「第二個系統是一個人設計過最危險的系統。」— Fred Brooks
93
+
94
+ 重寫時,團隊常常過度工程化。避免:
95
+ - 新增原本沒有的功能
96
+ - 「為了未來彈性」過度抽象
97
+ - 忽視現有系統的教訓
98
+
99
+ ---
100
+
101
+ ## 依規模的重構策略
102
+
103
+ ### 小規模:TDD 重構階段(分鐘級)
104
+
105
+ 紅-綠-重構循環的一部分。詳見[測試驅動開發](test-driven-development.md)。
106
+
107
+ **特點**:
108
+ - 時長:5-15 分鐘
109
+ - 範圍:單一方法或類別
110
+ - 測試:必須保持綠色
111
+
112
+ **常用技術**:
113
+ - 提取方法(Extract Method)
114
+ - 重新命名(Rename)
115
+ - 內聯變數(Inline Variable)
116
+ - 以常數取代魔術數字(Replace Magic Number with Constant)
117
+
118
+ ### 中規模:功能級重構(小時到天)
119
+
120
+ 改善特定功能或模組,不改變其外部行為。
121
+
122
+ **特點**:
123
+ - 時長:數小時到數天
124
+ - 範圍:單一功能或模組
125
+ - 測試:若缺少則補充特徵測試
126
+
127
+ **規劃檢查清單**:
128
+
129
+ ```
130
+ □ 定義範圍邊界(包含什麼、排除什麼)
131
+ □ 識別模組的所有進入點
132
+ □ 確保受影響程式碼的測試覆蓋率 > 80%
133
+ □ 規劃增量提交(每個都應可部署)
134
+ □ 與團隊溝通(避免合併衝突)
135
+ ```
136
+
137
+ ### 大規模:架構級重構(週到月)
138
+
139
+ 重大架構變更,如從單體遷移到微服務。
140
+
141
+ **特點**:
142
+ - 時長:數週到數月
143
+ - 範圍:多個模組或整個系統
144
+ - 測試:需要完整的整合測試
145
+
146
+ **模式**:見[大型重構模式](#大型重構模式)
147
+
148
+ ---
149
+
150
+ ## 遺留程式碼策略
151
+
152
+ 基於 Michael Feathers 的《Working Effectively with Legacy Code》。
153
+
154
+ ### 遺留程式碼困境
155
+
156
+ **定義**:遺留程式碼 = 沒有測試的程式碼(無關年齡)
157
+
158
+ **困境**:
159
+ - 要安全地修改程式碼,我們需要測試
160
+ - 要加測試,我們常常需要修改程式碼
161
+ - 沒有測試就修改程式碼是有風險的
162
+
163
+ **解決方案**:使用安全技術在修改前加入測試。
164
+
165
+ ### 特徵測試(Characterization Tests)
166
+
167
+ **目的**:捕獲現有行為(不是驗證正確性)
168
+
169
+ **流程**:
170
+
171
+ ```
172
+ 1. 呼叫你想了解的程式碼
173
+ 2. 寫一個你預期會失敗的斷言
174
+ 3. 執行測試看實際發生什麼
175
+ 4. 更新斷言以符合實際行為
176
+ 5. 重複直到覆蓋你需要修改的行為
177
+ ```
178
+
179
+ **範例**:
180
+
181
+ ```javascript
182
+ // 步驟 1:初始(預期會失敗)
183
+ test('calculateDiscount 回傳... 某個值', () => {
184
+ const result = calculateDiscount(100, 'GOLD');
185
+ expect(result).toBe(0); // 猜測 - 可能會失敗
186
+ });
187
+
188
+ // 步驟 2:執行後,更新為實際值
189
+ test('calculateDiscount 對 GOLD 客戶回傳 15', () => {
190
+ const result = calculateDiscount(100, 'GOLD');
191
+ expect(result).toBe(15); // 實際行為
192
+ });
193
+ ```
194
+
195
+ ### 尋找接縫(Finding Seams)
196
+
197
+ **定義**:接縫是可以在不編輯程式碼的情況下改變行為的地方。
198
+
199
+ | 接縫類型 | 運作方式 | 範例 |
200
+ |---------|---------|------|
201
+ | **物件接縫** | 透過多型覆寫 | 透過介面注入測試替身 |
202
+ | **預處理接縫** | 編譯時替換 | 條件編譯、巨集 |
203
+ | **連結接縫** | 連結時替換 | 依賴注入、模組替換 |
204
+
205
+ ### Sprout 與 Wrap 技術
206
+
207
+ | 技術 | 使用時機 | 做法 |
208
+ |-----|---------|-----|
209
+ | **Sprout Method** | 在現有方法中加入新邏輯 | 建立新方法,從舊方法呼叫 |
210
+ | **Sprout Class** | 新邏輯需要獨立演進 | 建立新類別,從舊程式碼參照 |
211
+ | **Wrap Method** | 需要在前後加入行為 | 重命名原方法,建立包裝器 |
212
+ | **Wrap Class** | 裝飾現有類別 | 裝飾者模式 |
213
+
214
+ **原則**:新程式碼使用 TDD;遺留程式碼在測試前保持不動。
215
+
216
+ ### 程式碼考古
217
+
218
+ 理解無文件程式碼的技術:
219
+
220
+ ```
221
+ 1. 草稿重構(Scratch Refactoring)
222
+ ├─ 重構以理解,不是保留
223
+ ├─ 使用 git stash 或分支
224
+ └─ 完成後捨棄(git reset --hard)
225
+
226
+ 2. 追蹤變數流動
227
+ ├─ 從輸入追蹤到輸出
228
+ ├─ 標記關鍵轉換點
229
+ └─ 邊發現邊記錄
230
+
231
+ 3. 執行時觀察
232
+ ├─ 加入暫時性日誌
233
+ ├─ 使用除錯器逐步執行
234
+ └─ 建立心智模型
235
+
236
+ 4. Git 考古
237
+ ├─ git log -p <file>(查看所有變更)
238
+ ├─ git blame(找到原作者)
239
+ └─ 搜尋提交訊息找脈絡
240
+ ```
241
+
242
+ ---
243
+
244
+ ## 大型重構模式
245
+
246
+ ### Strangler Fig 模式
247
+
248
+ **使用時機**:漸進替換遺留系統
249
+
250
+ ```
251
+ ┌─────────────────────────────────────────────────────────────────┐
252
+ │ Strangler Fig 模式 │
253
+ ├─────────────────────────────────────────────────────────────────┤
254
+ │ │
255
+ │ 階段 1: 攔截(INTERCEPT) │
256
+ │ ┌─────────┐ ┌─────────┐ ┌─────────────┐ │
257
+ │ │ 請求 │────▶│ 門面 │────▶│ 舊系統(100%)│ │
258
+ │ └─────────┘ └─────────┘ └─────────────┘ │
259
+ │ │
260
+ │ 階段 2: 遷移(MIGRATE) │
261
+ │ ┌─────────┐ ┌─────────┐ ┌─────────────┐ │
262
+ │ │ 請求 │────▶│ 門面 │──┬─▶│ 新系統(功能A)│ │
263
+ │ └─────────┘ └─────────┘ │ └─────────────┘ │
264
+ │ └─▶│ 舊系統(其餘) │ │
265
+ │ └─────────────┘ │
266
+ │ │
267
+ │ 階段 3: 完成(COMPLETE) │
268
+ │ ┌─────────┐ ┌─────────────┐ │
269
+ │ │ 請求 │────▶│ 新系統(100%)│ [舊系統已下線] │
270
+ │ └─────────┘ └─────────────┘ │
271
+ │ │
272
+ └─────────────────────────────────────────────────────────────────┘
273
+ ```
274
+
275
+ **檢查清單**:
276
+ - [ ] 識別攔截點(API 閘道、門面、代理)
277
+ - [ ] 建立事件捕獲層
278
+ - [ ] 在新系統中實作第一個功能
279
+ - [ ] 漸進式路由流量
280
+ - [ ] 監控並比較結果
281
+ - [ ] 下線舊元件
282
+
283
+ ### Branch by Abstraction
284
+
285
+ **使用時機**:在不用長期分支的情況下重構共享程式碼
286
+
287
+ ```
288
+ 步驟 1:引入抽象
289
+ 客戶端 → 抽象(介面)→ 舊實作
290
+
291
+ 步驟 2:新增新實作
292
+ 客戶端 → 抽象 → 舊實作
293
+ └─→ 新實作(功能開關控制)
294
+
295
+ 步驟 3:切換並移除
296
+ 客戶端 → 新實作
297
+ [舊實作已移除]
298
+ ```
299
+
300
+ **關鍵原則**:
301
+ - 所有變更在主幹(trunk)上(沒有長期分支)
302
+ - 功能開關控制哪個實作是活躍的
303
+ - 兩個實作可以在過渡期共存
304
+
305
+ ### 平行變更(Expand-Migrate-Contract)
306
+
307
+ **使用時機**:變更多個客戶端使用的介面
308
+
309
+ ```
310
+ 階段 1: 擴展(EXPAND)
311
+ ├─ 在舊的旁邊新增新欄位/方法
312
+ ├─ 新程式碼使用新介面
313
+ └─ 舊程式碼仍然運作
314
+
315
+ 階段 2: 遷移(MIGRATE)
316
+ ├─ 更新所有客戶端使用新介面
317
+ ├─ 驗證所有客戶端已遷移
318
+ └─ 資料遷移(如需要)
319
+
320
+ 階段 3: 收縮(CONTRACT)
321
+ ├─ 移除舊欄位/方法
322
+ ├─ 清理遷移程式碼
323
+ └─ 更新文件
324
+ ```
325
+
326
+ ---
327
+
328
+ ## 資料庫重構
329
+
330
+ ### Schema 變更的 Expand-Contract 模式
331
+
332
+ ```
333
+ ┌─────────────────────────────────────────────────────────────────┐
334
+ │ 資料庫重構(Expand-Contract) │
335
+ ├─────────────────────────────────────────────────────────────────┤
336
+ │ │
337
+ │ 階段 1: 擴展(新增新的,保留舊的) │
338
+ │ ├─ 新增新欄位/表 │
339
+ │ ├─ 應用程式同時寫入新舊 │
340
+ │ └─ 此時可安全回滾 │
341
+ │ │
342
+ │ 階段 2: 遷移(搬移資料) │
343
+ │ ├─ 從舊複製資料到新 │
344
+ │ ├─ 驗證資料一致性 │
345
+ │ └─ 應用程式開始從新讀取 │
346
+ │ │
347
+ │ 階段 3: 收縮(移除舊的) │
348
+ │ ├─ 確認舊欄位/表不再被讀取 │
349
+ │ ├─ 移除舊欄位/表 │
350
+ │ └─ 清理雙寫程式碼 │
351
+ │ │
352
+ └─────────────────────────────────────────────────────────────────┘
353
+ ```
354
+
355
+ ### 常見 Schema 重構場景
356
+
357
+ | 場景 | 策略 | 風險等級 |
358
+ |-----|------|---------|
359
+ | **重命名欄位** | 新增新的 → 遷移 → 刪除舊的 | 中 |
360
+ | **拆分表格** | 新表 + 外鍵 → 遷移 → 調整應用程式 | 高 |
361
+ | **合併表格** | 新表 → 合併資料 → 切換應用程式 | 高 |
362
+ | **變更資料型別** | 新欄位 → 轉換 → 切換應用程式 | 中 |
363
+ | **新增 NOT NULL** | 填入預設值 → 新增約束 | 低 |
364
+
365
+ ### 資料庫遷移安全檢查清單
366
+
367
+ ```
368
+ 遷移前:
369
+ □ 完整備份已完成
370
+ □ 遷移腳本已在測試環境驗證
371
+ □ 回滾腳本已準備
372
+ □ 遷移時間已估算(考慮資料量)
373
+ □ 維護視窗已通知
374
+
375
+ 遷移中:
376
+ □ 監控資料庫效能
377
+ □ 增量驗證資料完整性
378
+ □ 應用程式健康檢查通過
379
+
380
+ 遷移後:
381
+ □ 資料一致性驗證
382
+ □ 應用程式功能驗證
383
+ □ 效能基線比較
384
+ □ 備份保留一段時間以供回滾
385
+ ```
386
+
387
+ ### 零停機遷移技術
388
+
389
+ | 技術 | 說明 | 使用場景 |
390
+ |-----|------|---------|
391
+ | **Online Schema Change** | pt-osc, gh-ost | MySQL 大表變更 |
392
+ | **Blue-Green Database** | 雙資料庫切換 | 高可用需求 |
393
+ | **Shadow Write** | 同時寫入兩個資料庫並比較 | 驗證遷移正確性 |
394
+ | **Feature Flag** | 控制讀取來源 | 漸進式切換 |
395
+
396
+ ---
397
+
398
+ ## 安全重構工作流程
399
+
400
+ ### 重構前
401
+
402
+ ```
403
+ □ 定義成功標準(可衡量的)
404
+ □ 確保足夠的測試覆蓋率(建議 >80%)
405
+ □ 提交/暫存當前工作(乾淨的工作目錄)
406
+ □ 建立功能分支(或在主幹上使用功能開關)
407
+ □ 與團隊溝通以避免衝突
408
+ ```
409
+
410
+ ### 重構中
411
+
412
+ ```
413
+ □ 一次只做一個小變更
414
+ □ 每次變更後執行測試
415
+ □ 如果測試失敗,立即復原
416
+ □ 頻繁提交(每次測試通過都是一個存檔點)
417
+ □ 重構時絕不加入新功能
418
+ ```
419
+
420
+ ### 重構後
421
+
422
+ ```
423
+ □ 所有測試通過(與之前相同)
424
+ □ 程式碼可衡量地更好(複雜度、重複等)
425
+ □ 如需要則更新文件
426
+ □ 團隊審查完成
427
+ □ 沒有新增功能
428
+ ```
429
+
430
+ ---
431
+
432
+ ## 重構度量指標
433
+
434
+ ### 程式碼品質指標
435
+
436
+ | 指標 | 測量方式 | 目標 |
437
+ |-----|---------|-----|
438
+ | **循環複雜度** | 靜態分析工具 | 每函式 < 10 |
439
+ | **認知複雜度** | SonarQube 等 | 越低越好 |
440
+ | **耦合度** | 模組間依賴數 | 降低 |
441
+ | **內聚性** | LCOM 指標 | 提高 |
442
+ | **程式碼重複** | 重複程式碼百分比 | < 3% |
443
+ | **程式碼行數** | 僅供參考 | 較少 ≠ 一定更好 |
444
+
445
+ ### 測試品質指標
446
+
447
+ | 指標 | 目標 | 備註 |
448
+ |-----|-----|------|
449
+ | **測試覆蓋率** | ≥ 80% | 重構期間不要降低 |
450
+ | **測試速度** | 更快 | 重構應改善可測試性 |
451
+ | **不穩定測試數** | 降低 | 穩定性改善 |
452
+
453
+ ### 運維指標(DORA 指標)
454
+
455
+ | 指標 | 測量方式 | 預期改善 |
456
+ |-----|---------|---------|
457
+ | **部署頻率** | CI/CD 記錄 | 提高(可維護性改善)|
458
+ | **變更失敗率** | 回滾次數 | 降低 |
459
+ | **平均恢復時間** | 事故記錄 | 縮短 |
460
+ | **前置時間** | 從提交到部署 | 縮短 |
461
+
462
+ ### 團隊效率指標
463
+
464
+ | 指標 | 測量方式 | 備註 |
465
+ |-----|---------|------|
466
+ | **新人上手時間** | 新員工熟悉時間 | 縮短 = 更好的可讀性 |
467
+ | **PR 審查時間** | Git 記錄 | 縮短 = 更好的可理解性 |
468
+ | **Bug 修復時間** | Issue 追蹤 | 縮短 = 更好的可維護性 |
469
+
470
+ ### 重構 ROI 框架
471
+
472
+ ```
473
+ 成本:
474
+ ├─ 開發時間 × 時薪
475
+ ├─ 測試時間
476
+ ├─ 部署風險成本
477
+ └─ 機會成本(未建置的功能)
478
+
479
+ 收益:
480
+ ├─ 減少的維護時間 × 未來年數
481
+ ├─ 減少的 Bug × 修復成本
482
+ ├─ 更快的功能開發
483
+ └─ 更低的人員流動成本
484
+ ```
485
+
486
+ ---
487
+
488
+ ## 團隊協作
489
+
490
+ ### 重構專案啟動
491
+
492
+ ```
493
+ 啟動會議議程:
494
+ 1. 範圍定義
495
+ ├─ 哪些模組/檔案在範圍內
496
+ └─ 明確排除什麼
497
+
498
+ 2. 成功標準對齊
499
+ ├─ 量化目標(複雜度降低 X%)
500
+ └─ 功能目標(行為不變)
501
+
502
+ 3. 工作分配
503
+ ├─ 按模組(垂直切分)
504
+ └─ 按層級(水平切分)
505
+
506
+ 4. 風險評估
507
+ ├─ 最高風險區域
508
+ └─ 回滾策略
509
+ ```
510
+
511
+ ### 分工策略
512
+
513
+ | 策略 | 使用時機 | 注意事項 |
514
+ |-----|---------|---------|
515
+ | **垂直切分** | 獨立模組 | 確保介面不變 |
516
+ | **水平切分** | 跨模組重構(如命名規範)| 需嚴格同步 |
517
+ | **Strangler 分工** | 大型系統替換 | 一人一個 Strangler 切片 |
518
+ | **Mob Programming** | 核心/高風險區域 | 全團隊一起,降低風險 |
519
+
520
+ ### 溝通機制
521
+
522
+ ```
523
+ 日常溝通:
524
+ ├─ 站立會議同步重構進度
525
+ ├─ 共享的重構看板(Kanban)
526
+ └─ 專用頻道(#refactoring-xxx)
527
+
528
+ PR 規範:
529
+ ├─ 標題加 [Refactor] 前綴
530
+ ├─ 說明改了什麼以及為什麼
531
+ ├─ 包含前後複雜度比較
532
+ └─ 遺留程式碼需要特徵測試
533
+
534
+ 衝突處理:
535
+ ├─ 小範圍:立即解決
536
+ ├─ 中範圍:每日同步會議
537
+ └─ 大範圍:考慮 Branch by Abstraction
538
+ ```
539
+
540
+ ### PR 大小指引
541
+
542
+ | 大小 | 變更行數 | 審查時間 |
543
+ |-----|---------|---------|
544
+ | 小 | < 200 | < 30 分鐘 |
545
+ | 中 | 200-500 | < 1 小時 |
546
+ | 大 | > 500 | **應該拆分** |
547
+
548
+ **原則**:多個小 PR > 一個大 PR
549
+
550
+ ---
551
+
552
+ ## 技術債管理
553
+
554
+ ### 技術債象限
555
+
556
+ 基於 Martin Fowler 的技術債象限:
557
+
558
+ ```
559
+ 刻意的
560
+
561
+ ┌────────────────┼────────────────┐
562
+ │ │ │
563
+ │ 審慎的 │ 魯莽的 │
564
+ │ 「我們知道 │ 「我們沒時間 │
565
+ │ 這是債務」 │ 做設計」 │
566
+ │ │ │
567
+ 審慎的 ├────────────────┼────────────────┤ 魯莽的
568
+ │ │ │
569
+ │ 審慎的 │ 魯莽的 │
570
+ │ 「現在我們 │ 「什麼是 │
571
+ │ 知道該怎麼 │ 分層?」 │
572
+ │ 做了」 │ │
573
+ │ │ │
574
+ └────────────────┼────────────────┘
575
+
576
+ 無意的
577
+ ```
578
+
579
+ ### 債務優先順序
580
+
581
+ | 優先級 | 標準 | 行動 |
582
+ |-------|------|-----|
583
+ | **高** | 阻擋開發、導致頻繁 Bug | 立即處理 |
584
+ | **中** | 拖慢開發、增加複雜度 | 排入下個 Sprint |
585
+ | **低** | 小煩惱、影響隔離 | 隨機處理 |
586
+
587
+ ### 追蹤技術債
588
+
589
+ ```
590
+ 每個債務項目記錄:
591
+ ├─ 描述:問題是什麼?
592
+ ├─ 影響:如何影響開發?
593
+ ├─ 估計工作量:修復需要多久?
594
+ ├─ 忽視的風險:不處理會怎樣?
595
+ └─ 相關程式碼:受影響的檔案/模組連結
596
+ ```
597
+
598
+ ---
599
+
600
+ ## 相關標準
601
+
602
+ - [測試驅動開發](test-driven-development.md) - TDD 循環包含重構階段
603
+ - [程式碼審查清單](code-review-checklist.md) - 重構 PR 審查指引
604
+ - [提交訊息指南](commit-message-guide.md) - `refactor` 提交類型
605
+ - [程式碼簽入標準](checkin-standards.md) - 提交前要求
606
+
607
+ ---
608
+
609
+ ## 參考資料
610
+
611
+ ### 書籍
612
+
613
+ - Martin Fowler -《重構:改善既有程式的設計》第二版(2018)
614
+ - Michael Feathers -《Working Effectively with Legacy Code》(2004)
615
+ - Joshua Kerievsky -《Refactoring to Patterns》(2004)
616
+
617
+ ### 文章
618
+
619
+ - Martin Fowler - [Strangler Fig Application](https://martinfowler.com/bliki/StranglerFigApplication.html)
620
+ - Martin Fowler - [Branch by Abstraction](https://martinfowler.com/bliki/BranchByAbstraction.html)
621
+ - Pete Hodgson - [Feature Toggles](https://martinfowler.com/articles/feature-toggles.html)
622
+ - Martin Fowler - [Technical Debt Quadrant](https://martinfowler.com/bliki/TechnicalDebtQuadrant.html)
623
+
624
+ ### 工具
625
+
626
+ - [Refactoring Guru](https://refactoring.guru/) - 重構技術目錄
627
+ - [SonarQube](https://www.sonarqube.org/) - 程式碼品質與複雜度分析
628
+ - [ApprovalTests](https://approvaltests.com/) - Golden Master 測試
629
+
630
+ ---
631
+
632
+ ## 版本歷程
633
+
634
+ | 版本 | 日期 | 變更 |
635
+ |-----|------|------|
636
+ | 1.0.0 | 2026-01-12 | 初始重構標準定義 |
637
+
638
+ ---
639
+
640
+ ## 授權
641
+
642
+ 本標準以 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授權釋出。