devflow-kit 0.9.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (397) hide show
  1. package/CHANGELOG.md +167 -29
  2. package/LICENSE +1 -1
  3. package/README.md +179 -310
  4. package/dist/cli.js +3 -1
  5. package/dist/commands/init.d.ts +21 -0
  6. package/dist/commands/init.js +311 -576
  7. package/dist/commands/list.d.ts +3 -0
  8. package/dist/commands/list.js +20 -0
  9. package/dist/commands/uninstall.d.ts +10 -0
  10. package/dist/commands/uninstall.js +351 -78
  11. package/dist/plugins.d.ts +46 -0
  12. package/dist/plugins.js +162 -0
  13. package/dist/utils/cli.d.ts +5 -0
  14. package/dist/utils/cli.js +14 -0
  15. package/dist/utils/installer.d.ts +41 -0
  16. package/dist/utils/installer.js +177 -0
  17. package/dist/utils/paths.d.ts +10 -0
  18. package/dist/utils/paths.js +23 -3
  19. package/dist/utils/post-install.d.ts +68 -0
  20. package/dist/utils/post-install.js +427 -0
  21. package/dist/utils/safe-delete-install.d.ts +22 -0
  22. package/dist/utils/safe-delete-install.js +156 -0
  23. package/dist/utils/safe-delete.d.ts +12 -0
  24. package/dist/utils/safe-delete.js +83 -0
  25. package/package.json +18 -8
  26. package/plugins/devflow-audit-claude/.claude-plugin/plugin.json +7 -0
  27. package/plugins/devflow-audit-claude/README.md +46 -0
  28. package/plugins/devflow-audit-claude/agents/claude-md-auditor.md +134 -0
  29. package/plugins/devflow-audit-claude/commands/audit-claude.md +85 -0
  30. package/plugins/devflow-code-review/.claude-plugin/plugin.json +31 -0
  31. package/plugins/devflow-code-review/README.md +73 -0
  32. package/plugins/devflow-code-review/agents/git.md +272 -0
  33. package/plugins/devflow-code-review/agents/reviewer.md +119 -0
  34. package/plugins/devflow-code-review/agents/synthesizer.md +204 -0
  35. package/plugins/devflow-code-review/commands/code-review-teams.md +262 -0
  36. package/plugins/devflow-code-review/commands/code-review.md +141 -0
  37. package/plugins/devflow-code-review/skills/accessibility/SKILL.md +229 -0
  38. package/plugins/devflow-code-review/skills/accessibility/references/detection.md +171 -0
  39. package/plugins/devflow-code-review/skills/accessibility/references/patterns.md +670 -0
  40. package/plugins/devflow-code-review/skills/accessibility/references/violations.md +419 -0
  41. package/plugins/devflow-code-review/skills/agent-teams/SKILL.md +124 -0
  42. package/plugins/devflow-code-review/skills/agent-teams/references/cleanup.md +104 -0
  43. package/plugins/devflow-code-review/skills/agent-teams/references/communication.md +122 -0
  44. package/plugins/devflow-code-review/skills/agent-teams/references/team-patterns.md +217 -0
  45. package/plugins/devflow-code-review/skills/architecture-patterns/SKILL.md +153 -0
  46. package/plugins/devflow-code-review/skills/architecture-patterns/references/detection.md +337 -0
  47. package/plugins/devflow-code-review/skills/architecture-patterns/references/patterns.md +873 -0
  48. package/plugins/devflow-code-review/skills/architecture-patterns/references/violations.md +575 -0
  49. package/plugins/devflow-code-review/skills/complexity-patterns/SKILL.md +143 -0
  50. package/plugins/devflow-code-review/skills/complexity-patterns/references/detection.md +264 -0
  51. package/plugins/devflow-code-review/skills/complexity-patterns/references/patterns.md +487 -0
  52. package/plugins/devflow-code-review/skills/complexity-patterns/references/violations.md +361 -0
  53. package/plugins/devflow-code-review/skills/consistency-patterns/SKILL.md +140 -0
  54. package/plugins/devflow-code-review/skills/consistency-patterns/references/detection.md +207 -0
  55. package/plugins/devflow-code-review/skills/consistency-patterns/references/patterns.md +202 -0
  56. package/plugins/devflow-code-review/skills/consistency-patterns/references/violations.md +213 -0
  57. package/plugins/devflow-code-review/skills/database-patterns/SKILL.md +134 -0
  58. package/plugins/devflow-code-review/skills/database-patterns/references/detection.md +208 -0
  59. package/plugins/devflow-code-review/skills/database-patterns/references/patterns.md +394 -0
  60. package/plugins/devflow-code-review/skills/database-patterns/references/violations.md +332 -0
  61. package/plugins/devflow-code-review/skills/dependencies-patterns/SKILL.md +141 -0
  62. package/plugins/devflow-code-review/skills/dependencies-patterns/references/detection.md +181 -0
  63. package/plugins/devflow-code-review/skills/dependencies-patterns/references/patterns.md +225 -0
  64. package/plugins/devflow-code-review/skills/dependencies-patterns/references/violations.md +247 -0
  65. package/plugins/devflow-code-review/skills/documentation-patterns/SKILL.md +125 -0
  66. package/plugins/devflow-code-review/skills/documentation-patterns/references/detection.md +190 -0
  67. package/plugins/devflow-code-review/skills/documentation-patterns/references/patterns.md +189 -0
  68. package/plugins/devflow-code-review/skills/documentation-patterns/references/violations.md +163 -0
  69. package/plugins/devflow-code-review/skills/frontend-design/SKILL.md +254 -0
  70. package/plugins/devflow-code-review/skills/frontend-design/references/detection.md +184 -0
  71. package/plugins/devflow-code-review/skills/frontend-design/references/patterns.md +511 -0
  72. package/plugins/devflow-code-review/skills/frontend-design/references/violations.md +453 -0
  73. package/plugins/devflow-code-review/skills/performance-patterns/SKILL.md +154 -0
  74. package/plugins/devflow-code-review/skills/performance-patterns/references/detection.md +351 -0
  75. package/plugins/devflow-code-review/skills/performance-patterns/references/patterns.md +503 -0
  76. package/plugins/devflow-code-review/skills/performance-patterns/references/violations.md +354 -0
  77. package/plugins/devflow-code-review/skills/react/SKILL.md +276 -0
  78. package/plugins/devflow-code-review/skills/react/references/patterns.md +1331 -0
  79. package/plugins/devflow-code-review/skills/react/references/violations.md +565 -0
  80. package/plugins/devflow-code-review/skills/regression-patterns/SKILL.md +146 -0
  81. package/plugins/devflow-code-review/skills/regression-patterns/references/detection.md +237 -0
  82. package/plugins/devflow-code-review/skills/regression-patterns/references/patterns.md +226 -0
  83. package/plugins/devflow-code-review/skills/regression-patterns/references/violations.md +225 -0
  84. package/plugins/devflow-code-review/skills/review-methodology/SKILL.md +119 -0
  85. package/plugins/devflow-code-review/skills/review-methodology/references/patterns.md +186 -0
  86. package/plugins/devflow-code-review/skills/review-methodology/references/report-template.md +142 -0
  87. package/plugins/devflow-code-review/skills/review-methodology/references/violations.md +125 -0
  88. package/plugins/devflow-code-review/skills/security-patterns/SKILL.md +156 -0
  89. package/plugins/devflow-code-review/skills/security-patterns/references/detection.md +287 -0
  90. package/plugins/devflow-code-review/skills/security-patterns/references/patterns.md +507 -0
  91. package/plugins/devflow-code-review/skills/security-patterns/references/violations.md +237 -0
  92. package/plugins/devflow-code-review/skills/test-patterns/SKILL.md +183 -0
  93. package/plugins/devflow-code-review/skills/test-patterns/references/detection.md +149 -0
  94. package/plugins/devflow-code-review/skills/test-patterns/references/patterns.md +220 -0
  95. package/plugins/devflow-code-review/skills/test-patterns/references/report-template.md +108 -0
  96. package/plugins/devflow-code-review/skills/test-patterns/references/violations.md +221 -0
  97. package/plugins/devflow-core-skills/.claude-plugin/plugin.json +27 -0
  98. package/plugins/devflow-core-skills/README.md +50 -0
  99. package/plugins/devflow-core-skills/skills/accessibility/SKILL.md +229 -0
  100. package/plugins/devflow-core-skills/skills/accessibility/references/detection.md +171 -0
  101. package/plugins/devflow-core-skills/skills/accessibility/references/patterns.md +670 -0
  102. package/plugins/devflow-core-skills/skills/accessibility/references/violations.md +419 -0
  103. package/plugins/devflow-core-skills/skills/core-patterns/SKILL.md +162 -0
  104. package/plugins/devflow-core-skills/skills/core-patterns/references/checklist.md +276 -0
  105. package/plugins/devflow-core-skills/skills/core-patterns/references/code-smell-violations.md +144 -0
  106. package/plugins/devflow-core-skills/skills/core-patterns/references/detection.md +303 -0
  107. package/plugins/devflow-core-skills/skills/core-patterns/references/patterns.md +576 -0
  108. package/plugins/devflow-core-skills/skills/core-patterns/references/violations.md +369 -0
  109. package/plugins/devflow-core-skills/skills/docs-framework/SKILL.md +134 -0
  110. package/plugins/devflow-core-skills/skills/docs-framework/references/patterns.md +346 -0
  111. package/plugins/devflow-core-skills/skills/docs-framework/references/violations.md +221 -0
  112. package/plugins/devflow-core-skills/skills/frontend-design/SKILL.md +254 -0
  113. package/plugins/devflow-core-skills/skills/frontend-design/references/detection.md +184 -0
  114. package/plugins/devflow-core-skills/skills/frontend-design/references/patterns.md +511 -0
  115. package/plugins/devflow-core-skills/skills/frontend-design/references/violations.md +453 -0
  116. package/plugins/devflow-core-skills/skills/git-safety/SKILL.md +122 -0
  117. package/plugins/devflow-core-skills/skills/git-safety/references/detection.md +290 -0
  118. package/plugins/devflow-core-skills/skills/git-safety/references/patterns.md +289 -0
  119. package/plugins/devflow-core-skills/skills/git-safety/references/violations.md +18 -0
  120. package/plugins/devflow-core-skills/skills/git-workflow/SKILL.md +158 -0
  121. package/plugins/devflow-core-skills/skills/git-workflow/references/commit-patterns.md +115 -0
  122. package/plugins/devflow-core-skills/skills/git-workflow/references/commit-violations.md +77 -0
  123. package/plugins/devflow-core-skills/skills/git-workflow/references/pr-patterns.md +127 -0
  124. package/plugins/devflow-core-skills/skills/git-workflow/references/pr-violations.md +96 -0
  125. package/plugins/devflow-core-skills/skills/github-patterns/SKILL.md +153 -0
  126. package/plugins/devflow-core-skills/skills/github-patterns/references/patterns.md +572 -0
  127. package/plugins/devflow-core-skills/skills/github-patterns/references/violations.md +298 -0
  128. package/plugins/devflow-core-skills/skills/input-validation/SKILL.md +148 -0
  129. package/plugins/devflow-core-skills/skills/input-validation/references/detection.md +283 -0
  130. package/plugins/devflow-core-skills/skills/input-validation/references/patterns.md +361 -0
  131. package/plugins/devflow-core-skills/skills/input-validation/references/violations.md +224 -0
  132. package/plugins/devflow-core-skills/skills/react/SKILL.md +276 -0
  133. package/plugins/devflow-core-skills/skills/react/references/patterns.md +1331 -0
  134. package/plugins/devflow-core-skills/skills/react/references/violations.md +565 -0
  135. package/plugins/devflow-core-skills/skills/test-patterns/SKILL.md +183 -0
  136. package/plugins/devflow-core-skills/skills/test-patterns/references/detection.md +149 -0
  137. package/plugins/devflow-core-skills/skills/test-patterns/references/patterns.md +220 -0
  138. package/plugins/devflow-core-skills/skills/test-patterns/references/report-template.md +108 -0
  139. package/plugins/devflow-core-skills/skills/test-patterns/references/violations.md +221 -0
  140. package/plugins/devflow-core-skills/skills/typescript/SKILL.md +176 -0
  141. package/plugins/devflow-core-skills/skills/typescript/references/patterns.md +1105 -0
  142. package/plugins/devflow-core-skills/skills/typescript/references/violations.md +433 -0
  143. package/plugins/devflow-debug/.claude-plugin/plugin.json +18 -0
  144. package/plugins/devflow-debug/README.md +65 -0
  145. package/plugins/devflow-debug/agents/git.md +272 -0
  146. package/plugins/devflow-debug/commands/debug-teams.md +231 -0
  147. package/plugins/devflow-debug/commands/debug.md +160 -0
  148. package/plugins/devflow-debug/skills/agent-teams/SKILL.md +124 -0
  149. package/plugins/devflow-debug/skills/agent-teams/references/cleanup.md +104 -0
  150. package/plugins/devflow-debug/skills/agent-teams/references/communication.md +122 -0
  151. package/plugins/devflow-debug/skills/agent-teams/references/team-patterns.md +217 -0
  152. package/plugins/devflow-debug/skills/git-safety/SKILL.md +122 -0
  153. package/plugins/devflow-debug/skills/git-safety/references/detection.md +290 -0
  154. package/plugins/devflow-debug/skills/git-safety/references/patterns.md +289 -0
  155. package/plugins/devflow-debug/skills/git-safety/references/violations.md +18 -0
  156. package/plugins/devflow-implement/.claude-plugin/plugin.json +21 -0
  157. package/plugins/devflow-implement/README.md +71 -0
  158. package/plugins/devflow-implement/agents/coder.md +122 -0
  159. package/plugins/devflow-implement/agents/git.md +272 -0
  160. package/plugins/devflow-implement/agents/scrutinizer.md +80 -0
  161. package/plugins/devflow-implement/agents/shepherd.md +94 -0
  162. package/plugins/devflow-implement/agents/simplifier.md +62 -0
  163. package/plugins/devflow-implement/agents/skimmer.md +88 -0
  164. package/plugins/devflow-implement/agents/synthesizer.md +204 -0
  165. package/plugins/devflow-implement/agents/validator.md +86 -0
  166. package/plugins/devflow-implement/commands/implement-teams.md +608 -0
  167. package/plugins/devflow-implement/commands/implement.md +426 -0
  168. package/plugins/devflow-implement/skills/accessibility/SKILL.md +229 -0
  169. package/plugins/devflow-implement/skills/accessibility/references/detection.md +171 -0
  170. package/plugins/devflow-implement/skills/accessibility/references/patterns.md +670 -0
  171. package/plugins/devflow-implement/skills/accessibility/references/violations.md +419 -0
  172. package/plugins/devflow-implement/skills/agent-teams/SKILL.md +124 -0
  173. package/plugins/devflow-implement/skills/agent-teams/references/cleanup.md +104 -0
  174. package/plugins/devflow-implement/skills/agent-teams/references/communication.md +122 -0
  175. package/plugins/devflow-implement/skills/agent-teams/references/team-patterns.md +217 -0
  176. package/plugins/devflow-implement/skills/frontend-design/SKILL.md +254 -0
  177. package/plugins/devflow-implement/skills/frontend-design/references/detection.md +184 -0
  178. package/plugins/devflow-implement/skills/frontend-design/references/patterns.md +511 -0
  179. package/plugins/devflow-implement/skills/frontend-design/references/violations.md +453 -0
  180. package/plugins/devflow-implement/skills/implementation-patterns/SKILL.md +162 -0
  181. package/plugins/devflow-implement/skills/implementation-patterns/references/patterns.md +1063 -0
  182. package/plugins/devflow-implement/skills/implementation-patterns/references/violations.md +483 -0
  183. package/plugins/devflow-implement/skills/self-review/SKILL.md +149 -0
  184. package/plugins/devflow-implement/skills/self-review/references/patterns.md +405 -0
  185. package/plugins/devflow-implement/skills/self-review/references/report-template.md +253 -0
  186. package/plugins/devflow-implement/skills/self-review/references/violations.md +308 -0
  187. package/plugins/devflow-resolve/.claude-plugin/plugin.json +19 -0
  188. package/plugins/devflow-resolve/README.md +65 -0
  189. package/plugins/devflow-resolve/agents/git.md +272 -0
  190. package/plugins/devflow-resolve/agents/resolver.md +131 -0
  191. package/plugins/devflow-resolve/agents/simplifier.md +62 -0
  192. package/plugins/devflow-resolve/commands/resolve-teams.md +298 -0
  193. package/plugins/devflow-resolve/commands/resolve.md +237 -0
  194. package/plugins/devflow-resolve/skills/agent-teams/SKILL.md +124 -0
  195. package/plugins/devflow-resolve/skills/agent-teams/references/cleanup.md +104 -0
  196. package/plugins/devflow-resolve/skills/agent-teams/references/communication.md +122 -0
  197. package/plugins/devflow-resolve/skills/agent-teams/references/team-patterns.md +217 -0
  198. package/plugins/devflow-resolve/skills/implementation-patterns/SKILL.md +162 -0
  199. package/plugins/devflow-resolve/skills/implementation-patterns/references/patterns.md +1063 -0
  200. package/plugins/devflow-resolve/skills/implementation-patterns/references/violations.md +483 -0
  201. package/plugins/devflow-resolve/skills/security-patterns/SKILL.md +156 -0
  202. package/plugins/devflow-resolve/skills/security-patterns/references/detection.md +287 -0
  203. package/plugins/devflow-resolve/skills/security-patterns/references/patterns.md +507 -0
  204. package/plugins/devflow-resolve/skills/security-patterns/references/violations.md +237 -0
  205. package/plugins/devflow-self-review/.claude-plugin/plugin.json +7 -0
  206. package/plugins/devflow-self-review/README.md +38 -0
  207. package/plugins/devflow-self-review/agents/scrutinizer.md +80 -0
  208. package/plugins/devflow-self-review/agents/simplifier.md +62 -0
  209. package/plugins/devflow-self-review/agents/validator.md +86 -0
  210. package/plugins/devflow-self-review/commands/self-review.md +126 -0
  211. package/plugins/devflow-self-review/skills/core-patterns/SKILL.md +162 -0
  212. package/plugins/devflow-self-review/skills/core-patterns/references/checklist.md +276 -0
  213. package/plugins/devflow-self-review/skills/core-patterns/references/code-smell-violations.md +144 -0
  214. package/plugins/devflow-self-review/skills/core-patterns/references/detection.md +303 -0
  215. package/plugins/devflow-self-review/skills/core-patterns/references/patterns.md +576 -0
  216. package/plugins/devflow-self-review/skills/core-patterns/references/violations.md +369 -0
  217. package/plugins/devflow-self-review/skills/self-review/SKILL.md +149 -0
  218. package/plugins/devflow-self-review/skills/self-review/references/patterns.md +405 -0
  219. package/plugins/devflow-self-review/skills/self-review/references/report-template.md +253 -0
  220. package/plugins/devflow-self-review/skills/self-review/references/violations.md +308 -0
  221. package/plugins/devflow-specify/.claude-plugin/plugin.json +15 -0
  222. package/plugins/devflow-specify/README.md +46 -0
  223. package/plugins/devflow-specify/agents/skimmer.md +88 -0
  224. package/plugins/devflow-specify/agents/synthesizer.md +204 -0
  225. package/plugins/devflow-specify/commands/specify-teams.md +314 -0
  226. package/plugins/devflow-specify/commands/specify.md +179 -0
  227. package/plugins/devflow-specify/skills/agent-teams/SKILL.md +124 -0
  228. package/plugins/devflow-specify/skills/agent-teams/references/cleanup.md +104 -0
  229. package/plugins/devflow-specify/skills/agent-teams/references/communication.md +122 -0
  230. package/plugins/devflow-specify/skills/agent-teams/references/team-patterns.md +217 -0
  231. package/scripts/hooks/background-memory-update.sh +167 -0
  232. package/scripts/hooks/pre-compact-memory.sh +81 -0
  233. package/scripts/hooks/session-start-memory.sh +84 -0
  234. package/scripts/hooks/stop-update-memory.sh +81 -0
  235. package/shared/agents/coder.md +122 -0
  236. package/shared/agents/git.md +272 -0
  237. package/shared/agents/resolver.md +131 -0
  238. package/shared/agents/reviewer.md +119 -0
  239. package/shared/agents/scrutinizer.md +80 -0
  240. package/shared/agents/shepherd.md +94 -0
  241. package/shared/agents/simplifier.md +62 -0
  242. package/shared/agents/skimmer.md +88 -0
  243. package/shared/agents/synthesizer.md +204 -0
  244. package/shared/agents/validator.md +86 -0
  245. package/shared/skills/accessibility/SKILL.md +229 -0
  246. package/shared/skills/accessibility/references/detection.md +171 -0
  247. package/shared/skills/accessibility/references/patterns.md +670 -0
  248. package/shared/skills/accessibility/references/violations.md +419 -0
  249. package/shared/skills/agent-teams/SKILL.md +124 -0
  250. package/shared/skills/agent-teams/references/cleanup.md +104 -0
  251. package/shared/skills/agent-teams/references/communication.md +122 -0
  252. package/shared/skills/agent-teams/references/team-patterns.md +217 -0
  253. package/shared/skills/architecture-patterns/SKILL.md +153 -0
  254. package/shared/skills/architecture-patterns/references/detection.md +337 -0
  255. package/shared/skills/architecture-patterns/references/patterns.md +873 -0
  256. package/shared/skills/architecture-patterns/references/violations.md +575 -0
  257. package/shared/skills/complexity-patterns/SKILL.md +143 -0
  258. package/shared/skills/complexity-patterns/references/detection.md +264 -0
  259. package/shared/skills/complexity-patterns/references/patterns.md +487 -0
  260. package/shared/skills/complexity-patterns/references/violations.md +361 -0
  261. package/shared/skills/consistency-patterns/SKILL.md +140 -0
  262. package/shared/skills/consistency-patterns/references/detection.md +207 -0
  263. package/shared/skills/consistency-patterns/references/patterns.md +202 -0
  264. package/shared/skills/consistency-patterns/references/violations.md +213 -0
  265. package/shared/skills/core-patterns/SKILL.md +162 -0
  266. package/shared/skills/core-patterns/references/checklist.md +276 -0
  267. package/shared/skills/core-patterns/references/code-smell-violations.md +144 -0
  268. package/shared/skills/core-patterns/references/detection.md +303 -0
  269. package/shared/skills/core-patterns/references/patterns.md +576 -0
  270. package/shared/skills/core-patterns/references/violations.md +369 -0
  271. package/shared/skills/database-patterns/SKILL.md +134 -0
  272. package/shared/skills/database-patterns/references/detection.md +208 -0
  273. package/shared/skills/database-patterns/references/patterns.md +394 -0
  274. package/shared/skills/database-patterns/references/violations.md +332 -0
  275. package/shared/skills/dependencies-patterns/SKILL.md +141 -0
  276. package/shared/skills/dependencies-patterns/references/detection.md +181 -0
  277. package/shared/skills/dependencies-patterns/references/patterns.md +225 -0
  278. package/shared/skills/dependencies-patterns/references/violations.md +247 -0
  279. package/shared/skills/docs-framework/SKILL.md +134 -0
  280. package/shared/skills/docs-framework/references/patterns.md +346 -0
  281. package/shared/skills/docs-framework/references/violations.md +221 -0
  282. package/shared/skills/documentation-patterns/SKILL.md +125 -0
  283. package/shared/skills/documentation-patterns/references/detection.md +190 -0
  284. package/shared/skills/documentation-patterns/references/patterns.md +189 -0
  285. package/shared/skills/documentation-patterns/references/violations.md +163 -0
  286. package/shared/skills/frontend-design/SKILL.md +254 -0
  287. package/shared/skills/frontend-design/references/detection.md +184 -0
  288. package/shared/skills/frontend-design/references/patterns.md +511 -0
  289. package/shared/skills/frontend-design/references/violations.md +453 -0
  290. package/shared/skills/git-safety/SKILL.md +122 -0
  291. package/shared/skills/git-safety/references/detection.md +290 -0
  292. package/shared/skills/git-safety/references/patterns.md +289 -0
  293. package/shared/skills/git-safety/references/violations.md +18 -0
  294. package/shared/skills/git-workflow/SKILL.md +158 -0
  295. package/shared/skills/git-workflow/references/commit-patterns.md +115 -0
  296. package/shared/skills/git-workflow/references/commit-violations.md +77 -0
  297. package/shared/skills/git-workflow/references/pr-patterns.md +127 -0
  298. package/shared/skills/git-workflow/references/pr-violations.md +96 -0
  299. package/shared/skills/github-patterns/SKILL.md +153 -0
  300. package/shared/skills/github-patterns/references/patterns.md +572 -0
  301. package/shared/skills/github-patterns/references/violations.md +298 -0
  302. package/shared/skills/implementation-patterns/SKILL.md +162 -0
  303. package/shared/skills/implementation-patterns/references/patterns.md +1063 -0
  304. package/shared/skills/implementation-patterns/references/violations.md +483 -0
  305. package/shared/skills/input-validation/SKILL.md +148 -0
  306. package/shared/skills/input-validation/references/detection.md +283 -0
  307. package/shared/skills/input-validation/references/patterns.md +361 -0
  308. package/shared/skills/input-validation/references/violations.md +224 -0
  309. package/shared/skills/performance-patterns/SKILL.md +154 -0
  310. package/shared/skills/performance-patterns/references/detection.md +351 -0
  311. package/shared/skills/performance-patterns/references/patterns.md +503 -0
  312. package/shared/skills/performance-patterns/references/violations.md +354 -0
  313. package/shared/skills/react/SKILL.md +276 -0
  314. package/shared/skills/react/references/patterns.md +1331 -0
  315. package/shared/skills/react/references/violations.md +565 -0
  316. package/shared/skills/regression-patterns/SKILL.md +146 -0
  317. package/shared/skills/regression-patterns/references/detection.md +237 -0
  318. package/shared/skills/regression-patterns/references/patterns.md +226 -0
  319. package/shared/skills/regression-patterns/references/violations.md +225 -0
  320. package/shared/skills/review-methodology/SKILL.md +119 -0
  321. package/shared/skills/review-methodology/references/patterns.md +186 -0
  322. package/shared/skills/review-methodology/references/report-template.md +142 -0
  323. package/shared/skills/review-methodology/references/violations.md +125 -0
  324. package/shared/skills/security-patterns/SKILL.md +156 -0
  325. package/shared/skills/security-patterns/references/detection.md +287 -0
  326. package/shared/skills/security-patterns/references/patterns.md +507 -0
  327. package/shared/skills/security-patterns/references/violations.md +237 -0
  328. package/shared/skills/self-review/SKILL.md +149 -0
  329. package/shared/skills/self-review/references/patterns.md +405 -0
  330. package/shared/skills/self-review/references/report-template.md +253 -0
  331. package/shared/skills/self-review/references/violations.md +308 -0
  332. package/shared/skills/test-patterns/SKILL.md +183 -0
  333. package/shared/skills/test-patterns/references/detection.md +149 -0
  334. package/shared/skills/test-patterns/references/patterns.md +220 -0
  335. package/shared/skills/test-patterns/references/report-template.md +108 -0
  336. package/shared/skills/test-patterns/references/violations.md +221 -0
  337. package/shared/skills/typescript/SKILL.md +176 -0
  338. package/shared/skills/typescript/references/patterns.md +1105 -0
  339. package/shared/skills/typescript/references/violations.md +433 -0
  340. package/src/templates/claudeignore.template +188 -0
  341. package/src/templates/managed-settings.json +146 -0
  342. package/src/templates/settings.json +59 -0
  343. package/dist/cli.d.ts.map +0 -1
  344. package/dist/cli.js.map +0 -1
  345. package/dist/commands/init.d.ts.map +0 -1
  346. package/dist/commands/init.js.map +0 -1
  347. package/dist/commands/uninstall.d.ts.map +0 -1
  348. package/dist/commands/uninstall.js.map +0 -1
  349. package/dist/utils/git.d.ts.map +0 -1
  350. package/dist/utils/git.js.map +0 -1
  351. package/dist/utils/paths.d.ts.map +0 -1
  352. package/dist/utils/paths.js.map +0 -1
  353. package/src/claude/CLAUDE.md +0 -400
  354. package/src/claude/agents/devflow/audit-architecture.md +0 -132
  355. package/src/claude/agents/devflow/audit-complexity.md +0 -132
  356. package/src/claude/agents/devflow/audit-database.md +0 -132
  357. package/src/claude/agents/devflow/audit-dependencies.md +0 -132
  358. package/src/claude/agents/devflow/audit-documentation.md +0 -132
  359. package/src/claude/agents/devflow/audit-performance.md +0 -256
  360. package/src/claude/agents/devflow/audit-security.md +0 -259
  361. package/src/claude/agents/devflow/audit-tests.md +0 -132
  362. package/src/claude/agents/devflow/audit-typescript.md +0 -132
  363. package/src/claude/agents/devflow/brainstorm.md +0 -279
  364. package/src/claude/agents/devflow/catch-up.md +0 -345
  365. package/src/claude/agents/devflow/code-review.md +0 -307
  366. package/src/claude/agents/devflow/commit.md +0 -380
  367. package/src/claude/agents/devflow/debug.md +0 -476
  368. package/src/claude/agents/devflow/design.md +0 -491
  369. package/src/claude/agents/devflow/get-issue.md +0 -286
  370. package/src/claude/agents/devflow/pr-comments.md +0 -285
  371. package/src/claude/agents/devflow/project-state.md +0 -419
  372. package/src/claude/agents/devflow/pull-request.md +0 -493
  373. package/src/claude/agents/devflow/release.md +0 -1137
  374. package/src/claude/agents/devflow/tech-debt.md +0 -338
  375. package/src/claude/commands/devflow/brainstorm.md +0 -68
  376. package/src/claude/commands/devflow/breakdown.md +0 -125
  377. package/src/claude/commands/devflow/catch-up.md +0 -29
  378. package/src/claude/commands/devflow/code-review.md +0 -237
  379. package/src/claude/commands/devflow/commit.md +0 -17
  380. package/src/claude/commands/devflow/debug.md +0 -56
  381. package/src/claude/commands/devflow/design.md +0 -82
  382. package/src/claude/commands/devflow/devlog.md +0 -408
  383. package/src/claude/commands/devflow/get-issue.md +0 -16
  384. package/src/claude/commands/devflow/implement.md +0 -100
  385. package/src/claude/commands/devflow/plan.md +0 -223
  386. package/src/claude/commands/devflow/pull-request.md +0 -20
  387. package/src/claude/commands/devflow/release.md +0 -251
  388. package/src/claude/commands/devflow/resolve-comments.md +0 -583
  389. package/src/claude/scripts/statusline.sh +0 -47
  390. package/src/claude/settings.json +0 -6
  391. package/src/claude/skills/devflow/code-smell/SKILL.md +0 -428
  392. package/src/claude/skills/devflow/debug/SKILL.md +0 -119
  393. package/src/claude/skills/devflow/error-handling/SKILL.md +0 -597
  394. package/src/claude/skills/devflow/input-validation/SKILL.md +0 -514
  395. package/src/claude/skills/devflow/pattern-check/SKILL.md +0 -238
  396. package/src/claude/skills/devflow/research/SKILL.md +0 -138
  397. package/src/claude/skills/devflow/test-design/SKILL.md +0 -384
@@ -0,0 +1,575 @@
1
+ # Architecture Violation Examples
2
+
3
+ Extended violation patterns for architecture reviews. Reference from main SKILL.md.
4
+
5
+ ## SOLID Violations
6
+
7
+ ### Single Responsibility Principle (SRP)
8
+
9
+ **Monolithic Controller**
10
+ ```typescript
11
+ // VIOLATION: Controller handles HTTP, validation, business logic, DB, email, logging
12
+ class UserController {
13
+ async createUser(req, res) {
14
+ // Logging
15
+ console.log(`Creating user: ${req.body.email}`);
16
+
17
+ // Validation
18
+ if (!req.body.email.includes('@')) {
19
+ return res.status(400).json({ error: 'Invalid email' });
20
+ }
21
+ if (req.body.password.length < 8) {
22
+ return res.status(400).json({ error: 'Password too short' });
23
+ }
24
+
25
+ // Business logic
26
+ const existingUser = await db.users.findOne({ email: req.body.email });
27
+ if (existingUser) {
28
+ return res.status(409).json({ error: 'User exists' });
29
+ }
30
+
31
+ // Password hashing
32
+ const hash = await bcrypt.hash(req.body.password, 12);
33
+
34
+ // Database operation
35
+ const user = await db.users.create({
36
+ email: req.body.email,
37
+ password: hash,
38
+ createdAt: new Date()
39
+ });
40
+
41
+ // Email sending
42
+ await sendEmail(user.email, 'Welcome!', welcomeTemplate(user));
43
+
44
+ // Analytics
45
+ await analytics.track('user_created', { userId: user.id });
46
+
47
+ // Response formatting
48
+ res.json({
49
+ id: user.id,
50
+ email: user.email,
51
+ createdAt: user.createdAt
52
+ });
53
+ }
54
+ }
55
+ ```
56
+
57
+ **Reasons to Change Analysis**
58
+
59
+ | Responsibility | Reason to Change |
60
+ |----------------|------------------|
61
+ | HTTP handling | API contract changes |
62
+ | Validation | Business rules change |
63
+ | Password hashing | Security requirements change |
64
+ | Database access | Schema or ORM changes |
65
+ | Email sending | Email provider changes |
66
+ | Analytics | Tracking requirements change |
67
+ | Logging | Logging format changes |
68
+
69
+ Each reason = separate class.
70
+
71
+ ---
72
+
73
+ ### Open/Closed Principle (OCP)
74
+
75
+ **Payment Processing Without Strategy**
76
+ ```typescript
77
+ // VIOLATION: Every new payment method requires modifying existing code
78
+ class PaymentProcessor {
79
+ process(method: string, amount: number) {
80
+ if (method === 'credit_card') {
81
+ return this.processCreditCard(amount);
82
+ } else if (method === 'paypal') {
83
+ return this.processPayPal(amount);
84
+ } else if (method === 'stripe') {
85
+ // Stripe logic - added later, modified existing class
86
+ return this.processStripe(amount);
87
+ } else if (method === 'apple_pay') {
88
+ // Apple Pay - yet another modification
89
+ return this.processApplePay(amount);
90
+ }
91
+ throw new Error('Unknown payment method');
92
+ }
93
+
94
+ private processCreditCard(amount: number) { /* ... */ }
95
+ private processPayPal(amount: number) { /* ... */ }
96
+ private processStripe(amount: number) { /* ... */ }
97
+ private processApplePay(amount: number) { /* ... */ }
98
+ }
99
+ ```
100
+
101
+ ---
102
+
103
+ ### Liskov Substitution Principle (LSP)
104
+
105
+ **Subclass Changing Behavior**
106
+ ```typescript
107
+ // VIOLATION: Subclass changes behavior unexpectedly
108
+ class FileStorage {
109
+ read(path: string): string {
110
+ return fs.readFileSync(path, 'utf8');
111
+ }
112
+
113
+ write(path: string, content: string): void {
114
+ fs.writeFileSync(path, content);
115
+ }
116
+
117
+ delete(path: string): void {
118
+ fs.unlinkSync(path);
119
+ }
120
+ }
121
+
122
+ class ReadOnlyStorage extends FileStorage {
123
+ write(path: string, content: string): void {
124
+ throw new Error('Cannot write to read-only storage'); // Breaks LSP!
125
+ }
126
+
127
+ delete(path: string): void {
128
+ throw new Error('Cannot delete from read-only storage'); // Breaks LSP!
129
+ }
130
+ }
131
+
132
+ // Using the subclass breaks code expecting FileStorage behavior
133
+ function backup(storage: FileStorage, data: string) {
134
+ storage.write('/backup/data.txt', data); // Throws if ReadOnlyStorage!
135
+ }
136
+ ```
137
+
138
+ ---
139
+
140
+ ### Interface Segregation Principle (ISP)
141
+
142
+ **Fat Interface**
143
+ ```typescript
144
+ // VIOLATION: Fat interface forces unnecessary implementations
145
+ interface DocumentHandler {
146
+ open(path: string): Document;
147
+ save(doc: Document): void;
148
+ print(doc: Document): void;
149
+ email(doc: Document, to: string): void;
150
+ fax(doc: Document, number: string): void;
151
+ encrypt(doc: Document): Document;
152
+ compress(doc: Document): Buffer;
153
+ watermark(doc: Document, text: string): Document;
154
+ }
155
+
156
+ // PDF handler doesn't need fax capability
157
+ class PdfHandler implements DocumentHandler {
158
+ open(path: string) { /* OK */ }
159
+ save(doc: Document) { /* OK */ }
160
+ print(doc: Document) { /* OK */ }
161
+ email(doc: Document, to: string) { /* OK */ }
162
+ fax(doc: Document, number: string) {
163
+ throw new Error('PDF handler does not support fax'); // Forced implementation
164
+ }
165
+ encrypt(doc: Document) { /* OK */ }
166
+ compress(doc: Document) { /* OK */ }
167
+ watermark(doc: Document, text: string) { /* OK */ }
168
+ }
169
+ ```
170
+
171
+ ---
172
+
173
+ ### Dependency Inversion Principle (DIP)
174
+
175
+ **High-Level Module Depends on Low-Level**
176
+ ```typescript
177
+ // VIOLATION: High-level module depends on low-level implementations
178
+ class NotificationService {
179
+ private twilioClient = new TwilioClient(process.env.TWILIO_KEY);
180
+ private sendgridClient = new SendGridClient(process.env.SENDGRID_KEY);
181
+ private slackClient = new SlackClient(process.env.SLACK_TOKEN);
182
+
183
+ async notifyUser(userId: string, message: string) {
184
+ const user = await db.users.findById(userId);
185
+
186
+ if (user.preferences.sms) {
187
+ await this.twilioClient.sendSMS(user.phone, message);
188
+ }
189
+ if (user.preferences.email) {
190
+ await this.sendgridClient.sendEmail(user.email, 'Notification', message);
191
+ }
192
+ if (user.preferences.slack) {
193
+ await this.slackClient.postMessage(user.slackId, message);
194
+ }
195
+ }
196
+ }
197
+
198
+ // Problems:
199
+ // 1. Can't test without real API keys
200
+ // 2. Adding new channel requires modifying this class
201
+ // 3. Tightly coupled to specific providers
202
+ // 4. Can't swap providers easily
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Coupling Violations
208
+
209
+ ### Circular Dependencies
210
+
211
+ **User-Order Cycle**
212
+ ```typescript
213
+ // VIOLATION: Services depend on each other creating a cycle
214
+ // user.service.ts
215
+ import { OrderService } from './order.service';
216
+
217
+ class UserService {
218
+ constructor(private orderService: OrderService) {}
219
+
220
+ async deleteUser(userId: string) {
221
+ // Need to cancel all user's orders first
222
+ await this.orderService.cancelAllUserOrders(userId);
223
+ await this.repository.delete(userId);
224
+ }
225
+
226
+ async getUserWithOrderTotal(userId: string) {
227
+ const user = await this.repository.findById(userId);
228
+ user.totalSpent = await this.orderService.calculateUserTotal(userId);
229
+ return user;
230
+ }
231
+ }
232
+
233
+ // order.service.ts
234
+ import { UserService } from './user.service';
235
+
236
+ class OrderService {
237
+ constructor(private userService: UserService) {}
238
+
239
+ async createOrder(userId: string, items: Item[]) {
240
+ // Need to check user's credit limit
241
+ const user = await this.userService.getUser(userId);
242
+ if (user.creditLimit < this.calculateTotal(items)) {
243
+ throw new Error('Credit limit exceeded');
244
+ }
245
+ return this.repository.create({ userId, items });
246
+ }
247
+
248
+ async cancelAllUserOrders(userId: string) {
249
+ // Check if user exists first
250
+ const user = await this.userService.getUser(userId);
251
+ if (!user) throw new Error('User not found');
252
+
253
+ await this.repository.cancelByUserId(userId);
254
+ }
255
+ }
256
+
257
+ // PROBLEM: Cannot instantiate either without the other
258
+ // const userService = new UserService(???); // Need OrderService
259
+ // const orderService = new OrderService(???); // Need UserService
260
+ ```
261
+
262
+ **Detection Pattern**
263
+ ```bash
264
+ # Find potential circular dependencies
265
+ grep -rn "import.*from.*service" --include="*service*.ts" | \
266
+ awk -F: '{print $1, $3}' | sort | uniq
267
+
268
+ # Check with tooling
269
+ npx madge --circular src/
270
+ ```
271
+
272
+ ---
273
+
274
+ ### Feature Envy
275
+
276
+ **Order Processing Reaching Into Internals**
277
+ ```typescript
278
+ // VIOLATION: OrderProcessor reaches deeply into Order internals
279
+ class OrderProcessor {
280
+ async process(order: Order) {
281
+ // Reaching into customer details
282
+ const customerName = order.customer.profile.name;
283
+ const customerEmail = order.customer.profile.contact.email;
284
+ const customerPhone = order.customer.profile.contact.phone;
285
+ const shippingAddress = order.customer.addresses.find(a => a.type === 'shipping');
286
+ const billingAddress = order.customer.addresses.find(a => a.type === 'billing');
287
+
288
+ // Reaching into order items
289
+ let subtotal = 0;
290
+ for (const item of order.items) {
291
+ const basePrice = item.product.pricing.basePrice;
292
+ const discount = item.product.pricing.activePromotions
293
+ .filter(p => p.validUntil > new Date())
294
+ .reduce((sum, p) => sum + p.discountPercent, 0);
295
+ const quantity = item.quantity;
296
+ const itemTotal = basePrice * quantity * (1 - discount / 100);
297
+ subtotal += itemTotal;
298
+ }
299
+
300
+ // Reaching into shipping details
301
+ const weight = order.items.reduce((sum, i) => sum + i.product.dimensions.weight * i.quantity, 0);
302
+ const shippingCost = this.calculateShipping(weight, shippingAddress.zone);
303
+
304
+ // Reaching into tax calculation
305
+ const taxRate = order.customer.addresses
306
+ .find(a => a.type === 'billing')
307
+ ?.taxZone?.rate || 0;
308
+ const tax = subtotal * taxRate;
309
+
310
+ // ... 50 more lines of reaching into order internals
311
+ }
312
+ }
313
+ ```
314
+
315
+ **Signs of Feature Envy**
316
+
317
+ | Pattern | Example | Problem |
318
+ |---------|---------|---------|
319
+ | Chain of dots | `order.customer.profile.contact.email` | Knows too much about structure |
320
+ | Repeated prefix | Many lines starting with `order.items.` | Should be method on Order |
321
+ | Type casting | `(item.product as SpecialProduct).specialProperty` | Missing polymorphism |
322
+ | Null checks | `order.customer?.addresses?.find(...)?.zone` | Missing null object pattern |
323
+
324
+ ---
325
+
326
+ ### Tight Coupling
327
+
328
+ **Report Generator Direct Instantiation**
329
+ ```typescript
330
+ // VIOLATION: ReportGenerator directly instantiates all dependencies
331
+ class ReportGenerator {
332
+ async generateSalesReport(startDate: Date, endDate: Date) {
333
+ // Direct instantiation - can't mock for tests
334
+ const db = new PostgresDatabase({
335
+ host: process.env.DB_HOST,
336
+ password: process.env.DB_PASS
337
+ });
338
+
339
+ // Direct instantiation - tied to specific implementation
340
+ const cache = new RedisCache({
341
+ url: process.env.REDIS_URL
342
+ });
343
+
344
+ // Check cache first
345
+ const cacheKey = `report:${startDate}:${endDate}`;
346
+ const cached = await cache.get(cacheKey);
347
+ if (cached) return cached;
348
+
349
+ // Query database directly
350
+ const sales = await db.query(`
351
+ SELECT * FROM sales
352
+ WHERE date BETWEEN $1 AND $2
353
+ `, [startDate, endDate]);
354
+
355
+ // Direct instantiation of formatter
356
+ const formatter = new ExcelFormatter();
357
+ const report = formatter.format(sales);
358
+
359
+ // Direct instantiation of storage
360
+ const storage = new S3Storage({
361
+ bucket: process.env.S3_BUCKET
362
+ });
363
+ await storage.upload(`reports/sales-${Date.now()}.xlsx`, report);
364
+
365
+ // Direct instantiation of notifier
366
+ const notifier = new SlackNotifier(process.env.SLACK_WEBHOOK);
367
+ await notifier.send('Sales report generated');
368
+
369
+ await cache.set(cacheKey, report, 3600);
370
+ return report;
371
+ }
372
+ }
373
+
374
+ // Problems:
375
+ // 1. Requires real DB/Redis/S3/Slack for testing
376
+ // 2. Can't change providers without modifying this class
377
+ // 3. All configuration is hardcoded to environment variables
378
+ // 4. No way to use different implementations for different contexts
379
+ ```
380
+
381
+ ---
382
+
383
+ ## Layering Violations
384
+
385
+ ### Skipping Layers
386
+
387
+ **Controller Bypassing Service Layer**
388
+ ```typescript
389
+ // VIOLATION: Controller directly accesses database, cache, and external APIs
390
+ class ProductController {
391
+ async getProduct(req, res) {
392
+ const productId = req.params.id;
393
+
394
+ // Direct cache access
395
+ const cached = await redis.get(`product:${productId}`);
396
+ if (cached) {
397
+ return res.json(JSON.parse(cached));
398
+ }
399
+
400
+ // Direct database access
401
+ const product = await db.query(
402
+ 'SELECT * FROM products WHERE id = $1',
403
+ [productId]
404
+ );
405
+
406
+ if (!product) {
407
+ return res.status(404).json({ error: 'Not found' });
408
+ }
409
+
410
+ // Direct external API call
411
+ const inventory = await fetch(
412
+ `http://inventory-service/api/stock/${productId}`
413
+ ).then(r => r.json());
414
+
415
+ // Business logic in controller
416
+ const result = {
417
+ ...product,
418
+ inStock: inventory.quantity > 0,
419
+ availability: inventory.quantity > 10 ? 'high' : inventory.quantity > 0 ? 'low' : 'none'
420
+ };
421
+
422
+ // Direct cache write
423
+ await redis.setex(`product:${productId}`, 300, JSON.stringify(result));
424
+
425
+ res.json(result);
426
+ }
427
+
428
+ async updateProduct(req, res) {
429
+ // Direct database update
430
+ await db.query(
431
+ 'UPDATE products SET name = $1, price = $2 WHERE id = $3',
432
+ [req.body.name, req.body.price, req.params.id]
433
+ );
434
+
435
+ // Direct cache invalidation
436
+ await redis.del(`product:${req.params.id}`);
437
+ await redis.del('products:list');
438
+
439
+ // Direct audit log
440
+ await db.query(
441
+ 'INSERT INTO audit_log (action, entity, entity_id, data) VALUES ($1, $2, $3, $4)',
442
+ ['UPDATE', 'product', req.params.id, JSON.stringify(req.body)]
443
+ );
444
+
445
+ res.json({ success: true });
446
+ }
447
+ }
448
+ ```
449
+
450
+ ---
451
+
452
+ ### Leaky Abstractions
453
+
454
+ **ORM Leakage Into Domain**
455
+ ```typescript
456
+ // VIOLATION: ORM/database details leak into domain and service layers
457
+
458
+ // Domain model polluted with ORM decorators and infrastructure
459
+ @Entity('users')
460
+ class User {
461
+ @PrimaryGeneratedColumn('uuid')
462
+ id: string;
463
+
464
+ @Column({ type: 'varchar', length: 255 })
465
+ email: string;
466
+
467
+ @Column({ type: 'varchar', length: 255, select: false })
468
+ password: string;
469
+
470
+ @ManyToOne(() => Organization, { lazy: true })
471
+ @JoinColumn({ name: 'organization_id' })
472
+ organization: Promise<Organization>; // Lazy loading leaks into domain
473
+
474
+ @OneToMany(() => Order, order => order.user)
475
+ orders: Order[];
476
+
477
+ @Column({ type: 'jsonb', default: {} })
478
+ metadata: Record<string, unknown>; // JSONB is infrastructure detail
479
+
480
+ @CreateDateColumn()
481
+ createdAt: Date;
482
+
483
+ @UpdateDateColumn()
484
+ updatedAt: Date;
485
+
486
+ @DeleteDateColumn()
487
+ deletedAt: Date | null; // Soft delete is infrastructure pattern
488
+ }
489
+
490
+ // Service layer knows about ORM internals
491
+ class UserService {
492
+ async getUser(id: string) {
493
+ const user = await this.repository.findOne({
494
+ where: { id, deletedAt: IsNull() }, // ORM-specific query syntax
495
+ relations: ['organization', 'orders'], // ORM-specific loading
496
+ select: ['id', 'email', 'createdAt'] // ORM-specific projection
497
+ });
498
+
499
+ // Manually handling lazy loading - ORM detail in service
500
+ const org = await user.organization;
501
+
502
+ return user;
503
+ }
504
+ }
505
+ ```
506
+
507
+ ---
508
+
509
+ ### Wrong Direction Dependencies
510
+
511
+ **Domain Depending on Infrastructure**
512
+ ```typescript
513
+ // VIOLATION: Domain layer imports from infrastructure layer
514
+
515
+ // domain/order.ts
516
+ import { PostgresClient } from '../infrastructure/postgres';
517
+ import { RedisCache } from '../infrastructure/redis';
518
+ import { StripeClient } from '../infrastructure/stripe';
519
+ import { SendGridClient } from '../infrastructure/sendgrid';
520
+
521
+ class Order {
522
+ async save() {
523
+ // Domain knows about specific database
524
+ await PostgresClient.getInstance().query(
525
+ 'INSERT INTO orders ...',
526
+ [this.id, this.items, this.total]
527
+ );
528
+
529
+ // Domain knows about caching
530
+ await RedisCache.getInstance().del(`user:${this.userId}:orders`);
531
+ }
532
+
533
+ async processPayment() {
534
+ // Domain knows about specific payment provider
535
+ const stripe = new StripeClient(process.env.STRIPE_KEY);
536
+ await stripe.charges.create({
537
+ amount: this.total,
538
+ currency: 'usd',
539
+ source: this.paymentSource
540
+ });
541
+ }
542
+
543
+ async notifyCustomer() {
544
+ // Domain knows about specific email provider
545
+ const sendgrid = new SendGridClient(process.env.SENDGRID_KEY);
546
+ await sendgrid.send({
547
+ to: this.customerEmail,
548
+ template: 'order_confirmation',
549
+ data: { orderId: this.id }
550
+ });
551
+ }
552
+ }
553
+ ```
554
+
555
+ **Dependency Direction Rules**
556
+
557
+ ```
558
+ +------------------+
559
+ | Infrastructure | <- Implements domain interfaces
560
+ +------------------+
561
+ |
562
+ v
563
+ +------------------+
564
+ | Application | <- Orchestrates domain, uses interfaces
565
+ +------------------+
566
+ |
567
+ v
568
+ +------------------+
569
+ | Domain | <- Pure business logic, defines interfaces
570
+ +------------------+
571
+
572
+ Domain: No imports from other layers
573
+ Application: Imports from Domain only
574
+ Infrastructure: Imports from Domain and Application
575
+ ```
@@ -0,0 +1,143 @@
1
+ ---
2
+ name: complexity-patterns
3
+ description: Complexity analysis patterns for code review. Detects high cyclomatic complexity, deep nesting, long functions, and readability issues that hinder maintainability. Loaded by Reviewer agent when focus=complexity.
4
+ user-invocable: false
5
+ allowed-tools: Read, Grep, Glob
6
+ ---
7
+
8
+ # Complexity Patterns
9
+
10
+ Domain expertise for code complexity and maintainability analysis. Use alongside `review-methodology` for complete complexity reviews.
11
+
12
+ ## Iron Law
13
+
14
+ > **IF YOU CAN'T UNDERSTAND IT IN 5 MINUTES, IT'S TOO COMPLEX**
15
+ >
16
+ > Every function should be explainable to a colleague in under 5 minutes. If you need a
17
+ > diagram to understand control flow, refactor. If you need comments to explain what
18
+ > (not why), the code is too clever. Simplicity is a feature, complexity is a bug.
19
+
20
+ ---
21
+
22
+ ## Complexity Categories
23
+
24
+ ### 1. Cyclomatic Complexity
25
+
26
+ High decision path count makes code hard to test and understand.
27
+
28
+ **Violation**: Deep nesting (5+ levels)
29
+ ```typescript
30
+ if (order) {
31
+ if (order.items) {
32
+ for (const item of order.items) {
33
+ if (item.quantity > 0) {
34
+ if (item.product?.inStock) {
35
+ // Buried logic
36
+ ```
37
+
38
+ **Solution**: Early returns and extraction
39
+ ```typescript
40
+ function processOrder(order: Order) {
41
+ if (!order?.items) return;
42
+ for (const item of order.items) processItem(item);
43
+ }
44
+
45
+ function processItem(item: OrderItem) {
46
+ if (item.quantity <= 0 || !item.product?.inStock) return;
47
+ // Logic at top level
48
+ }
49
+ ```
50
+
51
+ ### 2. Readability Issues
52
+
53
+ Code that requires mental effort to parse.
54
+
55
+ **Violation**: Magic values
56
+ ```typescript
57
+ if (status === 3) {
58
+ setTimeout(callback, 86400000);
59
+ }
60
+ ```
61
+
62
+ **Solution**: Named constants
63
+ ```typescript
64
+ const OrderStatus = { COMPLETED: 3 } as const;
65
+ const ONE_DAY_MS = 24 * 60 * 60 * 1000;
66
+
67
+ if (status === OrderStatus.COMPLETED) {
68
+ setTimeout(callback, ONE_DAY_MS);
69
+ }
70
+ ```
71
+
72
+ ### 3. Maintainability Issues
73
+
74
+ Code that's expensive to change.
75
+
76
+ **Violation**: Long parameter lists
77
+ ```typescript
78
+ function createUser(name, email, password, role, dept, manager, startDate, salary) { }
79
+ ```
80
+
81
+ **Solution**: Object parameter
82
+ ```typescript
83
+ interface CreateUserParams {
84
+ name: string; email: string; password: string;
85
+ role: string; department: string; manager?: string;
86
+ startDate: Date; salary: number;
87
+ }
88
+ function createUser(params: CreateUserParams) { }
89
+ ```
90
+
91
+ ### 4. Boolean Complexity
92
+
93
+ Conditions that are hard to reason about.
94
+
95
+ **Violation**: Complex boolean expression
96
+ ```typescript
97
+ if (user.active && !user.deleted && (user.role === 'admin' || user.role === 'moderator') && user.verified && (!user.suspended || user.suspendedUntil < Date.now())) { }
98
+ ```
99
+
100
+ **Solution**: Extract to named predicate
101
+ ```typescript
102
+ const canModerate = (user: User): boolean => {
103
+ if (!user.active || user.deleted || !user.verified) return false;
104
+ if (!['admin', 'moderator'].includes(user.role)) return false;
105
+ if (user.suspended && user.suspendedUntil >= Date.now()) return false;
106
+ return true;
107
+ };
108
+
109
+ if (canModerate(user)) { }
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Extended References
115
+
116
+ For extended examples and detection techniques:
117
+
118
+ | Reference | Content |
119
+ |-----------|---------|
120
+ | `references/violations.md` | Extended violation examples for all categories |
121
+ | `references/patterns.md` | Detailed refactoring solutions |
122
+ | `references/detection.md` | Bash commands and static analysis setup |
123
+
124
+ ---
125
+
126
+ ## Severity Guidelines
127
+
128
+ | Severity | Criteria |
129
+ |----------|----------|
130
+ | **CRITICAL** | Functions > 200 lines, complexity > 20, nesting > 6, duplication in 5+ places |
131
+ | **HIGH** | Functions 50-200 lines, complexity 10-20, nesting 4-6, 5+ boolean conditions, 5+ parameters |
132
+ | **MEDIUM** | Functions 30-50 lines, complexity 5-10, magic values, minor duplication |
133
+ | **LOW** | Could be more readable, naming improvements, comments would help |
134
+
135
+ ## Metrics Quick Reference
136
+
137
+ | Metric | Good | Warning | Critical |
138
+ |--------|------|---------|----------|
139
+ | Function length | < 30 | 30-50 | > 50 |
140
+ | Cyclomatic complexity | < 5 | 5-10 | > 10 |
141
+ | Nesting depth | < 3 | 3-4 | > 4 |
142
+ | Parameters | < 3 | 3-5 | > 5 |
143
+ | File length | < 300 | 300-500 | > 500 |