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