@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.
@@ -0,0 +1,209 @@
1
+ ---
2
+ description: Guide for creating new slash commands
3
+ argument-hint: <command-name> <description>
4
+ ---
5
+
6
+ ## General Guidelines
7
+
8
+ ### Output Style
9
+
10
+ - **Never explicitly mention TDD** in code, comments, commits, PRs, or issues
11
+ - Write natural, descriptive code without meta-commentary about the development process
12
+ - The code should speak for itself - TDD is the process, not the product
13
+
14
+ # Slash Command Creator Guide
15
+
16
+ ## How This Command Works
17
+
18
+ The `/add-command` command shows this guide for creating new slash commands. It includes:
19
+
20
+ - Command structure and syntax
21
+ - Common patterns and examples
22
+ - Security restrictions and limitations
23
+ - Frontmatter options
24
+
25
+ **Note for AI**: When creating commands, you CAN use bash tools like `Bash(mkdir:*)`, `Bash(ls:*)`, `Bash(git status:*)` in the `allowed-tools` frontmatter of NEW commands - but ONLY for operations within the current project directory. This command itself doesn't need bash tools since it's just documentation.
26
+
27
+ ## Command Locations
28
+
29
+ - **Personal**: `~/.claude/commands/` (available across all projects)
30
+ - **Project**: `.claude/commands/` (shared with team, shows "(project)")
31
+
32
+ ## Basic Structure
33
+
34
+ ```markdown
35
+ ---
36
+ allowed-tools: Read, Glob, Grep, Bash(git status:*), Task
37
+ description: Brief description of what this command does
38
+ argument-hint: [required-arg] [optional-arg]
39
+ ---
40
+
41
+ # Command Title
42
+
43
+ Your command instructions here.
44
+
45
+ Arguments: $ARGUMENTS
46
+
47
+ File reference: @path/to/file.js
48
+
49
+ Bash command output: (exclamation)git status(backticks)
50
+ ```
51
+
52
+ ## ⚠️ Security Restrictions
53
+
54
+ **Bash Commands (exclamation prefix)**: Limited to current working directory only.
55
+
56
+ - ✅ Works: `! + backtick + git status + backtick` (in project dir)
57
+ - ❌ Blocked: `! + backtick + ls /outside/project + backtick` (outside project)
58
+ - ❌ Blocked: `! + backtick + pwd + backtick` (if referencing dirs outside project)
59
+
60
+ **File References (`@` prefix)**: No directory restrictions.
61
+
62
+ - ✅ Works: `@/path/to/system/file.md`
63
+ - ✅ Works: `@../other-project/file.js`
64
+
65
+ ## Common Patterns
66
+
67
+ ### Simple Command
68
+
69
+ ```bash
70
+ echo "Review this code for bugs and suggest fixes" > ~/.claude/commands/review.md
71
+ ```
72
+
73
+ ### Command with Arguments
74
+
75
+ **Note for AI**: The example below uses a fullwidth dollar sign ($, U+FF04) to prevent interpolation in this documentation. When creating actual commands, use the regular `$` character.
76
+
77
+ ```markdown
78
+ Fix issue $ARGUMENTS following our coding standards
79
+ ```
80
+
81
+ ### Command with File References
82
+
83
+ ```markdown
84
+ Compare @src/old.js with @src/new.js and explain differences
85
+ ```
86
+
87
+ ### Command with Bash Output (Project Directory Only)
88
+
89
+ ```markdown
90
+ ---
91
+ allowed-tools: Bash(git status:*), Bash(git branch:*), Bash(git log:*)
92
+ ---
93
+ Current status: (!)git status(`)
94
+ Current branch: (!)git branch --show-current(`)
95
+ Recent commits: (!)git log --oneline -5(`)
96
+
97
+ Create commit for these changes.
98
+ ```
99
+
100
+ **Note**: Only works with commands in the current project directory.
101
+
102
+ ### Namespaced Command
103
+
104
+ **Note for AI**: The example below uses a fullwidth dollar sign ($, U+FF04) to prevent interpolation in this documentation. When creating actual commands, use the regular `$` character.
105
+
106
+ ```bash
107
+ mkdir -p ~/.claude/commands/ai
108
+ echo "Ask GPT-5 about: $ARGUMENTS" > ~/.claude/commands/ai/gpt5.md
109
+ # Creates: /ai:gpt5
110
+ ```
111
+
112
+ ## Frontmatter Options
113
+
114
+ - `allowed-tools`: Tools this command can use
115
+ - **Important**: Intrusive tools like `Write`, `Edit`, `NotebookEdit` should NEVER be allowed in commands unless the user explicitly requests them. These tools modify files and should only be used when the command's purpose is to make changes.
116
+ - ✅ Safe for most commands: `Read`, `Glob`, `Grep`, `Bash(git status:*)`, `Task`, `AskUserQuestion`
117
+ - `description`: Brief description (shows in /help)
118
+ - `argument-hint`: Help text for arguments
119
+ - `model`: Specific model to use
120
+
121
+ ## Best Practices
122
+
123
+ ### Safe Commands (No Security Issues)
124
+
125
+ ```markdown
126
+ # System prompt editor (file reference only)
127
+ (@)path/to/system/prompt.md
128
+
129
+ Edit your system prompt above.
130
+ ```
131
+
132
+ ### Project-Specific Commands (Bash OK)
133
+
134
+ ```markdown
135
+ ---
136
+ allowed-tools: Bash(git status:*), Bash(npm list:*)
137
+ ---
138
+ Current git status: (!)git status(`)
139
+ Package info: (!)npm list --depth=0(`)
140
+
141
+ Review project state and suggest next steps.
142
+ ```
143
+
144
+ ### Cross-Directory File Access (Use @ not !)
145
+
146
+ ```markdown
147
+ # Compare config files
148
+ Compare (@)path/to/system.md with (@)project/config.md
149
+
150
+ Show differences and suggest improvements.
151
+ ```
152
+
153
+ ## Usage
154
+
155
+ After creating: `/<command-name> [arguments]`
156
+
157
+ Example: `/review` or `/ai:gpt5 "explain this code"`
158
+
159
+
160
+ ## 🛡 Project Rules (Injected into every command)
161
+
162
+ 1. **NO BROKEN BUILDS:**
163
+ - Run `pnpm test` before every `/commit`
164
+ - Ensure all tests pass
165
+ - Fix any type errors immediately
166
+
167
+ 2. **API DEVELOPMENT:**
168
+ - All new APIs MUST have Zod request/response schemas
169
+ - All APIs MUST be documented in both:
170
+ - OpenAPI spec ([src/lib/openapi/](src/lib/openapi/))
171
+ - API test manifest ([src/app/api-test/api-tests-manifest.json](src/app/api-test/api-tests-manifest.json))
172
+ - Test ALL parameters and edge cases
173
+ - Include code examples and real-world outputs
174
+
175
+ 3. **TDD WORKFLOW:**
176
+ - ALWAYS use /red → /green → /refactor cycle
177
+ - NEVER write implementation without failing test first
178
+ - Use /cycle for feature development
179
+ - Use characterization tests for refactoring
180
+
181
+ 4. **API KEY MANAGEMENT:**
182
+ - Support three loading methods:
183
+ - Server environment variables
184
+ - NEXT_PUBLIC_ variables (client-side)
185
+ - Custom headers (X-OpenAI-Key, X-Anthropic-Key, etc.)
186
+ - Never hardcode API keys
187
+ - Always validate key availability before use
188
+
189
+ 5. **COMPREHENSIVE TESTING:**
190
+ - When researching APIs, read actual implementation code
191
+ - Discover ALL possible parameters (not just documented ones)
192
+ - Test with various parameter combinations
193
+ - Document custom headers, query params, request/response schemas
194
+ - Include validation rules and testing notes
195
+
196
+ 6. **NO UI BLOAT:**
197
+ - This is an API project with minimal frontend
198
+ - Only keep necessary test/documentation interfaces
199
+ - Delete unused components immediately
200
+ - No unnecessary UI libraries or features
201
+
202
+ 7. **DOCUMENTATION:**
203
+ - If you change an API, you MUST update:
204
+ - OpenAPI spec
205
+ - api-tests-manifest.json
206
+ - Code examples
207
+ - Testing notes
208
+ - Document expected behavior and edge cases
209
+ - Include real-world output examples
@@ -0,0 +1,166 @@
1
+ # API Create - Comprehensive API Development Workflow
2
+
3
+ **Usage:** `/api-create [endpoint-name]`
4
+
5
+ **Purpose:** Orchestrates the complete API development workflow using interview-driven, test-first methodology.
6
+
7
+ ## Workflow Steps
8
+
9
+ This command executes the following phases automatically:
10
+
11
+ ### Phase 1: Planning & Research
12
+ 1. **Documentation Discovery**
13
+ - Search for official API documentation
14
+ - Track all documentation links
15
+ - Identify available SDKs and libraries
16
+ - Document version requirements
17
+
18
+ 2. **User Interview** (Anthropic Interviewer methodology)
19
+ - What is this API endpoint for? (Purpose)
20
+ - Who will use it? (Users)
21
+ - When/where will it be used? (Context)
22
+ - What are common use cases? (Real-world scenarios)
23
+ - What are edge cases to handle? (Boundaries)
24
+ - What are dependencies? (External services, API keys)
25
+
26
+ ### Phase 2: Documentation & Schema
27
+ 3. **Schema Documentation**
28
+ - Document ALL request parameters (required + optional)
29
+ - Document ALL response fields
30
+ - Create Zod request schema
31
+ - Create Zod response schema
32
+ - Document validation rules
33
+ - Document error cases
34
+
35
+ 4. **Environment Setup**
36
+ - Identify required API keys
37
+ - Check .env.example for keys
38
+ - Verify environment variables
39
+ - Document custom header support
40
+ - Create setup instructions
41
+
42
+ ### Phase 3: TDD Implementation
43
+ 5. **Red Phase** - Write failing tests
44
+ - Test basic success case
45
+ - Test all parameter combinations
46
+ - Test validation failures
47
+ - Test error handling
48
+ - Test edge cases from interview
49
+ - Run tests (should fail)
50
+
51
+ 6. **Green Phase** - Minimal implementation
52
+ - Create route handler
53
+ - Implement Zod validation
54
+ - Add AI SDK integration
55
+ - Pass all tests
56
+ - Run tests (should pass)
57
+
58
+ 7. **Refactor Phase** - Clean up
59
+ - Extract reusable patterns
60
+ - Improve error messages
61
+ - Add JSDoc comments
62
+ - Optimize performance
63
+ - Run tests (should still pass)
64
+
65
+ ### Phase 4: Documentation & Integration
66
+ 8. **Update Documentation**
67
+ - Add to `/src/app/api-test/api-tests-manifest.json`
68
+ - Update `/src/v2/docs/v2-api-implementation-status.md`
69
+ - Add OpenAPI spec to `/src/lib/openapi/`
70
+ - Include code examples
71
+ - Document real-world outputs
72
+ - Add testing notes
73
+
74
+ 9. **Final Validation**
75
+ - Run full test suite
76
+ - Check test coverage (must be 100%)
77
+ - Verify TypeScript compilation
78
+ - Test in API test interface
79
+ - Create commit with `/commit`
80
+
81
+ ## Template for Interview
82
+
83
+ When executing this command, conduct the following interview:
84
+
85
+ ```
86
+ ## API Endpoint: [endpoint-name]
87
+
88
+ ### 1. Purpose & Context
89
+ - **What problem does this solve?**
90
+ - **Who are the primary users?**
91
+ - **What triggers usage of this API?**
92
+
93
+ ### 2. Real-World Usage
94
+ - **Describe a typical request scenario:**
95
+ - **What are the most common parameters?**
96
+ - **What does a successful response look like?**
97
+
98
+ ### 3. Parameters & Configuration
99
+ - **What parameters are REQUIRED?**
100
+ - **What parameters are OPTIONAL?**
101
+ - **What are valid value ranges/formats?**
102
+ - **Are there parameter dependencies?**
103
+
104
+ ### 4. Dependencies & Integration
105
+ - **What external services does this use?**
106
+ - **What API keys are required?**
107
+ - **What AI models/providers are involved?**
108
+ - **Are there rate limits or quotas?**
109
+
110
+ ### 5. Edge Cases & Errors
111
+ - **What can go wrong?**
112
+ - **How should errors be handled?**
113
+ - **What are boundary conditions?**
114
+ - **What should be validated?**
115
+
116
+ ### 6. Documentation Sources
117
+ - **Official documentation links:**
118
+ - **SDK/library documentation:**
119
+ - **Related endpoints or examples:**
120
+ ```
121
+
122
+ ## Output Artifacts
123
+
124
+ This command creates:
125
+
126
+ 1. **Interview Document**: `/src/v2/docs/endpoints/[endpoint-name].md`
127
+ 2. **Route Handler**: `/src/app/api/v2/[endpoint-name]/route.ts`
128
+ 3. **Test Suite**: `/src/app/api/v2/[endpoint-name]/__tests__/[endpoint-name].api.test.ts`
129
+ 4. **OpenAPI Spec**: `/src/lib/openapi/endpoints/[endpoint-name].ts`
130
+ 5. **Updated Manifests**:
131
+ - `/src/app/api-test/api-tests-manifest.json`
132
+ - `/src/v2/docs/v2-api-implementation-status.md`
133
+
134
+ ## Execution
135
+
136
+ Execute this command and I will:
137
+ 1. ✅ Start the interview to understand the endpoint
138
+ 2. ✅ Research and document all available options
139
+ 3. ✅ Create comprehensive Zod schemas
140
+ 4. ✅ Verify environment/API key requirements
141
+ 5. ✅ Write failing tests first (TDD Red)
142
+ 6. ✅ Implement minimal passing code (TDD Green)
143
+ 7. ✅ Refactor for quality (TDD Refactor)
144
+ 8. ✅ Update all documentation and manifests
145
+ 9. ✅ Verify 100% test coverage
146
+ 10. ✅ Create semantic commit
147
+
148
+ <claude-commands-template>
149
+ ## Project-Specific Rules
150
+
151
+ 1. **API Location**: All V2 APIs go in `/src/app/api/v2/[endpoint-name]/`
152
+ 2. **Testing**: Use Vitest, require 100% coverage
153
+ 3. **Validation**: All requests/responses use Zod schemas
154
+ 4. **AI SDK**: Use Vercel AI SDK 5.0.11 patterns from `/src/v2/docs/ai-sdk-catalog.json`
155
+ 5. **Package Manager**: Use `pnpm` for all operations
156
+ 6. **Documentation**: Follow patterns in `/src/v2/docs/Main Doc – V2 Development Patterns.md`
157
+ 7. **API Keys**: Support three methods (env, NEXT_PUBLIC_, custom headers)
158
+ 8. **Test Command**: `pnpm test:run` before commits
159
+
160
+ ## Never Skip
161
+ - Interview phase (understand before coding)
162
+ - Documentation research (find ALL parameters)
163
+ - Failing tests first (TDD Red is mandatory)
164
+ - Manifest updates (keep docs in sync)
165
+ - Coverage verification (100% required)
166
+ </claude-commands-template>
@@ -0,0 +1,50 @@
1
+ # API Environment - Check API Keys & Configuration
2
+
3
+ **Usage:** `/api-env [endpoint-name]`
4
+
5
+ **Purpose:** Quick check for required API keys and environment setup before implementation.
6
+
7
+ ## What This Checks
8
+
9
+ 1. **Reads endpoint documentation** to identify required services
10
+ 2. **Checks .env.local** for API keys
11
+ 3. **Verifies .env.example** has templates
12
+ 4. **Reports missing keys** with setup instructions
13
+
14
+ ## Output
15
+
16
+ ```
17
+ 🔑 Environment Check: [endpoint-name]
18
+
19
+ Required API Keys:
20
+ ✅ OPENAI_API_KEY (found)
21
+ ❌ FIRECRAWL_API_KEY (missing)
22
+
23
+ Action Required:
24
+ 1. Get key from https://firecrawl.dev
25
+ 2. Add to .env.local: FIRECRAWL_API_KEY=fc-...
26
+ 3. Add to .env.example template
27
+
28
+ Status: BLOCKED - Cannot proceed without FIRECRAWL_API_KEY
29
+ ```
30
+
31
+ ## Usage in Workflow
32
+
33
+ ```bash
34
+ # Before starting implementation
35
+ /api-interview generate-css
36
+ /api-research firecrawl
37
+ /api-env generate-css ← Check keys
38
+ /red ← Start TDD if ready
39
+ ```
40
+
41
+ <claude-commands-template>
42
+ ## API Key Support
43
+
44
+ The project supports three methods:
45
+ 1. Server env: `OPENAI_API_KEY=sk-...`
46
+ 2. Client env: `NEXT_PUBLIC_OPENAI_API_KEY=sk-...`
47
+ 3. Custom headers: `X-OpenAI-Key: sk-...`
48
+
49
+ Check src/lib/api-keys.ts for implementation.
50
+ </claude-commands-template>
@@ -0,0 +1,211 @@
1
+ # API Interview - Structured API Discovery
2
+
3
+ **Usage:** `/api-interview [endpoint-name]`
4
+
5
+ **Purpose:** Conduct structured interview to understand API endpoint purpose, usage, and requirements before any implementation.
6
+
7
+ ## Interview Methodology
8
+
9
+ Based on Anthropic Interviewer approach with three phases:
10
+
11
+ ### Phase 1: Planning (Internal)
12
+ - Review endpoint name and context
13
+ - Identify key areas to explore
14
+ - Prepare follow-up questions
15
+
16
+ ### Phase 2: Interviewing (User Interaction)
17
+ Ask structured questions to understand:
18
+
19
+ #### A. Purpose & Context
20
+ 1. **What problem does this API endpoint solve?**
21
+ - What's the business/technical need?
22
+ - What happens without this endpoint?
23
+
24
+ 2. **Who are the primary users?**
25
+ - Frontend developers? End users? Other systems?
26
+ - What's their technical level?
27
+
28
+ 3. **What triggers usage of this API?**
29
+ - User action? Scheduled task? Event-driven?
30
+ - How frequently is it called?
31
+
32
+ #### B. Real-World Usage Scenarios
33
+ 4. **Walk me through a typical request:**
34
+ - What data does the user provide?
35
+ - What do they expect back?
36
+ - What happens with the response?
37
+
38
+ 5. **What are the most common use cases?** (Ask for 3-5 examples)
39
+ - Common scenario 1: ___
40
+ - Common scenario 2: ___
41
+ - Edge scenario: ___
42
+
43
+ 6. **Show me an example request/response you envision:**
44
+ - Request body/params
45
+ - Expected response
46
+ - Error cases
47
+
48
+ #### C. Technical Requirements
49
+ 7. **What parameters are absolutely REQUIRED?**
50
+ - Can the API work without them?
51
+ - What happens if they're missing?
52
+
53
+ 8. **What parameters are OPTIONAL?**
54
+ - What defaults make sense?
55
+ - How do they modify behavior?
56
+
57
+ 9. **What are valid value ranges/formats?**
58
+ - Type constraints (string, number, enum)?
59
+ - Length/size limits?
60
+ - Format requirements (email, URL, date)?
61
+
62
+ 10. **Are there parameter dependencies?**
63
+ - If X is provided, must Y also be provided?
64
+ - Mutually exclusive options?
65
+
66
+ #### D. Dependencies & Integration
67
+ 11. **What external services does this use?**
68
+ - AI providers (OpenAI, Anthropic, Google)?
69
+ - Third-party APIs (Firecrawl, Brave Search)?
70
+ - Database (Supabase)?
71
+
72
+ 12. **What API keys are required?**
73
+ - Where are they configured?
74
+ - Are there fallback options?
75
+ - Can users provide their own keys?
76
+
77
+ 13. **What AI models/providers are involved?**
78
+ - Specific models (GPT-4, Claude Sonnet)?
79
+ - Why those models?
80
+ - Are there alternatives?
81
+
82
+ 14. **Are there rate limits, quotas, or costs?**
83
+ - Per-request costs?
84
+ - Rate limiting needed?
85
+ - Cost tracking required?
86
+
87
+ #### E. Error Handling & Edge Cases
88
+ 15. **What can go wrong?**
89
+ - Invalid input?
90
+ - External service failures?
91
+ - Timeout scenarios?
92
+
93
+ 16. **How should errors be communicated?**
94
+ - HTTP status codes?
95
+ - Error message format?
96
+ - User-facing vs. technical errors?
97
+
98
+ 17. **What are boundary conditions?**
99
+ - Very large inputs?
100
+ - Empty/null values?
101
+ - Concurrent requests?
102
+
103
+ 18. **What should be validated before processing?**
104
+ - Input validation rules?
105
+ - Authentication/authorization?
106
+ - Resource availability?
107
+
108
+ #### F. Documentation & Resources
109
+ 19. **Where is official documentation?**
110
+ - Link to external API docs
111
+ - SDK documentation
112
+ - Code examples
113
+
114
+ 20. **Are there similar endpoints for reference?**
115
+ - In this codebase?
116
+ - In other projects?
117
+ - Industry examples?
118
+
119
+ ### Phase 3: Analysis (Documentation)
120
+ After interview, I will:
121
+ - Synthesize answers into structured document
122
+ - Identify gaps or ambiguities
123
+ - Create preliminary schema based on answers
124
+ - Document all external links and resources
125
+ - Outline test cases from real-world scenarios
126
+
127
+ ## Output
128
+
129
+ Creates: `/src/v2/docs/endpoints/[endpoint-name].md`
130
+
131
+ **Document Structure:**
132
+ ```markdown
133
+ # API Endpoint: [endpoint-name]
134
+
135
+ **Date:** [current-date]
136
+ **Interviewed by:** Claude Code
137
+ **Status:** Interview Complete
138
+
139
+ ## 1. Purpose & Context
140
+ [Synthesized understanding of why this exists]
141
+
142
+ ## 2. Users & Usage Patterns
143
+ [Who uses it and how]
144
+
145
+ ## 3. Request Schema (Preliminary)
146
+ [Zod-style schema based on interview]
147
+
148
+ ## 4. Response Schema (Preliminary)
149
+ [Expected response structure]
150
+
151
+ ## 5. Dependencies
152
+ - External Services: [list]
153
+ - API Keys Required: [list]
154
+ - AI Models: [list]
155
+
156
+ ## 6. Real-World Scenarios
157
+ ### Scenario 1: [Common Use Case]
158
+ **Request:**
159
+ ```json
160
+ {example}
161
+ ```
162
+ **Response:**
163
+ ```json
164
+ {example}
165
+ ```
166
+
167
+ ## 7. Edge Cases & Error Handling
168
+ [Identified edge cases and how to handle them]
169
+
170
+ ## 8. Validation Rules
171
+ [What must be validated]
172
+
173
+ ## 9. Documentation Links
174
+ - [Official docs]
175
+ - [SDK docs]
176
+ - [Related resources]
177
+
178
+ ## 10. Test Cases (To Implement)
179
+ - [ ] Test: [scenario from interview]
180
+ - [ ] Test: [edge case from interview]
181
+ - [ ] Test: [error handling from interview]
182
+
183
+ ## 11. Open Questions
184
+ [Any ambiguities to resolve]
185
+ ```
186
+
187
+ ## Usage Example
188
+
189
+ ```bash
190
+ /api-interview generate-css
191
+ ```
192
+
193
+ I will then ask all 20 questions, document responses, and create the endpoint documentation file ready for TDD implementation.
194
+
195
+ <claude-commands-template>
196
+ ## Interview Guidelines
197
+
198
+ 1. **Ask ALL questions** - Don't skip steps even if obvious
199
+ 2. **Request examples** - Concrete examples > abstract descriptions
200
+ 3. **Clarify ambiguity** - If answer is unclear, ask follow-ups
201
+ 4. **Document links** - Capture ALL external documentation URLs
202
+ 5. **Real scenarios** - Focus on actual usage, not hypothetical
203
+ 6. **Be thorough** - Better to over-document than under-document
204
+
205
+ ## After Interview
206
+
207
+ - Read interview document before implementing
208
+ - Refer to it during TDD cycles
209
+ - Update it if requirements change
210
+ - Use it for code review context
211
+ </claude-commands-template>