@hustle-together/api-dev-tools 2.0.7 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +343 -467
  2. package/bin/cli.js +229 -15
  3. package/commands/README.md +124 -251
  4. package/commands/api-create.md +318 -136
  5. package/commands/api-interview.md +252 -256
  6. package/commands/api-research.md +209 -234
  7. package/commands/api-verify.md +231 -0
  8. package/demo/audio/generate-all-narrations.js +581 -0
  9. package/demo/audio/generate-narration.js +120 -56
  10. package/demo/audio/generate-voice-previews.js +140 -0
  11. package/demo/audio/narration-adam-timing.json +4675 -0
  12. package/demo/audio/narration-adam.mp3 +0 -0
  13. package/demo/audio/narration-creature-timing.json +4675 -0
  14. package/demo/audio/narration-creature.mp3 +0 -0
  15. package/demo/audio/narration-gaming-timing.json +4675 -0
  16. package/demo/audio/narration-gaming.mp3 +0 -0
  17. package/demo/audio/narration-hope-timing.json +4675 -0
  18. package/demo/audio/narration-hope.mp3 +0 -0
  19. package/demo/audio/narration-mark-timing.json +4675 -0
  20. package/demo/audio/narration-mark.mp3 +0 -0
  21. package/demo/audio/previews/manifest.json +30 -0
  22. package/demo/audio/previews/preview-creature.mp3 +0 -0
  23. package/demo/audio/previews/preview-gaming.mp3 +0 -0
  24. package/demo/audio/previews/preview-hope.mp3 +0 -0
  25. package/demo/audio/previews/preview-mark.mp3 +0 -0
  26. package/demo/audio/voices-manifest.json +50 -0
  27. package/demo/hustle-together/blog/gemini-vs-claude-widgets.html +30 -28
  28. package/demo/hustle-together/blog/interview-driven-api-development.html +37 -23
  29. package/demo/hustle-together/index.html +142 -109
  30. package/demo/workflow-demo.html +2618 -1036
  31. package/hooks/api-workflow-check.py +2 -0
  32. package/hooks/enforce-deep-research.py +180 -0
  33. package/hooks/enforce-disambiguation.py +149 -0
  34. package/hooks/enforce-documentation.py +187 -0
  35. package/hooks/enforce-environment.py +249 -0
  36. package/hooks/enforce-refactor.py +187 -0
  37. package/hooks/enforce-research.py +93 -46
  38. package/hooks/enforce-schema.py +186 -0
  39. package/hooks/enforce-scope.py +156 -0
  40. package/hooks/enforce-tdd-red.py +246 -0
  41. package/hooks/enforce-verify.py +186 -0
  42. package/hooks/periodic-reground.py +154 -0
  43. package/hooks/session-startup.py +151 -0
  44. package/hooks/track-tool-use.py +109 -17
  45. package/hooks/verify-after-green.py +282 -0
  46. package/package.json +3 -2
  47. package/scripts/collect-test-results.ts +404 -0
  48. package/scripts/extract-parameters.ts +483 -0
  49. package/scripts/generate-test-manifest.ts +520 -0
  50. package/templates/CLAUDE-SECTION.md +84 -0
  51. package/templates/api-dev-state.json +83 -8
  52. package/templates/api-test/page.tsx +315 -0
  53. package/templates/api-test/test-structure/route.ts +269 -0
  54. package/templates/research-index.json +6 -0
  55. package/templates/settings.json +59 -0
package/README.md CHANGED
@@ -1,10 +1,20 @@
1
- # API Development Tools for Claude Code
1
+ # API Development Tools for Claude Code v3.0
2
2
 
3
- **Interview-driven, research-first API development workflow**
3
+ **Interview-driven, research-first API development workflow with continuous verification loops**
4
4
 
5
- Automates the complete API development lifecycle from understanding requirements to deployment through structured interviews, deep research, test-driven development, and comprehensive documentation.
5
+ Automates the complete API development lifecycle from understanding requirements to deployment through structured interviews, adaptive research, test-driven development, and comprehensive documentation with automatic re-grounding.
6
6
 
7
- ## 🚀 Quick Start
7
+ ## What's New in v3.0
8
+
9
+ - **Phase 0: Pre-Research Disambiguation** - Search variations to clarify ambiguous terms
10
+ - **Phase 9: Verify** - Re-research after tests pass to catch memory-based errors
11
+ - **Adaptive Research** - Propose searches based on interview answers, not shotgun approach
12
+ - **Questions FROM Research** - Interview questions generated from discovered parameters
13
+ - **7-Turn Re-grounding** - Periodic context injection prevents memory dilution
14
+ - **Research Freshness** - 7-day cache with automatic staleness warnings
15
+ - **Loop-Back Architecture** - Every verification loops back if not successful
16
+
17
+ ## Quick Start
8
18
 
9
19
  ```bash
10
20
  # Install in your project
@@ -14,574 +24,440 @@ npx @hustle-together/api-dev-tools --scope=project
14
24
  /api-create my-endpoint
15
25
  ```
16
26
 
17
- ## 📦 What This Installs
27
+ ## What This Installs
28
+
29
+ ```
30
+ .claude/
31
+ ├── commands/ # Slash commands (*.md)
32
+ ├── hooks/ # Enforcement hooks (*.py)
33
+ ├── settings.json # Hook configuration
34
+ ├── api-dev-state.json # Workflow state tracking
35
+ └── research/ # Cached research with freshness
36
+
37
+ scripts/
38
+ └── api-dev-tools/ # Manifest generation scripts (*.ts)
39
+
40
+ src/app/
41
+ ├── api-test/ # Test UI page (if Next.js)
42
+ └── api/test-structure/# Parser API route (if Next.js)
43
+ ```
18
44
 
19
45
  ### Slash Commands
20
- Five powerful slash commands for Claude Code:
21
46
 
22
- - **`/api-create [endpoint]`** - Complete automated workflow (Interview → Research → TDD → Docs)
23
- - **`/api-interview [endpoint]`** - Structured 20-question interview about purpose and usage
24
- - **`/api-research [library]`** - Deep research of external APIs/SDKs (finds ALL parameters)
47
+ Six powerful slash commands for Claude Code:
48
+
49
+ - **`/api-create [endpoint]`** - Complete workflow (Disambiguate Research Interview → TDD → Verify → Docs)
50
+ - **`/api-interview [endpoint]`** - Dynamic questions GENERATED from research findings
51
+ - **`/api-research [library]`** - Adaptive propose-approve research flow
52
+ - **`/api-verify [endpoint]`** - Re-research and compare implementation to docs
25
53
  - **`/api-env [endpoint]`** - Check required API keys and environment setup
26
54
  - **`/api-status [endpoint]`** - Track implementation progress and phase completion
27
55
 
28
- ### Enforcement Hooks
29
- Six Python hooks that provide **real programmatic guarantees**:
56
+ ### Enforcement Hooks (8 total)
57
+
58
+ Python hooks that provide **real programmatic guarantees**:
30
59
 
31
- - **`enforce-external-research.py`** - (v1.7.0) Detects external API questions and requires research before answering
32
- - **`enforce-research.py`** - Blocks API code writing until research is complete
33
- - **`enforce-interview.py`** - (v1.8.0+) Verifies structured questions with options were asked; (v1.9.0+) Injects decision reminders on writes
34
- - **`verify-implementation.py`** - Checks implementation matches interview requirements
35
- - **`track-tool-use.py`** - (v1.9.0+) Captures user decisions from AskUserQuestion; logs all research activity
36
- - **`api-workflow-check.py`** - Prevents stopping until required phases are complete + git diff verification
60
+ | Hook | Event | Purpose |
61
+ |------|-------|---------|
62
+ | `session-startup.py` | SessionStart | Inject current state at session start |
63
+ | `enforce-external-research.py` | UserPromptSubmit | Detect API terms, require research |
64
+ | `enforce-research.py` | PreToolUse | Block writes until research complete |
65
+ | `enforce-interview.py` | PreToolUse | Inject interview decisions on writes |
66
+ | `verify-implementation.py` | PreToolUse | Check test file exists before route |
67
+ | `track-tool-use.py` | PostToolUse | Log research, count turns |
68
+ | `periodic-reground.py` | PostToolUse | Re-inject context every 7 turns |
69
+ | `verify-after-green.py` | PostToolUse | Trigger Phase 9 after tests pass |
70
+ | `api-workflow-check.py` | Stop | Block completion if phases incomplete |
37
71
 
38
72
  ### State Tracking
39
- - **`.claude/api-dev-state.json`** - Persistent state file tracking all workflow progress
40
73
 
41
- ### MCP Servers (Auto-installed via `claude mcp add`)
42
- - **Context7** - Fetches LIVE documentation from library source code (not training data)
43
- - **GitHub** - Read/create issues, pull requests, and access repository data (requires `GITHUB_PERSONAL_ACCESS_TOKEN`)
74
+ - **`.claude/api-dev-state.json`** - Persistent workflow state with turn counting
75
+ - **`.claude/research/`** - Cached research with freshness tracking
76
+ - **`.claude/research/index.json`** - Research catalog with 7-day validity
44
77
 
45
- ## 🎯 Why Use This?
78
+ ### Manifest Generation Scripts (Programmatic, NO LLM)
46
79
 
47
- ### Problems This Solves
80
+ Scripts that automatically generate documentation from test files:
48
81
 
49
- - **Writing tests without understanding purpose** → Mechanical tests that miss real use cases
50
- - ❌ **Incomplete API research** → Missing optional parameters and edge cases
51
- - **Runtime errors from missing API keys** Tests fail due to configuration issues
52
- - **No documentation of real usage**Future developers don't understand context
53
- - **Inconsistent implementation patterns**Every endpoint looks different
82
+ | Script | Output | Purpose |
83
+ |--------|--------|---------|
84
+ | `generate-test-manifest.ts` | `api-tests-manifest.json` | Parses Vitest testsfull API manifest |
85
+ | `extract-parameters.ts` | `parameter-matrix.json` | Extracts Zod paramscoverage matrix |
86
+ | `collect-test-results.ts` | `test-results.json` | Runs tests results with pass/fail |
54
87
 
55
- ### What You Get
88
+ **Key principle:** Tests are the SOURCE OF TRUTH. Scripts parse source files programmatically. **NO LLM involvement** in manifest generation.
56
89
 
57
- - **Interview-first development**Deep understanding before any code
58
- - ✅ **Comprehensive research** → Discover ALL parameters, not just documented ones
59
- - ✅ **Environment validation** → Verify API keys before starting
60
- - ✅ **TDD enforced** → Red → Green → Refactor cycle mandatory
61
- - ✅ **Auto-documentation** → Updates manifests, OpenAPI specs, status tracking
62
- - ✅ **Consistent workflow** → Repeatable, testable, maintainable
90
+ Scripts are triggered automatically after tests pass (Phase 8 Phase 9) via `verify-after-green.py` hook.
63
91
 
64
- ## 💡 How It Works
92
+ ## Complete Phase Flow (12 Phases)
65
93
 
66
- ### Fully Automated
67
- ```bash
68
- /api-create generate-pdf
69
94
  ```
70
-
71
- This single command:
72
- 1. **Interviews you** about the endpoint (20 structured questions)
73
- 2. **Researches** required libraries and external APIs
74
- 3. **Checks environment** for API keys and configuration
75
- 4. **Writes failing tests** first (TDD Red phase)
76
- 5. **Implements** minimal solution (TDD Green phase)
77
- 6. **Refactors** for quality (TDD Refactor phase)
78
- 7. **Updates documentation** (manifests, OpenAPI, examples)
79
- 8. **Creates commit** with semantic message
80
-
81
- ### Manual Step-by-Step
82
- ```bash
83
- /api-interview generate-pdf # Understand purpose & requirements
84
- /api-research pdf-lib # Research PDF library thoroughly
85
- /api-env generate-pdf # Verify environment & API keys
86
- /red # Write ONE failing test
87
- /green # Implement to make it pass
88
- /refactor # Clean up the code
89
- /api-status generate-pdf # Update progress tracking
90
- /commit # Create semantic commit
95
+ ┌─ PHASE 0: DISAMBIGUATION ─────────────────────┐
96
+ Search 3-5 variations, clarify ambiguity │
97
+ Loop back if still unclear │
98
+ └───────────────────────────────────────────────┘
99
+
100
+
101
+ ┌─ PHASE 1: SCOPE CONFIRMATION ─────────────────┐
102
+ Confirm understanding of endpoint purpose │
103
+ └───────────────────────────────────────────────┘
104
+
105
+
106
+ ┌─ PHASE 2: INITIAL RESEARCH ───────────────────┐
107
+ │ 2-3 targeted searches (Context7, WebSearch) │
108
+ Present summary, ask to proceed or search more│
109
+ Loop back if user wants more │
110
+ └───────────────────────────────────────────────┘
111
+
112
+
113
+ ┌─ PHASE 3: INTERVIEW ──────────────────────────┐
114
+ Questions GENERATED from research findings │
115
+ - Enum params → multi-select │
116
+ │ - Continuous ranges → test strategy │
117
+ │ - Boolean params → enable/disable │
118
+ └───────────────────────────────────────────────┘
119
+
120
+
121
+ ┌─ PHASE 4: DEEP RESEARCH (Adaptive) ───────────┐
122
+ │ PROPOSE searches based on interview answers │
123
+ │ User approves/modifies/skips │
124
+ │ Not shotgun - targeted to selections │
125
+ └───────────────────────────────────────────────┘
126
+
127
+
128
+ ┌─ PHASE 5: SCHEMA DESIGN ──────────────────────┐
129
+ │ Create Zod schema from research + interview │
130
+ │ Loop back if schema wrong │
131
+ └───────────────────────────────────────────────┘
132
+
133
+
134
+ ┌─ PHASE 6: ENVIRONMENT CHECK ──────────────────┐
135
+ │ Verify API keys exist │
136
+ │ Loop back if keys missing │
137
+ └───────────────────────────────────────────────┘
138
+
139
+
140
+ ┌─ PHASE 7: TDD RED ────────────────────────────┐
141
+ │ Write failing tests from schema + decisions │
142
+ │ Test matrix derived from interview │
143
+ └───────────────────────────────────────────────┘
144
+
145
+
146
+ ┌─ PHASE 8: TDD GREEN ──────────────────────────┐
147
+ │ Minimal implementation to pass tests │
148
+ └───────────────────────────────────────────────┘
149
+
150
+
151
+ ┌─ MANIFEST GENERATION (Automatic) ─────────────┐
152
+ │ verify-after-green.py hook triggers: │
153
+ │ • generate-test-manifest.ts │
154
+ │ • extract-parameters.ts │
155
+ │ • collect-test-results.ts │
156
+ │ │
157
+ │ Output: api-tests-manifest.json (NO LLM) │
158
+ └───────────────────────────────────────────────┘
159
+
160
+
161
+ ┌─ PHASE 9: VERIFY (NEW) ───────────────────────┐
162
+ │ Re-read original documentation │
163
+ │ Compare implementation to docs feature-by- │
164
+ │ feature. Find gaps. │
165
+ │ │
166
+ │ Fix gaps? → Loop back to Phase 7 │
167
+ │ Skip (intentional)? → Document as omissions │
168
+ └───────────────────────────────────────────────┘
169
+
170
+
171
+ ┌─ PHASE 10: TDD REFACTOR ──────────────────────┐
172
+ │ Clean up code, tests still pass │
173
+ └───────────────────────────────────────────────┘
174
+
175
+
176
+ ┌─ PHASE 11: DOCUMENTATION ─────────────────────┐
177
+ │ Update manifests, OpenAPI, cache research │
178
+ └───────────────────────────────────────────────┘
179
+
180
+
181
+ ┌─ PHASE 12: COMPLETION ────────────────────────┐
182
+ │ All phases verified, commit │
183
+ └───────────────────────────────────────────────┘
91
184
  ```
92
185
 
93
- ## 📋 Installation
186
+ ## Key Features
94
187
 
95
- ### One-Time Installation
96
- ```bash
97
- cd your-project
98
- npx @hustle-together/api-dev-tools --scope=project
99
- ```
188
+ ### Adaptive Research (Not Shotgun)
100
189
 
101
- ### Team-Wide Auto-Installation
190
+ **OLD:** Run 20 searches blindly
102
191
 
103
- Add to your project's `package.json`:
104
- ```json
105
- {
106
- "scripts": {
107
- "postinstall": "npx @hustle-together/api-dev-tools --scope=project"
108
- }
109
- }
110
- ```
111
-
112
- Now anyone who runs `npm install` or `pnpm install` gets the commands automatically.
192
+ **NEW:**
193
+ 1. Run 2-3 initial searches
194
+ 2. Present summary
195
+ 3. PROPOSE additional searches based on context
196
+ 4. User approves/modifies
197
+ 5. Execute only approved searches
113
198
 
114
- ## 📚 Command Reference
199
+ ### Questions FROM Research
115
200
 
116
- ### `/api-create [endpoint-name]`
117
-
118
- **The orchestrator.** Runs the complete workflow automatically.
119
-
120
- **Example:**
121
- ```bash
122
- /api-create user-preferences
201
+ **OLD:** Generic template questions
123
202
  ```
124
-
125
- **What it does:**
126
- - Interviews you about requirements
127
- - Researches dependencies (Next.js API routes, Zod, etc.)
128
- - Checks environment (Supabase keys, etc.)
129
- - Writes comprehensive tests
130
- - Implements with Zod validation
131
- - Updates all documentation
132
- - Creates commit
133
-
134
- ---
135
-
136
- ### `/api-interview [endpoint-name]`
137
-
138
- **Structured discovery.** 20-question interview based on Anthropic Interviewer methodology.
139
-
140
- **Example:**
141
- ```bash
142
- /api-interview send-email
203
+ "Which AI provider should this endpoint support?"
143
204
  ```
144
205
 
145
- **Questions cover:**
146
- - Purpose & context
147
- - Real-world usage scenarios
148
- - Required vs. optional parameters
149
- - Dependencies & API keys
150
- - Error handling & edge cases
151
- - Documentation sources
152
-
153
- **Output:** `/src/v2/docs/endpoints/[endpoint-name].md`
154
-
155
- ---
156
-
157
- ### `/api-research [library-or-service]`
158
-
159
- **Deep dive.** Discovers ALL parameters by reading source code and documentation.
160
-
161
- **Example:**
162
- ```bash
163
- /api-research resend-api
164
- ```
165
-
166
- **Finds:**
167
- - Official documentation links
168
- - Complete request/response schemas
169
- - Undocumented parameters (from source code)
170
- - TypeScript type definitions
171
- - Rate limits, quotas, costs
172
- - Integration patterns
173
- - Code examples
174
-
175
- **Output:** `/src/v2/docs/research/[library-name].md`
176
-
177
- ---
178
-
179
- ### `/api-env [endpoint-name]`
180
-
181
- **Environment check.** Verifies API keys and configuration before implementation.
182
-
183
- **Example:**
184
- ```bash
185
- /api-env send-email
206
+ **NEW:** Questions generated from discovered parameters
186
207
  ```
208
+ Based on research, Brandfetch API has 7 parameters:
187
209
 
188
- **Checks:**
189
- - Required API keys exist in `.env.local`
190
- - Templates in `.env.example`
191
- - `.gitignore` protects secrets
192
- - Service connectivity (optional)
210
+ 1. DOMAIN (required) - string
211
+ No question needed
193
212
 
194
- **Output:** Terminal report + action items
213
+ 2. FORMAT: ["json", "svg", "png", "raw"]
214
+ Q: Which formats do you need?
195
215
 
196
- ---
197
-
198
- ### `/api-status [endpoint-name]`
199
-
200
- **Progress tracking.** Shows implementation status and phase completion.
201
-
202
- **Examples:**
203
- ```bash
204
- /api-status send-email # Specific endpoint
205
- /api-status --all # All endpoints
216
+ 3. QUALITY: 1-100 (continuous range)
217
+ Q: How should we TEST this?
218
+ [ ] All values (100 tests)
219
+ [x] Boundary (1, 50, 100)
206
220
  ```
207
221
 
208
- **Tracks:**
209
- - Interview completion
210
- - Research completion
211
- - Environment readiness
212
- - TDD phases (Red → Green → Refactor)
213
- - Documentation updates
214
- - Test coverage
215
-
216
- **Output:** Progress report + status document updates
217
-
218
- ## 🔄 Workflow Integration
219
-
220
- Works seamlessly with existing Claude Code commands:
221
-
222
- ```bash
223
- /plan # Create implementation checklist
224
- /gap # Find missing pieces
225
- /issue [url] # Start from GitHub issue
226
-
227
- /api-create # ← Run complete API workflow
228
-
229
- /commit # Semantic commit message
230
- /pr # Create pull request
231
- ```
232
-
233
- ## 🎓 Methodology
234
-
235
- Based on proven approaches:
236
-
237
- - **[Anthropic Interviewer](https://www.anthropic.com/news/anthropic-interviewer)** - Structured interview methodology
238
- - **TDD (Test-Driven Development)** - Red → Green → Refactor cycle
239
- - **[@wbern/claude-instructions](https://github.com/wbern/claude-instructions)** - Slash command pattern
240
- - **V2 Development Patterns** - Zod schemas, consistent structure
222
+ ### Phase 9: Verify (Catches Memory Errors)
241
223
 
242
- ## 📁 Output Artifacts
243
-
244
- Each endpoint creates:
224
+ After tests pass, automatically:
225
+ 1. Re-read original documentation
226
+ 2. Compare feature-by-feature
227
+ 3. Report discrepancies:
245
228
 
246
229
  ```
247
- src/app/api/v2/[endpoint]/
248
- ├── route.ts # Handler with Zod schemas
249
- ├── __tests__/
250
- └── [endpoint].api.test.ts # Comprehensive tests (100% coverage)
251
- └── README.md # Endpoint documentation
252
-
253
- src/v2/docs/
254
- ├── endpoints/
255
- │ └── [endpoint].md # Interview results & requirements
256
- └── research/
257
- └── [library].md # External API research findings
258
-
259
- Updated files:
260
- - src/app/api-test/api-tests-manifest.json # Test documentation
261
- - src/lib/openapi/endpoints/[endpoint].ts # OpenAPI spec
262
- - src/v2/docs/v2-api-implementation-status.md # Progress tracking
230
+ │ Feature │ In Docs │ Implemented │ Status │
231
+ ├───────────────┼─────────┼─────────────┼─────────────│
232
+ domain param │ ✓ │ ✓ │ ✅ Match │
233
+ format opts 4 │ 3 │ ⚠️ Missing │
234
+ webhook │ ✓ │ ✗ │ ℹ️ Optional │
235
+
236
+ Fix gaps? [Y] → Return to Phase 7
237
+ Skip? [n] → Document as omissions
263
238
  ```
264
239
 
265
- ## 🏗 Project Structure Required
266
-
267
- This tool expects:
268
- - **Next.js** API routes (`src/app/api/`)
269
- - **Vitest** for testing
270
- - **Zod** for validation
271
- - **TypeScript** strict mode
272
-
273
- Not tied to specific AI providers - works with any API architecture.
240
+ ### 7-Turn Re-grounding
274
241
 
275
- ## 🔑 Key Principles
242
+ Prevents context dilution in long sessions:
243
+ - Every 7 turns, hook injects state summary
244
+ - Current phase, decisions, research cache location
245
+ - Ensures Claude stays aware of workflow
276
246
 
277
- 1. **Context First** - Understand WHY before HOW
278
- 2. **Research Thoroughly** - Find ALL parameters, not just documented
279
- 3. **Test First** - No implementation without failing test
280
- 4. **Document Everything** - Future you needs to understand this
281
- 5. **Verify Environment** - Check API keys before starting
282
- 6. **Consistent Process** - Same workflow every time
247
+ ### Research Freshness
283
248
 
284
- ## 🆚 Comparison
285
-
286
- ### Without API Dev Tools
249
+ Research is cached with 7-day validity:
287
250
  ```
288
- 1. Start coding immediately
289
- 2. Guess at parameters
290
- 3. Discover missing API keys mid-development
291
- 4. Write tests after implementation (if at all)
292
- 5. Forget to update documentation
293
- 6. Inconsistent patterns across endpoints
294
- 7. No progress tracking
295
-
296
- Result: Brittle APIs, poor docs, hard to maintain
251
+ .claude/research/
252
+ ├── brandfetch/
253
+ │ ├── 2025-12-08_initial.md
254
+ │ └── CURRENT.md
255
+ └── index.json ← Tracks freshness
297
256
  ```
298
257
 
299
- ### With API Dev Tools
300
- ```
301
- 1. Interview to understand requirements
302
- 2. Research to find ALL parameters
303
- 3. Verify environment before coding
304
- 4. Write failing tests first (TDD)
305
- 5. Implement with minimal code
306
- 6. Auto-update all documentation
307
- 7. Track progress throughout
308
-
309
- Result: Robust APIs, comprehensive docs, easy to maintain
310
- ```
311
-
312
- ## 🔒 Programmatic Enforcement (Hooks)
313
-
314
- Unlike pure markdown instructions that rely on Claude following directions, this package includes **real Python hooks** that enforce workflow compliance.
315
-
316
- ### How Hooks Work
317
-
258
+ If research is >7 days old:
318
259
  ```
319
- ┌─────────────────────────────────────────────────────────────┐
320
- │ USER: "Add Vercel AI SDK" │
321
- │ ↓ │
322
- │ CLAUDE: Calls WebSearch for docs │
323
- │ ↓ │
324
- │ HOOK: PostToolUse (track-tool-use.py) │
325
- │ → Logs search to api-dev-state.json │
326
- │ ↓ │
327
- │ CLAUDE: Tries to Write route.ts │
328
- │ ↓ │
329
- │ HOOK: PreToolUse (enforce-research.py) │
330
- │ → Checks: Has research been completed? │
331
- │ → If NO: BLOCKED with error message │
332
- │ → If YES: Allowed to proceed │
333
- │ ↓ │
334
- │ CLAUDE: Tries to stop conversation │
335
- │ ↓ │
336
- │ HOOK: Stop (api-workflow-check.py) │
337
- │ → Checks: Are all required phases complete? │
338
- │ → If NO: BLOCKED with list of incomplete phases │
339
- │ → If YES: Allowed to stop │
340
- └─────────────────────────────────────────────────────────────┘
260
+ ⚠️ Research for "brandfetch" is 15 days old.
261
+ Re-research before using? [Y/n]
341
262
  ```
342
263
 
343
- ### What Gets Enforced
344
-
345
- | Action | Hook | Enforcement |
346
- |--------|------|-------------|
347
- | Claude calls WebSearch/WebFetch/Context7 | `track-tool-use.py` | Logged to state file |
348
- | Claude tries to write API code | `enforce-research.py` | **BLOCKED** if no research logged |
349
- | Claude tries to stop | `api-workflow-check.py` | **BLOCKED** if phases incomplete |
350
-
351
- ### Check Progress Anytime
264
+ ## Installation
352
265
 
353
266
  ```bash
354
- # View current state
355
- cat .claude/api-dev-state.json | jq '.phases'
356
-
357
- # Or use the status command
358
- /api-status
267
+ cd your-project
268
+ npx @hustle-together/api-dev-tools --scope=project
359
269
  ```
360
270
 
361
- ### State File Structure
362
-
363
- The `.claude/api-dev-state.json` file tracks:
271
+ ### Team-Wide Auto-Installation
364
272
 
273
+ Add to `package.json`:
365
274
  ```json
366
275
  {
367
- "endpoint": "stream-text",
368
- "library": "vercel-ai-sdk",
369
- "phases": {
370
- "scope": { "status": "complete" },
371
- "research_initial": {
372
- "status": "complete",
373
- "sources": [
374
- { "type": "context7", "tool": "resolve_library_id" },
375
- { "type": "websearch", "query": "Vercel AI SDK docs" },
376
- { "type": "webfetch", "url": "https://sdk.vercel.ai" }
377
- ]
378
- },
379
- "interview": { "status": "complete" },
380
- "research_deep": { "status": "complete" },
381
- "schema_creation": { "status": "in_progress" },
382
- "tdd_red": { "status": "pending" },
383
- "tdd_green": { "status": "pending" },
384
- "tdd_refactor": { "status": "pending" },
385
- "documentation": { "status": "pending" }
386
- },
387
- "verification": {
388
- "all_sources_fetched": true,
389
- "schema_matches_docs": false,
390
- "tests_cover_params": false,
391
- "all_tests_passing": false
276
+ "scripts": {
277
+ "postinstall": "npx @hustle-together/api-dev-tools --scope=project"
392
278
  }
393
279
  }
394
280
  ```
395
281
 
396
- ### Why This Matters
397
-
398
- **Without hooks (pure markdown instructions):**
399
- - Claude *might* skip research if confident
400
- - Claude *might* use outdated training data
401
- - No way to verify steps were actually completed
402
-
403
- **With hooks (programmatic enforcement):**
404
- - Research is **required** - can't write code without it
405
- - All research activity is **logged** - auditable trail
406
- - Workflow completion is **verified** - can't stop early
407
-
408
- ## 🔍 Gap Detection & Verification (v1.6.0+)
282
+ ## Command Reference
409
283
 
410
- The workflow now includes automatic detection of common implementation gaps:
411
-
412
- ### Gap 1: Exact Term Matching
413
- **Problem:** AI paraphrases user terminology instead of using exact terms for research.
284
+ ### `/api-create [endpoint-name]`
414
285
 
415
- **Example:**
416
- - User says: "Use Vercel AI Gateway"
417
- - AI searches for: "Vercel AI SDK" (wrong!)
286
+ Complete 12-phase workflow. See [commands/api-create.md](commands/api-create.md).
418
287
 
419
- **Fix:** `verify-implementation.py` extracts key terms from interview answers and warns if those exact terms weren't used in research queries.
288
+ ### `/api-interview [endpoint-name]`
420
289
 
421
- ### Gap 2: File Change Tracking
422
- **Problem:** AI claims "all files updated" but doesn't verify which files actually changed.
290
+ Dynamic interview with questions FROM research. See [commands/api-interview.md](commands/api-interview.md).
423
291
 
424
- **Fix:** `api-workflow-check.py` runs `git diff --name-only` and compares against tracked `files_created`/`files_modified` in state. Warns about untracked changes.
292
+ ### `/api-research [library-name]`
425
293
 
426
- ### Gap 3: Skipped Test Investigation
427
- **Problem:** AI accepts "9 tests skipped" without investigating why.
294
+ Adaptive propose-approve research. See [commands/api-research.md](commands/api-research.md).
428
295
 
429
- **Fix:** `verification_warnings` in state file tracks issues that need review. Stop hook shows unaddressed warnings.
296
+ ### `/api-verify [endpoint-name]`
430
297
 
431
- ### Gap 4: Implementation Verification
432
- **Problem:** AI marks task complete without verifying implementation matches interview.
298
+ Manual Phase 9 verification. See [commands/api-verify.md](commands/api-verify.md).
433
299
 
434
- **Fix:** Stop hook checks that:
435
- - Route files exist if endpoints mentioned
436
- - Test files are tracked
437
- - Key terms from interview appear in implementation
300
+ ### `/api-env [endpoint-name]`
438
301
 
439
- ### Gap 5: Test/Production Alignment
440
- **Problem:** Test files check different environment variables than production code.
302
+ Environment and API key check. See [commands/api-env.md](commands/api-env.md).
441
303
 
442
- **Example:**
443
- - Interview: "single gateway key"
444
- - Production: uses `AI_GATEWAY_API_KEY`
445
- - Test: still checks `OPENAI_API_KEY` (wrong!)
304
+ ### `/api-status [endpoint-name]`
446
305
 
447
- **Fix:** `verify-implementation.py` warns when test files check env vars that don't match interview requirements.
306
+ Progress tracking. See [commands/api-status.md](commands/api-status.md).
448
307
 
449
- ### Gap 6: Training Data Reliance (v1.7.0+)
450
- **Problem:** AI answers questions about external APIs from potentially outdated training data instead of researching first.
308
+ ## State File Structure (v3.0)
451
309
 
452
- **Example:**
453
- - User asks: "What providers does Vercel AI Gateway support?"
454
- - AI answers from memory: "Groq not in gateway" (WRONG!)
455
- - Reality: Groq has 4 models in the gateway (Llama variants)
310
+ ```json
311
+ {
312
+ "version": "3.0.0",
313
+ "endpoint": "brandfetch",
314
+ "turn_count": 23,
315
+ "phases": {
316
+ "disambiguation": { "status": "complete" },
317
+ "scope": { "status": "complete" },
318
+ "research_initial": { "status": "complete", "sources": [...] },
319
+ "interview": {
320
+ "status": "complete",
321
+ "decisions": {
322
+ "format": ["json", "svg", "png"],
323
+ "quality_testing": "boundary"
324
+ }
325
+ },
326
+ "research_deep": {
327
+ "status": "complete",
328
+ "proposed_searches": [...],
329
+ "approved_searches": [...],
330
+ "skipped_searches": [...]
331
+ },
332
+ "schema_creation": { "status": "complete" },
333
+ "environment_check": { "status": "complete" },
334
+ "tdd_red": { "status": "complete", "test_count": 23 },
335
+ "tdd_green": { "status": "complete" },
336
+ "verify": {
337
+ "status": "complete",
338
+ "gaps_found": 2,
339
+ "gaps_fixed": 2,
340
+ "intentional_omissions": ["webhook support"]
341
+ },
342
+ "tdd_refactor": { "status": "complete" },
343
+ "documentation": { "status": "complete" }
344
+ },
345
+ "manifest_generation": {
346
+ "last_run": "2025-12-09T10:30:00.000Z",
347
+ "manifest_generated": true,
348
+ "parameters_extracted": true,
349
+ "test_results_collected": true,
350
+ "output_files": {
351
+ "manifest": "src/app/api-test/api-tests-manifest.json",
352
+ "parameters": "src/app/api-test/parameter-matrix.json",
353
+ "results": "src/app/api-test/test-results.json"
354
+ }
355
+ },
356
+ "reground_history": [
357
+ { "turn": 7, "phase": "interview" },
358
+ { "turn": 14, "phase": "tdd_red" }
359
+ ]
360
+ }
361
+ ```
456
362
 
457
- **Fix:** New `UserPromptSubmit` hook (`enforce-external-research.py`) that:
458
- 1. Detects questions about external APIs/SDKs using pattern matching
459
- 2. Injects context requiring research before answering
460
- 3. Works for ANY API (Brandfetch, Stripe, Twilio, etc.) - not just specific ones
461
- 4. Auto-allows WebSearch and Context7 without permission prompts
363
+ ## Hook Architecture
462
364
 
463
365
  ```
464
- USER: "What providers does Brandfetch API support?"
465
-
466
- HOOK: Detects "Brandfetch", "API", "providers"
467
-
468
- INJECTS: "RESEARCH REQUIRED: Use Context7/WebSearch before answering"
469
-
470
- CLAUDE: Researches first → Gives accurate answer
366
+ ┌──────────────────────────────────────────────────────────┐
367
+ │ SESSION START │
368
+ │ → session-startup.py injects current state │
369
+ └──────────────────────────────────────────────────────────┘
370
+
371
+
372
+ ┌──────────────────────────────────────────────────────────┐
373
+ │ USER PROMPT │
374
+ │ → enforce-external-research.py detects API terms │
375
+ └──────────────────────────────────────────────────────────┘
376
+
377
+
378
+ ┌──────────────────────────────────────────────────────────┐
379
+ │ RESEARCH TOOLS (WebSearch, Context7) │
380
+ │ → track-tool-use.py logs activity, counts turns │
381
+ │ → periodic-reground.py injects summary every 7 turns │
382
+ └──────────────────────────────────────────────────────────┘
383
+
384
+
385
+ ┌──────────────────────────────────────────────────────────┐
386
+ │ WRITE/EDIT TOOLS │
387
+ │ → enforce-research.py blocks if no research │
388
+ │ → enforce-interview.py injects decisions │
389
+ │ → verify-implementation.py checks test file exists │
390
+ └──────────────────────────────────────────────────────────┘
391
+
392
+
393
+ ┌──────────────────────────────────────────────────────────┐
394
+ │ TEST COMMANDS (pnpm test) │
395
+ │ → verify-after-green.py triggers Phase 9 after pass │
396
+ └──────────────────────────────────────────────────────────┘
397
+
398
+
399
+ ┌──────────────────────────────────────────────────────────┐
400
+ │ STOP │
401
+ │ → api-workflow-check.py blocks if phases incomplete │
402
+ └──────────────────────────────────────────────────────────┘
471
403
  ```
472
404
 
473
- ### Gap 7: Interview Decisions Not Used During Implementation (v1.9.0+)
474
- **Problem:** AI asks good interview questions but then ignores the answers when writing code.
475
-
476
- **Example:**
477
- - Interview: User selected "server environment variables only" for API key handling
478
- - Implementation: AI writes code with custom header overrides (not what user wanted!)
479
-
480
- **Fix:** Two-part solution in `track-tool-use.py` and `enforce-interview.py`:
405
+ ## Manual Script Usage
481
406
 
482
- 1. **track-tool-use.py** now captures:
483
- - The user's actual response from AskUserQuestion
484
- - Matches responses to option values
485
- - Stores decisions in categorized `decisions` dict (purpose, api_key_handling, etc.)
407
+ While scripts run automatically after tests pass, you can also run them manually:
486
408
 
487
- 2. **enforce-interview.py** now injects a decision summary on EVERY write:
488
- ```
489
- Interview complete. REMEMBER THE USER'S DECISIONS:
409
+ ```bash
410
+ # Generate manifest from test files
411
+ npx tsx scripts/api-dev-tools/generate-test-manifest.ts
490
412
 
491
- Primary Purpose: full_brand_kit
492
- API Key Handling: server_only
493
- • Response Format: JSON with asset URLs
494
- • Error Handling: detailed (error, code, details)
413
+ # Extract parameters and calculate coverage
414
+ npx tsx scripts/api-dev-tools/extract-parameters.ts
495
415
 
496
- Your implementation MUST align with these choices.
416
+ # Collect test results (runs Vitest)
417
+ npx tsx scripts/api-dev-tools/collect-test-results.ts
497
418
  ```
498
419
 
499
- This ensures the AI is constantly reminded of what the user actually wanted throughout the entire implementation phase.
420
+ Output files are written to `src/app/api-test/`:
421
+ - `api-tests-manifest.json` - Complete API documentation
422
+ - `parameter-matrix.json` - Parameter coverage analysis
423
+ - `test-results.json` - Latest test run results
500
424
 
501
- ## 🔧 Requirements
425
+ ## Requirements
502
426
 
503
427
  - **Node.js** 14.0.0 or higher
504
428
  - **Python 3** (for enforcement hooks)
505
429
  - **Claude Code** (CLI tool for Claude)
506
430
  - **Project structure** with `.claude/commands/` support
507
431
 
508
- ## 🔌 MCP Servers
509
-
510
- This package auto-configures two MCP servers:
432
+ ## MCP Servers (Auto-installed)
511
433
 
512
434
  ### Context7
513
- - **Live documentation lookup** from library source code
514
- - **Current API parameters** (not outdated training data)
515
- - **TypeScript type definitions** directly from packages
516
-
517
- When you research a library like `@ai-sdk/core`, Context7 fetches the actual current documentation rather than relying on Claude's training data which may be outdated.
435
+ - Live documentation from library source code
436
+ - Current API parameters (not training data)
518
437
 
519
438
  ### GitHub
520
- - **Issue management** - Read and create GitHub issues
521
- - **Pull requests** - Create PRs with proper formatting
522
- - **Repository access** - Browse repo contents and metadata
439
+ - Issue management
440
+ - Pull request creation
523
441
 
524
- Required for `/pr` and `/issue` commands to work with GitHub MCP tools.
442
+ Set `GITHUB_PERSONAL_ACCESS_TOKEN` for GitHub MCP.
525
443
 
526
- **Setup:** Set `GITHUB_PERSONAL_ACCESS_TOKEN` in your environment:
527
- ```bash
528
- export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_your_token_here
529
- ```
530
-
531
- The installer runs `claude mcp add` commands directly, which registers the servers in your Claude Code config (`~/.claude.json`). Restart Claude Code after installation for MCP tools to be available.
532
-
533
- ## 📖 Documentation
534
-
535
- After installation, see:
536
- - `.claude/commands/README.md` - Complete command reference
537
- - `.claude/commands/api-create.md` - Full workflow details
538
- - `.claude/commands/api-interview.md` - Interview questions
539
- - `.claude/commands/api-research.md` - Research methodology
444
+ ## Acknowledgments
540
445
 
541
- ## 🤝 Contributing
446
+ - **[@wbern/claude-instructions](https://github.com/wbern/claude-instructions)** - TDD commands
447
+ - **[Anthropic Interviewer](https://www.anthropic.com/news/anthropic-interviewer)** - Interview methodology
448
+ - **[Context7](https://context7.com)** - Live documentation lookup
542
449
 
543
- This is the initial release. Feedback welcome!
450
+ ## License
544
451
 
545
- **Ideas for improvement:**
546
- - Additional interview questions
547
- - More research sources
548
- - Integration with other tools
549
- - Custom templates
550
- - Multi-language support
452
+ MIT License
551
453
 
552
- ## 🙏 Acknowledgments
553
-
554
- ### @wbern/claude-instructions
555
- The TDD workflow commands (`/red`, `/green`, `/refactor`, `/cycle`) are based on the excellent [@wbern/claude-instructions](https://github.com/wbern/claude-instructions) package by **William Bernmalm**. This project extends those patterns with interview-driven API development, research enforcement hooks, and comprehensive state tracking.
556
-
557
- ### Anthropic
558
- The interview methodology is inspired by [Anthropic's Interviewer approach](https://www.anthropic.com/news/anthropic-interviewer) for structured discovery.
559
-
560
- ### Context7
561
- Special thanks to the [Context7](https://context7.com) team for providing live documentation lookup that makes research-first development possible.
562
-
563
- ---
564
-
565
- Thank you to the Claude Code community for making AI-assisted development more rigorous!
566
-
567
- ## 📄 License
568
-
569
- MIT License - Use freely in your projects
570
-
571
- ## 🔗 Links
454
+ ## Links
572
455
 
573
456
  - **Repository:** https://github.com/hustle-together/api-dev-tools
574
- - **Issues:** https://github.com/hustle-together/api-dev-tools/issues
575
457
  - **NPM:** https://www.npmjs.com/package/@hustle-together/api-dev-tools
576
458
 
577
- ## 💬 Support
578
-
579
- - Open an issue on GitHub
580
- - Check command documentation in `.claude/commands/README.md`
581
- - Review example workflows in the repository
582
-
583
459
  ---
584
460
 
585
- **Made with ❤️ for API developers using Claude Code**
461
+ **Made with care for API developers using Claude Code**
586
462
 
587
- *"Interview first, test first, document always"*
463
+ *"Disambiguate, research, interview, verify, repeat"*