superpowers-spec 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 (301) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +141 -0
  3. package/agents/code-reviewer.md +48 -0
  4. package/bin/openspec.js +3 -0
  5. package/bin/superpowers.js +3 -0
  6. package/dist/cli/index.d.ts +2 -0
  7. package/dist/cli/index.js +482 -0
  8. package/dist/commands/change.d.ts +35 -0
  9. package/dist/commands/change.js +277 -0
  10. package/dist/commands/completion.d.ts +72 -0
  11. package/dist/commands/completion.js +257 -0
  12. package/dist/commands/config.d.ts +36 -0
  13. package/dist/commands/config.js +552 -0
  14. package/dist/commands/feedback.d.ts +9 -0
  15. package/dist/commands/feedback.js +183 -0
  16. package/dist/commands/schema.d.ts +6 -0
  17. package/dist/commands/schema.js +869 -0
  18. package/dist/commands/show.d.ts +14 -0
  19. package/dist/commands/show.js +132 -0
  20. package/dist/commands/spec.d.ts +15 -0
  21. package/dist/commands/spec.js +225 -0
  22. package/dist/commands/validate.d.ts +24 -0
  23. package/dist/commands/validate.js +294 -0
  24. package/dist/commands/workflow/index.d.ts +17 -0
  25. package/dist/commands/workflow/index.js +12 -0
  26. package/dist/commands/workflow/instructions.d.ts +29 -0
  27. package/dist/commands/workflow/instructions.js +381 -0
  28. package/dist/commands/workflow/new-change.d.ts +11 -0
  29. package/dist/commands/workflow/new-change.js +44 -0
  30. package/dist/commands/workflow/schemas.d.ts +10 -0
  31. package/dist/commands/workflow/schemas.js +34 -0
  32. package/dist/commands/workflow/shared.d.ts +57 -0
  33. package/dist/commands/workflow/shared.js +116 -0
  34. package/dist/commands/workflow/status.d.ts +14 -0
  35. package/dist/commands/workflow/status.js +75 -0
  36. package/dist/commands/workflow/templates.d.ts +16 -0
  37. package/dist/commands/workflow/templates.js +68 -0
  38. package/dist/core/archive.d.ts +11 -0
  39. package/dist/core/archive.js +318 -0
  40. package/dist/core/artifact-graph/graph.d.ts +56 -0
  41. package/dist/core/artifact-graph/graph.js +141 -0
  42. package/dist/core/artifact-graph/index.d.ts +7 -0
  43. package/dist/core/artifact-graph/index.js +13 -0
  44. package/dist/core/artifact-graph/instruction-loader.d.ts +143 -0
  45. package/dist/core/artifact-graph/instruction-loader.js +214 -0
  46. package/dist/core/artifact-graph/resolver.d.ts +81 -0
  47. package/dist/core/artifact-graph/resolver.js +257 -0
  48. package/dist/core/artifact-graph/schema.d.ts +13 -0
  49. package/dist/core/artifact-graph/schema.js +108 -0
  50. package/dist/core/artifact-graph/state.d.ts +12 -0
  51. package/dist/core/artifact-graph/state.js +54 -0
  52. package/dist/core/artifact-graph/types.d.ts +45 -0
  53. package/dist/core/artifact-graph/types.js +43 -0
  54. package/dist/core/available-tools.d.ts +16 -0
  55. package/dist/core/available-tools.js +30 -0
  56. package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
  57. package/dist/core/command-generation/adapters/amazon-q.js +26 -0
  58. package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
  59. package/dist/core/command-generation/adapters/antigravity.js +26 -0
  60. package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
  61. package/dist/core/command-generation/adapters/auggie.js +27 -0
  62. package/dist/core/command-generation/adapters/claude.d.ts +13 -0
  63. package/dist/core/command-generation/adapters/claude.js +50 -0
  64. package/dist/core/command-generation/adapters/cline.d.ts +14 -0
  65. package/dist/core/command-generation/adapters/cline.js +27 -0
  66. package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
  67. package/dist/core/command-generation/adapters/codebuddy.js +28 -0
  68. package/dist/core/command-generation/adapters/codex.d.ts +16 -0
  69. package/dist/core/command-generation/adapters/codex.js +39 -0
  70. package/dist/core/command-generation/adapters/continue.d.ts +13 -0
  71. package/dist/core/command-generation/adapters/continue.js +28 -0
  72. package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
  73. package/dist/core/command-generation/adapters/costrict.js +27 -0
  74. package/dist/core/command-generation/adapters/crush.d.ts +13 -0
  75. package/dist/core/command-generation/adapters/crush.js +30 -0
  76. package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
  77. package/dist/core/command-generation/adapters/cursor.js +44 -0
  78. package/dist/core/command-generation/adapters/factory.d.ts +13 -0
  79. package/dist/core/command-generation/adapters/factory.js +27 -0
  80. package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
  81. package/dist/core/command-generation/adapters/gemini.js +26 -0
  82. package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
  83. package/dist/core/command-generation/adapters/github-copilot.js +26 -0
  84. package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
  85. package/dist/core/command-generation/adapters/iflow.js +29 -0
  86. package/dist/core/command-generation/adapters/index.d.ts +29 -0
  87. package/dist/core/command-generation/adapters/index.js +29 -0
  88. package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
  89. package/dist/core/command-generation/adapters/kilocode.js +23 -0
  90. package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
  91. package/dist/core/command-generation/adapters/kiro.js +26 -0
  92. package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
  93. package/dist/core/command-generation/adapters/opencode.js +29 -0
  94. package/dist/core/command-generation/adapters/pi.d.ts +14 -0
  95. package/dist/core/command-generation/adapters/pi.js +41 -0
  96. package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
  97. package/dist/core/command-generation/adapters/qoder.js +30 -0
  98. package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
  99. package/dist/core/command-generation/adapters/qwen.js +26 -0
  100. package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
  101. package/dist/core/command-generation/adapters/roocode.js +27 -0
  102. package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
  103. package/dist/core/command-generation/adapters/windsurf.js +51 -0
  104. package/dist/core/command-generation/generator.d.ts +21 -0
  105. package/dist/core/command-generation/generator.js +27 -0
  106. package/dist/core/command-generation/index.d.ts +22 -0
  107. package/dist/core/command-generation/index.js +24 -0
  108. package/dist/core/command-generation/registry.d.ts +36 -0
  109. package/dist/core/command-generation/registry.js +92 -0
  110. package/dist/core/command-generation/types.d.ts +56 -0
  111. package/dist/core/command-generation/types.js +8 -0
  112. package/dist/core/completions/command-registry.d.ts +7 -0
  113. package/dist/core/completions/command-registry.js +461 -0
  114. package/dist/core/completions/completion-provider.d.ts +60 -0
  115. package/dist/core/completions/completion-provider.js +102 -0
  116. package/dist/core/completions/factory.d.ts +64 -0
  117. package/dist/core/completions/factory.js +75 -0
  118. package/dist/core/completions/generators/bash-generator.d.ts +32 -0
  119. package/dist/core/completions/generators/bash-generator.js +174 -0
  120. package/dist/core/completions/generators/fish-generator.d.ts +32 -0
  121. package/dist/core/completions/generators/fish-generator.js +157 -0
  122. package/dist/core/completions/generators/powershell-generator.d.ts +33 -0
  123. package/dist/core/completions/generators/powershell-generator.js +207 -0
  124. package/dist/core/completions/generators/zsh-generator.d.ts +44 -0
  125. package/dist/core/completions/generators/zsh-generator.js +250 -0
  126. package/dist/core/completions/installers/bash-installer.d.ts +87 -0
  127. package/dist/core/completions/installers/bash-installer.js +318 -0
  128. package/dist/core/completions/installers/fish-installer.d.ts +43 -0
  129. package/dist/core/completions/installers/fish-installer.js +143 -0
  130. package/dist/core/completions/installers/powershell-installer.d.ts +88 -0
  131. package/dist/core/completions/installers/powershell-installer.js +327 -0
  132. package/dist/core/completions/installers/zsh-installer.d.ts +125 -0
  133. package/dist/core/completions/installers/zsh-installer.js +449 -0
  134. package/dist/core/completions/templates/bash-templates.d.ts +6 -0
  135. package/dist/core/completions/templates/bash-templates.js +24 -0
  136. package/dist/core/completions/templates/fish-templates.d.ts +7 -0
  137. package/dist/core/completions/templates/fish-templates.js +39 -0
  138. package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
  139. package/dist/core/completions/templates/powershell-templates.js +25 -0
  140. package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
  141. package/dist/core/completions/templates/zsh-templates.js +36 -0
  142. package/dist/core/completions/types.d.ts +79 -0
  143. package/dist/core/completions/types.js +2 -0
  144. package/dist/core/config-prompts.d.ts +9 -0
  145. package/dist/core/config-prompts.js +34 -0
  146. package/dist/core/config-schema.d.ts +86 -0
  147. package/dist/core/config-schema.js +213 -0
  148. package/dist/core/config.d.ts +17 -0
  149. package/dist/core/config.js +33 -0
  150. package/dist/core/converters/json-converter.d.ts +6 -0
  151. package/dist/core/converters/json-converter.js +51 -0
  152. package/dist/core/global-config.d.ts +44 -0
  153. package/dist/core/global-config.js +125 -0
  154. package/dist/core/index.d.ts +2 -0
  155. package/dist/core/index.js +3 -0
  156. package/dist/core/init.d.ts +39 -0
  157. package/dist/core/init.js +634 -0
  158. package/dist/core/legacy-cleanup.d.ts +162 -0
  159. package/dist/core/legacy-cleanup.js +512 -0
  160. package/dist/core/list.d.ts +9 -0
  161. package/dist/core/list.js +171 -0
  162. package/dist/core/migration.d.ts +23 -0
  163. package/dist/core/migration.js +108 -0
  164. package/dist/core/parsers/change-parser.d.ts +13 -0
  165. package/dist/core/parsers/change-parser.js +193 -0
  166. package/dist/core/parsers/markdown-parser.d.ts +22 -0
  167. package/dist/core/parsers/markdown-parser.js +187 -0
  168. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  169. package/dist/core/parsers/requirement-blocks.js +201 -0
  170. package/dist/core/profile-sync-drift.d.ts +38 -0
  171. package/dist/core/profile-sync-drift.js +200 -0
  172. package/dist/core/profiles.d.ts +26 -0
  173. package/dist/core/profiles.js +40 -0
  174. package/dist/core/project-config.d.ts +64 -0
  175. package/dist/core/project-config.js +223 -0
  176. package/dist/core/schemas/base.schema.d.ts +13 -0
  177. package/dist/core/schemas/base.schema.js +13 -0
  178. package/dist/core/schemas/change.schema.d.ts +73 -0
  179. package/dist/core/schemas/change.schema.js +31 -0
  180. package/dist/core/schemas/index.d.ts +4 -0
  181. package/dist/core/schemas/index.js +4 -0
  182. package/dist/core/schemas/spec.schema.d.ts +18 -0
  183. package/dist/core/schemas/spec.schema.js +15 -0
  184. package/dist/core/shared/index.d.ts +8 -0
  185. package/dist/core/shared/index.js +8 -0
  186. package/dist/core/shared/skill-generation.d.ts +49 -0
  187. package/dist/core/shared/skill-generation.js +96 -0
  188. package/dist/core/shared/tool-detection.d.ts +71 -0
  189. package/dist/core/shared/tool-detection.js +158 -0
  190. package/dist/core/specs-apply.d.ts +73 -0
  191. package/dist/core/specs-apply.js +384 -0
  192. package/dist/core/styles/palette.d.ts +7 -0
  193. package/dist/core/styles/palette.js +8 -0
  194. package/dist/core/templates/index.d.ts +8 -0
  195. package/dist/core/templates/index.js +9 -0
  196. package/dist/core/templates/skill-templates.d.ts +19 -0
  197. package/dist/core/templates/skill-templates.js +18 -0
  198. package/dist/core/templates/types.d.ts +19 -0
  199. package/dist/core/templates/types.js +5 -0
  200. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  201. package/dist/core/templates/workflows/apply-change.js +313 -0
  202. package/dist/core/templates/workflows/archive-change.d.ts +10 -0
  203. package/dist/core/templates/workflows/archive-change.js +271 -0
  204. package/dist/core/templates/workflows/bulk-archive-change.d.ts +10 -0
  205. package/dist/core/templates/workflows/bulk-archive-change.js +488 -0
  206. package/dist/core/templates/workflows/continue-change.d.ts +10 -0
  207. package/dist/core/templates/workflows/continue-change.js +232 -0
  208. package/dist/core/templates/workflows/explore.d.ts +10 -0
  209. package/dist/core/templates/workflows/explore.js +469 -0
  210. package/dist/core/templates/workflows/feedback.d.ts +9 -0
  211. package/dist/core/templates/workflows/feedback.js +108 -0
  212. package/dist/core/templates/workflows/ff-change.d.ts +10 -0
  213. package/dist/core/templates/workflows/ff-change.js +198 -0
  214. package/dist/core/templates/workflows/new-change.d.ts +10 -0
  215. package/dist/core/templates/workflows/new-change.js +143 -0
  216. package/dist/core/templates/workflows/onboard.d.ts +10 -0
  217. package/dist/core/templates/workflows/onboard.js +565 -0
  218. package/dist/core/templates/workflows/propose.d.ts +10 -0
  219. package/dist/core/templates/workflows/propose.js +223 -0
  220. package/dist/core/templates/workflows/sync-specs.d.ts +10 -0
  221. package/dist/core/templates/workflows/sync-specs.js +272 -0
  222. package/dist/core/templates/workflows/verify-change.d.ts +10 -0
  223. package/dist/core/templates/workflows/verify-change.js +332 -0
  224. package/dist/core/update.d.ts +77 -0
  225. package/dist/core/update.js +537 -0
  226. package/dist/core/validation/constants.d.ts +34 -0
  227. package/dist/core/validation/constants.js +40 -0
  228. package/dist/core/validation/types.d.ts +18 -0
  229. package/dist/core/validation/types.js +2 -0
  230. package/dist/core/validation/validator.d.ts +33 -0
  231. package/dist/core/validation/validator.js +409 -0
  232. package/dist/core/view.d.ts +8 -0
  233. package/dist/core/view.js +168 -0
  234. package/dist/index.d.ts +3 -0
  235. package/dist/index.js +3 -0
  236. package/dist/prompts/searchable-multi-select.d.ts +28 -0
  237. package/dist/prompts/searchable-multi-select.js +159 -0
  238. package/dist/telemetry/config.d.ts +32 -0
  239. package/dist/telemetry/config.js +68 -0
  240. package/dist/telemetry/index.d.ts +31 -0
  241. package/dist/telemetry/index.js +180 -0
  242. package/dist/ui/ascii-patterns.d.ts +16 -0
  243. package/dist/ui/ascii-patterns.js +133 -0
  244. package/dist/ui/welcome-screen.d.ts +10 -0
  245. package/dist/ui/welcome-screen.js +146 -0
  246. package/dist/utils/change-metadata.d.ts +51 -0
  247. package/dist/utils/change-metadata.js +147 -0
  248. package/dist/utils/change-utils.d.ts +62 -0
  249. package/dist/utils/change-utils.js +121 -0
  250. package/dist/utils/command-references.d.ts +18 -0
  251. package/dist/utils/command-references.js +20 -0
  252. package/dist/utils/file-system.d.ts +36 -0
  253. package/dist/utils/file-system.js +281 -0
  254. package/dist/utils/index.d.ts +6 -0
  255. package/dist/utils/index.js +9 -0
  256. package/dist/utils/interactive.d.ts +18 -0
  257. package/dist/utils/interactive.js +21 -0
  258. package/dist/utils/item-discovery.d.ts +4 -0
  259. package/dist/utils/item-discovery.js +72 -0
  260. package/dist/utils/match.d.ts +3 -0
  261. package/dist/utils/match.js +22 -0
  262. package/dist/utils/shell-detection.d.ts +20 -0
  263. package/dist/utils/shell-detection.js +41 -0
  264. package/dist/utils/task-progress.d.ts +8 -0
  265. package/dist/utils/task-progress.js +36 -0
  266. package/extension-manifest.json +9 -0
  267. package/hooks/hooks.json +16 -0
  268. package/hooks/run-hook.cmd +46 -0
  269. package/hooks/session-start +51 -0
  270. package/package.json +87 -0
  271. package/schemas/spec-driven/schema.yaml +153 -0
  272. package/schemas/spec-driven/templates/design.md +19 -0
  273. package/schemas/spec-driven/templates/proposal.md +23 -0
  274. package/schemas/spec-driven/templates/spec.md +8 -0
  275. package/schemas/spec-driven/templates/tasks.md +9 -0
  276. package/scripts/postinstall.js +147 -0
  277. package/skills/dispatching-parallel-agents/SKILL.md +113 -0
  278. package/skills/finishing-a-development-branch/SKILL.md +200 -0
  279. package/skills/receiving-code-review/SKILL.md +213 -0
  280. package/skills/requesting-code-review/SKILL.md +73 -0
  281. package/skills/requesting-code-review/code-reviewer.md +146 -0
  282. package/skills/subagent-driven-development/SKILL.md +98 -0
  283. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
  284. package/skills/subagent-driven-development/implementer-prompt.md +78 -0
  285. package/skills/systematic-debugging/CREATION-LOG.md +119 -0
  286. package/skills/systematic-debugging/SKILL.md +296 -0
  287. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  288. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  289. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  290. package/skills/systematic-debugging/find-polluter.sh +63 -0
  291. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  292. package/skills/systematic-debugging/test-academic.md +14 -0
  293. package/skills/systematic-debugging/test-pressure-1.md +58 -0
  294. package/skills/systematic-debugging/test-pressure-2.md +68 -0
  295. package/skills/systematic-debugging/test-pressure-3.md +69 -0
  296. package/skills/test-driven-development/SKILL.md +356 -0
  297. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  298. package/skills/using-git-worktrees/SKILL.md +212 -0
  299. package/skills/using-superpowers/SKILL.md +95 -0
  300. package/skills/verification-before-completion/SKILL.md +126 -0
  301. package/skills/writing-skills/SKILL.md +148 -0
@@ -0,0 +1,299 @@
1
+ # Testing Anti-Patterns
2
+
3
+ **Load this reference when:** writing or changing tests, adding mocks, or tempted to add test-only methods to production code.
4
+
5
+ ## Overview
6
+
7
+ Tests must verify real behavior, not mock behavior. Mocks are a means to isolate, not the thing being tested.
8
+
9
+ **Core principle:** Test what the code does, not what the mocks do.
10
+
11
+ **Following strict TDD prevents these anti-patterns.**
12
+
13
+ ## The Iron Laws
14
+
15
+ ```
16
+ 1. NEVER test mock behavior
17
+ 2. NEVER add test-only methods to production classes
18
+ 3. NEVER mock without understanding dependencies
19
+ ```
20
+
21
+ ## Anti-Pattern 1: Testing Mock Behavior
22
+
23
+ **The violation:**
24
+ ```typescript
25
+ // ❌ BAD: Testing that the mock exists
26
+ test('renders sidebar', () => {
27
+ render(<Page />);
28
+ expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument();
29
+ });
30
+ ```
31
+
32
+ **Why this is wrong:**
33
+ - You're verifying the mock works, not that the component works
34
+ - Test passes when mock is present, fails when it's not
35
+ - Tells you nothing about real behavior
36
+
37
+ **your human partner's correction:** "Are we testing the behavior of a mock?"
38
+
39
+ **The fix:**
40
+ ```typescript
41
+ // ✅ GOOD: Test real component or don't mock it
42
+ test('renders sidebar', () => {
43
+ render(<Page />); // Don't mock sidebar
44
+ expect(screen.getByRole('navigation')).toBeInTheDocument();
45
+ });
46
+
47
+ // OR if sidebar must be mocked for isolation:
48
+ // Don't assert on the mock - test Page's behavior with sidebar present
49
+ ```
50
+
51
+ ### Gate Function
52
+
53
+ ```
54
+ BEFORE asserting on any mock element:
55
+ Ask: "Am I testing real component behavior or just mock existence?"
56
+
57
+ IF testing mock existence:
58
+ STOP - Delete the assertion or unmock the component
59
+
60
+ Test real behavior instead
61
+ ```
62
+
63
+ ## Anti-Pattern 2: Test-Only Methods in Production
64
+
65
+ **The violation:**
66
+ ```typescript
67
+ // ❌ BAD: destroy() only used in tests
68
+ class Session {
69
+ async destroy() { // Looks like production API!
70
+ await this._workspaceManager?.destroyWorkspace(this.id);
71
+ // ... cleanup
72
+ }
73
+ }
74
+
75
+ // In tests
76
+ afterEach(() => session.destroy());
77
+ ```
78
+
79
+ **Why this is wrong:**
80
+ - Production class polluted with test-only code
81
+ - Dangerous if accidentally called in production
82
+ - Violates YAGNI and separation of concerns
83
+ - Confuses object lifecycle with entity lifecycle
84
+
85
+ **The fix:**
86
+ ```typescript
87
+ // ✅ GOOD: Test utilities handle test cleanup
88
+ // Session has no destroy() - it's stateless in production
89
+
90
+ // In test-utils/
91
+ export async function cleanupSession(session: Session) {
92
+ const workspace = session.getWorkspaceInfo();
93
+ if (workspace) {
94
+ await workspaceManager.destroyWorkspace(workspace.id);
95
+ }
96
+ }
97
+
98
+ // In tests
99
+ afterEach(() => cleanupSession(session));
100
+ ```
101
+
102
+ ### Gate Function
103
+
104
+ ```
105
+ BEFORE adding any method to production class:
106
+ Ask: "Is this only used by tests?"
107
+
108
+ IF yes:
109
+ STOP - Don't add it
110
+ Put it in test utilities instead
111
+
112
+ Ask: "Does this class own this resource's lifecycle?"
113
+
114
+ IF no:
115
+ STOP - Wrong class for this method
116
+ ```
117
+
118
+ ## Anti-Pattern 3: Mocking Without Understanding
119
+
120
+ **The violation:**
121
+ ```typescript
122
+ // ❌ BAD: Mock breaks test logic
123
+ test('detects duplicate server', () => {
124
+ // Mock prevents config write that test depends on!
125
+ vi.mock('ToolCatalog', () => ({
126
+ discoverAndCacheTools: vi.fn().mockResolvedValue(undefined)
127
+ }));
128
+
129
+ await addServer(config);
130
+ await addServer(config); // Should throw - but won't!
131
+ });
132
+ ```
133
+
134
+ **Why this is wrong:**
135
+ - Mocked method had side effect test depended on (writing config)
136
+ - Over-mocking to "be safe" breaks actual behavior
137
+ - Test passes for wrong reason or fails mysteriously
138
+
139
+ **The fix:**
140
+ ```typescript
141
+ // ✅ GOOD: Mock at correct level
142
+ test('detects duplicate server', () => {
143
+ // Mock the slow part, preserve behavior test needs
144
+ vi.mock('MCPServerManager'); // Just mock slow server startup
145
+
146
+ await addServer(config); // Config written
147
+ await addServer(config); // Duplicate detected ✓
148
+ });
149
+ ```
150
+
151
+ ### Gate Function
152
+
153
+ ```
154
+ BEFORE mocking any method:
155
+ STOP - Don't mock yet
156
+
157
+ 1. Ask: "What side effects does the real method have?"
158
+ 2. Ask: "Does this test depend on any of those side effects?"
159
+ 3. Ask: "Do I fully understand what this test needs?"
160
+
161
+ IF depends on side effects:
162
+ Mock at lower level (the actual slow/external operation)
163
+ OR use test doubles that preserve necessary behavior
164
+ NOT the high-level method the test depends on
165
+
166
+ IF unsure what test depends on:
167
+ Run test with real implementation FIRST
168
+ Observe what actually needs to happen
169
+ THEN add minimal mocking at the right level
170
+
171
+ Red flags:
172
+ - "I'll mock this to be safe"
173
+ - "This might be slow, better mock it"
174
+ - Mocking without understanding the dependency chain
175
+ ```
176
+
177
+ ## Anti-Pattern 4: Incomplete Mocks
178
+
179
+ **The violation:**
180
+ ```typescript
181
+ // ❌ BAD: Partial mock - only fields you think you need
182
+ const mockResponse = {
183
+ status: 'success',
184
+ data: { userId: '123', name: 'Alice' }
185
+ // Missing: metadata that downstream code uses
186
+ };
187
+
188
+ // Later: breaks when code accesses response.metadata.requestId
189
+ ```
190
+
191
+ **Why this is wrong:**
192
+ - **Partial mocks hide structural assumptions** - You only mocked fields you know about
193
+ - **Downstream code may depend on fields you didn't include** - Silent failures
194
+ - **Tests pass but integration fails** - Mock incomplete, real API complete
195
+ - **False confidence** - Test proves nothing about real behavior
196
+
197
+ **The Iron Rule:** Mock the COMPLETE data structure as it exists in reality, not just fields your immediate test uses.
198
+
199
+ **The fix:**
200
+ ```typescript
201
+ // ✅ GOOD: Mirror real API completeness
202
+ const mockResponse = {
203
+ status: 'success',
204
+ data: { userId: '123', name: 'Alice' },
205
+ metadata: { requestId: 'req-789', timestamp: 1234567890 }
206
+ // All fields real API returns
207
+ };
208
+ ```
209
+
210
+ ### Gate Function
211
+
212
+ ```
213
+ BEFORE creating mock responses:
214
+ Check: "What fields does the real API response contain?"
215
+
216
+ Actions:
217
+ 1. Examine actual API response from docs/examples
218
+ 2. Include ALL fields system might consume downstream
219
+ 3. Verify mock matches real response schema completely
220
+
221
+ Critical:
222
+ If you're creating a mock, you must understand the ENTIRE structure
223
+ Partial mocks fail silently when code depends on omitted fields
224
+
225
+ If uncertain: Include all documented fields
226
+ ```
227
+
228
+ ## Anti-Pattern 5: Integration Tests as Afterthought
229
+
230
+ **The violation:**
231
+ ```
232
+ ✅ Implementation complete
233
+ ❌ No tests written
234
+ "Ready for testing"
235
+ ```
236
+
237
+ **Why this is wrong:**
238
+ - Testing is part of implementation, not optional follow-up
239
+ - TDD would have caught this
240
+ - Can't claim complete without tests
241
+
242
+ **The fix:**
243
+ ```
244
+ TDD cycle:
245
+ 1. Write failing test
246
+ 2. Implement to pass
247
+ 3. Refactor
248
+ 4. THEN claim complete
249
+ ```
250
+
251
+ ## When Mocks Become Too Complex
252
+
253
+ **Warning signs:**
254
+ - Mock setup longer than test logic
255
+ - Mocking everything to make test pass
256
+ - Mocks missing methods real components have
257
+ - Test breaks when mock changes
258
+
259
+ **your human partner's question:** "Do we need to be using a mock here?"
260
+
261
+ **Consider:** Integration tests with real components often simpler than complex mocks
262
+
263
+ ## TDD Prevents These Anti-Patterns
264
+
265
+ **Why TDD helps:**
266
+ 1. **Write test first** → Forces you to think about what you're actually testing
267
+ 2. **Watch it fail** → Confirms test tests real behavior, not mocks
268
+ 3. **Minimal implementation** → No test-only methods creep in
269
+ 4. **Real dependencies** → You see what the test actually needs before mocking
270
+
271
+ **If you're testing mock behavior, you violated TDD** - you added mocks without watching test fail against real code first.
272
+
273
+ ## Quick Reference
274
+
275
+ | Anti-Pattern | Fix |
276
+ |--------------|-----|
277
+ | Assert on mock elements | Test real component or unmock it |
278
+ | Test-only methods in production | Move to test utilities |
279
+ | Mock without understanding | Understand dependencies first, mock minimally |
280
+ | Incomplete mocks | Mirror real API completely |
281
+ | Tests as afterthought | TDD - tests first |
282
+ | Over-complex mocks | Consider integration tests |
283
+
284
+ ## Red Flags
285
+
286
+ - Assertion checks for `*-mock` test IDs
287
+ - Methods only called in test files
288
+ - Mock setup is >50% of test
289
+ - Test fails when you remove mock
290
+ - Can't explain why mock is needed
291
+ - Mocking "just to be safe"
292
+
293
+ ## The Bottom Line
294
+
295
+ **Mocks are tools to isolate, not things to test.**
296
+
297
+ If TDD reveals you're testing mock behavior, you've gone wrong.
298
+
299
+ Fix: Test real behavior or question why you're mocking at all.
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: using-git-worktrees
3
+ description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
4
+ ---
5
+
6
+ # Using Git Worktrees
7
+
8
+ ## Overview
9
+
10
+ Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
11
+
12
+ **Core principle:** Systematic directory selection + safety verification = reliable isolation.
13
+
14
+ **Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
15
+
16
+ ## Directory Selection Process
17
+
18
+ Follow this priority order:
19
+
20
+ ### 1. Check Existing Directories
21
+
22
+ ```bash
23
+ # Check in priority order
24
+ ls -d .worktrees 2>/dev/null # Preferred (hidden)
25
+ ls -d worktrees 2>/dev/null # Alternative
26
+ ```
27
+
28
+ **If found:** Use that directory. If both exist, `.worktrees` wins.
29
+
30
+ ### 2. Check CLAUDE.md
31
+
32
+ ```bash
33
+ grep -i "worktree.*director" CLAUDE.md 2>/dev/null
34
+ ```
35
+
36
+ **If preference specified:** Use it without asking.
37
+
38
+ ### 3. Ask User
39
+
40
+ If no directory exists and no CLAUDE.md preference:
41
+
42
+ ```
43
+ No worktree directory found. Where should I create worktrees?
44
+
45
+ 1. .worktrees/ (project-local, hidden)
46
+ 2. ~/.config/superpowers/worktrees/<project-name>/ (global location)
47
+
48
+ Which would you prefer?
49
+ ```
50
+
51
+ ## Safety Verification
52
+
53
+ ### For Project-Local Directories (.worktrees or worktrees)
54
+
55
+ **MUST verify directory is ignored before creating worktree:**
56
+
57
+ ```bash
58
+ git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
59
+ ```
60
+
61
+ **If NOT ignored:**
62
+ 1. Add appropriate line to .gitignore
63
+ 2. Commit the change
64
+ 3. Proceed with worktree creation
65
+
66
+ **Why critical:** Prevents accidentally committing worktree contents to repository.
67
+
68
+ ### For Global Directory (~/.config/superpowers/worktrees)
69
+
70
+ No .gitignore verification needed — outside project entirely.
71
+
72
+ ## Creation Steps
73
+
74
+ ### 1. Detect Project Name
75
+
76
+ ```bash
77
+ project=$(basename "$(git rev-parse --show-toplevel)")
78
+ ```
79
+
80
+ ### 2. Create Worktree
81
+
82
+ ```bash
83
+ # Determine full path
84
+ case $LOCATION in
85
+ .worktrees|worktrees)
86
+ path="$LOCATION/$BRANCH_NAME"
87
+ ;;
88
+ ~/.config/superpowers/worktrees/*)
89
+ path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME"
90
+ ;;
91
+ esac
92
+
93
+ # Create worktree with new branch
94
+ git worktree add "$path" -b "$BRANCH_NAME"
95
+ cd "$path"
96
+ ```
97
+
98
+ ### 3. Run Project Setup
99
+
100
+ Auto-detect and run appropriate setup:
101
+
102
+ ```bash
103
+ # Node.js
104
+ if [ -f package.json ]; then npm install; fi
105
+
106
+ # Rust
107
+ if [ -f Cargo.toml ]; then cargo build; fi
108
+
109
+ # Python
110
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
111
+ if [ -f pyproject.toml ]; then poetry install; fi
112
+
113
+ # Go
114
+ if [ -f go.mod ]; then go mod download; fi
115
+ ```
116
+
117
+ ### 4. Verify Clean Baseline
118
+
119
+ Run tests to ensure worktree starts clean.
120
+
121
+ ```bash
122
+ # Examples - use project-appropriate command
123
+ npm test
124
+ cargo test
125
+ pytest
126
+ go test ./...
127
+ ```
128
+
129
+ **If tests fail:** Report failures, ask whether to proceed or investigate.
130
+
131
+ **If tests pass:** Report ready.
132
+
133
+ ### 5. Report Location
134
+
135
+ ```
136
+ Worktree ready at <full-path>
137
+ Tests passing (<N> tests, 0 failures)
138
+ Ready to implement <feature-name>
139
+ ```
140
+
141
+ ## Quick Reference
142
+
143
+ | Situation | Action |
144
+ |-----------|--------|
145
+ | `.worktrees/` exists | Use it (verify ignored) |
146
+ | `worktrees/` exists | Use it (verify ignored) |
147
+ | Both exist | Use `.worktrees/` |
148
+ | Neither exists | Check CLAUDE.md → Ask user |
149
+ | Directory not ignored | Add to .gitignore + commit |
150
+ | Tests fail during baseline | Report failures + ask |
151
+ | No package.json/Cargo.toml | Skip dependency install |
152
+
153
+ ## Common Mistakes
154
+
155
+ ### Skipping ignore verification
156
+
157
+ - **Problem:** Worktree contents get tracked, pollute git status
158
+ - **Fix:** Always use `git check-ignore` before creating project-local worktree
159
+
160
+ ### Assuming directory location
161
+
162
+ - **Problem:** Creates inconsistency, violates project conventions
163
+ - **Fix:** Follow priority: existing > CLAUDE.md > ask
164
+
165
+ ### Proceeding with failing tests
166
+
167
+ - **Problem:** Can't distinguish new bugs from pre-existing issues
168
+ - **Fix:** Report failures, get explicit permission to proceed
169
+
170
+ ### Hardcoding setup commands
171
+
172
+ - **Problem:** Breaks on projects using different tools
173
+ - **Fix:** Auto-detect from project files (package.json, etc.)
174
+
175
+ ## Example Workflow
176
+
177
+ ```
178
+ You: I'm using the using-git-worktrees skill to set up an isolated workspace.
179
+
180
+ [Check .worktrees/ - exists]
181
+ [Verify ignored - git check-ignore confirms .worktrees/ is ignored]
182
+ [Create worktree: git worktree add .worktrees/auth -b feature/auth]
183
+ [Run npm install]
184
+ [Run npm test - 47 passing]
185
+
186
+ Worktree ready at /Users/jesse/myproject/.worktrees/auth
187
+ Tests passing (47 tests, 0 failures)
188
+ Ready to implement auth feature
189
+ ```
190
+
191
+ ## Red Flags
192
+
193
+ **Never:**
194
+ - Create worktree without verifying it's ignored (project-local)
195
+ - Skip baseline test verification
196
+ - Proceed with failing tests without asking
197
+ - Assume directory location when ambiguous
198
+ - Skip CLAUDE.md check
199
+
200
+ **Always:**
201
+ - Follow directory priority: existing > CLAUDE.md > ask
202
+ - Verify directory is ignored for project-local
203
+ - Auto-detect and run project setup
204
+ - Verify clean test baseline
205
+
206
+ ## Integration
207
+
208
+ **Called by:**
209
+ - **superpowers:subagent-driven-development** — REQUIRED before executing any tasks
210
+ - `/sp:apply` — REQUIRED before executing any tasks
211
+ - Any skill needing isolated workspace
212
+
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: using-superpowers
3
+ description: Use when starting any conversation - establishes how to find and use skills, requiring Skill tool invocation before ANY response including clarifying questions
4
+ ---
5
+
6
+ <EXTREMELY-IMPORTANT>
7
+ If you think there is even a 1% chance a skill might apply to what you are doing, you ABSOLUTELY MUST invoke the skill.
8
+
9
+ IF A SKILL APPLIES TO YOUR TASK, YOU DO NOT HAVE A CHOICE. YOU MUST USE IT.
10
+
11
+ This is not negotiable. This is not optional. You cannot rationalize your way out of this.
12
+ </EXTREMELY-IMPORTANT>
13
+
14
+ ## How to Access Skills
15
+
16
+ **In Claude Code:** Use the `Skill` tool. When you invoke a skill, its content is loaded and presented to you—follow it directly. Never use the Read tool on skill files.
17
+
18
+ **In other environments:** Check your platform's documentation for how skills are loaded.
19
+
20
+ # Using Skills
21
+
22
+ ## The Rule
23
+
24
+ **Invoke relevant or requested skills BEFORE any response or action.** Even a 1% chance a skill might apply means that you should invoke the skill to check. If an invoked skill turns out to be wrong for the situation, you don't need to use it.
25
+
26
+ ```dot
27
+ digraph skill_flow {
28
+ "User message received" [shape=doublecircle];
29
+ "About to EnterPlanMode?" [shape=doublecircle];
30
+ "Already brainstormed?" [shape=diamond];
31
+ "Invoke explore skill" [shape=box];
32
+ "Might any skill apply?" [shape=diamond];
33
+ "Invoke Skill tool" [shape=box];
34
+ "Announce: 'Using [skill] to [purpose]'" [shape=box];
35
+ "Has checklist?" [shape=diamond];
36
+ "Create TodoWrite todo per item" [shape=box];
37
+ "Follow skill exactly" [shape=box];
38
+ "Respond (including clarifications)" [shape=doublecircle];
39
+
40
+ "About to EnterPlanMode?" -> "Already brainstormed?";
41
+ "Already brainstormed?" -> "Invoke explore skill" [label="no"];
42
+ "Already brainstormed?" -> "Might any skill apply?" [label="yes"];
43
+ "Invoke explore skill" -> "Might any skill apply?";
44
+
45
+ "User message received" -> "Might any skill apply?";
46
+ "Might any skill apply?" -> "Invoke Skill tool" [label="yes, even 1%"];
47
+ "Might any skill apply?" -> "Respond (including clarifications)" [label="definitely not"];
48
+ "Invoke Skill tool" -> "Announce: 'Using [skill] to [purpose]'";
49
+ "Announce: 'Using [skill] to [purpose]'" -> "Has checklist?";
50
+ "Has checklist?" -> "Create TodoWrite todo per item" [label="yes"];
51
+ "Has checklist?" -> "Follow skill exactly" [label="no"];
52
+ "Create TodoWrite todo per item" -> "Follow skill exactly";
53
+ }
54
+ ```
55
+
56
+ ## Red Flags
57
+
58
+ These thoughts mean STOP—you're rationalizing:
59
+
60
+ | Thought | Reality |
61
+ |---------|---------|
62
+ | "This is just a simple question" | Questions are tasks. Check for skills. |
63
+ | "I need more context first" | Skill check comes BEFORE clarifying questions. |
64
+ | "Let me explore the codebase first" | Skills tell you HOW to explore. Check first. |
65
+ | "I can check git/files quickly" | Files lack conversation context. Check for skills. |
66
+ | "Let me gather information first" | Skills tell you HOW to gather information. |
67
+ | "This doesn't need a formal skill" | If a skill exists, use it. |
68
+ | "I remember this skill" | Skills evolve. Read current version. |
69
+ | "This doesn't count as a task" | Action = task. Check for skills. |
70
+ | "The skill is overkill" | Simple things become complex. Use it. |
71
+ | "I'll just do this one thing first" | Check BEFORE doing anything. |
72
+ | "This feels productive" | Undisciplined action wastes time. Skills prevent this. |
73
+ | "I know what that means" | Knowing the concept ≠ using the skill. Invoke it. |
74
+
75
+ ## Skill Priority
76
+
77
+ When multiple skills could apply, use this order:
78
+
79
+ 1. **Process skills first** (exploring, debugging) - these determine HOW to approach the task
80
+ 2. **Implementation skills second** (frontend-design, mcp-builder) - these guide execution
81
+
82
+ "Let's build X" → exploring first, then implementation skills.
83
+ "Fix this bug" → debugging first, then domain-specific skills.
84
+
85
+ ## Skill Types
86
+
87
+ **Rigid** (TDD, debugging): Follow exactly. Don't adapt away discipline.
88
+
89
+ **Flexible** (patterns): Adapt principles to context.
90
+
91
+ The skill itself tells you which.
92
+
93
+ ## User Instructions
94
+
95
+ Instructions say WHAT, not HOW. "Add X" or "Fix Y" doesn't mean skip workflows.