@humanbased/crosscheck 1.2.0-beta.80 → 1.2.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 (301) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +388 -149
  3. package/README.zh.md +1 -1
  4. package/crosscheck.config.example.yml +2 -63
  5. package/dist/__tests__/codex.test.js +27 -14
  6. package/dist/__tests__/codex.test.js.map +1 -1
  7. package/dist/__tests__/comment-bodies.test.js +1 -49
  8. package/dist/__tests__/comment-bodies.test.js.map +1 -1
  9. package/dist/__tests__/conflict-resolve.test.js +1 -44
  10. package/dist/__tests__/conflict-resolve.test.js.map +1 -1
  11. package/dist/__tests__/fix.test.js +0 -33
  12. package/dist/__tests__/fix.test.js.map +1 -1
  13. package/dist/__tests__/onboard-preservation.test.js +0 -5
  14. package/dist/__tests__/onboard-preservation.test.js.map +1 -1
  15. package/dist/__tests__/optimize.test.js +0 -2
  16. package/dist/__tests__/optimize.test.js.map +1 -1
  17. package/dist/__tests__/repo-picker.test.js +1 -7
  18. package/dist/__tests__/repo-picker.test.js.map +1 -1
  19. package/dist/__tests__/review-comment-body.test.js +0 -35
  20. package/dist/__tests__/review-comment-body.test.js.map +1 -1
  21. package/dist/__tests__/review-models.test.js +3 -19
  22. package/dist/__tests__/review-models.test.js.map +1 -1
  23. package/dist/__tests__/runner.test.js +1 -29
  24. package/dist/__tests__/runner.test.js.map +1 -1
  25. package/dist/cli.js +0 -29
  26. package/dist/cli.js.map +1 -1
  27. package/dist/commands/onboard.d.ts +0 -11
  28. package/dist/commands/onboard.d.ts.map +1 -1
  29. package/dist/commands/onboard.js +2 -88
  30. package/dist/commands/onboard.js.map +1 -1
  31. package/dist/commands/review.d.ts.map +1 -1
  32. package/dist/commands/review.js +6 -65
  33. package/dist/commands/review.js.map +1 -1
  34. package/dist/commands/run.d.ts.map +1 -1
  35. package/dist/commands/run.js +3 -23
  36. package/dist/commands/run.js.map +1 -1
  37. package/dist/commands/status.d.ts.map +1 -1
  38. package/dist/commands/status.js +1 -53
  39. package/dist/commands/status.js.map +1 -1
  40. package/dist/commands/watch.d.ts.map +1 -1
  41. package/dist/commands/watch.js +6 -52
  42. package/dist/commands/watch.js.map +1 -1
  43. package/dist/config/loader.d.ts +1 -3
  44. package/dist/config/loader.d.ts.map +1 -1
  45. package/dist/config/loader.js +0 -13
  46. package/dist/config/loader.js.map +1 -1
  47. package/dist/config/review-model-tiers.json +3 -3
  48. package/dist/config/schema.d.ts +10 -254
  49. package/dist/config/schema.d.ts.map +1 -1
  50. package/dist/config/schema.js +2 -62
  51. package/dist/config/schema.js.map +1 -1
  52. package/dist/github/client.d.ts +1 -6
  53. package/dist/github/client.d.ts.map +1 -1
  54. package/dist/github/client.js +7 -15
  55. package/dist/github/client.js.map +1 -1
  56. package/dist/issues/ticket-ref.d.ts.map +1 -1
  57. package/dist/issues/ticket-ref.js +5 -6
  58. package/dist/issues/ticket-ref.js.map +1 -1
  59. package/dist/lib/clone.d.ts +0 -1
  60. package/dist/lib/clone.d.ts.map +1 -1
  61. package/dist/lib/clone.js +10 -32
  62. package/dist/lib/clone.js.map +1 -1
  63. package/dist/lib/comment-bodies.d.ts +0 -35
  64. package/dist/lib/comment-bodies.d.ts.map +1 -1
  65. package/dist/lib/comment-bodies.js +9 -43
  66. package/dist/lib/comment-bodies.js.map +1 -1
  67. package/dist/lib/repo-picker.d.ts +0 -3
  68. package/dist/lib/repo-picker.d.ts.map +1 -1
  69. package/dist/lib/repo-picker.js +9 -45
  70. package/dist/lib/repo-picker.js.map +1 -1
  71. package/dist/lib/review-models.d.ts +2 -15
  72. package/dist/lib/review-models.d.ts.map +1 -1
  73. package/dist/lib/review-models.js +6 -26
  74. package/dist/lib/review-models.js.map +1 -1
  75. package/dist/lib/runner.d.ts +0 -12
  76. package/dist/lib/runner.d.ts.map +1 -1
  77. package/dist/lib/runner.js +42 -186
  78. package/dist/lib/runner.js.map +1 -1
  79. package/dist/lib/workflow.d.ts +0 -9
  80. package/dist/lib/workflow.d.ts.map +1 -1
  81. package/dist/lib/workflow.js +0 -20
  82. package/dist/lib/workflow.js.map +1 -1
  83. package/dist/reviewers/claude.d.ts +1 -4
  84. package/dist/reviewers/claude.d.ts.map +1 -1
  85. package/dist/reviewers/claude.js +7 -39
  86. package/dist/reviewers/claude.js.map +1 -1
  87. package/dist/reviewers/codex.d.ts +1 -3
  88. package/dist/reviewers/codex.d.ts.map +1 -1
  89. package/dist/reviewers/codex.js +70 -76
  90. package/dist/reviewers/codex.js.map +1 -1
  91. package/dist/reviewers/conflict-resolve.d.ts +1 -3
  92. package/dist/reviewers/conflict-resolve.d.ts.map +1 -1
  93. package/dist/reviewers/conflict-resolve.js +6 -21
  94. package/dist/reviewers/conflict-resolve.js.map +1 -1
  95. package/dist/reviewers/fix.d.ts +2 -5
  96. package/dist/reviewers/fix.d.ts.map +1 -1
  97. package/dist/reviewers/fix.js +10 -26
  98. package/dist/reviewers/fix.js.map +1 -1
  99. package/get-started.md +4 -139
  100. package/package.json +3 -4
  101. package/assets/icon-256.png +0 -0
  102. package/assets/linear-comment.svg +0 -18
  103. package/assets/linear-onboard.svg +0 -30
  104. package/assets/linear-status.svg +0 -23
  105. package/assets/linear-test.svg +0 -34
  106. package/assets/skills/code-review/.crosscheck-skill.json +0 -9
  107. package/assets/skills/code-review/LICENSE +0 -21
  108. package/assets/skills/code-review/SKILL.md +0 -89
  109. package/assets/skills/code-review/agents/openai.yaml +0 -3
  110. package/assets/skills/code-review-skill/.crosscheck-skill.json +0 -9
  111. package/assets/skills/code-review-skill/LICENSE +0 -21
  112. package/assets/skills/code-review-skill/SKILL.md +0 -231
  113. package/assets/skills/code-review-skill/assets/pr-review-template.md +0 -137
  114. package/assets/skills/code-review-skill/assets/review-checklist.md +0 -123
  115. package/assets/skills/code-review-skill/reference/angular.md +0 -768
  116. package/assets/skills/code-review-skill/reference/architecture-review-guide.md +0 -472
  117. package/assets/skills/code-review-skill/reference/c.md +0 -890
  118. package/assets/skills/code-review-skill/reference/code-quality-universal.md +0 -488
  119. package/assets/skills/code-review-skill/reference/code-review-best-practices.md +0 -136
  120. package/assets/skills/code-review-skill/reference/common-bugs-checklist.md +0 -286
  121. package/assets/skills/code-review-skill/reference/cpp.md +0 -893
  122. package/assets/skills/code-review-skill/reference/cross-cutting/async-concurrency-patterns.md +0 -515
  123. package/assets/skills/code-review-skill/reference/cross-cutting/error-handling-principles.md +0 -492
  124. package/assets/skills/code-review-skill/reference/cross-cutting/n-plus-one-queries.md +0 -309
  125. package/assets/skills/code-review-skill/reference/cross-cutting/sql-injection-prevention.md +0 -308
  126. package/assets/skills/code-review-skill/reference/cross-cutting/xss-prevention.md +0 -264
  127. package/assets/skills/code-review-skill/reference/csharp.md +0 -525
  128. package/assets/skills/code-review-skill/reference/css-less-sass.md +0 -661
  129. package/assets/skills/code-review-skill/reference/django.md +0 -985
  130. package/assets/skills/code-review-skill/reference/fastapi.md +0 -580
  131. package/assets/skills/code-review-skill/reference/go.md +0 -993
  132. package/assets/skills/code-review-skill/reference/java.md +0 -409
  133. package/assets/skills/code-review-skill/reference/java8.md +0 -586
  134. package/assets/skills/code-review-skill/reference/kotlin.md +0 -1018
  135. package/assets/skills/code-review-skill/reference/nestjs.md +0 -593
  136. package/assets/skills/code-review-skill/reference/performance-review-guide.md +0 -816
  137. package/assets/skills/code-review-skill/reference/php.md +0 -684
  138. package/assets/skills/code-review-skill/reference/python.md +0 -1073
  139. package/assets/skills/code-review-skill/reference/qt.md +0 -757
  140. package/assets/skills/code-review-skill/reference/react.md +0 -871
  141. package/assets/skills/code-review-skill/reference/ruby.md +0 -964
  142. package/assets/skills/code-review-skill/reference/rust.md +0 -846
  143. package/assets/skills/code-review-skill/reference/security-review-guide.md +0 -494
  144. package/assets/skills/code-review-skill/reference/svelte.md +0 -1064
  145. package/assets/skills/code-review-skill/reference/swift.md +0 -936
  146. package/assets/skills/code-review-skill/reference/typescript.md +0 -1016
  147. package/assets/skills/code-review-skill/reference/vue.md +0 -924
  148. package/assets/skills/code-review-skill/reference/zig.md +0 -440
  149. package/assets/skills/code-review-skill/scripts/pr-analyzer.py +0 -435
  150. package/assets/skills/code-review-skill/scripts/test_pr_analyzer.py +0 -380
  151. package/assets/skills/codebase-design/.crosscheck-skill.json +0 -9
  152. package/assets/skills/codebase-design/DEEPENING.md +0 -37
  153. package/assets/skills/codebase-design/DESIGN-IT-TWICE.md +0 -44
  154. package/assets/skills/codebase-design/LICENSE +0 -21
  155. package/assets/skills/codebase-design/SKILL.md +0 -114
  156. package/assets/skills/codebase-design/agents/openai.yaml +0 -3
  157. package/assets/skills/diagnosing-bugs/.crosscheck-skill.json +0 -9
  158. package/assets/skills/diagnosing-bugs/LICENSE +0 -21
  159. package/assets/skills/diagnosing-bugs/SKILL.md +0 -134
  160. package/assets/skills/diagnosing-bugs/agents/openai.yaml +0 -3
  161. package/assets/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +0 -41
  162. package/dist/__tests__/can-write-verdict.test.d.ts +0 -2
  163. package/dist/__tests__/can-write-verdict.test.d.ts.map +0 -1
  164. package/dist/__tests__/can-write-verdict.test.js +0 -31
  165. package/dist/__tests__/can-write-verdict.test.js.map +0 -1
  166. package/dist/__tests__/linear-branding.test.d.ts +0 -2
  167. package/dist/__tests__/linear-branding.test.d.ts.map +0 -1
  168. package/dist/__tests__/linear-branding.test.js +0 -156
  169. package/dist/__tests__/linear-branding.test.js.map +0 -1
  170. package/dist/__tests__/linear-client.test.d.ts +0 -2
  171. package/dist/__tests__/linear-client.test.d.ts.map +0 -1
  172. package/dist/__tests__/linear-client.test.js +0 -120
  173. package/dist/__tests__/linear-client.test.js.map +0 -1
  174. package/dist/__tests__/linear-comment.test.d.ts +0 -2
  175. package/dist/__tests__/linear-comment.test.d.ts.map +0 -1
  176. package/dist/__tests__/linear-comment.test.js +0 -151
  177. package/dist/__tests__/linear-comment.test.js.map +0 -1
  178. package/dist/__tests__/linear-identity.test.d.ts +0 -2
  179. package/dist/__tests__/linear-identity.test.d.ts.map +0 -1
  180. package/dist/__tests__/linear-identity.test.js +0 -253
  181. package/dist/__tests__/linear-identity.test.js.map +0 -1
  182. package/dist/__tests__/linear-notify.test.d.ts +0 -2
  183. package/dist/__tests__/linear-notify.test.d.ts.map +0 -1
  184. package/dist/__tests__/linear-notify.test.js +0 -144
  185. package/dist/__tests__/linear-notify.test.js.map +0 -1
  186. package/dist/__tests__/linear-ref.test.d.ts +0 -2
  187. package/dist/__tests__/linear-ref.test.d.ts.map +0 -1
  188. package/dist/__tests__/linear-ref.test.js +0 -261
  189. package/dist/__tests__/linear-ref.test.js.map +0 -1
  190. package/dist/__tests__/linear-test-ref.test.d.ts +0 -2
  191. package/dist/__tests__/linear-test-ref.test.d.ts.map +0 -1
  192. package/dist/__tests__/linear-test-ref.test.js +0 -81
  193. package/dist/__tests__/linear-test-ref.test.js.map +0 -1
  194. package/dist/__tests__/linear-verify.test.d.ts +0 -2
  195. package/dist/__tests__/linear-verify.test.d.ts.map +0 -1
  196. package/dist/__tests__/linear-verify.test.js +0 -132
  197. package/dist/__tests__/linear-verify.test.js.map +0 -1
  198. package/dist/__tests__/linear-worker.test.d.ts +0 -2
  199. package/dist/__tests__/linear-worker.test.d.ts.map +0 -1
  200. package/dist/__tests__/linear-worker.test.js +0 -83
  201. package/dist/__tests__/linear-worker.test.js.map +0 -1
  202. package/dist/__tests__/linear-write-possible.test.d.ts +0 -2
  203. package/dist/__tests__/linear-write-possible.test.d.ts.map +0 -1
  204. package/dist/__tests__/linear-write-possible.test.js +0 -30
  205. package/dist/__tests__/linear-write-possible.test.js.map +0 -1
  206. package/dist/__tests__/repository-guidance.test.d.ts +0 -2
  207. package/dist/__tests__/repository-guidance.test.d.ts.map +0 -1
  208. package/dist/__tests__/repository-guidance.test.js +0 -107
  209. package/dist/__tests__/repository-guidance.test.js.map +0 -1
  210. package/dist/__tests__/review-strategy.test.d.ts +0 -2
  211. package/dist/__tests__/review-strategy.test.d.ts.map +0 -1
  212. package/dist/__tests__/review-strategy.test.js +0 -195
  213. package/dist/__tests__/review-strategy.test.js.map +0 -1
  214. package/dist/__tests__/skill-attribution.test.d.ts +0 -2
  215. package/dist/__tests__/skill-attribution.test.d.ts.map +0 -1
  216. package/dist/__tests__/skill-attribution.test.js +0 -53
  217. package/dist/__tests__/skill-attribution.test.js.map +0 -1
  218. package/dist/__tests__/skill-broker.test.d.ts +0 -2
  219. package/dist/__tests__/skill-broker.test.d.ts.map +0 -1
  220. package/dist/__tests__/skill-broker.test.js +0 -144
  221. package/dist/__tests__/skill-broker.test.js.map +0 -1
  222. package/dist/__tests__/skill-catalog.test.d.ts +0 -2
  223. package/dist/__tests__/skill-catalog.test.d.ts.map +0 -1
  224. package/dist/__tests__/skill-catalog.test.js +0 -40
  225. package/dist/__tests__/skill-catalog.test.js.map +0 -1
  226. package/dist/__tests__/skill-installer.test.d.ts +0 -2
  227. package/dist/__tests__/skill-installer.test.d.ts.map +0 -1
  228. package/dist/__tests__/skill-installer.test.js +0 -96
  229. package/dist/__tests__/skill-installer.test.js.map +0 -1
  230. package/dist/__tests__/skills-config.test.d.ts +0 -2
  231. package/dist/__tests__/skills-config.test.d.ts.map +0 -1
  232. package/dist/__tests__/skills-config.test.js +0 -12
  233. package/dist/__tests__/skills-config.test.js.map +0 -1
  234. package/dist/commands/linear-test.d.ts +0 -18
  235. package/dist/commands/linear-test.d.ts.map +0 -1
  236. package/dist/commands/linear-test.js +0 -130
  237. package/dist/commands/linear-test.js.map +0 -1
  238. package/dist/commands/skill.d.ts +0 -2
  239. package/dist/commands/skill.d.ts.map +0 -1
  240. package/dist/commands/skill.js +0 -16
  241. package/dist/commands/skill.js.map +0 -1
  242. package/dist/config/review-strategy.json +0 -202
  243. package/dist/lib/repository-guidance.d.ts +0 -2
  244. package/dist/lib/repository-guidance.d.ts.map +0 -1
  245. package/dist/lib/repository-guidance.js +0 -55
  246. package/dist/lib/repository-guidance.js.map +0 -1
  247. package/dist/lib/review-strategy.d.ts +0 -62
  248. package/dist/lib/review-strategy.d.ts.map +0 -1
  249. package/dist/lib/review-strategy.js +0 -235
  250. package/dist/lib/review-strategy.js.map +0 -1
  251. package/dist/linear/client.d.ts +0 -18
  252. package/dist/linear/client.d.ts.map +0 -1
  253. package/dist/linear/client.js +0 -67
  254. package/dist/linear/client.js.map +0 -1
  255. package/dist/linear/comment.d.ts +0 -20
  256. package/dist/linear/comment.d.ts.map +0 -1
  257. package/dist/linear/comment.js +0 -57
  258. package/dist/linear/comment.js.map +0 -1
  259. package/dist/linear/identity.d.ts +0 -59
  260. package/dist/linear/identity.d.ts.map +0 -1
  261. package/dist/linear/identity.js +0 -187
  262. package/dist/linear/identity.js.map +0 -1
  263. package/dist/linear/notify.d.ts +0 -35
  264. package/dist/linear/notify.d.ts.map +0 -1
  265. package/dist/linear/notify.js +0 -76
  266. package/dist/linear/notify.js.map +0 -1
  267. package/dist/linear/ref.d.ts +0 -13
  268. package/dist/linear/ref.d.ts.map +0 -1
  269. package/dist/linear/ref.js +0 -90
  270. package/dist/linear/ref.js.map +0 -1
  271. package/dist/linear/verify.d.ts +0 -26
  272. package/dist/linear/verify.d.ts.map +0 -1
  273. package/dist/linear/verify.js +0 -67
  274. package/dist/linear/verify.js.map +0 -1
  275. package/dist/skills/attribution.d.ts +0 -4
  276. package/dist/skills/attribution.d.ts.map +0 -1
  277. package/dist/skills/attribution.js +0 -14
  278. package/dist/skills/attribution.js.map +0 -1
  279. package/dist/skills/broker-server.d.ts +0 -2
  280. package/dist/skills/broker-server.d.ts.map +0 -1
  281. package/dist/skills/broker-server.js +0 -17
  282. package/dist/skills/broker-server.js.map +0 -1
  283. package/dist/skills/broker.d.ts +0 -42
  284. package/dist/skills/broker.d.ts.map +0 -1
  285. package/dist/skills/broker.js +0 -285
  286. package/dist/skills/broker.js.map +0 -1
  287. package/dist/skills/catalog.d.ts +0 -28
  288. package/dist/skills/catalog.d.ts.map +0 -1
  289. package/dist/skills/catalog.js +0 -104
  290. package/dist/skills/catalog.js.map +0 -1
  291. package/dist/skills/installer.d.ts +0 -10
  292. package/dist/skills/installer.d.ts.map +0 -1
  293. package/dist/skills/installer.js +0 -138
  294. package/dist/skills/installer.js.map +0 -1
  295. package/dist/skills/integrity.d.ts +0 -4
  296. package/dist/skills/integrity.d.ts.map +0 -1
  297. package/dist/skills/integrity.js +0 -36
  298. package/dist/skills/integrity.js.map +0 -1
  299. package/docs/dynamic-thoroughness.md +0 -286
  300. package/docs/linear-identity-contract.md +0 -139
  301. package/docs/linear-identity.md +0 -293
@@ -1,380 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Tests for pr-analyzer.py (stdlib unittest, no extra deps)."""
3
-
4
- import importlib.util
5
- import os
6
- import unittest
7
-
8
- # The script has a hyphen in its name, so load it by path.
9
- _HERE = os.path.dirname(os.path.abspath(__file__))
10
- _spec = importlib.util.spec_from_file_location(
11
- 'pr_analyzer', os.path.join(_HERE, 'pr-analyzer.py')
12
- )
13
- pr_analyzer = importlib.util.module_from_spec(_spec)
14
- _spec.loader.exec_module(pr_analyzer)
15
-
16
- # Convenient aliases
17
- FileStats = pr_analyzer.FileStats
18
-
19
-
20
- # ═══════════════════════════════════════════════════════════════
21
- # parse_diff — filename extraction (existing tests)
22
- # ═══════════════════════════════════════════════════════════════
23
-
24
- class ParseDiffFilenameTest(unittest.TestCase):
25
- def test_lib_prefixed_path(self):
26
- # "lib/" embeds a literal "b/" that the old regex swallowed.
27
- diff = (
28
- "diff --git a/lib/foo.py b/lib/foo.py\n"
29
- "index 1234567..89abcde 100644\n"
30
- "--- a/lib/foo.py\n"
31
- "+++ b/lib/foo.py\n"
32
- "@@ -1,2 +1,3 @@\n"
33
- " unchanged\n"
34
- "+added line\n"
35
- "-removed line\n"
36
- )
37
- files = pr_analyzer.parse_diff(diff)
38
- self.assertEqual(len(files), 1)
39
- self.assertEqual(files[0].filename, 'lib/foo.py')
40
- self.assertEqual(files[0].additions, 1)
41
- self.assertEqual(files[0].deletions, 1)
42
-
43
- def test_normal_path(self):
44
- diff = (
45
- "diff --git a/src/main.py b/src/main.py\n"
46
- "index 1111111..2222222 100644\n"
47
- "--- a/src/main.py\n"
48
- "+++ b/src/main.py\n"
49
- "@@ -0,0 +1 @@\n"
50
- "+print('hi')\n"
51
- )
52
- files = pr_analyzer.parse_diff(diff)
53
- self.assertEqual(len(files), 1)
54
- self.assertEqual(files[0].filename, 'src/main.py')
55
-
56
- def test_other_embedded_b_slash_prefixes(self):
57
- # web/ and db/ also contain a literal "b/".
58
- diff = (
59
- "diff --git a/web/x.js b/web/x.js\n"
60
- "+++ b/web/x.js\n"
61
- "+console.log(1)\n"
62
- "diff --git a/db/y.sql b/db/y.sql\n"
63
- "+++ b/db/y.sql\n"
64
- "+SELECT 1;\n"
65
- )
66
- files = pr_analyzer.parse_diff(diff)
67
- self.assertEqual([f.filename for f in files], ['web/x.js', 'db/y.sql'])
68
-
69
- def test_rename_falls_back_to_b_side(self):
70
- diff = (
71
- "diff --git a/old/name.py b/new/name.py\n"
72
- "similarity index 100%\n"
73
- "rename from old/name.py\n"
74
- "rename to new/name.py\n"
75
- )
76
- files = pr_analyzer.parse_diff(diff)
77
- self.assertEqual(len(files), 1)
78
- self.assertEqual(files[0].filename, 'new/name.py')
79
-
80
-
81
- # ═══════════════════════════════════════════════════════════════
82
- # detect_language
83
- # ═══════════════════════════════════════════════════════════════
84
-
85
- class DetectLanguageTest(unittest.TestCase):
86
- def test_common_extensions(self):
87
- cases = {
88
- 'app.py': 'Python',
89
- 'index.ts': 'TypeScript',
90
- 'main.rs': 'Rust',
91
- 'handler.go': 'Go',
92
- 'App.java': 'Java',
93
- 'Activity.kt': 'Kotlin',
94
- 'ViewController.swift': 'Swift',
95
- 'app.tsx': 'TypeScript/React',
96
- 'style.css': 'CSS',
97
- 'query.sql': 'SQL',
98
- }
99
- for filename, expected in cases.items():
100
- with self.subTest(filename=filename):
101
- self.assertEqual(pr_analyzer.detect_language(filename), expected)
102
-
103
- def test_unknown_extension(self):
104
- self.assertEqual(pr_analyzer.detect_language('data.xyz'), 'unknown')
105
- self.assertEqual(pr_analyzer.detect_language('Makefile'), 'unknown')
106
-
107
- def test_cpp_variants(self):
108
- for ext in ('.cpp', '.hpp', '.cc', '.cxx', '.hh', '.hxx'):
109
- with self.subTest(ext=ext):
110
- self.assertEqual(pr_analyzer.detect_language(f'file{ext}'), 'C++')
111
-
112
-
113
- # ═══════════════════════════════════════════════════════════════
114
- # is_test_file
115
- # ═══════════════════════════════════════════════════════════════
116
-
117
- class IsTestFileTest(unittest.TestCase):
118
- def test_python_test_prefix(self):
119
- self.assertTrue(pr_analyzer.is_test_file('tests/test_handler.py'))
120
- self.assertTrue(pr_analyzer.is_test_file('test_utils.py'))
121
-
122
- def test_python_test_suffix(self):
123
- self.assertTrue(pr_analyzer.is_test_file('handler_test.py'))
124
-
125
- def test_rust_test_suffix(self):
126
- self.assertTrue(pr_analyzer.is_test_file('src/my_module_test.rs'))
127
- self.assertTrue(pr_analyzer.is_test_file('parser_test.rs'))
128
-
129
- def test_go_test_suffix(self):
130
- self.assertTrue(pr_analyzer.is_test_file('handler_test.go'))
131
- self.assertTrue(pr_analyzer.is_test_file('pkg/auth_test.go'))
132
-
133
- def test_js_ts_test_and_spec(self):
134
- self.assertTrue(pr_analyzer.is_test_file('handler.test.ts'))
135
- self.assertTrue(pr_analyzer.is_test_file('utils.spec.js'))
136
- self.assertTrue(pr_analyzer.is_test_file('App.test.tsx'))
137
-
138
- def test_tests_directory(self):
139
- self.assertTrue(pr_analyzer.is_test_file('tests/conftest.py'))
140
- self.assertTrue(pr_analyzer.is_test_file('test/helpers.js'))
141
-
142
- def test_dunder_tests_directory(self):
143
- self.assertTrue(pr_analyzer.is_test_file('__tests__/Button.test.tsx'))
144
-
145
- def test_non_test_files_rejected(self):
146
- self.assertFalse(pr_analyzer.is_test_file('handler.go'))
147
- self.assertFalse(pr_analyzer.is_test_file('module.rs'))
148
- self.assertFalse(pr_analyzer.is_test_file('src/utils.py'))
149
- self.assertFalse(pr_analyzer.is_test_file('lib/parser.js'))
150
- self.assertFalse(pr_analyzer.is_test_file('contest.py'))
151
-
152
- def test_test_substring_not_matched(self):
153
- """Files containing 'test_' as substring must NOT be flagged."""
154
- self.assertFalse(pr_analyzer.is_test_file('latest_report.py'))
155
- self.assertFalse(pr_analyzer.is_test_file('contest_utils.py'))
156
- self.assertFalse(pr_analyzer.is_test_file('src/latest_handler.py'))
157
-
158
-
159
- # ═══════════════════════════════════════════════════════════════
160
- # is_config_file
161
- # ═══════════════════════════════════════════════════════════════
162
-
163
- class IsConfigFileTest(unittest.TestCase):
164
- def test_known_json_configs(self):
165
- self.assertTrue(pr_analyzer.is_config_file('package.json'))
166
- self.assertTrue(pr_analyzer.is_config_file('tsconfig.json'))
167
- self.assertTrue(pr_analyzer.is_config_file('.eslintrc.json'))
168
-
169
- def test_known_yaml_configs(self):
170
- self.assertTrue(pr_analyzer.is_config_file('docker-compose.yml'))
171
- self.assertTrue(pr_analyzer.is_config_file('.github/workflows/ci.yml'))
172
- self.assertTrue(pr_analyzer.is_config_file('.prettierrc.yml'))
173
-
174
- def test_known_toml_configs(self):
175
- self.assertTrue(pr_analyzer.is_config_file('Cargo.toml'))
176
- self.assertTrue(pr_analyzer.is_config_file('pyproject.toml'))
177
-
178
- def test_env_files(self):
179
- self.assertTrue(pr_analyzer.is_config_file('.env'))
180
- self.assertTrue(pr_analyzer.is_config_file('.env.local'))
181
- self.assertTrue(pr_analyzer.is_config_file('.env.production'))
182
-
183
- def test_config_in_filename(self):
184
- self.assertTrue(pr_analyzer.is_config_file('app.config.ts'))
185
- self.assertTrue(pr_analyzer.is_config_file('database_config.yml'))
186
-
187
- def test_data_files_rejected(self):
188
- """Data files must NOT be flagged as config."""
189
- self.assertFalse(pr_analyzer.is_config_file('data.json'))
190
- self.assertFalse(pr_analyzer.is_config_file('openapi.yaml'))
191
- self.assertFalse(pr_analyzer.is_config_file('swagger.json'))
192
- self.assertFalse(pr_analyzer.is_config_file('fixtures/sample.yml'))
193
- self.assertFalse(pr_analyzer.is_config_file('translations.json'))
194
- self.assertFalse(pr_analyzer.is_config_file('schema.toml'))
195
-
196
- def test_config_directory(self):
197
- self.assertTrue(pr_analyzer.is_config_file('config/settings.yaml'))
198
- self.assertTrue(pr_analyzer.is_config_file('config/database.yml'))
199
- self.assertTrue(pr_analyzer.is_config_file('src/config/settings.json'))
200
-
201
- def test_source_files_rejected(self):
202
- self.assertFalse(pr_analyzer.is_config_file('src/index.ts'))
203
- self.assertFalse(pr_analyzer.is_config_file('lib/utils.py'))
204
-
205
-
206
- # ═══════════════════════════════════════════════════════════════
207
- # calculate_complexity
208
- # ═══════════════════════════════════════════════════════════════
209
-
210
- class CalculateComplexityTest(unittest.TestCase):
211
- def test_empty_files(self):
212
- self.assertEqual(pr_analyzer.calculate_complexity([]), 0.0)
213
-
214
- def test_small_simple_change(self):
215
- files = [FileStats(filename='app.py', additions=5, deletions=2,
216
- language='Python')]
217
- score = pr_analyzer.calculate_complexity(files)
218
- self.assertLess(score, 0.3)
219
-
220
- def test_large_multi_language_change(self):
221
- files = [
222
- FileStats(filename='app.py', additions=300, deletions=100, language='Python'),
223
- FileStats(filename='main.rs', additions=200, deletions=50, language='Rust'),
224
- FileStats(filename='index.ts', additions=150, deletions=80, language='TypeScript'),
225
- FileStats(filename='handler.go', additions=100, deletions=30, language='Go'),
226
- FileStats(filename='App.tsx', additions=50, deletions=20, language='TypeScript/React'),
227
- ]
228
- score = pr_analyzer.calculate_complexity(files)
229
- self.assertGreater(score, 0.5)
230
-
231
- def test_test_heavy_change_is_lower(self):
232
- """Changes with high test ratio should have lower complexity."""
233
- prod_files = [FileStats(filename='app.py', additions=100, deletions=50,
234
- language='Python')]
235
- test_files = [
236
- FileStats(filename='app.py', additions=100, deletions=50,
237
- language='Python'),
238
- FileStats(filename='tests/test_app.py', additions=100, deletions=0,
239
- language='Python', is_test=True),
240
- ]
241
- score_prod = pr_analyzer.calculate_complexity(prod_files)
242
- score_test = pr_analyzer.calculate_complexity(test_files)
243
- self.assertLess(score_test, score_prod)
244
-
245
-
246
- # ═══════════════════════════════════════════════════════════════
247
- # identify_risk_factors
248
- # ═══════════════════════════════════════════════════════════════
249
-
250
- class IdentifyRiskFactorsTest(unittest.TestCase):
251
- def test_large_pr_flagged(self):
252
- files = [FileStats(filename='big.py', additions=300, deletions=200,
253
- language='Python')]
254
- risks = pr_analyzer.identify_risk_factors(files)
255
- self.assertTrue(any('Large PR' in r for r in risks))
256
-
257
- def test_no_tests_flagged(self):
258
- files = [FileStats(filename='app.py', additions=40, deletions=20,
259
- language='Python')]
260
- risks = pr_analyzer.identify_risk_factors(files)
261
- self.assertTrue(any(pr_analyzer.RISK_NO_TESTS in r for r in risks))
262
-
263
- def test_with_tests_not_flagged(self):
264
- files = [
265
- FileStats(filename='app.py', additions=40, deletions=20,
266
- language='Python'),
267
- FileStats(filename='tests/test_app.py', additions=30, deletions=0,
268
- language='Python', is_test=True),
269
- ]
270
- risks = pr_analyzer.identify_risk_factors(files)
271
- self.assertFalse(any(pr_analyzer.RISK_NO_TESTS in r for r in risks))
272
-
273
- def test_security_sensitive_file(self):
274
- files = [FileStats(filename='src/auth/login.py', additions=10, deletions=5,
275
- language='Python')]
276
- risks = pr_analyzer.identify_risk_factors(files)
277
- self.assertTrue(any('Security-sensitive' in r for r in risks))
278
-
279
- def test_database_migration(self):
280
- files = [FileStats(filename='migrations/001_init.sql', additions=20, deletions=0,
281
- language='SQL')]
282
- risks = pr_analyzer.identify_risk_factors(files)
283
- self.assertTrue(any('Database' in r for r in risks))
284
-
285
- def test_test_substring_files_still_flag_no_tests(self):
286
- """Files like latest_report.py must not suppress NO_TEST_CHANGES."""
287
- files = [
288
- FileStats(filename='latest_report.py', additions=40, deletions=20,
289
- language='Python'),
290
- FileStats(filename='contest_utils.py', additions=30, deletions=10,
291
- language='Python'),
292
- ]
293
- risks = pr_analyzer.identify_risk_factors(files)
294
- self.assertTrue(any(pr_analyzer.RISK_NO_TESTS in r for r in risks))
295
-
296
-
297
- # ═══════════════════════════════════════════════════════════════
298
- # generate_suggestions
299
- # ═══════════════════════════════════════════════════════════════
300
-
301
- class GenerateSuggestionsTest(unittest.TestCase):
302
- def test_returns_list(self):
303
- files = [FileStats(filename='app.py', additions=10, deletions=5,
304
- language='Python')]
305
- result = pr_analyzer.generate_suggestions(files, 0.1, [])
306
- self.assertIsInstance(result, list)
307
- self.assertGreater(len(result), 0)
308
-
309
- def test_large_pr_split_suggestion(self):
310
- files = [FileStats(filename='big.py', additions=600, deletions=300,
311
- language='Python')]
312
- result = pr_analyzer.generate_suggestions(files, 0.3, [])
313
- self.assertTrue(any('splitting' in s.lower() for s in result))
314
-
315
- def test_no_tests_suggestion(self):
316
- files = [FileStats(filename='app.py', additions=40, deletions=20,
317
- language='Python')]
318
- risks = [f"{pr_analyzer.RISK_NO_TESTS}: no tests"]
319
- result = pr_analyzer.generate_suggestions(files, 0.2, risks)
320
- self.assertTrue(any('test' in s.lower() for s in result))
321
-
322
- def test_rust_suggestion(self):
323
- files = [FileStats(filename='lib.rs', additions=10, deletions=5,
324
- language='Rust')]
325
- result = pr_analyzer.generate_suggestions(files, 0.1, [])
326
- self.assertTrue(any('unwrap' in s.lower() for s in result))
327
-
328
-
329
- # ═══════════════════════════════════════════════════════════════
330
- # analyze_pr — end-to-end integration
331
- # ═══════════════════════════════════════════════════════════════
332
-
333
- class AnalyzePRTest(unittest.TestCase):
334
- def test_end_to_end(self):
335
- diff = (
336
- "diff --git a/src/app.py b/src/app.py\n"
337
- "index 1111111..2222222 100644\n"
338
- "--- a/src/app.py\n"
339
- "+++ b/src/app.py\n"
340
- "@@ -1,3 +1,5 @@\n"
341
- " import os\n"
342
- "+import sys\n"
343
- "+import json\n"
344
- " def main():\n"
345
- "+ print('hello')\n"
346
- "+ return 0\n"
347
- "diff --git a/tests/test_app.py b/tests/test_app.py\n"
348
- "new file mode 100644\n"
349
- "--- /dev/null\n"
350
- "+++ b/tests/test_app.py\n"
351
- "@@ -0,0 +1,3 @@\n"
352
- "+from app import main\n"
353
- "+def test_main():\n"
354
- "+ assert main() == 0\n"
355
- )
356
- analysis = pr_analyzer.analyze_pr(diff)
357
-
358
- self.assertEqual(analysis.total_files, 2)
359
- self.assertEqual(analysis.total_additions, 7) # 4 + 3
360
- self.assertEqual(analysis.total_deletions, 0)
361
- self.assertGreater(len(analysis.suggestions), 0)
362
- self.assertIn('XS (Extra Small)', analysis.size_category)
363
-
364
- # Verify test file was detected
365
- test_file = [f for f in analysis.files if 'test' in f.filename][0]
366
- self.assertTrue(test_file.is_test)
367
-
368
- # Verify no "NO_TEST_CHANGES" risk since tests are present
369
- self.assertFalse(
370
- any(pr_analyzer.RISK_NO_TESTS in r for r in analysis.risk_factors)
371
- )
372
-
373
- def test_empty_diff(self):
374
- analysis = pr_analyzer.analyze_pr("")
375
- self.assertEqual(analysis.total_files, 0)
376
- self.assertEqual(analysis.complexity_score, 0.0)
377
-
378
-
379
- if __name__ == '__main__':
380
- unittest.main()
@@ -1,9 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "name": "codebase-design",
4
- "author": "mattpocock",
5
- "license": "MIT",
6
- "source": "https://github.com/mattpocock/skills",
7
- "revision": "2ab958093e83e0ec752e6c1c5932da465bf23e0c",
8
- "integrity": "sha256:de9cabc2c28f4597fd9534e734974ffbdf1713f6a8411aa1ea87d602fc956e82"
9
- }
@@ -1,37 +0,0 @@
1
- # Deepening
2
-
3
- How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [SKILL.md](SKILL.md) — **module**, **interface**, **seam**, **adapter**.
4
-
5
- ## Dependency categories
6
-
7
- When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
8
-
9
- ### 1. In-process
10
-
11
- Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed.
12
-
13
- ### 2. Local-substitutable
14
-
15
- Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
16
-
17
- ### 3. Remote but owned (Ports & Adapters)
18
-
19
- Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
20
-
21
- Recommendation shape: *"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."*
22
-
23
- ### 4. True external (Mock)
24
-
25
- Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
26
-
27
- ## Seam discipline
28
-
29
- - **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
30
- - **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
31
-
32
- ## Testing strategy: replace, don't layer
33
-
34
- - Old unit tests on shallow modules become waste once tests at the deepened module's interface exist — delete them.
35
- - Write new tests at the deepened module's interface. The **interface is the test surface**.
36
- - Tests assert on observable outcomes through the interface, not internal state.
37
- - Tests should survive internal refactors — they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
@@ -1,44 +0,0 @@
1
- # Design It Twice
2
-
3
- When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout) — your first idea is unlikely to be the best.
4
-
5
- Uses the vocabulary in [SKILL.md](SKILL.md) — **module**, **interface**, **seam**, **adapter**, **leverage**.
6
-
7
- ## Process
8
-
9
- ### 1. Frame the problem space
10
-
11
- Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
12
-
13
- - The constraints any new interface would need to satisfy
14
- - The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
15
- - A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete
16
-
17
- Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
18
-
19
- ### 2. Spawn sub-agents
20
-
21
- Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module.
22
-
23
- Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
24
-
25
- - Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point."
26
- - Agent 2: "Maximise flexibility — support many use cases and extension."
27
- - Agent 3: "Optimise for the most common caller — make the default case trivial."
28
- - Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
29
-
30
- Include both [SKILL.md](SKILL.md) vocabulary and CONTEXT.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
31
-
32
- Each sub-agent outputs:
33
-
34
- 1. Interface (types, methods, params — plus invariants, ordering, error modes)
35
- 2. Usage example showing how callers use it
36
- 3. What the implementation hides behind the seam
37
- 4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md))
38
- 5. Trade-offs — where leverage is high, where it's thin
39
-
40
- ### 3. Present and compare
41
-
42
- Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
43
-
44
- After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not a menu.
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Matt Pocock
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,114 +0,0 @@
1
- ---
2
- name: codebase-design
3
- description: Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
4
- ---
5
-
6
- # Codebase Design
7
-
8
- Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Use this language and these principles wherever code is being designed or restructured. The aim is leverage for callers, locality for maintainers, and testability for everyone.
9
-
10
- ## Glossary
11
-
12
- Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
13
-
14
- **Module** — anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
15
-
16
- **Interface** — everything a caller must know to use the module correctly: the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics. _Avoid_: API, signature (too narrow — they refer only to the type-level surface).
17
-
18
- **Implementation** — what's inside a module, its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
19
-
20
- **Depth** — leverage at the interface: the amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface, **shallow** when the interface is nearly as complex as the implementation.
21
-
22
- **Seam** _(Michael Feathers)_ — a place where you can alter behaviour without editing in that place; the *location* at which a module's interface lives. Where to put the seam is its own design decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded context).
23
-
24
- **Adapter** — a concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
25
-
26
- **Leverage** — what callers get from depth: more capability per unit of interface they learn. One implementation pays back across N call sites and M tests.
27
-
28
- **Locality** — what maintainers get from depth: change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
29
-
30
- ## Deep vs shallow
31
-
32
- **Deep module** = small interface + lots of implementation:
33
-
34
- ```
35
- ┌─────────────────────┐
36
- │ Small Interface │ ← Few methods, simple params
37
- ├─────────────────────┤
38
- │ │
39
- │ Deep Implementation│ ← Complex logic hidden
40
- │ │
41
- └─────────────────────┘
42
- ```
43
-
44
- **Shallow module** = large interface + little implementation (avoid):
45
-
46
- ```
47
- ┌─────────────────────────────────┐
48
- │ Large Interface │ ← Many methods, complex params
49
- ├─────────────────────────────────┤
50
- │ Thin Implementation │ ← Just passes through
51
- └─────────────────────────────────┘
52
- ```
53
-
54
- When designing an interface, ask:
55
-
56
- - Can I reduce the number of methods?
57
- - Can I simplify the parameters?
58
- - Can I hide more complexity inside?
59
-
60
- ## Principles
61
-
62
- - **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts — they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
63
- - **The deletion test.** Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
64
- - **The interface is the test surface.** Callers and tests cross the same seam. If you want to test *past* the interface, the module is probably the wrong shape.
65
- - **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
66
-
67
- ## Designing for testability
68
-
69
- Good interfaces make testing natural:
70
-
71
- 1. **Accept dependencies, don't create them.**
72
-
73
- ```typescript
74
- // Testable
75
- function processOrder(order, paymentGateway) {}
76
-
77
- // Hard to test
78
- function processOrder(order) {
79
- const gateway = new StripeGateway();
80
- }
81
- ```
82
-
83
- 2. **Return results, don't produce side effects.**
84
-
85
- ```typescript
86
- // Testable
87
- function calculateDiscount(cart): Discount {}
88
-
89
- // Hard to test
90
- function applyDiscount(cart): void {
91
- cart.total -= discount;
92
- }
93
- ```
94
-
95
- 3. **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.
96
-
97
- ## Relationships
98
-
99
- - A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
100
- - **Depth** is a property of a **Module**, measured against its **Interface**.
101
- - A **Seam** is where a **Module**'s **Interface** lives.
102
- - An **Adapter** sits at a **Seam** and satisfies the **Interface**.
103
- - **Depth** produces **Leverage** for callers and **Locality** for maintainers.
104
-
105
- ## Rejected framings
106
-
107
- - **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
108
- - **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
109
- - **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
110
-
111
- ## Going deeper
112
-
113
- - **Deepening a cluster given its dependencies** — see [DEEPENING.md](DEEPENING.md): dependency categories, seam discipline, and replace-don't-layer testing.
114
- - **Exploring alternative interfaces** — see [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md): spin up parallel sub-agents to design the interface several radically different ways, then compare on depth, locality, and seam placement.
@@ -1,3 +0,0 @@
1
- interface:
2
- display_name: "Codebase Design"
3
- short_description: "Vocabulary for deep-module design"
@@ -1,9 +0,0 @@
1
- {
2
- "schemaVersion": 1,
3
- "name": "diagnosing-bugs",
4
- "author": "mattpocock",
5
- "license": "MIT",
6
- "source": "https://github.com/mattpocock/skills",
7
- "revision": "2ab958093e83e0ec752e6c1c5932da465bf23e0c",
8
- "integrity": "sha256:970eac3fd8742eb4e3e3a3c4320ef84bff928fb253377ff109fcc1ea06cfdd78"
9
- }
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Matt Pocock
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.