@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.
- package/.claude/agents/code-reviewer.md +170 -0
- package/.claude/agents/docs-generator.md +80 -0
- package/.claude/agents/implementation-reviewer.md +119 -0
- package/.claude/agents/parallel-researcher.md +52 -0
- package/.claude/agents/research-validator.md +116 -0
- package/.claude/agents/schema-generator.md +70 -0
- package/.claude/agents/test-writer.md +104 -0
- package/.claude/api-dev-state.json +331 -0
- package/.claude/commands/README.md +196 -0
- package/.claude/commands/add-command.md +212 -0
- package/.claude/commands/api-create.md +510 -0
- package/.claude/commands/api-env.md +51 -0
- package/.claude/commands/api-interview.md +344 -0
- package/.claude/commands/api-research.md +357 -0
- package/.claude/commands/api-status.md +279 -0
- package/.claude/commands/api-verify.md +232 -0
- package/.claude/commands/beepboop.md +96 -0
- package/.claude/commands/busycommit.md +111 -0
- package/.claude/commands/commit.md +82 -0
- package/.claude/commands/cycle.md +137 -0
- package/.claude/commands/gap.md +85 -0
- package/.claude/commands/green.md +137 -0
- package/.claude/commands/issue.md +187 -0
- package/.claude/commands/ntfy-setup.md +91 -0
- package/.claude/commands/ntfy-test.md +74 -0
- package/.claude/commands/plan.md +167 -0
- package/.claude/commands/pr.md +121 -0
- package/.claude/commands/publish.md +40 -0
- package/.claude/commands/red.md +137 -0
- package/.claude/commands/refactor.md +137 -0
- package/.claude/commands/spike.md +137 -0
- package/.claude/commands/summarize.md +93 -0
- package/.claude/commands/tdd.md +139 -0
- package/.claude/commands/worktree-add.md +307 -0
- package/.claude/commands/worktree-cleanup.md +275 -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 +144 -0
- package/.claude/settings.local.json +12 -0
- package/.claude-plugin/marketplace.json +103 -0
- package/.skills/README.md +293 -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 +227 -0
- package/.skills/api-create/SKILL.md +623 -0
- package/.skills/api-env/SKILL.md +64 -0
- package/.skills/api-interview/SKILL.md +357 -0
- package/.skills/api-research/SKILL.md +370 -0
- package/.skills/api-status/SKILL.md +292 -0
- package/.skills/api-verify/SKILL.md +245 -0
- package/.skills/beepboop/SKILL.md +111 -0
- package/.skills/busycommit/SKILL.md +126 -0
- package/.skills/commit/SKILL.md +97 -0
- package/.skills/cycle/SKILL.md +152 -0
- package/.skills/gap/SKILL.md +100 -0
- package/.skills/green/SKILL.md +152 -0
- package/.skills/issue/SKILL.md +202 -0
- package/.skills/plan/SKILL.md +182 -0
- package/.skills/pr/SKILL.md +136 -0
- package/.skills/publish/SKILL.md +160 -0
- package/.skills/red/SKILL.md +152 -0
- package/.skills/refactor/SKILL.md +152 -0
- package/.skills/spike/SKILL.md +152 -0
- package/.skills/summarize/SKILL.md +108 -0
- package/.skills/tdd/SKILL.md +154 -0
- package/.skills/update-todos/SKILL.md +250 -0
- package/.skills/worktree-add/SKILL.md +322 -0
- package/.skills/worktree-cleanup/SKILL.md +290 -0
- package/CHANGELOG.md +115 -0
- package/README.md +161 -7101
- package/bin/cli.js +448 -805
- package/commands/README.md +66 -31
- package/commands/add-command.md +8 -5
- package/commands/beepboop.md +4 -5
- package/commands/busycommit.md +2 -3
- package/commands/commit.md +2 -3
- package/commands/cycle.md +2 -7
- package/commands/gap.md +2 -3
- package/commands/green.md +2 -7
- package/commands/hustle-api-continue.md +8 -5
- package/commands/hustle-api-create.md +70 -29
- package/commands/hustle-api-env.md +1 -0
- package/commands/hustle-api-interview.md +32 -19
- package/commands/hustle-api-research.md +47 -21
- package/commands/hustle-api-sessions.md +8 -7
- package/commands/hustle-api-status.md +21 -1
- package/commands/hustle-api-verify.md +14 -13
- package/commands/hustle-combine.md +488 -241
- package/commands/hustle-ui-create-page.md +113 -50
- package/commands/hustle-ui-create.md +179 -26
- package/commands/issue.md +3 -8
- package/commands/plan.md +2 -3
- package/commands/pr.md +2 -3
- package/commands/red.md +2 -7
- package/commands/refactor.md +2 -7
- package/commands/spike.md +2 -7
- package/commands/summarize.md +2 -3
- package/commands/tdd.md +2 -7
- package/commands/worktree-add.md +208 -216
- package/commands/worktree-cleanup.md +172 -178
- package/hooks/api-workflow-check.py +5 -3
- package/hooks/enforce-component-type-confirm.py +97 -0
- package/hooks/lib/__init__.py +1 -0
- package/hooks/lib/greptile.py +355 -0
- package/hooks/lib/ntfy.py +209 -0
- package/hooks/notify-input-needed.py +73 -0
- package/hooks/notify-phase-complete.py +90 -0
- package/hooks/run-code-review.py +246 -0
- package/hooks/track-token-usage.py +121 -0
- package/package.json +33 -12
- package/scripts/collect-test-results.ts +102 -77
- package/scripts/extract-parameters.ts +112 -70
- package/scripts/generate-test-manifest.ts +118 -77
- package/templates/.env.example +57 -0
- package/templates/BRAND_GUIDE.md +92 -52
- package/templates/CLAUDE-SECTION.md +40 -37
- package/templates/SPEC.json +186 -38
- package/templates/api-dev-state.json +33 -4
- package/templates/api-showcase/_components/APICard.tsx +22 -18
- package/templates/api-showcase/_components/APIModal.tsx +110 -64
- package/templates/api-showcase/_components/APIShowcase.tsx +53 -35
- package/templates/api-showcase/_components/APITester.tsx +128 -67
- package/templates/api-showcase/page.tsx +4 -4
- package/templates/api-test/page.tsx +51 -30
- package/templates/api-test/test-structure/route.ts +43 -34
- package/templates/component/Component.stories.tsx +41 -39
- package/templates/component/Component.test.tsx +96 -78
- package/templates/component/Component.tsx +63 -52
- package/templates/component/Component.types.ts +10 -6
- package/templates/component/Component.visual.spec.ts +170 -0
- package/templates/component/index.ts +2 -2
- package/templates/dev-tools/_components/DevToolsLanding.tsx +8 -8
- package/templates/dev-tools/page.tsx +4 -3
- package/templates/mcp-servers.json +30 -2
- package/templates/page/page.e2e.test.ts +56 -48
- package/templates/page/page.tsx +3 -3
- package/templates/shared/HeroHeader.tsx +16 -15
- package/templates/shared/index.ts +1 -1
- package/templates/ui-showcase/_components/PreviewCard.tsx +20 -20
- package/templates/ui-showcase/_components/PreviewModal.tsx +149 -108
- package/templates/ui-showcase/_components/UIShowcase.tsx +43 -35
- package/templates/ui-showcase/page.tsx +4 -4
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-create
|
|
3
|
+
description: Complete API development workflow using interview-driven, research-first, test-first methodology with continuous verification loops. Use when creating new V2 API endpoints. Includes 13 phases from disambiguation through completion with loop-back architecture. Keywords: api, endpoint, tdd, research, interview, verification, workflow, testing, documentation
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: Requires Claude Code with MCP servers (Context7 for docs, GitHub for PRs), Python 3.9+ for enforcement hooks, pnpm 10.11.0+ for package management, Vitest for testing
|
|
6
|
+
metadata:
|
|
7
|
+
version: "3.0.0"
|
|
8
|
+
category: "development"
|
|
9
|
+
tags: ["api", "tdd", "workflow", "research", "interview", "verification", "testing"]
|
|
10
|
+
author: "Hustle Together"
|
|
11
|
+
allowed-tools: WebSearch WebFetch mcp__context7 mcp__github AskUserQuestion Read Write Edit Bash TodoWrite
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# API Create - Comprehensive API Development Workflow v3.0
|
|
15
|
+
|
|
16
|
+
**Usage:** `/api-create [endpoint-name]`
|
|
17
|
+
|
|
18
|
+
**Purpose:** Orchestrates the complete API development workflow using interview-driven, research-first, test-first methodology with continuous verification loops.
|
|
19
|
+
|
|
20
|
+
## ⚠️ CRITICAL: MANDATORY USER INTERACTION
|
|
21
|
+
|
|
22
|
+
**YOU MUST USE THE `AskUserQuestion` TOOL AT EVERY CHECKPOINT.**
|
|
23
|
+
|
|
24
|
+
This workflow requires REAL user input at each phase. You are **FORBIDDEN** from:
|
|
25
|
+
|
|
26
|
+
- Self-answering questions
|
|
27
|
+
- Assuming user responses
|
|
28
|
+
- Proceeding without explicit user confirmation
|
|
29
|
+
- Making decisions on behalf of the user
|
|
30
|
+
|
|
31
|
+
### How to Ask Questions Correctly
|
|
32
|
+
|
|
33
|
+
At every `[Y/n]` or multiple-choice prompt in this workflow, you MUST call the `AskUserQuestion` tool with this EXACT schema:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"questions": [
|
|
38
|
+
{
|
|
39
|
+
"question": "Your question here? (must end with ?)",
|
|
40
|
+
"header": "Phase",
|
|
41
|
+
"multiSelect": false,
|
|
42
|
+
"options": [
|
|
43
|
+
{ "label": "Option A", "description": "What this option means" },
|
|
44
|
+
{ "label": "Option B", "description": "What this option means" },
|
|
45
|
+
{ "label": "Other", "description": "I'll type my own answer" }
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**CRITICAL REQUIREMENTS:**
|
|
53
|
+
|
|
54
|
+
- `header`: Max 12 characters (e.g., "Scope", "Research", "Format")
|
|
55
|
+
- `options`: 2-4 options, each with `label` (1-5 words) and `description`
|
|
56
|
+
- `multiSelect`: Required boolean (true for checkboxes, false for radio)
|
|
57
|
+
- `question`: Must end with a question mark
|
|
58
|
+
- Users can always select "Other" to provide custom input
|
|
59
|
+
|
|
60
|
+
**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.
|
|
61
|
+
|
|
62
|
+
### Violation Detection
|
|
63
|
+
|
|
64
|
+
The enforcement hooks will BLOCK your progress if:
|
|
65
|
+
|
|
66
|
+
- `user_question_asked` is false for any phase
|
|
67
|
+
- `user_confirmed`/`user_approved`/`user_completed` is false
|
|
68
|
+
- `phase_exit_confirmed` is false (user must explicitly approve proceeding to next phase)
|
|
69
|
+
- Questions were not asked via the AskUserQuestion tool
|
|
70
|
+
|
|
71
|
+
If you see "BLOCKED" messages, it means you skipped user interaction.
|
|
72
|
+
|
|
73
|
+
### Phase Exit Confirmation (NEW in v3.5.0)
|
|
74
|
+
|
|
75
|
+
**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.
|
|
76
|
+
|
|
77
|
+
The exit confirmation question MUST:
|
|
78
|
+
|
|
79
|
+
1. Summarize what was accomplished in the current phase
|
|
80
|
+
2. Ask if user is ready to proceed to the next phase
|
|
81
|
+
3. Include options like "Yes, proceed", "No, I have changes", "Add more"
|
|
82
|
+
|
|
83
|
+
Example exit confirmation:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"questions": [
|
|
88
|
+
{
|
|
89
|
+
"question": "Phase complete. Research found 5 sources. Ready to proceed to Interview phase?",
|
|
90
|
+
"header": "Proceed",
|
|
91
|
+
"multiSelect": false,
|
|
92
|
+
"options": [
|
|
93
|
+
{ "label": "Yes, proceed", "description": "Move to next phase" },
|
|
94
|
+
{
|
|
95
|
+
"label": "No, more research",
|
|
96
|
+
"description": "I need additional research on [topic]"
|
|
97
|
+
},
|
|
98
|
+
{ "label": "Review sources", "description": "Show me what was found" }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The `phase_exit_confirmed` flag is automatically set when:
|
|
106
|
+
|
|
107
|
+
1. An `AskUserQuestion` is called with a question containing words like "proceed", "continue", "ready", "confirm", "approve"
|
|
108
|
+
2. The user responds with an affirmative answer (yes, proceed, confirm, approve, etc.)
|
|
109
|
+
|
|
110
|
+
Both conditions must be true for the flag to be set.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Progress Tracking (TodoWrite Integration)
|
|
115
|
+
|
|
116
|
+
**FIRST ACTION:** Initialize the todo list to show user real-time progress:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
TodoWrite([
|
|
120
|
+
{"content": "Phase 1: Disambiguation", "status": "in_progress", "activeForm": "Clarifying API terms"},
|
|
121
|
+
{"content": "Phase 2: Scope", "status": "pending", "activeForm": "Confirming endpoint scope"},
|
|
122
|
+
{"content": "Phase 3: Initial Research", "status": "pending", "activeForm": "Researching documentation"},
|
|
123
|
+
{"content": "Phase 4: Interview", "status": "pending", "activeForm": "Gathering requirements"},
|
|
124
|
+
{"content": "Phase 5: Deep Research", "status": "pending", "activeForm": "Deep diving documentation"},
|
|
125
|
+
{"content": "Phase 6: Schema", "status": "pending", "activeForm": "Creating Zod schema"},
|
|
126
|
+
{"content": "Phase 7: Environment", "status": "pending", "activeForm": "Verifying API keys"},
|
|
127
|
+
{"content": "Phase 8: TDD Red", "status": "pending", "activeForm": "Writing failing tests"},
|
|
128
|
+
{"content": "Phase 9: TDD Green", "status": "pending", "activeForm": "Implementing to pass tests"},
|
|
129
|
+
{"content": "Phase 10: Verify", "status": "pending", "activeForm": "Verifying against docs"},
|
|
130
|
+
{"content": "Phase 11: Code Review (Greptile)", "status": "pending", "activeForm": "Running AI code review"},
|
|
131
|
+
{"content": "Phase 12: Refactor", "status": "pending", "activeForm": "Fixing issues, cleaning up"},
|
|
132
|
+
{"content": "Phase 13: Documentation", "status": "pending", "activeForm": "Updating documentation"},
|
|
133
|
+
{"content": "Phase 14: Completion", "status": "pending", "activeForm": "Final commit and PR"}
|
|
134
|
+
])
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**At each phase transition:**
|
|
138
|
+
|
|
139
|
+
1. Mark current phase as `completed`
|
|
140
|
+
2. Mark next phase as `in_progress`
|
|
141
|
+
3. This gives the user visual progress during long workflows
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Key Principles
|
|
146
|
+
|
|
147
|
+
1. **Loop Until Green** - Every verification phase loops back if not successful
|
|
148
|
+
2. **Continuous Interviews** - Checkpoints at EVERY phase transition (USE AskUserQuestion!)
|
|
149
|
+
3. **Adaptive Research** - Propose searches based on context, not shotgun approach
|
|
150
|
+
4. **Self-Documenting** - State file captures everything for re-grounding
|
|
151
|
+
5. **Verify After Green** - Re-research docs to catch memory-based implementation errors
|
|
152
|
+
6. **Visual Progress** - Update TodoWrite at every phase for user visibility
|
|
153
|
+
|
|
154
|
+
## Complete Phase Flow
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
/api-create [endpoint]
|
|
158
|
+
│
|
|
159
|
+
▼
|
|
160
|
+
┌─ PHASE 1: DISAMBIGUATION ─────────────────────────────────┐
|
|
161
|
+
│ Search 3-5 variations of the term: │
|
|
162
|
+
│ • "[term]" │
|
|
163
|
+
│ • "[term] API" │
|
|
164
|
+
│ • "[term] SDK" │
|
|
165
|
+
│ • "[term] npm package" │
|
|
166
|
+
│ │
|
|
167
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool with EXACT schema: │
|
|
168
|
+
│ │
|
|
169
|
+
│ { │
|
|
170
|
+
│ "questions": [{ │
|
|
171
|
+
│ "question": "Which interpretation of [term]?", │
|
|
172
|
+
│ "header": "Disambig", │
|
|
173
|
+
│ "multiSelect": false, │
|
|
174
|
+
│ "options": [ │
|
|
175
|
+
│ {"label": "REST API", "description": "Official API"},│
|
|
176
|
+
│ {"label": "SDK/Package", "description": "NPM wrapper"},│
|
|
177
|
+
│ {"label": "Both", "description": "API + SDK"} │
|
|
178
|
+
│ ] │
|
|
179
|
+
│ }] │
|
|
180
|
+
│ } │
|
|
181
|
+
│ │
|
|
182
|
+
│ WAIT for user response. Do NOT proceed without it. │
|
|
183
|
+
│ ──── Loop back if user selects "Something else" ──── │
|
|
184
|
+
└───────────────────────────────────────────────────────────┘
|
|
185
|
+
│ Clear
|
|
186
|
+
▼
|
|
187
|
+
┌─ PHASE 2: SCOPE CONFIRMATION ─────────────────────────────┐
|
|
188
|
+
│ │
|
|
189
|
+
│ Present your understanding, then: │
|
|
190
|
+
│ │
|
|
191
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
192
|
+
│ │
|
|
193
|
+
│ AskUserQuestion({ │
|
|
194
|
+
│ questions: [{ │
|
|
195
|
+
│ question: "I understand you want /api/v2/[endpoint] │
|
|
196
|
+
│ to [purpose]. Using [external API]. │
|
|
197
|
+
│ Is this correct?", │
|
|
198
|
+
│ header: "Scope", │
|
|
199
|
+
│ options: [ │
|
|
200
|
+
│ "Yes, proceed", │
|
|
201
|
+
│ "I have modifications to add", │
|
|
202
|
+
│ "No, let me clarify the purpose" │
|
|
203
|
+
│ ] │
|
|
204
|
+
│ }] │
|
|
205
|
+
│ }) │
|
|
206
|
+
│ │
|
|
207
|
+
│ WAIT for user response. Do NOT assume "yes". │
|
|
208
|
+
│ ──── Loop back if user has modifications ──── │
|
|
209
|
+
└───────────────────────────────────────────────────────────┘
|
|
210
|
+
│
|
|
211
|
+
▼
|
|
212
|
+
┌─ PHASE 3: INITIAL RESEARCH (Parallel Subagents) ──────────┐
|
|
213
|
+
│ │
|
|
214
|
+
│ Execute 2-3 initial searches using PARALLEL SUBAGENTS: │
|
|
215
|
+
│ │
|
|
216
|
+
│ ** ASYNC PARALLEL RESEARCH ** │
|
|
217
|
+
│ For faster research, spawn multiple subagents in parallel │
|
|
218
|
+
│ using the Task tool with different research strategies: │
|
|
219
|
+
│ │
|
|
220
|
+
│ // Spawn 3 parallel research agents │
|
|
221
|
+
│ Task({ │
|
|
222
|
+
│ subagent_type: "parallel-researcher", │
|
|
223
|
+
│ prompt: "Research [API] via Context7 - find all │
|
|
224
|
+
│ endpoints, parameters, webhooks", │
|
|
225
|
+
│ model: "haiku" │
|
|
226
|
+
│ }) │
|
|
227
|
+
│ // Press Ctrl+B to background this agent │
|
|
228
|
+
│ │
|
|
229
|
+
│ Task({ │
|
|
230
|
+
│ subagent_type: "parallel-researcher", │
|
|
231
|
+
│ prompt: "WebSearch [API] official docs and guides", │
|
|
232
|
+
│ model: "haiku" │
|
|
233
|
+
│ }) │
|
|
234
|
+
│ // Press Ctrl+B to background this agent │
|
|
235
|
+
│ │
|
|
236
|
+
│ // Use /tasks to monitor progress of background agents │
|
|
237
|
+
│ │
|
|
238
|
+
│ ** ALTERNATIVE: Sequential Research ** │
|
|
239
|
+
│ If not using parallel agents, execute sequentially: │
|
|
240
|
+
│ • Context7: "[library/api name]" │
|
|
241
|
+
│ • WebSearch: "[name] official documentation" │
|
|
242
|
+
│ • WebSearch: "site:[domain] api reference" │
|
|
243
|
+
│ │
|
|
244
|
+
│ Present summary table, then: │
|
|
245
|
+
│ │
|
|
246
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
247
|
+
│ │
|
|
248
|
+
│ AskUserQuestion({ │
|
|
249
|
+
│ questions: [{ │
|
|
250
|
+
│ question: "Research summary above. Found [N] │
|
|
251
|
+
│ sources. Should I proceed or search │
|
|
252
|
+
│ for more?", │
|
|
253
|
+
│ header: "Research", │
|
|
254
|
+
│ options: [ │
|
|
255
|
+
│ "Proceed to interview", │
|
|
256
|
+
│ "Search more - I need [specific topic]", │
|
|
257
|
+
│ "Search for something specific (I'll describe)" │
|
|
258
|
+
│ ] │
|
|
259
|
+
│ }] │
|
|
260
|
+
│ }) │
|
|
261
|
+
│ │
|
|
262
|
+
│ WAIT for user response. Do NOT auto-proceed. │
|
|
263
|
+
│ ──── Loop back if user wants more research ──── │
|
|
264
|
+
└───────────────────────────────────────────────────────────┘
|
|
265
|
+
│
|
|
266
|
+
▼
|
|
267
|
+
┌─ PHASE 4: INTERVIEW (Generated FROM Research) ────────────┐
|
|
268
|
+
│ │
|
|
269
|
+
│ For EACH parameter discovered in research, ask ONE │
|
|
270
|
+
│ question at a time using AskUserQuestion: │
|
|
271
|
+
│ │
|
|
272
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion for EACH question: │
|
|
273
|
+
│ │
|
|
274
|
+
│ // Question 1: Format preference │
|
|
275
|
+
│ AskUserQuestion({ │
|
|
276
|
+
│ questions: [{ │
|
|
277
|
+
│ question: "Which response formats do you need?", │
|
|
278
|
+
│ header: "Format", │
|
|
279
|
+
│ multiSelect: true, │
|
|
280
|
+
│ options: ["JSON", "SVG", "PNG", "All formats"] │
|
|
281
|
+
│ }] │
|
|
282
|
+
│ }) │
|
|
283
|
+
│ // WAIT for response, record in state, then next Q │
|
|
284
|
+
│ │
|
|
285
|
+
│ // Question 2: Error handling │
|
|
286
|
+
│ AskUserQuestion({ │
|
|
287
|
+
│ questions: [{ │
|
|
288
|
+
│ question: "How should errors be handled?", │
|
|
289
|
+
│ header: "Errors", │
|
|
290
|
+
│ options: [ │
|
|
291
|
+
│ "Throw exceptions", │
|
|
292
|
+
│ "Return error objects", │
|
|
293
|
+
│ "Both (configurable)" │
|
|
294
|
+
│ ] │
|
|
295
|
+
│ }] │
|
|
296
|
+
│ }) │
|
|
297
|
+
│ // Continue for ALL parameters... │
|
|
298
|
+
│ │
|
|
299
|
+
│ After ALL questions answered: │
|
|
300
|
+
│ │
|
|
301
|
+
│ AskUserQuestion({ │
|
|
302
|
+
│ questions: [{ │
|
|
303
|
+
│ question: "Interview complete. Your decisions: │
|
|
304
|
+
│ [summary]. All correct?", │
|
|
305
|
+
│ header: "Confirm", │
|
|
306
|
+
│ options: [ │
|
|
307
|
+
│ "Yes, proceed to schema", │
|
|
308
|
+
│ "Change an answer", │
|
|
309
|
+
│ "Add another question" │
|
|
310
|
+
│ ] │
|
|
311
|
+
│ }] │
|
|
312
|
+
│ }) │
|
|
313
|
+
│ │
|
|
314
|
+
│ Decisions saved to state file for consistency. │
|
|
315
|
+
│ ──── Loop back if user wants to change answers ──── │
|
|
316
|
+
└───────────────────────────────────────────────────────────┘
|
|
317
|
+
│
|
|
318
|
+
▼
|
|
319
|
+
┌─ PHASE 5: DEEP RESEARCH (Adaptive) ───────────────────────┐
|
|
320
|
+
│ │
|
|
321
|
+
│ Based on interview answers, PROPOSE additional research. │
|
|
322
|
+
│ │
|
|
323
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
324
|
+
│ │
|
|
325
|
+
│ AskUserQuestion({ │
|
|
326
|
+
│ questions: [{ │
|
|
327
|
+
│ question: "Based on your interview answers, I │
|
|
328
|
+
│ want to research: [list]. Approve?", │
|
|
329
|
+
│ header: "Deep Research", │
|
|
330
|
+
│ options: [ │
|
|
331
|
+
│ "Yes, run these searches", │
|
|
332
|
+
│ "Add more - I also need [topic]", │
|
|
333
|
+
│ "Skip deep research, proceed to schema" │
|
|
334
|
+
│ ] │
|
|
335
|
+
│ }] │
|
|
336
|
+
│ }) │
|
|
337
|
+
│ │
|
|
338
|
+
│ WAIT for user response. Do NOT auto-approve. │
|
|
339
|
+
│ KEY: Research is PROPOSED, not automatic shotgun. │
|
|
340
|
+
│ ──── Loop back if user wants to add topics ──── │
|
|
341
|
+
└───────────────────────────────────────────────────────────┘
|
|
342
|
+
│
|
|
343
|
+
▼
|
|
344
|
+
┌─ PHASE 6: SCHEMA DESIGN ──────────────────────────────────┐
|
|
345
|
+
│ │
|
|
346
|
+
│ Create Zod schema from research + interview, then: │
|
|
347
|
+
│ │
|
|
348
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
349
|
+
│ │
|
|
350
|
+
│ AskUserQuestion({ │
|
|
351
|
+
│ questions: [{ │
|
|
352
|
+
│ question: "Schema created based on your interview. │
|
|
353
|
+
│ [show schema]. Does this match your │
|
|
354
|
+
│ requirements?", │
|
|
355
|
+
│ header: "Schema", │
|
|
356
|
+
│ options: [ │
|
|
357
|
+
│ "Yes, schema looks correct", │
|
|
358
|
+
│ "No, I need changes (I'll describe)", │
|
|
359
|
+
│ "Let's redo the interview" │
|
|
360
|
+
│ ] │
|
|
361
|
+
│ }] │
|
|
362
|
+
│ }) │
|
|
363
|
+
│ │
|
|
364
|
+
│ WAIT for user response. Do NOT assume approval. │
|
|
365
|
+
│ ──── Loop back if schema needs changes ──── │
|
|
366
|
+
└───────────────────────────────────────────────────────────┘
|
|
367
|
+
│
|
|
368
|
+
▼
|
|
369
|
+
┌─ PHASE 7: ENVIRONMENT CHECK ──────────────────────────────┐
|
|
370
|
+
│ │
|
|
371
|
+
│ Check required API keys, show status table, then: │
|
|
372
|
+
│ │
|
|
373
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
374
|
+
│ │
|
|
375
|
+
│ AskUserQuestion({ │
|
|
376
|
+
│ questions: [{ │
|
|
377
|
+
│ question: "Environment check: [N] keys found, │
|
|
378
|
+
│ [M] missing. Ready to start TDD?", │
|
|
379
|
+
│ header: "Environment", │
|
|
380
|
+
│ options: [ │
|
|
381
|
+
│ "Yes, ready to write tests", │
|
|
382
|
+
│ "No, need to set up API keys first", │
|
|
383
|
+
│ "No, need to fix something else" │
|
|
384
|
+
│ ] │
|
|
385
|
+
│ }] │
|
|
386
|
+
│ }) │
|
|
387
|
+
│ │
|
|
388
|
+
│ WAIT for user response. Do NOT auto-proceed. │
|
|
389
|
+
│ ──── Loop back if keys missing ──── │
|
|
390
|
+
└───────────────────────────────────────────────────────────┘
|
|
391
|
+
│
|
|
392
|
+
▼
|
|
393
|
+
┌─ PHASE 8: TDD RED (Write Failing Tests) ──────────────────┐
|
|
394
|
+
│ │
|
|
395
|
+
│ Generate test matrix from schema + interview, then: │
|
|
396
|
+
│ │
|
|
397
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
398
|
+
│ │
|
|
399
|
+
│ AskUserQuestion({ │
|
|
400
|
+
│ questions: [{ │
|
|
401
|
+
│ question: "Test matrix: [N] test scenarios based │
|
|
402
|
+
│ on your interview. Covers: [list]. │
|
|
403
|
+
│ Approve this test plan?", │
|
|
404
|
+
│ header: "Tests", │
|
|
405
|
+
│ options: [ │
|
|
406
|
+
│ "Yes, write these tests", │
|
|
407
|
+
│ "Add more scenarios (I'll describe)", │
|
|
408
|
+
│ "Change a scenario (I'll describe)" │
|
|
409
|
+
│ ] │
|
|
410
|
+
│ }] │
|
|
411
|
+
│ }) │
|
|
412
|
+
│ │
|
|
413
|
+
│ WAIT for user response. Do NOT auto-approve. │
|
|
414
|
+
│ HOOK: PreToolUse blocks Write if no research/interview │
|
|
415
|
+
│ ──── Loop back if user wants changes ──── │
|
|
416
|
+
└───────────────────────────────────────────────────────────┘
|
|
417
|
+
│
|
|
418
|
+
▼
|
|
419
|
+
┌─ PHASE 9: TDD GREEN (Minimal Implementation) ─────────────┐
|
|
420
|
+
│ │
|
|
421
|
+
│ Write minimal code to pass ALL tests. │
|
|
422
|
+
│ Tests derived from schema. │
|
|
423
|
+
│ Implementation validates with schema. │
|
|
424
|
+
│ │
|
|
425
|
+
│ Run tests → All must pass before proceeding. │
|
|
426
|
+
│ │
|
|
427
|
+
│ HOOK: PreToolUse blocks Write if test file doesn't exist │
|
|
428
|
+
└───────────────────────────────────────────────────────────┘
|
|
429
|
+
│
|
|
430
|
+
▼
|
|
431
|
+
┌─ PHASE 10: VERIFY (Re-Research After Green) ───────────────┐
|
|
432
|
+
│ │
|
|
433
|
+
│ MANDATORY: Re-read original documentation. │
|
|
434
|
+
│ Compare implementation to docs, then: │
|
|
435
|
+
│ │
|
|
436
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
437
|
+
│ │
|
|
438
|
+
│ AskUserQuestion({ │
|
|
439
|
+
│ questions: [{ │
|
|
440
|
+
│ question: "Verification found [N] gap(s) between │
|
|
441
|
+
│ docs and implementation: [list]. │
|
|
442
|
+
│ How should I proceed?", │
|
|
443
|
+
│ header: "Verify", │
|
|
444
|
+
│ options: [ │
|
|
445
|
+
│ "Fix gaps - loop back to Red phase", │
|
|
446
|
+
│ "Skip - these are intentional omissions", │
|
|
447
|
+
│ "Fix some, skip others (I'll specify)" │
|
|
448
|
+
│ ] │
|
|
449
|
+
│ }] │
|
|
450
|
+
│ }) │
|
|
451
|
+
│ │
|
|
452
|
+
│ WAIT for user response. Do NOT auto-decide. │
|
|
453
|
+
│ HOOK: PostToolUse triggers after test pass │
|
|
454
|
+
│ ──── Loop back to Phase 8 if user wants fixes ──── │
|
|
455
|
+
└───────────────────────────────────────────────────────────┘
|
|
456
|
+
│
|
|
457
|
+
▼
|
|
458
|
+
┌─ PHASE 11: AI CODE REVIEW (Greptile) ────────────────────┐
|
|
459
|
+
│ │
|
|
460
|
+
│ Run Greptile BEFORE refactoring to catch issues early: │
|
|
461
|
+
│ • Bug detection with full codebase context │
|
|
462
|
+
│ • Security vulnerability scanning (OWASP top 10) │
|
|
463
|
+
│ • Performance issue identification │
|
|
464
|
+
│ • Code quality and maintainability checks │
|
|
465
|
+
│ │
|
|
466
|
+
│ Greptile uses query endpoint to review your diff: │
|
|
467
|
+
│ POST https://api.greptile.com/v2/query │
|
|
468
|
+
│ - Analyzes changes against entire codebase │
|
|
469
|
+
│ - Returns issues with file:line references │
|
|
470
|
+
│ - Provides actionable fix suggestions │
|
|
471
|
+
│ │
|
|
472
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
473
|
+
│ │
|
|
474
|
+
│ AskUserQuestion({ │
|
|
475
|
+
│ questions: [{ │
|
|
476
|
+
│ question: "Greptile review complete. Score: [N]/10 │
|
|
477
|
+
│ Issues found: [list]. How to proceed?", │
|
|
478
|
+
│ header: "Review", │
|
|
479
|
+
│ multiSelect: false, │
|
|
480
|
+
│ options: [ │
|
|
481
|
+
│ {"label": "Fix all issues", "description": "Address each issue in Phase 12"},│
|
|
482
|
+
│ {"label": "Fix critical only", "description": "Skip medium/low priority"},│
|
|
483
|
+
│ {"label": "Skip review", "description": "Proceed without fixes (not recommended)"}│
|
|
484
|
+
│ ] │
|
|
485
|
+
│ }] │
|
|
486
|
+
│ }) │
|
|
487
|
+
│ │
|
|
488
|
+
│ WAIT for user response. Do NOT auto-skip issues. │
|
|
489
|
+
│ REQUIRES: GREPTILE_API_KEY + GITHUB_TOKEN in .env │
|
|
490
|
+
│ ──── Loop back to Phase 9 if major issues found ──── │
|
|
491
|
+
└───────────────────────────────────────────────────────────┘
|
|
492
|
+
│
|
|
493
|
+
▼
|
|
494
|
+
┌─ PHASE 12: TDD REFACTOR ──────────────────────────────────┐
|
|
495
|
+
│ │
|
|
496
|
+
│ Fix Greptile issues AND clean up code: │
|
|
497
|
+
│ • Fix all issues from Phase 11 code review │
|
|
498
|
+
│ • Extract reusable patterns │
|
|
499
|
+
│ • Improve error messages │
|
|
500
|
+
│ • Add JSDoc comments │
|
|
501
|
+
│ • Optimize performance │
|
|
502
|
+
│ │
|
|
503
|
+
│ Run tests after EVERY change → Must still pass. │
|
|
504
|
+
└───────────────────────────────────────────────────────────┘
|
|
505
|
+
│
|
|
506
|
+
▼
|
|
507
|
+
┌─ PHASE 13: DOCUMENTATION ─────────────────────────────────┐
|
|
508
|
+
│ │
|
|
509
|
+
│ Update documentation files, then: │
|
|
510
|
+
│ │
|
|
511
|
+
│ ⚠️ REQUIRED: Use AskUserQuestion tool: │
|
|
512
|
+
│ │
|
|
513
|
+
│ AskUserQuestion({ │
|
|
514
|
+
│ questions: [{ │
|
|
515
|
+
│ question: "Documentation checklist: [list files]. │
|
|
516
|
+
│ All documentation complete?", │
|
|
517
|
+
│ header: "Docs", │
|
|
518
|
+
│ multiSelect: false, │
|
|
519
|
+
│ options: [ │
|
|
520
|
+
│ {"label": "Yes, complete", "description": "All docs updated"},│
|
|
521
|
+
│ {"label": "Need to add more", "description": "I'll describe what's missing"},│
|
|
522
|
+
│ {"label": "Skip for now", "description": "Not recommended"}│
|
|
523
|
+
│ ] │
|
|
524
|
+
│ }] │
|
|
525
|
+
│ }) │
|
|
526
|
+
│ │
|
|
527
|
+
│ WAIT for user response. Do NOT auto-complete. │
|
|
528
|
+
│ HOOK: Stop hook blocks if docs incomplete │
|
|
529
|
+
│ ──── Loop back if user needs to add docs ──── │
|
|
530
|
+
└───────────────────────────────────────────────────────────┘
|
|
531
|
+
│
|
|
532
|
+
▼
|
|
533
|
+
┌─ PHASE 14: COMPLETION ────────────────────────────────────┐
|
|
534
|
+
│ │
|
|
535
|
+
│ Final verification: │
|
|
536
|
+
│ • All tests passing │
|
|
537
|
+
│ • 100% coverage │
|
|
538
|
+
│ • TypeScript compiles │
|
|
539
|
+
│ • Code review issues addressed │
|
|
540
|
+
│ • Docs updated │
|
|
541
|
+
│ • State file shows all phases complete │
|
|
542
|
+
│ │
|
|
543
|
+
│ Run /commit to create semantic commit. │
|
|
544
|
+
│ Run /pr to create pull request. │
|
|
545
|
+
└───────────────────────────────────────────────────────────┘
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
## State File Tracking
|
|
549
|
+
|
|
550
|
+
All phases are tracked in `.claude/api-dev-state.json`:
|
|
551
|
+
|
|
552
|
+
```json
|
|
553
|
+
{
|
|
554
|
+
"endpoint": "brandfetch",
|
|
555
|
+
"turn_count": 23,
|
|
556
|
+
"phases": {
|
|
557
|
+
"disambiguation": { "status": "complete" },
|
|
558
|
+
"scope": { "status": "complete" },
|
|
559
|
+
"research_initial": { "status": "complete", "sources": [...] },
|
|
560
|
+
"interview": { "status": "complete", "decisions": {...} },
|
|
561
|
+
"research_deep": { "status": "complete" },
|
|
562
|
+
"schema_creation": { "status": "complete" },
|
|
563
|
+
"environment_check": { "status": "complete" },
|
|
564
|
+
"tdd_red": { "status": "complete", "test_count": 23 },
|
|
565
|
+
"tdd_green": { "status": "complete" },
|
|
566
|
+
"verify": { "status": "complete", "gaps_found": 2, "gaps_fixed": 2 },
|
|
567
|
+
"code_review": { "status": "complete", "score": 9, "issues_found": 1, "issues_fixed": 1 },
|
|
568
|
+
"tdd_refactor": { "status": "complete" },
|
|
569
|
+
"documentation": { "status": "complete" },
|
|
570
|
+
"completion": { "status": "complete" }
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
## Output Artifacts
|
|
576
|
+
|
|
577
|
+
This command creates:
|
|
578
|
+
|
|
579
|
+
1. **State File**: `.claude/api-dev-state.json` (tracks all progress)
|
|
580
|
+
2. **Research Cache**: `.claude/research/[api-name]/CURRENT.md`
|
|
581
|
+
3. **Route Handler**: `/src/app/api/v2/[endpoint-name]/route.ts`
|
|
582
|
+
4. **Test Suite**: `/src/app/api/v2/[endpoint-name]/__tests__/[endpoint-name].api.test.ts`
|
|
583
|
+
5. **OpenAPI Spec**: `/src/lib/openapi/endpoints/[endpoint-name].ts`
|
|
584
|
+
6. **Updated Manifests**:
|
|
585
|
+
- `/src/app/api-test/api-tests-manifest.json`
|
|
586
|
+
- `/src/v2/docs/v2-api-implementation-status.md`
|
|
587
|
+
|
|
588
|
+
## Hooks That Enforce This Workflow
|
|
589
|
+
|
|
590
|
+
| Phase | Hook | Purpose |
|
|
591
|
+
| ----- | ------------------------------ | ------------------------------------------ |
|
|
592
|
+
| 0 | `enforce-external-research.py` | Detects API terms, requires disambiguation |
|
|
593
|
+
| 2-4 | `track-tool-use.py` | Logs all research, tracks turns |
|
|
594
|
+
| 7-8 | `enforce-research.py` | Blocks Write if no research done |
|
|
595
|
+
| 7-8 | `enforce-interview.py` | Injects interview decisions |
|
|
596
|
+
| 8 | `verify-implementation.py` | Blocks route if no test file |
|
|
597
|
+
| 9 | `verify-after-green.py` | Triggers verification after tests pass |
|
|
598
|
+
| 10 | `run-code-review.py` | Triggers Greptile AI code review |
|
|
599
|
+
| All | `periodic-reground.py` | Re-grounds every 7 turns |
|
|
600
|
+
| 14 | `api-workflow-check.py` | Blocks completion if docs incomplete |
|
|
601
|
+
|
|
602
|
+
<claude-commands-template>
|
|
603
|
+
## Project-Specific Rules
|
|
604
|
+
|
|
605
|
+
1. **API Location**: All V2 APIs go in `/src/app/api/v2/[endpoint-name]/`
|
|
606
|
+
2. **Testing**: Use Vitest, require 100% coverage
|
|
607
|
+
3. **Validation**: All requests/responses use Zod schemas
|
|
608
|
+
4. **AI SDK**: Use Vercel AI SDK 5.0.11 patterns from `/src/v2/docs/ai-sdk-catalog.json`
|
|
609
|
+
5. **Package Manager**: Use `pnpm` for all operations
|
|
610
|
+
6. **Documentation**: Follow patterns in `/src/v2/docs/Main Doc – V2 Development Patterns.md`
|
|
611
|
+
7. **API Keys**: Support three methods (env, NEXT*PUBLIC*, custom headers)
|
|
612
|
+
8. **Test Command**: `pnpm test:run` before commits
|
|
613
|
+
|
|
614
|
+
## Never Skip
|
|
615
|
+
|
|
616
|
+
- Phase 1 (Disambiguation) - Clarify before research
|
|
617
|
+
- Phase 3 (Initial Research) - Find ALL parameters
|
|
618
|
+
- Phase 4 (Interview) - Questions FROM research, not templates
|
|
619
|
+
- Phase 8 (TDD Red) - Failing tests FIRST
|
|
620
|
+
- Phase 10 (Verify) - Re-research after Green
|
|
621
|
+
- Phase 12 (Documentation) - Keep docs in sync
|
|
622
|
+
- Coverage verification - 100% required
|
|
623
|
+
</claude-commands-template>
|