codymaster 4.1.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 (193) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +285 -0
  3. package/adapters/antigravity.js +15 -0
  4. package/adapters/claude-code.js +17 -0
  5. package/adapters/cursor.js +16 -0
  6. package/commands/bootstrap.md +49 -0
  7. package/commands/build.md +48 -0
  8. package/commands/content.md +48 -0
  9. package/commands/continuity.md +60 -0
  10. package/commands/debug.md +51 -0
  11. package/commands/demo.md +96 -0
  12. package/commands/deploy.md +51 -0
  13. package/commands/plan.md +42 -0
  14. package/commands/review.md +55 -0
  15. package/commands/track.md +46 -0
  16. package/commands/ux.md +46 -0
  17. package/dist/agent-dispatch.js +161 -0
  18. package/dist/chains/builtin.js +85 -0
  19. package/dist/continuity.js +385 -0
  20. package/dist/dashboard.js +926 -0
  21. package/dist/data.js +122 -0
  22. package/dist/index.js +2434 -0
  23. package/dist/judge.js +252 -0
  24. package/dist/parallel-dispatch.js +359 -0
  25. package/dist/parallel-quality.js +172 -0
  26. package/dist/skill-chain.js +258 -0
  27. package/install.sh +513 -0
  28. package/package.json +79 -0
  29. package/skills/.content-factory-state.json +132 -0
  30. package/skills/.git 2/logs/refs/heads/main +1 -0
  31. package/skills/.git 2/logs/refs/remotes/origin/main +1 -0
  32. package/skills/.git 2/objects/02/fb0956734b5f8ba3f918b7defd04a89cfe0076 +0 -0
  33. package/skills/.git 2/objects/08/1e129d75dc6feac6c02037272e6bd1a04e3324 +0 -0
  34. package/skills/.git 2/objects/0c/5393416f3c5e01c9a655a802bff0dd52f76f0a +0 -0
  35. package/skills/.git 2/objects/10/0b9be46978a946a77188f68be725098a122001 +0 -0
  36. package/skills/.git 2/objects/10/cf041167fc9843610eb3d90259ef3396315fdc +0 -0
  37. package/skills/.git 2/objects/12/5e19538dd6e1338ffe74f6c4c165b00435bf48 +0 -0
  38. package/skills/.git 2/objects/16/a9b9d0088d5c1347628b45a2620b479d8ad57c +0 -0
  39. package/skills/.git 2/objects/17/8c2a9ef93c33ae4eec9d58e82321f9229843a1 +0 -0
  40. package/skills/.git 2/objects/25/397ae41d09104d763bdcac2695209d85cdea89 +0 -0
  41. package/skills/.git 2/objects/2f/a836b7947f2d458e1f639788bf4bb0983a3305 +0 -0
  42. package/skills/.git 2/objects/3a/baaaf0a1c0909c0828335791557125fba911e0 +0 -0
  43. package/skills/.git 2/objects/42/2924221b81f5ce3c4e4daac9a64a24f9b01f9a +0 -0
  44. package/skills/.git 2/objects/42/ec0ce707447dc11446a34c9995fb8533801731 +0 -0
  45. package/skills/.git 2/objects/46/e43ce92866d56ce74b1d750db307cfe6154a15 +0 -0
  46. package/skills/.git 2/objects/48/5e41b633c63f55b8277bcc59f44f67681f671a +0 -0
  47. package/skills/.git 2/objects/49/49c596a3a89fa240642acd95dd3258e261eb09 +0 -0
  48. package/skills/.git 2/objects/50/9d42d8412ef8eaf7f7e138476bac2e4d10ce60 +0 -0
  49. package/skills/.git 2/objects/55/0c8c389d981b463ef849aeb792d8be3ccb6ec8 +0 -0
  50. package/skills/.git 2/objects/5d/82d3b18410cdda3ace3677436f0cb599dbe2d2 +0 -0
  51. package/skills/.git 2/objects/60/0617c58e871a38b33bf29e282d132bb3c381ad +0 -0
  52. package/skills/.git 2/objects/6a/8369a99c687b7245c92ffaf0e0f0dab9014504 +0 -0
  53. package/skills/.git 2/objects/79/bea435d40ab531c1aaf6be0432c6a5b7aaed21 +0 -0
  54. package/skills/.git 2/objects/7e/5ebd79251c2f14e4aceb86c74b6b6daae6b500 +0 -0
  55. package/skills/.git 2/objects/81/98a822a60178d6d5023ddb3e222cddf048742e +0 -0
  56. package/skills/.git 2/objects/86/0a0e1943dfe53411d2e499a1f16f46a96ef758 +0 -0
  57. package/skills/.git 2/objects/86/971fb55fdc081fdbae52376f0f13e57a4e9b04 +0 -0
  58. package/skills/.git 2/objects/88/b89dd609a0a03f8d4fe8bfde20d5b8fc1d326d +0 -0
  59. package/skills/.git 2/objects/90/8737edb6b7809e32cc01590b4e08ba42a9d40d +0 -0
  60. package/skills/.git 2/objects/93/d5a8a9a7d4fb7f11491cb596a6880528725118 +0 -0
  61. package/skills/.git 2/objects/98/46a2ab81d0c3b3eb00ef88fc56989aa7e9f316 +0 -0
  62. package/skills/.git 2/objects/9b/d8dd1e49cf274eaf9c555f3ab39dce7af5715e +0 -0
  63. package/skills/.git 2/objects/a1/13329fb0cec96ae78b222d33a24c3b5bc7fa1f +0 -0
  64. package/skills/.git 2/objects/a9/e6effe626e8a3aea3a8fc3364b492191c6e7d0 +0 -0
  65. package/skills/.git 2/objects/ad/6de7e48d9782cca9353d1ff0aa1aab7fe1df85 +0 -0
  66. package/skills/.git 2/objects/af/54ae316f771ff692e299ffcd8bf2f06b413b59 +0 -0
  67. package/skills/.git 2/objects/b0/4cb8b0b00dad633e731c1472161419e738d674 +0 -0
  68. package/skills/.git 2/objects/b3/094abb0b9ed46419b269e4a4e36a459690e3b0 +0 -0
  69. package/skills/.git 2/objects/b9/435c5d4baac2cfc5c83009ddd27b46b60db5f1 +0 -0
  70. package/skills/.git 2/objects/ba/5da17dbaec5ec2dcfdfd126aead518d1171d5c +0 -0
  71. package/skills/.git 2/objects/c0/bf58703aa258ba5dd63083bebaec8f223d844c +0 -0
  72. package/skills/.git 2/objects/c4/701a34edf1fc1bad58ccc57bd03f9426acb59a +0 -0
  73. package/skills/.git 2/objects/c7/5ccce9a4e5cc74d9b3174550cf6d993ca43638 +0 -0
  74. package/skills/.git 2/objects/c7/710d59b5a35b0f1f0a0399386643a0bd94c929 +0 -0
  75. package/skills/.git 2/objects/d1/fe58237112e953e5fec52da22cf38e08be3df9 +5 -0
  76. package/skills/.git 2/objects/d2/2bbe9fd2f74c95bc5583e803f5e435f1e2cd86 +0 -0
  77. package/skills/.git 2/objects/d7/e72852ea2bff74581dbf247d400120086229f4 +0 -0
  78. package/skills/.git 2/objects/d8/d4c3b5553e4fd72807e1d4b49ef07d9ef3ac35 +0 -0
  79. package/skills/.git 2/objects/dc/75050c2876f6a02ae2a53a3c886f395b622977 +0 -0
  80. package/skills/.git 2/objects/ee/e8546f95acec500187c08a28a8b9ee02db0dec +0 -0
  81. package/skills/.git 2/objects/ef/263c059208b416c2146434f10cb2b9fabcba16 +0 -0
  82. package/skills/.git 2/objects/f3/ae597e84d9a59b88acd21c99bde2eaf686d785 +0 -0
  83. package/skills/.git 2/objects/f3/f6f5673c821d3d8e76fa267a9e882e7a5387ea +0 -0
  84. package/skills/.git 2/objects/f9/6e6d0ad02624dd11d5848594d056caef7a5e8b +0 -0
  85. package/skills/.git 2/objects/ff/278988fc1edf0db3abcf18de795f4cc0b4f3e1 +0 -0
  86. package/skills/.git 2/refs/heads/main +1 -0
  87. package/skills/.git 2/refs/remotes/origin/main +1 -0
  88. package/skills/.pytest_cache 2/v/cache/nodeids +76 -0
  89. package/skills/.pytest_cache 2/v/cache/stepwise +1 -0
  90. package/skills/_shared/helpers.md +123 -0
  91. package/skills/_shared/outputs-convention.md +24 -0
  92. package/skills/cm-ads-tracker/SKILL.md +109 -0
  93. package/skills/cm-ads-tracker/evals/evals.json +55 -0
  94. package/skills/cm-ads-tracker/references/gtm-architecture.md +321 -0
  95. package/skills/cm-ads-tracker/references/industry-events.md +294 -0
  96. package/skills/cm-ads-tracker/references/platforms-api.md +238 -0
  97. package/skills/cm-ads-tracker/templates/capi-payload.md +79 -0
  98. package/skills/cm-ads-tracker/templates/datalayer-push.js +104 -0
  99. package/skills/cm-ads-tracker/templates/gtm-variables.js +56 -0
  100. package/skills/cm-brainstorm-idea/SKILL.md +423 -0
  101. package/skills/cm-code-review/SKILL.md +151 -0
  102. package/skills/cm-content-factory/SKILL.md +416 -0
  103. package/skills/cm-continuity/SKILL.md +399 -0
  104. package/skills/cm-dashboard/SKILL.md +533 -0
  105. package/skills/cm-dashboard/ui/app.js +1270 -0
  106. package/skills/cm-dashboard/ui/index.html +206 -0
  107. package/skills/cm-dashboard/ui/style.css +440 -0
  108. package/skills/cm-debugging/SKILL.md +412 -0
  109. package/skills/cm-deep-search/SKILL.md +242 -0
  110. package/skills/cm-design-system/SKILL.md +97 -0
  111. package/skills/cm-design-system/resources/halo-modern.md +40 -0
  112. package/skills/cm-design-system/resources/lunaris-advanced.md +40 -0
  113. package/skills/cm-design-system/resources/nitro-enterprise.md +39 -0
  114. package/skills/cm-design-system/resources/shadcn-default.md +37 -0
  115. package/skills/cm-dockit/README.md +100 -0
  116. package/skills/cm-dockit/SKILL.md +302 -0
  117. package/skills/cm-dockit/index.html +443 -0
  118. package/skills/cm-dockit/package-lock.json +1850 -0
  119. package/skills/cm-dockit/package.json +14 -0
  120. package/skills/cm-dockit/prompts/analysis.md +34 -0
  121. package/skills/cm-dockit/prompts/api-reference.md +24 -0
  122. package/skills/cm-dockit/prompts/architecture.md +21 -0
  123. package/skills/cm-dockit/prompts/data-flow.md +20 -0
  124. package/skills/cm-dockit/prompts/database.md +21 -0
  125. package/skills/cm-dockit/prompts/deployment.md +22 -0
  126. package/skills/cm-dockit/prompts/flows.md +21 -0
  127. package/skills/cm-dockit/prompts/jtbd.md +20 -0
  128. package/skills/cm-dockit/prompts/personas.md +24 -0
  129. package/skills/cm-dockit/prompts/sop-modules.md +40 -0
  130. package/skills/cm-dockit/scripts/doc-gen.sh +121 -0
  131. package/skills/cm-dockit/scripts/dockit-dashboard.sh +142 -0
  132. package/skills/cm-dockit/scripts/dockit-runner.sh +607 -0
  133. package/skills/cm-dockit/scripts/dockit-task.sh +166 -0
  134. package/skills/cm-dockit/skills/analyze-codebase.md +174 -0
  135. package/skills/cm-dockit/skills/api-reference.md +237 -0
  136. package/skills/cm-dockit/skills/changelog-guide.md +195 -0
  137. package/skills/cm-dockit/skills/content-guidelines.md +190 -0
  138. package/skills/cm-dockit/skills/sop-guide.md +184 -0
  139. package/skills/cm-dockit/skills/tech-docs.md +287 -0
  140. package/skills/cm-dockit/templates/markdown/structure.md +60 -0
  141. package/skills/cm-dockit/templates/vitepress-premium/.vitepress/config.mts +110 -0
  142. package/skills/cm-dockit/templates/vitepress-premium/.vitepress/theme/custom.css +189 -0
  143. package/skills/cm-dockit/templates/vitepress-premium/.vitepress/theme/index.ts +4 -0
  144. package/skills/cm-dockit/templates/vitepress-premium/package.json +19 -0
  145. package/skills/cm-dockit/templates/vitepress-premium/tests/frontend.test.ts +45 -0
  146. package/skills/cm-dockit/tests/runner.test.ts +66 -0
  147. package/skills/cm-dockit/workflows/export-markdown.md +82 -0
  148. package/skills/cm-dockit/workflows/generate-docs.md +68 -0
  149. package/skills/cm-dockit/workflows/setup-vitepress.md +181 -0
  150. package/skills/cm-example/SKILL.md +26 -0
  151. package/skills/cm-execution/SKILL.md +268 -0
  152. package/skills/cm-git-worktrees/SKILL.md +164 -0
  153. package/skills/cm-how-it-work/SKILL.md +189 -0
  154. package/skills/cm-identity-guard/SKILL.md +412 -0
  155. package/skills/cm-jtbd/SKILL.md +98 -0
  156. package/skills/cm-planning/SKILL.md +130 -0
  157. package/skills/cm-project-bootstrap/SKILL.md +161 -0
  158. package/skills/cm-project-bootstrap/templates/AGENTS.md +42 -0
  159. package/skills/cm-project-bootstrap/templates/frontend-safety.test.js +51 -0
  160. package/skills/cm-project-bootstrap/templates/i18n-sync.test.js +38 -0
  161. package/skills/cm-project-bootstrap/templates/pr-template.md +12 -0
  162. package/skills/cm-project-bootstrap/templates/project-identity.json +29 -0
  163. package/skills/cm-project-bootstrap/templates/vitest.config.js +10 -0
  164. package/skills/cm-quality-gate/SKILL.md +218 -0
  165. package/skills/cm-readit/SKILL.md +289 -0
  166. package/skills/cm-readit/audio-player.md +206 -0
  167. package/skills/cm-readit/examples/blog-reader.js +352 -0
  168. package/skills/cm-readit/examples/voice-cro.js +390 -0
  169. package/skills/cm-readit/tts-engine.md +262 -0
  170. package/skills/cm-readit/ui-patterns.md +362 -0
  171. package/skills/cm-readit/voice-cro.md +223 -0
  172. package/skills/cm-safe-deploy/SKILL.md +120 -0
  173. package/skills/cm-safe-deploy/templates/deploy.sh +89 -0
  174. package/skills/cm-safe-i18n/SKILL.md +473 -0
  175. package/skills/cm-secret-shield/SKILL.md +580 -0
  176. package/skills/cm-skill-chain/SKILL.md +78 -0
  177. package/skills/cm-skill-index/SKILL.md +318 -0
  178. package/skills/cm-skill-mastery/SKILL.md +169 -0
  179. package/skills/cm-start/SKILL.md +65 -0
  180. package/skills/cm-status/SKILL.md +12 -0
  181. package/skills/cm-tdd/SKILL.md +370 -0
  182. package/skills/cm-terminal/SKILL.md +177 -0
  183. package/skills/cm-test-gate/SKILL.md +242 -0
  184. package/skills/cm-ui-preview/SKILL.md +291 -0
  185. package/skills/cm-ux-master/DESIGN_STANDARD_TEMPLATE.md +54 -0
  186. package/skills/cm-ux-master/SKILL.md +114 -0
  187. package/skills/cro-methodology/SKILL.md +98 -0
  188. package/skills/cro-methodology/references/COPYWRITING.md +178 -0
  189. package/skills/cro-methodology/references/OBJECTIONS.md +135 -0
  190. package/skills/cro-methodology/references/PERSUASION.md +158 -0
  191. package/skills/cro-methodology/references/RESEARCH.md +220 -0
  192. package/skills/cro-methodology/references/funnel-analysis.md +365 -0
  193. package/skills/cro-methodology/references/testing-methodology.md +330 -0
@@ -0,0 +1,370 @@
1
+ ---
2
+ name: cm-tdd
3
+ description: Use when implementing any feature or bugfix, before writing implementation code
4
+ ---
5
+
6
+ # Test-Driven Development (TDD)
7
+
8
+ > **Role: Test Engineer** — You write failing tests first, then minimal code to pass, then refactor. No exceptions.
9
+
10
+ ## Overview
11
+
12
+ Write the test first. Watch it fail. Write minimal code to pass.
13
+
14
+ **Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
15
+
16
+ **Violating the letter of the rules is violating the spirit of the rules.**
17
+
18
+ ## When to Use
19
+
20
+ **Always:**
21
+ - New features
22
+ - Bug fixes
23
+ - Refactoring
24
+ - Behavior changes
25
+
26
+ **Exceptions (ask your human partner):**
27
+ - Throwaway prototypes
28
+ - Generated code
29
+ - Configuration files
30
+
31
+ Thinking "skip TDD just this once"? Stop. That's rationalization.
32
+
33
+ ## The Iron Law
34
+
35
+ ```
36
+ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
37
+ ```
38
+
39
+ Write code before the test? Delete it. Start over.
40
+
41
+ **No exceptions:**
42
+ - Don't keep it as "reference"
43
+ - Don't "adapt" it while writing tests
44
+ - Don't look at it
45
+ - Delete means delete
46
+
47
+ Implement fresh from tests. Period.
48
+
49
+ ## Red-Green-Refactor
50
+
51
+ ```dot
52
+ digraph tdd_cycle {
53
+ rankdir=LR;
54
+ red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
55
+ verify_red [label="Verify fails\ncorrectly", shape=diamond];
56
+ green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
57
+ verify_green [label="Verify passes\nAll green", shape=diamond];
58
+ refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
59
+ next [label="Next", shape=ellipse];
60
+
61
+ red -> verify_red;
62
+ verify_red -> green [label="yes"];
63
+ verify_red -> red [label="wrong\nfailure"];
64
+ green -> verify_green;
65
+ verify_green -> refactor [label="yes"];
66
+ verify_green -> green [label="no"];
67
+ refactor -> verify_green [label="stay\ngreen"];
68
+ verify_green -> next;
69
+ next -> red;
70
+ }
71
+ ```
72
+
73
+ ### Step 0: Check Working Memory
74
+
75
+ Per `_shared/helpers.md#Load-Working-Memory` — focus on known edge cases and past failures for this module.
76
+
77
+ ### RED - Write Failing Test
78
+
79
+ Write one minimal test showing what should happen.
80
+
81
+ <Good>
82
+ ```typescript
83
+ test('retries failed operations 3 times', async () => {
84
+ let attempts = 0;
85
+ const operation = () => {
86
+ attempts++;
87
+ if (attempts < 3) throw new Error('fail');
88
+ return 'success';
89
+ };
90
+
91
+ const result = await retryOperation(operation);
92
+
93
+ expect(result).toBe('success');
94
+ expect(attempts).toBe(3);
95
+ });
96
+ ```
97
+ Clear name, tests real behavior, one thing
98
+ </Good>
99
+
100
+ <Bad>
101
+ ```typescript
102
+ test('retry works', async () => {
103
+ const mock = jest.fn()
104
+ .mockRejectedValueOnce(new Error())
105
+ .mockRejectedValueOnce(new Error())
106
+ .mockResolvedValueOnce('success');
107
+ await retryOperation(mock);
108
+ expect(mock).toHaveBeenCalledTimes(3);
109
+ });
110
+ ```
111
+ Vague name, tests mock not code
112
+ </Bad>
113
+
114
+ **Requirements:**
115
+ - One behavior
116
+ - Clear name
117
+ - Real code (no mocks unless unavoidable)
118
+
119
+ ### Verify RED - Watch It Fail
120
+
121
+ **MANDATORY. Never skip.**
122
+
123
+ ```bash
124
+ npm test path/to/test.test.ts
125
+ ```
126
+
127
+ Confirm:
128
+ - Test fails (not errors)
129
+ - Failure message is expected
130
+ - Fails because feature missing (not typos)
131
+
132
+ **Test passes?** You're testing existing behavior. Fix test.
133
+
134
+ **Test errors?** Fix error, re-run until it fails correctly.
135
+
136
+ ### GREEN - Minimal Code
137
+
138
+ Write simplest code to pass the test.
139
+
140
+ <Good>
141
+ ```typescript
142
+ async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
143
+ for (let i = 0; i < 3; i++) {
144
+ try {
145
+ return await fn();
146
+ } catch (e) {
147
+ if (i === 2) throw e;
148
+ }
149
+ }
150
+ throw new Error('unreachable');
151
+ }
152
+ ```
153
+ Just enough to pass
154
+ </Good>
155
+
156
+ <Bad>
157
+ ```typescript
158
+ async function retryOperation<T>(
159
+ fn: () => Promise<T>,
160
+ options?: {
161
+ maxRetries?: number;
162
+ backoff?: 'linear' | 'exponential';
163
+ onRetry?: (attempt: number) => void;
164
+ }
165
+ ): Promise<T> {
166
+ // YAGNI
167
+ }
168
+ ```
169
+ Over-engineered
170
+ </Bad>
171
+
172
+ Don't add features, refactor other code, or "improve" beyond the test.
173
+
174
+ ### Verify GREEN - Watch It Pass
175
+
176
+ **MANDATORY.**
177
+
178
+ ```bash
179
+ npm test path/to/test.test.ts
180
+ ```
181
+
182
+ Confirm:
183
+ - Test passes
184
+ - Other tests still pass
185
+ - Output pristine (no errors, warnings)
186
+
187
+ **Test fails?** Fix code, not test.
188
+
189
+ **Other tests fail?** Fix now.
190
+
191
+ ### REFACTOR - Clean Up
192
+
193
+ After green only:
194
+ - Remove duplication
195
+ - Improve names
196
+ - Extract helpers
197
+
198
+ Keep tests green. Don't add behavior.
199
+
200
+ ### Repeat
201
+
202
+ Next failing test for next feature.
203
+
204
+ ## Good Tests
205
+
206
+ | Quality | Good | Bad |
207
+ |---------|------|-----|
208
+ | **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` |
209
+ | **Clear** | Name describes behavior | `test('test1')` |
210
+ | **Shows intent** | Demonstrates desired API | Obscures what code should do |
211
+
212
+ ## Why Order Matters
213
+
214
+ **"I'll write tests after to verify it works"**
215
+
216
+ Tests written after code pass immediately. Passing immediately proves nothing:
217
+ - Might test wrong thing
218
+ - Might test implementation, not behavior
219
+ - Might miss edge cases you forgot
220
+ - You never saw it catch the bug
221
+
222
+ Test-first forces you to see the test fail, proving it actually tests something.
223
+
224
+ **"I already manually tested all the edge cases"**
225
+
226
+ Manual testing is ad-hoc. You think you tested everything but:
227
+ - No record of what you tested
228
+ - Can't re-run when code changes
229
+ - Easy to forget cases under pressure
230
+ - "It worked when I tried it" ≠ comprehensive
231
+
232
+ Automated tests are systematic. They run the same way every time.
233
+
234
+ **"Deleting X hours of work is wasteful"**
235
+
236
+ Sunk cost fallacy. The time is already gone. Your choice now:
237
+ - Delete and rewrite with TDD (X more hours, high confidence)
238
+ - Keep it and add tests after (30 min, low confidence, likely bugs)
239
+
240
+ The "waste" is keeping code you can't trust. Working code without real tests is technical debt.
241
+
242
+ **"TDD is dogmatic, being pragmatic means adapting"**
243
+
244
+ TDD IS pragmatic:
245
+ - Finds bugs before commit (faster than debugging after)
246
+ - Prevents regressions (tests catch breaks immediately)
247
+ - Documents behavior (tests show how to use code)
248
+ - Enables refactoring (change freely, tests catch breaks)
249
+
250
+ "Pragmatic" shortcuts = debugging in production = slower.
251
+
252
+ **"Tests after achieve the same goals - it's spirit not ritual"**
253
+
254
+ No. Tests-after answer "What does this do?" Tests-first answer "What should this do?"
255
+
256
+ Tests-after are biased by your implementation. You test what you built, not what's required. You verify remembered edge cases, not discovered ones.
257
+
258
+ Tests-first force edge case discovery before implementing. Tests-after verify you remembered everything (you didn't).
259
+
260
+ 30 minutes of tests after ≠ TDD. You get coverage, lose proof tests work.
261
+
262
+ ## Common Rationalizations
263
+
264
+ | Excuse | Reality |
265
+ |--------|---------|
266
+ | "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
267
+ | "I'll test after" | Tests passing immediately prove nothing. |
268
+ | "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
269
+ | "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. |
270
+ | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
271
+ | "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
272
+ | "Need to explore first" | Fine. Throw away exploration, start with TDD. |
273
+ | "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
274
+ | "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. |
275
+ | "Manual test faster" | Manual doesn't prove edge cases. You'll re-test every change. |
276
+ | "Existing code has no tests" | You're improving it. Add tests for existing code. |
277
+
278
+ ## Red Flags - STOP and Start Over
279
+
280
+ - Code before test
281
+ - Test after implementation
282
+ - Test passes immediately
283
+ - Can't explain why test failed
284
+ - Tests added "later"
285
+ - Rationalizing "just this once"
286
+ - "I already manually tested it"
287
+ - "Tests after achieve the same purpose"
288
+ - "It's about spirit not ritual"
289
+ - "Keep as reference" or "adapt existing code"
290
+ - "Already spent X hours, deleting is wasteful"
291
+ - "TDD is dogmatic, I'm being pragmatic"
292
+ - "This is different because..."
293
+
294
+ **All of these mean: Delete code. Start over with TDD.**
295
+
296
+ ## Example: Bug Fix
297
+
298
+ **Bug:** Empty email accepted
299
+
300
+ **RED**
301
+ ```typescript
302
+ test('rejects empty email', async () => {
303
+ const result = await submitForm({ email: '' });
304
+ expect(result.error).toBe('Email required');
305
+ });
306
+ ```
307
+
308
+ **Verify RED**
309
+ ```bash
310
+ $ npm test
311
+ FAIL: expected 'Email required', got undefined
312
+ ```
313
+
314
+ **GREEN**
315
+ ```typescript
316
+ function submitForm(data: FormData) {
317
+ if (!data.email?.trim()) {
318
+ return { error: 'Email required' };
319
+ }
320
+ // ...
321
+ }
322
+ ```
323
+
324
+ **Verify GREEN**
325
+ ```bash
326
+ $ npm test
327
+ PASS
328
+ ```
329
+
330
+ **REFACTOR**
331
+ Extract validation for multiple fields if needed.
332
+
333
+ ## Verification Checklist
334
+
335
+ Before marking work complete:
336
+
337
+ - [ ] Every new function/method has a test
338
+ - [ ] Watched each test fail before implementing
339
+ - [ ] Each test failed for expected reason (feature missing, not typo)
340
+ - [ ] Wrote minimal code to pass each test
341
+ - [ ] All tests pass
342
+ - [ ] Output pristine (no errors, warnings)
343
+ - [ ] Tests use real code (mocks only if unavoidable)
344
+ - [ ] Edge cases and errors covered
345
+
346
+ Can't check all boxes? You skipped TDD. Start over.
347
+
348
+ ## When Stuck
349
+
350
+ | Problem | Solution |
351
+ |---------|----------|
352
+ | Don't know how to test | Write wished-for API. Write assertion first. Ask your human partner. |
353
+ | Test too complicated | Design too complicated. Simplify interface. |
354
+ | Must mock everything | Code too coupled. Use dependency injection. |
355
+ | Test setup huge | Extract helpers. Still complex? Simplify design. |
356
+
357
+ ## Debugging Integration
358
+
359
+ Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
360
+
361
+ Never fix bugs without a test.
362
+
363
+ ## Final Rule
364
+
365
+ ```
366
+ Production code → test exists and failed first
367
+ Otherwise → not TDD
368
+ ```
369
+
370
+ No exceptions without your human partner's permission.
@@ -0,0 +1,177 @@
1
+ ---
2
+ name: cm-terminal
3
+ description: Use when running ANY terminal command - enforces clear progress logging, output reading, and error-stop behavior so terminal processes are never left unchecked
4
+ ---
5
+
6
+ # Terminal Process Monitoring
7
+
8
+ ## Overview
9
+
10
+ Running commands without checking output is flying blind. Users MUST see what's happening at every step.
11
+
12
+ **Core principle:** Every command gets announced, monitored, and verified. No exceptions.
13
+
14
+ **Violating the letter of this rule is violating the spirit of this rule.**
15
+
16
+ ## The Iron Law
17
+
18
+ ```
19
+ NO COMMAND RUNS WITHOUT READING ITS OUTPUT.
20
+ NO ERROR GOES UNREPORTED.
21
+ NO NEXT STEP WITHOUT PREVIOUS STEP CONFIRMED.
22
+ ```
23
+
24
+ ## When to Use
25
+
26
+ **ALWAYS** when running terminal commands via `run_command`. This includes:
27
+ - Build commands (`npm run build`, `npm run dev`)
28
+ - Test commands (`npx vitest run`)
29
+ - Install commands (`npm install`)
30
+ - Deploy commands (`npx wrangler pages deploy`)
31
+ - Git commands (`git push`, `git commit`)
32
+ - Any script or CLI tool
33
+
34
+ ## The Protocol
35
+
36
+ ### Step 1: Announce Before Running
37
+
38
+ **BEFORE calling `run_command`:**
39
+
40
+ Update `task_boundary` TaskStatus to describe what you're about to run and why.
41
+
42
+ ```
43
+ TaskStatus: "Running npm build to compile production bundle"
44
+ TaskStatus: "Installing dependencies with npm install"
45
+ TaskStatus: "Deploying to Cloudflare Pages"
46
+ ```
47
+
48
+ ### Step 2: Set Appropriate Wait Time
49
+
50
+ Choose `WaitMsBeforeAsync` based on expected command duration:
51
+
52
+ | Command Type | WaitMsBeforeAsync | Strategy |
53
+ |-------------|-------------------|----------|
54
+ | Quick (< 3s) — `git status`, `ls`, `cat` | 3000-5000 | Synchronous, read output directly |
55
+ | Medium (3-30s) — `npm install`, `build` | 5000-10000 | Wait for initial output, then poll |
56
+ | Long (> 30s) — `deploy`, `test suites` | 2000-5000 | Send to background, poll actively |
57
+
58
+ ### Step 3: Read Output Immediately
59
+
60
+ **After `run_command` returns:**
61
+
62
+ 1. If command completed synchronously → read output in the response
63
+ 2. If command sent to background → call `command_status` immediately with `WaitDurationSeconds: 10`
64
+ 3. **NEVER proceed to next step without reading output**
65
+
66
+ ### Step 4: Check for Errors
67
+
68
+ Scan output for error indicators:
69
+
70
+ ```
71
+ ERROR PATTERNS TO DETECT:
72
+ - Exit code ≠ 0
73
+ - "error", "Error", "ERROR"
74
+ - "fail", "FAIL", "failed", "FAILED"
75
+ - "ENOENT", "EACCES", "EPERM"
76
+ - "not found", "No such file"
77
+ - "Cannot find module"
78
+ - "SyntaxError", "TypeError", "ReferenceError"
79
+ - "Build failed"
80
+ - "Command failed"
81
+ - "Permission denied"
82
+ - "FATAL"
83
+ - Stack traces (lines with "at " prefix)
84
+ - npm ERR!
85
+ - Warning patterns that indicate real problems
86
+ ```
87
+
88
+ ### Step 5: Stop on Error
89
+
90
+ **If ANY error is detected:**
91
+
92
+ ```
93
+ 1. STOP — Do not run any more commands
94
+ 2. IDENTIFY — Extract the exact error message and context
95
+ 3. REPORT — Call notify_user with error if critical
96
+ 4. FIX — Use cm-debugging if proceeding to fix
97
+ ```
98
+
99
+ ### Step 6: Poll Long-Running Commands
100
+
101
+ **For background commands (returned a CommandId):**
102
+
103
+ 1. Poll `command_status` every 10-15 seconds
104
+ 2. After EACH poll, update `task_boundary` TaskStatus with latest output summary
105
+ 3. Continue until command completes (status: "done")
106
+ 4. Read final output and check for errors
107
+
108
+ ### Step 7: Confirm Success
109
+
110
+ **Only after reading output AND confirming no errors:**
111
+
112
+ Update `task_boundary` TaskSummary with the result:
113
+ ```
114
+ TaskSummary: "Build completed successfully (0 errors, 0 warnings)"
115
+ TaskSummary: "All 519 tests passed"
116
+ TaskSummary: "Deployed to https://prms-4pv.pages.dev successfully"
117
+ ```
118
+
119
+ ## Red Flags — STOP and Follow Protocol
120
+
121
+ If you catch yourself doing ANY of these:
122
+
123
+ - Running a command without updating TaskStatus first
124
+ - Calling `run_command` while previous command is still running
125
+ - Skipping `command_status` for a background command
126
+ - Proceeding to next step without reading output
127
+ - Ignoring warnings or errors in output
128
+ - Assuming a command succeeded without checking exit code
129
+ - Running 3+ commands in parallel without monitoring each
130
+
131
+ **ALL of these mean: STOP. Follow the protocol.**
132
+
133
+ ## Anti-Patterns
134
+
135
+ | DON'T | DO |
136
+ |-------|-----|
137
+ | Run and forget | Run and read output |
138
+ | Assume success | Verify success from output |
139
+ | Chain commands blindly | Verify each before next |
140
+ | Ignore warnings | Report warnings to user |
141
+ | Multiple commands without checking | Sequential with verification |
142
+
143
+ ## Special Cases
144
+
145
+ ### Interactive Commands (dev servers, watch mode)
146
+
147
+ 1. Start with `WaitMsBeforeAsync: 3000-5000`
148
+ 2. Check initial output for startup success/failure
149
+ 3. Look for "ready" / "listening on" / "compiled successfully" signals
150
+ 4. Report the URL/port to user
151
+ 5. Note the CommandId for future reference
152
+
153
+ ### Parallel Commands
154
+
155
+ If running multiple commands at once:
156
+ 1. Track ALL CommandIds
157
+ 2. Poll each one separately
158
+ 3. If ANY fails → report which one failed
159
+
160
+ ### Piped/Chained Commands (`&&`, `|`)
161
+
162
+ 1. The exit code reflects the LAST command in the chain
163
+ 2. Read full output — errors from earlier commands may appear but the chain continues
164
+ 3. Be extra careful with `cd dir && npm run build` — if `cd` fails, build won't run
165
+
166
+ ## Severity Levels
167
+
168
+ | Level | Action | Example |
169
+ |-------|--------|---------|
170
+ | 🟢 **Success** | Update TaskSummary, proceed | "Build succeeded" |
171
+ | 🟡 **Warning** | Report to user, ask if proceed | "Deprecated dependency" |
172
+ | 🔴 **Error** | STOP immediately, notify_user or fix | "Build failed", "Test failed" |
173
+ | ⚫ **Fatal** | STOP immediately, notify_user | "ENOENT", "Permission denied" |
174
+
175
+ ## The Bottom Line
176
+
177
+ **Every command tells a story through its output. READ the story. SHARE it with the user. STOP if the story is bad.**