@hustle-together/api-dev-tools 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mirror Factory
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,447 @@
1
+ # API Development Tools for Claude Code
2
+
3
+ **Interview-driven, research-first API development workflow**
4
+
5
+ Automates the complete API development lifecycle from understanding requirements to deployment through structured interviews, deep research, test-driven development, and comprehensive documentation.
6
+
7
+ ## 🚀 Quick Start
8
+
9
+ ```bash
10
+ # Install in your project
11
+ npx @hustle-together/api-dev-tools --scope=project
12
+
13
+ # Start developing an API
14
+ /api-create my-endpoint
15
+ ```
16
+
17
+ ## 📦 What This Installs
18
+
19
+ ### Slash Commands
20
+ Five powerful slash commands for Claude Code:
21
+
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)
25
+ - **`/api-env [endpoint]`** - Check required API keys and environment setup
26
+ - **`/api-status [endpoint]`** - Track implementation progress and phase completion
27
+
28
+ ### Enforcement Hooks
29
+ Three Python hooks that provide **real programmatic guarantees**:
30
+
31
+ - **`enforce-research.py`** - Blocks API code writing until research is complete
32
+ - **`track-tool-use.py`** - Logs all research activity (Context7, WebSearch, WebFetch)
33
+ - **`api-workflow-check.py`** - Prevents stopping until required phases are complete
34
+
35
+ ### State Tracking
36
+ - **`.claude/api-dev-state.json`** - Persistent state file tracking all workflow progress
37
+
38
+ ## 🎯 Why Use This?
39
+
40
+ ### Problems This Solves
41
+
42
+ - ❌ **Writing tests without understanding purpose** → Mechanical tests that miss real use cases
43
+ - ❌ **Incomplete API research** → Missing optional parameters and edge cases
44
+ - ❌ **Runtime errors from missing API keys** → Tests fail due to configuration issues
45
+ - ❌ **No documentation of real usage** → Future developers don't understand context
46
+ - ❌ **Inconsistent implementation patterns** → Every endpoint looks different
47
+
48
+ ### What You Get
49
+
50
+ - ✅ **Interview-first development** → Deep understanding before any code
51
+ - ✅ **Comprehensive research** → Discover ALL parameters, not just documented ones
52
+ - ✅ **Environment validation** → Verify API keys before starting
53
+ - ✅ **TDD enforced** → Red → Green → Refactor cycle mandatory
54
+ - ✅ **Auto-documentation** → Updates manifests, OpenAPI specs, status tracking
55
+ - ✅ **Consistent workflow** → Repeatable, testable, maintainable
56
+
57
+ ## 💡 How It Works
58
+
59
+ ### Fully Automated
60
+ ```bash
61
+ /api-create generate-pdf
62
+ ```
63
+
64
+ This single command:
65
+ 1. **Interviews you** about the endpoint (20 structured questions)
66
+ 2. **Researches** required libraries and external APIs
67
+ 3. **Checks environment** for API keys and configuration
68
+ 4. **Writes failing tests** first (TDD Red phase)
69
+ 5. **Implements** minimal solution (TDD Green phase)
70
+ 6. **Refactors** for quality (TDD Refactor phase)
71
+ 7. **Updates documentation** (manifests, OpenAPI, examples)
72
+ 8. **Creates commit** with semantic message
73
+
74
+ ### Manual Step-by-Step
75
+ ```bash
76
+ /api-interview generate-pdf # Understand purpose & requirements
77
+ /api-research pdf-lib # Research PDF library thoroughly
78
+ /api-env generate-pdf # Verify environment & API keys
79
+ /red # Write ONE failing test
80
+ /green # Implement to make it pass
81
+ /refactor # Clean up the code
82
+ /api-status generate-pdf # Update progress tracking
83
+ /commit # Create semantic commit
84
+ ```
85
+
86
+ ## 📋 Installation
87
+
88
+ ### One-Time Installation
89
+ ```bash
90
+ cd your-project
91
+ npx @hustle-together/api-dev-tools --scope=project
92
+ ```
93
+
94
+ ### Team-Wide Auto-Installation
95
+
96
+ Add to your project's `package.json`:
97
+ ```json
98
+ {
99
+ "scripts": {
100
+ "postinstall": "npx @hustle-together/api-dev-tools --scope=project"
101
+ }
102
+ }
103
+ ```
104
+
105
+ Now anyone who runs `npm install` or `pnpm install` gets the commands automatically.
106
+
107
+ ## 📚 Command Reference
108
+
109
+ ### `/api-create [endpoint-name]`
110
+
111
+ **The orchestrator.** Runs the complete workflow automatically.
112
+
113
+ **Example:**
114
+ ```bash
115
+ /api-create user-preferences
116
+ ```
117
+
118
+ **What it does:**
119
+ - Interviews you about requirements
120
+ - Researches dependencies (Next.js API routes, Zod, etc.)
121
+ - Checks environment (Supabase keys, etc.)
122
+ - Writes comprehensive tests
123
+ - Implements with Zod validation
124
+ - Updates all documentation
125
+ - Creates commit
126
+
127
+ ---
128
+
129
+ ### `/api-interview [endpoint-name]`
130
+
131
+ **Structured discovery.** 20-question interview based on Anthropic Interviewer methodology.
132
+
133
+ **Example:**
134
+ ```bash
135
+ /api-interview send-email
136
+ ```
137
+
138
+ **Questions cover:**
139
+ - Purpose & context
140
+ - Real-world usage scenarios
141
+ - Required vs. optional parameters
142
+ - Dependencies & API keys
143
+ - Error handling & edge cases
144
+ - Documentation sources
145
+
146
+ **Output:** `/src/v2/docs/endpoints/[endpoint-name].md`
147
+
148
+ ---
149
+
150
+ ### `/api-research [library-or-service]`
151
+
152
+ **Deep dive.** Discovers ALL parameters by reading source code and documentation.
153
+
154
+ **Example:**
155
+ ```bash
156
+ /api-research resend-api
157
+ ```
158
+
159
+ **Finds:**
160
+ - Official documentation links
161
+ - Complete request/response schemas
162
+ - Undocumented parameters (from source code)
163
+ - TypeScript type definitions
164
+ - Rate limits, quotas, costs
165
+ - Integration patterns
166
+ - Code examples
167
+
168
+ **Output:** `/src/v2/docs/research/[library-name].md`
169
+
170
+ ---
171
+
172
+ ### `/api-env [endpoint-name]`
173
+
174
+ **Environment check.** Verifies API keys and configuration before implementation.
175
+
176
+ **Example:**
177
+ ```bash
178
+ /api-env send-email
179
+ ```
180
+
181
+ **Checks:**
182
+ - Required API keys exist in `.env.local`
183
+ - Templates in `.env.example`
184
+ - `.gitignore` protects secrets
185
+ - Service connectivity (optional)
186
+
187
+ **Output:** Terminal report + action items
188
+
189
+ ---
190
+
191
+ ### `/api-status [endpoint-name]`
192
+
193
+ **Progress tracking.** Shows implementation status and phase completion.
194
+
195
+ **Examples:**
196
+ ```bash
197
+ /api-status send-email # Specific endpoint
198
+ /api-status --all # All endpoints
199
+ ```
200
+
201
+ **Tracks:**
202
+ - Interview completion
203
+ - Research completion
204
+ - Environment readiness
205
+ - TDD phases (Red → Green → Refactor)
206
+ - Documentation updates
207
+ - Test coverage
208
+
209
+ **Output:** Progress report + status document updates
210
+
211
+ ## 🔄 Workflow Integration
212
+
213
+ Works seamlessly with existing Claude Code commands:
214
+
215
+ ```bash
216
+ /plan # Create implementation checklist
217
+ /gap # Find missing pieces
218
+ /issue [url] # Start from GitHub issue
219
+
220
+ /api-create # ← Run complete API workflow
221
+
222
+ /commit # Semantic commit message
223
+ /pr # Create pull request
224
+ ```
225
+
226
+ ## 🎓 Methodology
227
+
228
+ Based on proven approaches:
229
+
230
+ - **[Anthropic Interviewer](https://www.anthropic.com/news/anthropic-interviewer)** - Structured interview methodology
231
+ - **TDD (Test-Driven Development)** - Red → Green → Refactor cycle
232
+ - **[@wbern/claude-instructions](https://github.com/wbern/claude-instructions)** - Slash command pattern
233
+ - **V2 Development Patterns** - Zod schemas, consistent structure
234
+
235
+ ## 📁 Output Artifacts
236
+
237
+ Each endpoint creates:
238
+
239
+ ```
240
+ src/app/api/v2/[endpoint]/
241
+ ├── route.ts # Handler with Zod schemas
242
+ ├── __tests__/
243
+ │ └── [endpoint].api.test.ts # Comprehensive tests (100% coverage)
244
+ └── README.md # Endpoint documentation
245
+
246
+ src/v2/docs/
247
+ ├── endpoints/
248
+ │ └── [endpoint].md # Interview results & requirements
249
+ └── research/
250
+ └── [library].md # External API research findings
251
+
252
+ Updated files:
253
+ - src/app/api-test/api-tests-manifest.json # Test documentation
254
+ - src/lib/openapi/endpoints/[endpoint].ts # OpenAPI spec
255
+ - src/v2/docs/v2-api-implementation-status.md # Progress tracking
256
+ ```
257
+
258
+ ## 🏗 Project Structure Required
259
+
260
+ This tool expects:
261
+ - **Next.js** API routes (`src/app/api/`)
262
+ - **Vitest** for testing
263
+ - **Zod** for validation
264
+ - **TypeScript** strict mode
265
+
266
+ Not tied to specific AI providers - works with any API architecture.
267
+
268
+ ## 🔑 Key Principles
269
+
270
+ 1. **Context First** - Understand WHY before HOW
271
+ 2. **Research Thoroughly** - Find ALL parameters, not just documented
272
+ 3. **Test First** - No implementation without failing test
273
+ 4. **Document Everything** - Future you needs to understand this
274
+ 5. **Verify Environment** - Check API keys before starting
275
+ 6. **Consistent Process** - Same workflow every time
276
+
277
+ ## 🆚 Comparison
278
+
279
+ ### Without API Dev Tools
280
+ ```
281
+ 1. Start coding immediately
282
+ 2. Guess at parameters
283
+ 3. Discover missing API keys mid-development
284
+ 4. Write tests after implementation (if at all)
285
+ 5. Forget to update documentation
286
+ 6. Inconsistent patterns across endpoints
287
+ 7. No progress tracking
288
+
289
+ Result: Brittle APIs, poor docs, hard to maintain
290
+ ```
291
+
292
+ ### With API Dev Tools
293
+ ```
294
+ 1. Interview to understand requirements
295
+ 2. Research to find ALL parameters
296
+ 3. Verify environment before coding
297
+ 4. Write failing tests first (TDD)
298
+ 5. Implement with minimal code
299
+ 6. Auto-update all documentation
300
+ 7. Track progress throughout
301
+
302
+ Result: Robust APIs, comprehensive docs, easy to maintain
303
+ ```
304
+
305
+ ## 🔒 Programmatic Enforcement (Hooks)
306
+
307
+ Unlike pure markdown instructions that rely on Claude following directions, this package includes **real Python hooks** that enforce workflow compliance.
308
+
309
+ ### How Hooks Work
310
+
311
+ ```
312
+ ┌─────────────────────────────────────────────────────────────┐
313
+ │ USER: "Add Vercel AI SDK" │
314
+ │ ↓ │
315
+ │ CLAUDE: Calls WebSearch for docs │
316
+ │ ↓ │
317
+ │ HOOK: PostToolUse (track-tool-use.py) │
318
+ │ → Logs search to api-dev-state.json │
319
+ │ ↓ │
320
+ │ CLAUDE: Tries to Write route.ts │
321
+ │ ↓ │
322
+ │ HOOK: PreToolUse (enforce-research.py) │
323
+ │ → Checks: Has research been completed? │
324
+ │ → If NO: BLOCKED with error message │
325
+ │ → If YES: Allowed to proceed │
326
+ │ ↓ │
327
+ │ CLAUDE: Tries to stop conversation │
328
+ │ ↓ │
329
+ │ HOOK: Stop (api-workflow-check.py) │
330
+ │ → Checks: Are all required phases complete? │
331
+ │ → If NO: BLOCKED with list of incomplete phases │
332
+ │ → If YES: Allowed to stop │
333
+ └─────────────────────────────────────────────────────────────┘
334
+ ```
335
+
336
+ ### What Gets Enforced
337
+
338
+ | Action | Hook | Enforcement |
339
+ |--------|------|-------------|
340
+ | Claude calls WebSearch/WebFetch/Context7 | `track-tool-use.py` | Logged to state file |
341
+ | Claude tries to write API code | `enforce-research.py` | **BLOCKED** if no research logged |
342
+ | Claude tries to stop | `api-workflow-check.py` | **BLOCKED** if phases incomplete |
343
+
344
+ ### Check Progress Anytime
345
+
346
+ ```bash
347
+ # View current state
348
+ cat .claude/api-dev-state.json | jq '.phases'
349
+
350
+ # Or use the status command
351
+ /api-status
352
+ ```
353
+
354
+ ### State File Structure
355
+
356
+ The `.claude/api-dev-state.json` file tracks:
357
+
358
+ ```json
359
+ {
360
+ "endpoint": "stream-text",
361
+ "library": "vercel-ai-sdk",
362
+ "phases": {
363
+ "scope": { "status": "complete" },
364
+ "research_initial": {
365
+ "status": "complete",
366
+ "sources": [
367
+ { "type": "context7", "tool": "resolve_library_id" },
368
+ { "type": "websearch", "query": "Vercel AI SDK docs" },
369
+ { "type": "webfetch", "url": "https://sdk.vercel.ai" }
370
+ ]
371
+ },
372
+ "interview": { "status": "complete" },
373
+ "research_deep": { "status": "complete" },
374
+ "schema_creation": { "status": "in_progress" },
375
+ "tdd_red": { "status": "pending" },
376
+ "tdd_green": { "status": "pending" },
377
+ "tdd_refactor": { "status": "pending" },
378
+ "documentation": { "status": "pending" }
379
+ },
380
+ "verification": {
381
+ "all_sources_fetched": true,
382
+ "schema_matches_docs": false,
383
+ "tests_cover_params": false,
384
+ "all_tests_passing": false
385
+ }
386
+ }
387
+ ```
388
+
389
+ ### Why This Matters
390
+
391
+ **Without hooks (pure markdown instructions):**
392
+ - Claude *might* skip research if confident
393
+ - Claude *might* use outdated training data
394
+ - No way to verify steps were actually completed
395
+
396
+ **With hooks (programmatic enforcement):**
397
+ - Research is **required** - can't write code without it
398
+ - All research activity is **logged** - auditable trail
399
+ - Workflow completion is **verified** - can't stop early
400
+
401
+ ## 🔧 Requirements
402
+
403
+ - **Node.js** 14.0.0 or higher
404
+ - **Python 3** (for enforcement hooks)
405
+ - **Claude Code** (CLI tool for Claude)
406
+ - **Project structure** with `.claude/commands/` support
407
+
408
+ ## 📖 Documentation
409
+
410
+ After installation, see:
411
+ - `.claude/commands/README.md` - Complete command reference
412
+ - `.claude/commands/api-create.md` - Full workflow details
413
+ - `.claude/commands/api-interview.md` - Interview questions
414
+ - `.claude/commands/api-research.md` - Research methodology
415
+
416
+ ## 🤝 Contributing
417
+
418
+ This is the initial release. Feedback welcome!
419
+
420
+ **Ideas for improvement:**
421
+ - Additional interview questions
422
+ - More research sources
423
+ - Integration with other tools
424
+ - Custom templates
425
+ - Multi-language support
426
+
427
+ ## 📄 License
428
+
429
+ MIT License - Use freely in your projects
430
+
431
+ ## 🔗 Links
432
+
433
+ - **Repository:** https://github.com/hustle-together/api-dev-tools
434
+ - **Issues:** https://github.com/hustle-together/api-dev-tools/issues
435
+ - **NPM:** https://www.npmjs.com/package/@hustle-together/api-dev-tools
436
+
437
+ ## 💬 Support
438
+
439
+ - Open an issue on GitHub
440
+ - Check command documentation in `.claude/commands/README.md`
441
+ - Review example workflows in the repository
442
+
443
+ ---
444
+
445
+ **Made with ❤️ for API developers using Claude Code**
446
+
447
+ *"Interview first, test first, document always"*