@hustle-together/api-dev-tools 3.10.1 → 3.12.1

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 (178) hide show
  1. package/.claude/agents/code-reviewer.md +170 -0
  2. package/.claude/agents/docs-generator.md +80 -0
  3. package/.claude/agents/implementation-reviewer.md +119 -0
  4. package/.claude/agents/parallel-researcher.md +52 -0
  5. package/.claude/agents/research-validator.md +116 -0
  6. package/.claude/agents/schema-generator.md +70 -0
  7. package/.claude/agents/test-writer.md +104 -0
  8. package/.claude/api-dev-state.json +331 -0
  9. package/.claude/commands/README.md +196 -0
  10. package/.claude/commands/add-command.md +212 -0
  11. package/.claude/commands/api-create.md +510 -0
  12. package/.claude/commands/api-env.md +51 -0
  13. package/.claude/commands/api-interview.md +344 -0
  14. package/.claude/commands/api-research.md +357 -0
  15. package/.claude/commands/api-status.md +279 -0
  16. package/.claude/commands/api-verify.md +232 -0
  17. package/.claude/commands/beepboop.md +96 -0
  18. package/.claude/commands/busycommit.md +111 -0
  19. package/.claude/commands/commit.md +82 -0
  20. package/.claude/commands/cycle.md +137 -0
  21. package/.claude/commands/gap.md +85 -0
  22. package/.claude/commands/green.md +137 -0
  23. package/.claude/commands/issue.md +187 -0
  24. package/.claude/commands/ntfy-setup.md +91 -0
  25. package/.claude/commands/ntfy-test.md +74 -0
  26. package/.claude/commands/plan.md +167 -0
  27. package/.claude/commands/pr.md +121 -0
  28. package/.claude/commands/publish.md +40 -0
  29. package/.claude/commands/red.md +137 -0
  30. package/.claude/commands/refactor.md +137 -0
  31. package/.claude/commands/spike.md +137 -0
  32. package/.claude/commands/summarize.md +93 -0
  33. package/.claude/commands/tdd.md +139 -0
  34. package/.claude/commands/worktree-add.md +307 -0
  35. package/.claude/commands/worktree-cleanup.md +275 -0
  36. package/.claude/hooks/api-workflow-check.py +227 -0
  37. package/.claude/hooks/enforce-deep-research.py +185 -0
  38. package/.claude/hooks/enforce-disambiguation.py +155 -0
  39. package/.claude/hooks/enforce-documentation.py +192 -0
  40. package/.claude/hooks/enforce-environment.py +253 -0
  41. package/.claude/hooks/enforce-external-research.py +328 -0
  42. package/.claude/hooks/enforce-interview.py +421 -0
  43. package/.claude/hooks/enforce-refactor.py +189 -0
  44. package/.claude/hooks/enforce-research.py +159 -0
  45. package/.claude/hooks/enforce-schema.py +186 -0
  46. package/.claude/hooks/enforce-scope.py +160 -0
  47. package/.claude/hooks/enforce-tdd-red.py +250 -0
  48. package/.claude/hooks/enforce-verify.py +186 -0
  49. package/.claude/hooks/periodic-reground.py +154 -0
  50. package/.claude/hooks/session-startup.py +151 -0
  51. package/.claude/hooks/track-tool-use.py +626 -0
  52. package/.claude/hooks/verify-after-green.py +282 -0
  53. package/.claude/hooks/verify-implementation.py +225 -0
  54. package/.claude/research/index.json +6 -0
  55. package/.claude/settings.json +144 -0
  56. package/.claude/settings.local.json +12 -0
  57. package/.claude-plugin/marketplace.json +103 -0
  58. package/.skills/README.md +293 -0
  59. package/.skills/_shared/convert-commands.py +192 -0
  60. package/.skills/_shared/hooks/api-workflow-check.py +227 -0
  61. package/.skills/_shared/hooks/enforce-deep-research.py +185 -0
  62. package/.skills/_shared/hooks/enforce-disambiguation.py +155 -0
  63. package/.skills/_shared/hooks/enforce-documentation.py +192 -0
  64. package/.skills/_shared/hooks/enforce-environment.py +253 -0
  65. package/.skills/_shared/hooks/enforce-external-research.py +328 -0
  66. package/.skills/_shared/hooks/enforce-interview.py +421 -0
  67. package/.skills/_shared/hooks/enforce-refactor.py +189 -0
  68. package/.skills/_shared/hooks/enforce-research.py +159 -0
  69. package/.skills/_shared/hooks/enforce-schema.py +186 -0
  70. package/.skills/_shared/hooks/enforce-scope.py +160 -0
  71. package/.skills/_shared/hooks/enforce-tdd-red.py +250 -0
  72. package/.skills/_shared/hooks/enforce-verify.py +186 -0
  73. package/.skills/_shared/hooks/periodic-reground.py +154 -0
  74. package/.skills/_shared/hooks/session-startup.py +151 -0
  75. package/.skills/_shared/hooks/track-tool-use.py +626 -0
  76. package/.skills/_shared/hooks/verify-after-green.py +282 -0
  77. package/.skills/_shared/hooks/verify-implementation.py +225 -0
  78. package/.skills/_shared/install.sh +114 -0
  79. package/.skills/_shared/settings.json +93 -0
  80. package/.skills/add-command/SKILL.md +227 -0
  81. package/.skills/api-create/SKILL.md +623 -0
  82. package/.skills/api-env/SKILL.md +64 -0
  83. package/.skills/api-interview/SKILL.md +357 -0
  84. package/.skills/api-research/SKILL.md +370 -0
  85. package/.skills/api-status/SKILL.md +292 -0
  86. package/.skills/api-verify/SKILL.md +245 -0
  87. package/.skills/beepboop/SKILL.md +111 -0
  88. package/.skills/busycommit/SKILL.md +126 -0
  89. package/.skills/commit/SKILL.md +97 -0
  90. package/.skills/cycle/SKILL.md +152 -0
  91. package/.skills/gap/SKILL.md +100 -0
  92. package/.skills/green/SKILL.md +152 -0
  93. package/.skills/issue/SKILL.md +202 -0
  94. package/.skills/plan/SKILL.md +182 -0
  95. package/.skills/pr/SKILL.md +136 -0
  96. package/.skills/publish/SKILL.md +160 -0
  97. package/.skills/red/SKILL.md +152 -0
  98. package/.skills/refactor/SKILL.md +152 -0
  99. package/.skills/spike/SKILL.md +152 -0
  100. package/.skills/summarize/SKILL.md +108 -0
  101. package/.skills/tdd/SKILL.md +154 -0
  102. package/.skills/update-todos/SKILL.md +250 -0
  103. package/.skills/worktree-add/SKILL.md +322 -0
  104. package/.skills/worktree-cleanup/SKILL.md +290 -0
  105. package/CHANGELOG.md +115 -0
  106. package/README.md +161 -7101
  107. package/bin/cli.js +448 -805
  108. package/commands/README.md +66 -31
  109. package/commands/add-command.md +8 -5
  110. package/commands/beepboop.md +4 -5
  111. package/commands/busycommit.md +2 -3
  112. package/commands/commit.md +2 -3
  113. package/commands/cycle.md +2 -7
  114. package/commands/gap.md +2 -3
  115. package/commands/green.md +2 -7
  116. package/commands/hustle-api-continue.md +8 -5
  117. package/commands/hustle-api-create.md +70 -29
  118. package/commands/hustle-api-env.md +1 -0
  119. package/commands/hustle-api-interview.md +32 -19
  120. package/commands/hustle-api-research.md +47 -21
  121. package/commands/hustle-api-sessions.md +8 -7
  122. package/commands/hustle-api-status.md +21 -1
  123. package/commands/hustle-api-verify.md +14 -13
  124. package/commands/hustle-combine.md +488 -241
  125. package/commands/hustle-ui-create-page.md +113 -50
  126. package/commands/hustle-ui-create.md +179 -26
  127. package/commands/issue.md +3 -8
  128. package/commands/plan.md +2 -3
  129. package/commands/pr.md +2 -3
  130. package/commands/red.md +2 -7
  131. package/commands/refactor.md +2 -7
  132. package/commands/spike.md +2 -7
  133. package/commands/summarize.md +2 -3
  134. package/commands/tdd.md +2 -7
  135. package/commands/worktree-add.md +208 -216
  136. package/commands/worktree-cleanup.md +172 -178
  137. package/hooks/api-workflow-check.py +5 -3
  138. package/hooks/enforce-component-type-confirm.py +97 -0
  139. package/hooks/lib/__init__.py +1 -0
  140. package/hooks/lib/greptile.py +355 -0
  141. package/hooks/lib/ntfy.py +209 -0
  142. package/hooks/notify-input-needed.py +73 -0
  143. package/hooks/notify-phase-complete.py +90 -0
  144. package/hooks/run-code-review.py +246 -0
  145. package/hooks/track-token-usage.py +121 -0
  146. package/package.json +33 -12
  147. package/scripts/collect-test-results.ts +102 -77
  148. package/scripts/extract-parameters.ts +112 -70
  149. package/scripts/generate-test-manifest.ts +118 -77
  150. package/templates/.env.example +57 -0
  151. package/templates/BRAND_GUIDE.md +92 -52
  152. package/templates/CLAUDE-SECTION.md +40 -37
  153. package/templates/SPEC.json +186 -38
  154. package/templates/api-dev-state.json +33 -4
  155. package/templates/api-showcase/_components/APICard.tsx +22 -18
  156. package/templates/api-showcase/_components/APIModal.tsx +110 -64
  157. package/templates/api-showcase/_components/APIShowcase.tsx +53 -35
  158. package/templates/api-showcase/_components/APITester.tsx +128 -67
  159. package/templates/api-showcase/page.tsx +4 -4
  160. package/templates/api-test/page.tsx +51 -30
  161. package/templates/api-test/test-structure/route.ts +43 -34
  162. package/templates/component/Component.stories.tsx +41 -39
  163. package/templates/component/Component.test.tsx +96 -78
  164. package/templates/component/Component.tsx +63 -52
  165. package/templates/component/Component.types.ts +10 -6
  166. package/templates/component/Component.visual.spec.ts +170 -0
  167. package/templates/component/index.ts +2 -2
  168. package/templates/dev-tools/_components/DevToolsLanding.tsx +8 -8
  169. package/templates/dev-tools/page.tsx +4 -3
  170. package/templates/mcp-servers.json +30 -2
  171. package/templates/page/page.e2e.test.ts +56 -48
  172. package/templates/page/page.tsx +3 -3
  173. package/templates/shared/HeroHeader.tsx +16 -15
  174. package/templates/shared/index.ts +1 -1
  175. package/templates/ui-showcase/_components/PreviewCard.tsx +20 -20
  176. package/templates/ui-showcase/_components/PreviewModal.tsx +149 -108
  177. package/templates/ui-showcase/_components/UIShowcase.tsx +43 -35
  178. package/templates/ui-showcase/page.tsx +4 -4
@@ -0,0 +1,510 @@
1
+ # API Create - Comprehensive API Development Workflow v3.0
2
+
3
+ **Usage:** `/api-create [endpoint-name]`
4
+
5
+ **Purpose:** Orchestrates the complete API development workflow using interview-driven, research-first, test-first methodology with continuous verification loops.
6
+
7
+ ## ⚠️ CRITICAL: MANDATORY USER INTERACTION
8
+
9
+ **YOU MUST USE THE `AskUserQuestion` TOOL AT EVERY CHECKPOINT.**
10
+
11
+ This workflow requires REAL user input at each phase. You are **FORBIDDEN** from:
12
+
13
+ - Self-answering questions
14
+ - Assuming user responses
15
+ - Proceeding without explicit user confirmation
16
+ - Making decisions on behalf of the user
17
+
18
+ ### How to Ask Questions Correctly
19
+
20
+ At every `[Y/n]` or multiple-choice prompt in this workflow, you MUST call the `AskUserQuestion` tool with this EXACT schema:
21
+
22
+ ```json
23
+ {
24
+ "questions": [
25
+ {
26
+ "question": "Your question here? (must end with ?)",
27
+ "header": "Phase",
28
+ "multiSelect": false,
29
+ "options": [
30
+ { "label": "Option A", "description": "What this option means" },
31
+ { "label": "Option B", "description": "What this option means" },
32
+ { "label": "Other", "description": "I'll type my own answer" }
33
+ ]
34
+ }
35
+ ]
36
+ }
37
+ ```
38
+
39
+ **CRITICAL REQUIREMENTS:**
40
+
41
+ - `header`: Max 12 characters (e.g., "Scope", "Research", "Format")
42
+ - `options`: 2-4 options, each with `label` (1-5 words) and `description`
43
+ - `multiSelect`: Required boolean (true for checkboxes, false for radio)
44
+ - `question`: Must end with a question mark
45
+ - Users can always select "Other" to provide custom input
46
+
47
+ **WAIT for the user's response before proceeding.** The tool will show a UI dialog and pause execution until the user answers. Do NOT continue until you receive the response.
48
+
49
+ ### Violation Detection
50
+
51
+ The enforcement hooks will BLOCK your progress if:
52
+
53
+ - `user_question_asked` is false for any phase
54
+ - `user_confirmed`/`user_approved`/`user_completed` is false
55
+ - `phase_exit_confirmed` is false (user must explicitly approve proceeding to next phase)
56
+ - Questions were not asked via the AskUserQuestion tool
57
+
58
+ If you see "BLOCKED" messages, it means you skipped user interaction.
59
+
60
+ ### Phase Exit Confirmation (NEW in v3.5.0)
61
+
62
+ **Every phase requires an EXIT CONFIRMATION question** before proceeding to the next phase. This prevents Claude from self-answering and moving on without explicit user approval.
63
+
64
+ The exit confirmation question MUST:
65
+
66
+ 1. Summarize what was accomplished in the current phase
67
+ 2. Ask if user is ready to proceed to the next phase
68
+ 3. Include options like "Yes, proceed", "No, I have changes", "Add more"
69
+
70
+ Example exit confirmation:
71
+
72
+ ```json
73
+ {
74
+ "questions": [
75
+ {
76
+ "question": "Phase complete. Research found 5 sources. Ready to proceed to Interview phase?",
77
+ "header": "Proceed",
78
+ "multiSelect": false,
79
+ "options": [
80
+ { "label": "Yes, proceed", "description": "Move to next phase" },
81
+ {
82
+ "label": "No, more research",
83
+ "description": "I need additional research on [topic]"
84
+ },
85
+ { "label": "Review sources", "description": "Show me what was found" }
86
+ ]
87
+ }
88
+ ]
89
+ }
90
+ ```
91
+
92
+ The `phase_exit_confirmed` flag is automatically set when:
93
+
94
+ 1. An `AskUserQuestion` is called with a question containing words like "proceed", "continue", "ready", "confirm", "approve"
95
+ 2. The user responds with an affirmative answer (yes, proceed, confirm, approve, etc.)
96
+
97
+ Both conditions must be true for the flag to be set.
98
+
99
+ ---
100
+
101
+ ## Key Principles
102
+
103
+ 1. **Loop Until Green** - Every verification phase loops back if not successful
104
+ 2. **Continuous Interviews** - Checkpoints at EVERY phase transition (USE AskUserQuestion!)
105
+ 3. **Adaptive Research** - Propose searches based on context, not shotgun approach
106
+ 4. **Self-Documenting** - State file captures everything for re-grounding
107
+ 5. **Verify After Green** - Re-research docs to catch memory-based implementation errors
108
+
109
+ ## Complete Phase Flow
110
+
111
+ ```
112
+ /api-create [endpoint]
113
+
114
+
115
+ ┌─ PHASE 1: DISAMBIGUATION ─────────────────────────────────┐
116
+ │ Search 3-5 variations of the term: │
117
+ │ • "[term]" │
118
+ │ • "[term] API" │
119
+ │ • "[term] SDK" │
120
+ │ • "[term] npm package" │
121
+ │ │
122
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool with EXACT schema: │
123
+ │ │
124
+ │ { │
125
+ │ "questions": [{ │
126
+ │ "question": "Which interpretation of [term]?", │
127
+ │ "header": "Disambig", │
128
+ │ "multiSelect": false, │
129
+ │ "options": [ │
130
+ │ {"label": "REST API", "description": "Official API"},│
131
+ │ {"label": "SDK/Package", "description": "NPM wrapper"},│
132
+ │ {"label": "Both", "description": "API + SDK"} │
133
+ │ ] │
134
+ │ }] │
135
+ │ } │
136
+ │ │
137
+ │ WAIT for user response. Do NOT proceed without it. │
138
+ │ ──── Loop back if user selects "Something else" ──── │
139
+ └───────────────────────────────────────────────────────────┘
140
+ │ Clear
141
+
142
+ ┌─ PHASE 2: SCOPE CONFIRMATION ─────────────────────────────┐
143
+ │ │
144
+ │ Present your understanding, then: │
145
+ │ │
146
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool: │
147
+ │ │
148
+ │ AskUserQuestion({ │
149
+ │ questions: [{ │
150
+ │ question: "I understand you want /api/v2/[endpoint] │
151
+ │ to [purpose]. Using [external API]. │
152
+ │ Is this correct?", │
153
+ │ header: "Scope", │
154
+ │ options: [ │
155
+ │ "Yes, proceed", │
156
+ │ "I have modifications to add", │
157
+ │ "No, let me clarify the purpose" │
158
+ │ ] │
159
+ │ }] │
160
+ │ }) │
161
+ │ │
162
+ │ WAIT for user response. Do NOT assume "yes". │
163
+ │ ──── Loop back if user has modifications ──── │
164
+ └───────────────────────────────────────────────────────────┘
165
+
166
+
167
+ ┌─ PHASE 3: INITIAL RESEARCH ───────────────────────────────┐
168
+ │ │
169
+ │ Execute 2-3 initial searches: │
170
+ │ • Context7: "[library/api name]" │
171
+ │ • WebSearch: "[name] official documentation" │
172
+ │ • WebSearch: "site:[domain] api reference" │
173
+ │ │
174
+ │ Present summary table, then: │
175
+ │ │
176
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool: │
177
+ │ │
178
+ │ AskUserQuestion({ │
179
+ │ questions: [{ │
180
+ │ question: "Research summary above. Found [N] │
181
+ │ sources. Should I proceed or search │
182
+ │ for more?", │
183
+ │ header: "Research", │
184
+ │ options: [ │
185
+ │ "Proceed to interview", │
186
+ │ "Search more - I need [specific topic]", │
187
+ │ "Search for something specific (I'll describe)" │
188
+ │ ] │
189
+ │ }] │
190
+ │ }) │
191
+ │ │
192
+ │ WAIT for user response. Do NOT auto-proceed. │
193
+ │ ──── Loop back if user wants more research ──── │
194
+ └───────────────────────────────────────────────────────────┘
195
+
196
+
197
+ ┌─ PHASE 4: INTERVIEW (Generated FROM Research) ────────────┐
198
+ │ │
199
+ │ For EACH parameter discovered in research, ask ONE │
200
+ │ question at a time using AskUserQuestion: │
201
+ │ │
202
+ │ ⚠️ REQUIRED: Use AskUserQuestion for EACH question: │
203
+ │ │
204
+ │ // Question 1: Format preference │
205
+ │ AskUserQuestion({ │
206
+ │ questions: [{ │
207
+ │ question: "Which response formats do you need?", │
208
+ │ header: "Format", │
209
+ │ multiSelect: true, │
210
+ │ options: ["JSON", "SVG", "PNG", "All formats"] │
211
+ │ }] │
212
+ │ }) │
213
+ │ // WAIT for response, record in state, then next Q │
214
+ │ │
215
+ │ // Question 2: Error handling │
216
+ │ AskUserQuestion({ │
217
+ │ questions: [{ │
218
+ │ question: "How should errors be handled?", │
219
+ │ header: "Errors", │
220
+ │ options: [ │
221
+ │ "Throw exceptions", │
222
+ │ "Return error objects", │
223
+ │ "Both (configurable)" │
224
+ │ ] │
225
+ │ }] │
226
+ │ }) │
227
+ │ // Continue for ALL parameters... │
228
+ │ │
229
+ │ After ALL questions answered: │
230
+ │ │
231
+ │ AskUserQuestion({ │
232
+ │ questions: [{ │
233
+ │ question: "Interview complete. Your decisions: │
234
+ │ [summary]. All correct?", │
235
+ │ header: "Confirm", │
236
+ │ options: [ │
237
+ │ "Yes, proceed to schema", │
238
+ │ "Change an answer", │
239
+ │ "Add another question" │
240
+ │ ] │
241
+ │ }] │
242
+ │ }) │
243
+ │ │
244
+ │ Decisions saved to state file for consistency. │
245
+ │ ──── Loop back if user wants to change answers ──── │
246
+ └───────────────────────────────────────────────────────────┘
247
+
248
+
249
+ ┌─ PHASE 5: DEEP RESEARCH (Adaptive) ───────────────────────┐
250
+ │ │
251
+ │ Based on interview answers, PROPOSE additional research. │
252
+ │ │
253
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool: │
254
+ │ │
255
+ │ AskUserQuestion({ │
256
+ │ questions: [{ │
257
+ │ question: "Based on your interview answers, I │
258
+ │ want to research: [list]. Approve?", │
259
+ │ header: "Deep Research", │
260
+ │ options: [ │
261
+ │ "Yes, run these searches", │
262
+ │ "Add more - I also need [topic]", │
263
+ │ "Skip deep research, proceed to schema" │
264
+ │ ] │
265
+ │ }] │
266
+ │ }) │
267
+ │ │
268
+ │ WAIT for user response. Do NOT auto-approve. │
269
+ │ KEY: Research is PROPOSED, not automatic shotgun. │
270
+ │ ──── Loop back if user wants to add topics ──── │
271
+ └───────────────────────────────────────────────────────────┘
272
+
273
+
274
+ ┌─ PHASE 6: SCHEMA DESIGN ──────────────────────────────────┐
275
+ │ │
276
+ │ Create Zod schema from research + interview, then: │
277
+ │ │
278
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool: │
279
+ │ │
280
+ │ AskUserQuestion({ │
281
+ │ questions: [{ │
282
+ │ question: "Schema created based on your interview. │
283
+ │ [show schema]. Does this match your │
284
+ │ requirements?", │
285
+ │ header: "Schema", │
286
+ │ options: [ │
287
+ │ "Yes, schema looks correct", │
288
+ │ "No, I need changes (I'll describe)", │
289
+ │ "Let's redo the interview" │
290
+ │ ] │
291
+ │ }] │
292
+ │ }) │
293
+ │ │
294
+ │ WAIT for user response. Do NOT assume approval. │
295
+ │ ──── Loop back if schema needs changes ──── │
296
+ └───────────────────────────────────────────────────────────┘
297
+
298
+
299
+ ┌─ PHASE 7: ENVIRONMENT CHECK ──────────────────────────────┐
300
+ │ │
301
+ │ Check required API keys, show status table, then: │
302
+ │ │
303
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool: │
304
+ │ │
305
+ │ AskUserQuestion({ │
306
+ │ questions: [{ │
307
+ │ question: "Environment check: [N] keys found, │
308
+ │ [M] missing. Ready to start TDD?", │
309
+ │ header: "Environment", │
310
+ │ options: [ │
311
+ │ "Yes, ready to write tests", │
312
+ │ "No, need to set up API keys first", │
313
+ │ "No, need to fix something else" │
314
+ │ ] │
315
+ │ }] │
316
+ │ }) │
317
+ │ │
318
+ │ WAIT for user response. Do NOT auto-proceed. │
319
+ │ ──── Loop back if keys missing ──── │
320
+ └───────────────────────────────────────────────────────────┘
321
+
322
+
323
+ ┌─ PHASE 8: TDD RED (Write Failing Tests) ──────────────────┐
324
+ │ │
325
+ │ Generate test matrix from schema + interview, then: │
326
+ │ │
327
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool: │
328
+ │ │
329
+ │ AskUserQuestion({ │
330
+ │ questions: [{ │
331
+ │ question: "Test matrix: [N] test scenarios based │
332
+ │ on your interview. Covers: [list]. │
333
+ │ Approve this test plan?", │
334
+ │ header: "Tests", │
335
+ │ options: [ │
336
+ │ "Yes, write these tests", │
337
+ │ "Add more scenarios (I'll describe)", │
338
+ │ "Change a scenario (I'll describe)" │
339
+ │ ] │
340
+ │ }] │
341
+ │ }) │
342
+ │ │
343
+ │ WAIT for user response. Do NOT auto-approve. │
344
+ │ HOOK: PreToolUse blocks Write if no research/interview │
345
+ │ ──── Loop back if user wants changes ──── │
346
+ └───────────────────────────────────────────────────────────┘
347
+
348
+
349
+ ┌─ PHASE 9: TDD GREEN (Minimal Implementation) ─────────────┐
350
+ │ │
351
+ │ Write minimal code to pass ALL tests. │
352
+ │ Tests derived from schema. │
353
+ │ Implementation validates with schema. │
354
+ │ │
355
+ │ Run tests → All must pass before proceeding. │
356
+ │ │
357
+ │ HOOK: PreToolUse blocks Write if test file doesn't exist │
358
+ └───────────────────────────────────────────────────────────┘
359
+
360
+
361
+ ┌─ PHASE 10: VERIFY (Re-Research After Green) ───────────────┐
362
+ │ │
363
+ │ MANDATORY: Re-read original documentation. │
364
+ │ Compare implementation to docs, then: │
365
+ │ │
366
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool: │
367
+ │ │
368
+ │ AskUserQuestion({ │
369
+ │ questions: [{ │
370
+ │ question: "Verification found [N] gap(s) between │
371
+ │ docs and implementation: [list]. │
372
+ │ How should I proceed?", │
373
+ │ header: "Verify", │
374
+ │ options: [ │
375
+ │ "Fix gaps - loop back to Red phase", │
376
+ │ "Skip - these are intentional omissions", │
377
+ │ "Fix some, skip others (I'll specify)" │
378
+ │ ] │
379
+ │ }] │
380
+ │ }) │
381
+ │ │
382
+ │ WAIT for user response. Do NOT auto-decide. │
383
+ │ HOOK: PostToolUse triggers after test pass │
384
+ │ ──── Loop back to Phase 8 if user wants fixes ──── │
385
+ └───────────────────────────────────────────────────────────┘
386
+
387
+
388
+ ┌─ PHASE 11: TDD REFACTOR ──────────────────────────────────┐
389
+ │ │
390
+ │ Clean up code while tests stay green: │
391
+ │ • Extract reusable patterns │
392
+ │ • Improve error messages │
393
+ │ • Add JSDoc comments │
394
+ │ • Optimize performance │
395
+ │ │
396
+ │ Run tests after EVERY change → Must still pass. │
397
+ └───────────────────────────────────────────────────────────┘
398
+
399
+
400
+ ┌─ PHASE 12: DOCUMENTATION ─────────────────────────────────┐
401
+ │ │
402
+ │ Update documentation files, then: │
403
+ │ │
404
+ │ ⚠️ REQUIRED: Use AskUserQuestion tool: │
405
+ │ │
406
+ │ AskUserQuestion({ │
407
+ │ questions: [{ │
408
+ │ question: "Documentation checklist: [list files]. │
409
+ │ All documentation complete?", │
410
+ │ header: "Docs", │
411
+ │ options: [ │
412
+ │ "Yes, all documentation is done", │
413
+ │ "No, I need to add something (I'll describe)", │
414
+ │ "Skip docs for now (not recommended)" │
415
+ │ ] │
416
+ │ }] │
417
+ │ }) │
418
+ │ │
419
+ │ WAIT for user response. Do NOT auto-complete. │
420
+ │ HOOK: Stop hook blocks if docs incomplete │
421
+ │ ──── Loop back if user needs to add docs ──── │
422
+ └───────────────────────────────────────────────────────────┘
423
+
424
+
425
+ ┌─ PHASE 13: COMPLETION ────────────────────────────────────┐
426
+ │ │
427
+ │ Final verification: │
428
+ │ • All tests passing │
429
+ │ • 100% coverage │
430
+ │ • TypeScript compiles │
431
+ │ • Docs updated │
432
+ │ • State file shows all phases complete │
433
+ │ │
434
+ │ Run /commit to create semantic commit. │
435
+ └───────────────────────────────────────────────────────────┘
436
+ ```
437
+
438
+ ## State File Tracking
439
+
440
+ All phases are tracked in `.claude/api-dev-state.json`:
441
+
442
+ ```json
443
+ {
444
+ "endpoint": "brandfetch",
445
+ "turn_count": 23,
446
+ "phases": {
447
+ "disambiguation": { "status": "complete" },
448
+ "scope": { "status": "complete" },
449
+ "research_initial": { "status": "complete", "sources": [...] },
450
+ "interview": { "status": "complete", "decisions": {...} },
451
+ "research_deep": { "status": "complete" },
452
+ "schema_creation": { "status": "complete" },
453
+ "environment_check": { "status": "complete" },
454
+ "tdd_red": { "status": "complete", "test_count": 23 },
455
+ "tdd_green": { "status": "complete" },
456
+ "verify": { "status": "complete", "gaps_found": 2, "gaps_fixed": 2 },
457
+ "tdd_refactor": { "status": "complete" },
458
+ "documentation": { "status": "complete" }
459
+ }
460
+ }
461
+ ```
462
+
463
+ ## Output Artifacts
464
+
465
+ This command creates:
466
+
467
+ 1. **State File**: `.claude/api-dev-state.json` (tracks all progress)
468
+ 2. **Research Cache**: `.claude/research/[api-name]/CURRENT.md`
469
+ 3. **Route Handler**: `/src/app/api/v2/[endpoint-name]/route.ts`
470
+ 4. **Test Suite**: `/src/app/api/v2/[endpoint-name]/__tests__/[endpoint-name].api.test.ts`
471
+ 5. **OpenAPI Spec**: `/src/lib/openapi/endpoints/[endpoint-name].ts`
472
+ 6. **Updated Manifests**:
473
+ - `/src/app/api-test/api-tests-manifest.json`
474
+ - `/src/v2/docs/v2-api-implementation-status.md`
475
+
476
+ ## Hooks That Enforce This Workflow
477
+
478
+ | Phase | Hook | Purpose |
479
+ | ----- | ------------------------------ | ------------------------------------------ |
480
+ | 0 | `enforce-external-research.py` | Detects API terms, requires disambiguation |
481
+ | 2-4 | `track-tool-use.py` | Logs all research, tracks turns |
482
+ | 7-8 | `enforce-research.py` | Blocks Write if no research done |
483
+ | 7-8 | `enforce-interview.py` | Injects interview decisions |
484
+ | 8 | `verify-implementation.py` | Blocks route if no test file |
485
+ | 9 | `verify-after-green.py` | Triggers verification after tests pass |
486
+ | All | `periodic-reground.py` | Re-grounds every 7 turns |
487
+ | 11 | `api-workflow-check.py` | Blocks completion if docs incomplete |
488
+
489
+ <claude-commands-template>
490
+ ## Project-Specific Rules
491
+
492
+ 1. **API Location**: All V2 APIs go in `/src/app/api/v2/[endpoint-name]/`
493
+ 2. **Testing**: Use Vitest, require 100% coverage
494
+ 3. **Validation**: All requests/responses use Zod schemas
495
+ 4. **AI SDK**: Use Vercel AI SDK 5.0.11 patterns from `/src/v2/docs/ai-sdk-catalog.json`
496
+ 5. **Package Manager**: Use `pnpm` for all operations
497
+ 6. **Documentation**: Follow patterns in `/src/v2/docs/Main Doc – V2 Development Patterns.md`
498
+ 7. **API Keys**: Support three methods (env, NEXT*PUBLIC*, custom headers)
499
+ 8. **Test Command**: `pnpm test:run` before commits
500
+
501
+ ## Never Skip
502
+
503
+ - Phase 1 (Disambiguation) - Clarify before research
504
+ - Phase 3 (Initial Research) - Find ALL parameters
505
+ - Phase 4 (Interview) - Questions FROM research, not templates
506
+ - Phase 8 (TDD Red) - Failing tests FIRST
507
+ - Phase 10 (Verify) - Re-research after Green
508
+ - Phase 12 (Documentation) - Keep docs in sync
509
+ - Coverage verification - 100% required
510
+ </claude-commands-template>
@@ -0,0 +1,51 @@
1
+ # API Environment - Check API Keys & Configuration
2
+
3
+ **Usage:** `/api-env [endpoint-name]`
4
+
5
+ **Purpose:** Quick check for required API keys and environment setup before implementation.
6
+
7
+ ## What This Checks
8
+
9
+ 1. **Reads endpoint documentation** to identify required services
10
+ 2. **Checks .env.local** for API keys
11
+ 3. **Verifies .env.example** has templates
12
+ 4. **Reports missing keys** with setup instructions
13
+
14
+ ## Output
15
+
16
+ ```
17
+ 🔑 Environment Check: [endpoint-name]
18
+
19
+ Required API Keys:
20
+ ✅ OPENAI_API_KEY (found)
21
+ ❌ FIRECRAWL_API_KEY (missing)
22
+
23
+ Action Required:
24
+ 1. Get key from https://firecrawl.dev
25
+ 2. Add to .env.local: FIRECRAWL_API_KEY=fc-...
26
+ 3. Add to .env.example template
27
+
28
+ Status: BLOCKED - Cannot proceed without FIRECRAWL_API_KEY
29
+ ```
30
+
31
+ ## Usage in Workflow
32
+
33
+ ```bash
34
+ # Before starting implementation
35
+ /api-interview generate-css
36
+ /api-research firecrawl
37
+ /api-env generate-css ← Check keys
38
+ /red ← Start TDD if ready
39
+ ```
40
+
41
+ <claude-commands-template>
42
+ ## API Key Support
43
+
44
+ The project supports three methods:
45
+
46
+ 1. Server env: `OPENAI_API_KEY=sk-...`
47
+ 2. Client env: `NEXT_PUBLIC_OPENAI_API_KEY=sk-...`
48
+ 3. Custom headers: `X-OpenAI-Key: sk-...`
49
+
50
+ Check src/lib/api-keys.ts for implementation.
51
+ </claude-commands-template>