@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 +21 -0
- package/README.md +447 -0
- package/bin/cli.js +322 -0
- package/commands/README.md +312 -0
- package/commands/add-command.md +209 -0
- package/commands/api-create.md +166 -0
- package/commands/api-env.md +50 -0
- package/commands/api-interview.md +211 -0
- package/commands/api-research.md +279 -0
- package/commands/api-status.md +259 -0
- package/commands/beepboop.md +97 -0
- package/commands/busycommit.md +112 -0
- package/commands/commit.md +83 -0
- package/commands/cycle.md +142 -0
- package/commands/gap.md +86 -0
- package/commands/green.md +142 -0
- package/commands/issue.md +192 -0
- package/commands/plan.md +168 -0
- package/commands/pr.md +122 -0
- package/commands/red.md +142 -0
- package/commands/refactor.md +142 -0
- package/commands/spike.md +142 -0
- package/commands/summarize.md +94 -0
- package/commands/tdd.md +144 -0
- package/commands/worktree-add.md +315 -0
- package/commands/worktree-cleanup.md +281 -0
- package/hooks/api-workflow-check.py +116 -0
- package/hooks/enforce-research.py +112 -0
- package/hooks/track-tool-use.py +194 -0
- package/package.json +45 -0
- package/templates/api-dev-state.json +65 -0
- package/templates/settings.json +36 -0
package/bin/cli.js
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* API Development Tools Installer
|
|
9
|
+
*
|
|
10
|
+
* Installs slash commands AND enforcement hooks for interview-driven API development.
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Slash commands in .claude/commands/
|
|
14
|
+
* - Python hooks for programmatic enforcement
|
|
15
|
+
* - Settings configuration for hook registration
|
|
16
|
+
* - State file template for progress tracking
|
|
17
|
+
*
|
|
18
|
+
* Usage: npx @mirror-factory/api-dev-tools --scope=project
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// Parse command-line arguments
|
|
22
|
+
const args = process.argv.slice(2);
|
|
23
|
+
const scope = args.find(arg => arg.startsWith('--scope='))?.split('=')[1] || 'project';
|
|
24
|
+
|
|
25
|
+
// Colors for terminal output
|
|
26
|
+
const colors = {
|
|
27
|
+
reset: '\x1b[0m',
|
|
28
|
+
bright: '\x1b[1m',
|
|
29
|
+
green: '\x1b[32m',
|
|
30
|
+
blue: '\x1b[34m',
|
|
31
|
+
yellow: '\x1b[33m',
|
|
32
|
+
red: '\x1b[31m',
|
|
33
|
+
cyan: '\x1b[36m',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function log(message, color = 'reset') {
|
|
37
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Check if Python 3 is available
|
|
42
|
+
*/
|
|
43
|
+
function checkPython() {
|
|
44
|
+
const pythonCommands = ['python3', 'python'];
|
|
45
|
+
|
|
46
|
+
for (const cmd of pythonCommands) {
|
|
47
|
+
try {
|
|
48
|
+
const version = execSync(`${cmd} --version 2>&1`, { encoding: 'utf8' }).trim();
|
|
49
|
+
if (version.includes('Python 3')) {
|
|
50
|
+
return { available: true, command: cmd, version };
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
// Command not found, try next
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { available: false, command: null, version: null };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Verify installation was successful
|
|
62
|
+
*/
|
|
63
|
+
function verifyInstallation(claudeDir, hooksDir) {
|
|
64
|
+
const checks = [
|
|
65
|
+
{ path: path.join(claudeDir, 'commands'), name: 'Commands directory' },
|
|
66
|
+
{ path: path.join(claudeDir, 'settings.json'), name: 'Settings file' },
|
|
67
|
+
{ path: path.join(claudeDir, 'api-dev-state.json'), name: 'State file' },
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
// Add hook checks if hooks directory exists
|
|
71
|
+
if (fs.existsSync(hooksDir)) {
|
|
72
|
+
checks.push(
|
|
73
|
+
{ path: path.join(hooksDir, 'enforce-research.py'), name: 'enforce-research.py' },
|
|
74
|
+
{ path: path.join(hooksDir, 'track-tool-use.py'), name: 'track-tool-use.py' },
|
|
75
|
+
{ path: path.join(hooksDir, 'api-workflow-check.py'), name: 'api-workflow-check.py' }
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const failures = [];
|
|
80
|
+
for (const check of checks) {
|
|
81
|
+
if (!fs.existsSync(check.path)) {
|
|
82
|
+
failures.push(check.name);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return { success: failures.length === 0, failures };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function main() {
|
|
90
|
+
log('\nš Installing API Development Tools for Claude Code...\n', 'bright');
|
|
91
|
+
|
|
92
|
+
// Check Python availability first
|
|
93
|
+
const python = checkPython();
|
|
94
|
+
if (!python.available) {
|
|
95
|
+
log('ā ļø Warning: Python 3 not found', 'yellow');
|
|
96
|
+
log(' Enforcement hooks require Python 3 to run.', 'yellow');
|
|
97
|
+
log(' Hooks will be installed but may not work until Python 3 is available.', 'yellow');
|
|
98
|
+
log(' Install Python 3: https://www.python.org/downloads/\n', 'yellow');
|
|
99
|
+
} else {
|
|
100
|
+
log(`ā
Found ${python.version}`, 'green');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Get target directory (where user ran the command)
|
|
104
|
+
const targetDir = process.cwd();
|
|
105
|
+
const claudeDir = path.join(targetDir, '.claude');
|
|
106
|
+
const commandsDir = path.join(claudeDir, 'commands');
|
|
107
|
+
const hooksDir = path.join(claudeDir, 'hooks');
|
|
108
|
+
|
|
109
|
+
// Get source directories from this package
|
|
110
|
+
const packageDir = path.dirname(__dirname);
|
|
111
|
+
const sourceCommandsDir = path.join(packageDir, 'commands');
|
|
112
|
+
const sourceHooksDir = path.join(packageDir, 'hooks');
|
|
113
|
+
const sourceTemplatesDir = path.join(packageDir, 'templates');
|
|
114
|
+
|
|
115
|
+
// Verify source commands exist
|
|
116
|
+
if (!fs.existsSync(sourceCommandsDir)) {
|
|
117
|
+
log('ā Error: Commands directory not found in package', 'red');
|
|
118
|
+
log(` Looking for: ${sourceCommandsDir}`, 'red');
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ========================================
|
|
123
|
+
// 1. Install Commands
|
|
124
|
+
// ========================================
|
|
125
|
+
if (!fs.existsSync(commandsDir)) {
|
|
126
|
+
log(`š Creating directory: ${commandsDir}`, 'blue');
|
|
127
|
+
fs.mkdirSync(commandsDir, { recursive: true });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const commandFiles = fs.readdirSync(sourceCommandsDir).filter(file =>
|
|
131
|
+
file.endsWith('.md')
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
if (commandFiles.length === 0) {
|
|
135
|
+
log('ā ļø Warning: No command files found to install', 'yellow');
|
|
136
|
+
} else {
|
|
137
|
+
log('š¦ Installing commands:', 'blue');
|
|
138
|
+
commandFiles.forEach(file => {
|
|
139
|
+
const source = path.join(sourceCommandsDir, file);
|
|
140
|
+
const dest = path.join(commandsDir, file);
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
fs.copyFileSync(source, dest);
|
|
144
|
+
log(` ā
${file}`, 'green');
|
|
145
|
+
} catch (error) {
|
|
146
|
+
log(` ā Failed to copy ${file}: ${error.message}`, 'red');
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ========================================
|
|
152
|
+
// 2. Install Hooks (Programmatic Enforcement)
|
|
153
|
+
// ========================================
|
|
154
|
+
if (fs.existsSync(sourceHooksDir)) {
|
|
155
|
+
if (!fs.existsSync(hooksDir)) {
|
|
156
|
+
log(`\nš Creating directory: ${hooksDir}`, 'blue');
|
|
157
|
+
fs.mkdirSync(hooksDir, { recursive: true });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const hookFiles = fs.readdirSync(sourceHooksDir).filter(file =>
|
|
161
|
+
file.endsWith('.py')
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
if (hookFiles.length > 0) {
|
|
165
|
+
log('\nš Installing enforcement hooks:', 'cyan');
|
|
166
|
+
hookFiles.forEach(file => {
|
|
167
|
+
const source = path.join(sourceHooksDir, file);
|
|
168
|
+
const dest = path.join(hooksDir, file);
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
fs.copyFileSync(source, dest);
|
|
172
|
+
// Make executable
|
|
173
|
+
fs.chmodSync(dest, '755');
|
|
174
|
+
log(` ā
${file}`, 'green');
|
|
175
|
+
} catch (error) {
|
|
176
|
+
log(` ā Failed to copy ${file}: ${error.message}`, 'red');
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
log('\n Hook purposes:', 'blue');
|
|
181
|
+
log(' ⢠enforce-research.py - Blocks code writing without research', 'blue');
|
|
182
|
+
log(' ⢠track-tool-use.py - Logs all research activity', 'blue');
|
|
183
|
+
log(' ⢠api-workflow-check.py - Prevents stopping until complete', 'blue');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ========================================
|
|
188
|
+
// 3. Install/Merge Settings (Hook Registration)
|
|
189
|
+
// ========================================
|
|
190
|
+
const settingsSource = path.join(sourceTemplatesDir, 'settings.json');
|
|
191
|
+
const settingsDest = path.join(claudeDir, 'settings.json');
|
|
192
|
+
|
|
193
|
+
if (fs.existsSync(settingsSource)) {
|
|
194
|
+
log('\nāļø Configuring hook settings:', 'cyan');
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
const newSettings = JSON.parse(fs.readFileSync(settingsSource, 'utf8'));
|
|
198
|
+
|
|
199
|
+
if (fs.existsSync(settingsDest)) {
|
|
200
|
+
// Merge with existing settings
|
|
201
|
+
const existingSettings = JSON.parse(fs.readFileSync(settingsDest, 'utf8'));
|
|
202
|
+
const mergedSettings = mergeSettings(existingSettings, newSettings);
|
|
203
|
+
fs.writeFileSync(settingsDest, JSON.stringify(mergedSettings, null, 2));
|
|
204
|
+
log(' ā
Merged with existing settings.json', 'green');
|
|
205
|
+
} else {
|
|
206
|
+
// Create new settings file
|
|
207
|
+
fs.writeFileSync(settingsDest, JSON.stringify(newSettings, null, 2));
|
|
208
|
+
log(' ā
Created settings.json with hook configuration', 'green');
|
|
209
|
+
}
|
|
210
|
+
} catch (error) {
|
|
211
|
+
log(` ā Failed to configure settings: ${error.message}`, 'red');
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ========================================
|
|
216
|
+
// 4. Install State File Template
|
|
217
|
+
// ========================================
|
|
218
|
+
const stateSource = path.join(sourceTemplatesDir, 'api-dev-state.json');
|
|
219
|
+
const stateDest = path.join(claudeDir, 'api-dev-state.json');
|
|
220
|
+
|
|
221
|
+
if (fs.existsSync(stateSource)) {
|
|
222
|
+
log('\nš Setting up state tracking:', 'cyan');
|
|
223
|
+
|
|
224
|
+
if (!fs.existsSync(stateDest)) {
|
|
225
|
+
try {
|
|
226
|
+
fs.copyFileSync(stateSource, stateDest);
|
|
227
|
+
log(' ā
Created api-dev-state.json template', 'green');
|
|
228
|
+
} catch (error) {
|
|
229
|
+
log(` ā Failed to create state file: ${error.message}`, 'red');
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
log(' ā¹ļø State file already exists (preserved)', 'blue');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ========================================
|
|
237
|
+
// Success Summary
|
|
238
|
+
// ========================================
|
|
239
|
+
log('\n' + 'ā'.repeat(60), 'green');
|
|
240
|
+
log('š API Development Tools installed successfully!', 'green');
|
|
241
|
+
log('ā'.repeat(60) + '\n', 'green');
|
|
242
|
+
|
|
243
|
+
log('š What was installed:', 'bright');
|
|
244
|
+
log(' Commands: .claude/commands/*.md', 'blue');
|
|
245
|
+
log(' Hooks: .claude/hooks/*.py', 'blue');
|
|
246
|
+
log(' Settings: .claude/settings.json', 'blue');
|
|
247
|
+
log(' State: .claude/api-dev-state.json', 'blue');
|
|
248
|
+
|
|
249
|
+
log('\nš Enforcement Features:', 'bright');
|
|
250
|
+
log(' ⢠Research MUST happen before code writing', 'cyan');
|
|
251
|
+
log(' ⢠All research activity is logged to state file', 'cyan');
|
|
252
|
+
log(' ⢠Workflow completion is verified before stopping', 'cyan');
|
|
253
|
+
log(' ⢠Progress is tracked and visible in state file', 'cyan');
|
|
254
|
+
|
|
255
|
+
log('\nš Available Commands:', 'bright');
|
|
256
|
+
log(' /api-create [endpoint] - Complete API development workflow', 'blue');
|
|
257
|
+
log(' /api-interview [endpoint] - Structured interview about endpoint', 'blue');
|
|
258
|
+
log(' /api-research [library] - Deep research of external APIs/SDKs', 'blue');
|
|
259
|
+
log(' /api-env [endpoint] - Check API keys and environment', 'blue');
|
|
260
|
+
log(' /api-status [endpoint] - Track implementation progress', 'blue');
|
|
261
|
+
|
|
262
|
+
log('\nš Quick Start:', 'bright');
|
|
263
|
+
log(' /api-create my-endpoint', 'blue');
|
|
264
|
+
|
|
265
|
+
log('\nš” Check progress anytime:', 'yellow');
|
|
266
|
+
log(' cat .claude/api-dev-state.json | jq \'.phases\'', 'yellow');
|
|
267
|
+
|
|
268
|
+
log('\nš Documentation:', 'bright');
|
|
269
|
+
log(` ${path.join(commandsDir, 'README.md')}\n`, 'blue');
|
|
270
|
+
|
|
271
|
+
// ========================================
|
|
272
|
+
// 5. Verify Installation
|
|
273
|
+
// ========================================
|
|
274
|
+
const verification = verifyInstallation(claudeDir, hooksDir);
|
|
275
|
+
if (!verification.success) {
|
|
276
|
+
log('ā ļø Installation verification found issues:', 'yellow');
|
|
277
|
+
verification.failures.forEach(f => log(` ⢠Missing: ${f}`, 'yellow'));
|
|
278
|
+
log(' Some features may not work correctly.\n', 'yellow');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Merge two settings objects, combining hooks arrays
|
|
284
|
+
*/
|
|
285
|
+
function mergeSettings(existing, newSettings) {
|
|
286
|
+
const merged = { ...existing };
|
|
287
|
+
|
|
288
|
+
// Merge hooks
|
|
289
|
+
if (newSettings.hooks) {
|
|
290
|
+
merged.hooks = merged.hooks || {};
|
|
291
|
+
|
|
292
|
+
for (const hookType of Object.keys(newSettings.hooks)) {
|
|
293
|
+
if (!merged.hooks[hookType]) {
|
|
294
|
+
merged.hooks[hookType] = [];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Add new hooks that don't already exist (check by command path)
|
|
298
|
+
for (const newHook of newSettings.hooks[hookType]) {
|
|
299
|
+
const hookCommand = newHook.hooks?.[0]?.command || '';
|
|
300
|
+
const exists = merged.hooks[hookType].some(existing => {
|
|
301
|
+
const existingCommand = existing.hooks?.[0]?.command || '';
|
|
302
|
+
return existingCommand === hookCommand;
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
if (!exists) {
|
|
306
|
+
merged.hooks[hookType].push(newHook);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return merged;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Run installer
|
|
316
|
+
try {
|
|
317
|
+
main();
|
|
318
|
+
} catch (error) {
|
|
319
|
+
log(`\nā Installation failed: ${error.message}`, 'red');
|
|
320
|
+
log(` ${error.stack}\n`, 'red');
|
|
321
|
+
process.exit(1);
|
|
322
|
+
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# API Development Slash Commands
|
|
2
|
+
|
|
3
|
+
**Comprehensive API development workflow with programmatic enforcement**
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
These slash commands implement an interview-driven, test-first methodology for API development. They automate the workflow described in the V2 Development Patterns and ensure consistent, high-quality API implementations.
|
|
8
|
+
|
|
9
|
+
## Programmatic Enforcement (Hooks)
|
|
10
|
+
|
|
11
|
+
This package includes **Python hooks** that provide real programmatic guarantees:
|
|
12
|
+
|
|
13
|
+
| Hook | Trigger | Purpose |
|
|
14
|
+
|------|---------|---------|
|
|
15
|
+
| `enforce-research.py` | PreToolUse (Write/Edit) | Blocks API code writing until research is complete |
|
|
16
|
+
| `track-tool-use.py` | PostToolUse (WebSearch/Context7) | Logs all research activity to state file |
|
|
17
|
+
| `api-workflow-check.py` | Stop | Prevents stopping until required phases complete |
|
|
18
|
+
|
|
19
|
+
### What Gets Enforced
|
|
20
|
+
|
|
21
|
+
- **Research MUST happen first** - Cannot write API route code without completing research
|
|
22
|
+
- **All research is logged** - WebSearch, WebFetch, Context7 calls tracked in state file
|
|
23
|
+
- **Progress is visible** - Check `.claude/api-dev-state.json` anytime
|
|
24
|
+
- **Workflow completion verified** - Cannot stop until TDD phases complete
|
|
25
|
+
|
|
26
|
+
### Check Progress
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# View current state
|
|
30
|
+
cat .claude/api-dev-state.json | jq '.phases'
|
|
31
|
+
|
|
32
|
+
# Or use the status command
|
|
33
|
+
/api-status
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Available Commands
|
|
37
|
+
|
|
38
|
+
### šÆ Complete Workflow
|
|
39
|
+
|
|
40
|
+
**`/api-create [endpoint-name]`**
|
|
41
|
+
- Orchestrates the entire API development process
|
|
42
|
+
- Runs all phases automatically: Interview ā Research ā Environment Check ā TDD ā Documentation
|
|
43
|
+
- Use this for new endpoints to ensure nothing is missed
|
|
44
|
+
|
|
45
|
+
### š Individual Phases
|
|
46
|
+
|
|
47
|
+
**`/api-interview [endpoint-name]`**
|
|
48
|
+
- Conducts structured 20-question interview (Anthropic Interviewer methodology)
|
|
49
|
+
- Documents purpose, usage, requirements, edge cases
|
|
50
|
+
- Creates endpoint documentation file
|
|
51
|
+
- **Output:** `/src/v2/docs/endpoints/[endpoint-name].md`
|
|
52
|
+
|
|
53
|
+
**`/api-research [library-or-service]`**
|
|
54
|
+
- Researches external APIs, SDKs, and libraries
|
|
55
|
+
- Discovers ALL parameters (documented + undocumented)
|
|
56
|
+
- Extracts complete schemas from source code
|
|
57
|
+
- Documents integration requirements
|
|
58
|
+
- **Output:** `/src/v2/docs/research/[library-name].md`
|
|
59
|
+
|
|
60
|
+
**`/api-env [endpoint-name]`**
|
|
61
|
+
- Checks for required API keys
|
|
62
|
+
- Verifies .env.local and .env.example
|
|
63
|
+
- Provides setup instructions for missing keys
|
|
64
|
+
- **Output:** Terminal report + action items
|
|
65
|
+
|
|
66
|
+
**`/api-status [endpoint-name]`** or **`/api-status --all`**
|
|
67
|
+
- Shows implementation progress
|
|
68
|
+
- Tracks phases (Interview ā Research ā Red ā Green ā Refactor ā Complete)
|
|
69
|
+
- Updates V2 implementation status document
|
|
70
|
+
- **Output:** Progress report
|
|
71
|
+
|
|
72
|
+
### š“š¢šµ TDD Cycle
|
|
73
|
+
|
|
74
|
+
Use the existing TDD commands from AI_WORKFLOW.md:
|
|
75
|
+
- `/red` - Write ONE failing test
|
|
76
|
+
- `/green` - Minimal implementation to pass
|
|
77
|
+
- `/refactor` - Clean up code while tests pass
|
|
78
|
+
- `/cycle [description]` - Full Red ā Green ā Refactor loop
|
|
79
|
+
|
|
80
|
+
## Complete Workflow Example
|
|
81
|
+
|
|
82
|
+
### Option 1: Fully Automated
|
|
83
|
+
```bash
|
|
84
|
+
/api-create generate-css
|
|
85
|
+
```
|
|
86
|
+
This will:
|
|
87
|
+
1. Interview you about the endpoint
|
|
88
|
+
2. Research required libraries (Gemini SDK, etc.)
|
|
89
|
+
3. Check environment/API keys
|
|
90
|
+
4. Write failing tests (Red)
|
|
91
|
+
5. Implement minimal solution (Green)
|
|
92
|
+
6. Refactor for quality (Refactor)
|
|
93
|
+
7. Update all documentation
|
|
94
|
+
8. Verify tests and coverage
|
|
95
|
+
9. Create commit
|
|
96
|
+
|
|
97
|
+
### Option 2: Manual Step-by-Step
|
|
98
|
+
```bash
|
|
99
|
+
# Phase 1: Understanding
|
|
100
|
+
/api-interview generate-css
|
|
101
|
+
# (Answer 20 questions about purpose, usage, requirements)
|
|
102
|
+
|
|
103
|
+
# Phase 2: Research
|
|
104
|
+
/api-research google-generative-ai
|
|
105
|
+
# (Discovers all Gemini SDK parameters)
|
|
106
|
+
|
|
107
|
+
# Phase 3: Environment
|
|
108
|
+
/api-env generate-css
|
|
109
|
+
# (Verifies GOOGLE_GENERATIVE_AI_API_KEY exists)
|
|
110
|
+
|
|
111
|
+
# Phase 4: TDD Implementation
|
|
112
|
+
/red
|
|
113
|
+
# (Write failing tests based on interview + research)
|
|
114
|
+
|
|
115
|
+
/green
|
|
116
|
+
# (Implement route handler with Zod schemas)
|
|
117
|
+
|
|
118
|
+
/refactor
|
|
119
|
+
# (Clean up, extract patterns, improve code)
|
|
120
|
+
|
|
121
|
+
# Phase 5: Documentation
|
|
122
|
+
# (Update api-tests-manifest.json, OpenAPI spec, status doc)
|
|
123
|
+
|
|
124
|
+
# Phase 6: Commit
|
|
125
|
+
pnpm test:run
|
|
126
|
+
/commit
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Command Cheat Sheet
|
|
130
|
+
|
|
131
|
+
| Command | When to Use | Output |
|
|
132
|
+
|---------|-------------|--------|
|
|
133
|
+
| `/api-create [endpoint]` | Starting new endpoint | Complete implementation |
|
|
134
|
+
| `/api-interview [endpoint]` | Need to understand requirements | Documentation file |
|
|
135
|
+
| `/api-research [library]` | Integrating external API/SDK | Research document |
|
|
136
|
+
| `/api-env [endpoint]` | Before implementation | Environment check report |
|
|
137
|
+
| `/api-status [endpoint]` | Check progress | Status report |
|
|
138
|
+
| `/red` | Write test first | Failing test |
|
|
139
|
+
| `/green` | Make test pass | Working implementation |
|
|
140
|
+
| `/refactor` | Clean up code | Improved code |
|
|
141
|
+
| `/cycle [desc]` | Implement feature | Full TDD cycle |
|
|
142
|
+
|
|
143
|
+
## File Structure Created
|
|
144
|
+
|
|
145
|
+
Each endpoint creates this structure:
|
|
146
|
+
```
|
|
147
|
+
src/app/api/v2/[endpoint-name]/
|
|
148
|
+
āāā route.ts # API handler with Zod schemas
|
|
149
|
+
āāā __tests__/
|
|
150
|
+
ā āāā [endpoint-name].api.test.ts # Comprehensive tests
|
|
151
|
+
āāā README.md # Endpoint documentation
|
|
152
|
+
|
|
153
|
+
src/v2/docs/
|
|
154
|
+
āāā endpoints/
|
|
155
|
+
ā āāā [endpoint-name].md # Interview results
|
|
156
|
+
āāā research/
|
|
157
|
+
āāā [library-name].md # External API research
|
|
158
|
+
|
|
159
|
+
src/app/api-test/
|
|
160
|
+
āāā api-tests-manifest.json # Updated with new tests
|
|
161
|
+
|
|
162
|
+
src/lib/openapi/endpoints/
|
|
163
|
+
āāā [endpoint-name].ts # OpenAPI spec
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Workflow Principles
|
|
167
|
+
|
|
168
|
+
### 1. Context First
|
|
169
|
+
**Never write code without understanding WHY it exists.**
|
|
170
|
+
- Interview before implementation
|
|
171
|
+
- Document real-world usage
|
|
172
|
+
- Understand edge cases
|
|
173
|
+
|
|
174
|
+
### 2. Research Thoroughly
|
|
175
|
+
**Find ALL parameters, not just the documented ones.**
|
|
176
|
+
- Read official docs
|
|
177
|
+
- Check source code
|
|
178
|
+
- Review TypeScript definitions
|
|
179
|
+
- Test assumptions
|
|
180
|
+
|
|
181
|
+
### 3. Test First (TDD)
|
|
182
|
+
**No implementation without a failing test.**
|
|
183
|
+
- Red: Write test that fails
|
|
184
|
+
- Green: Minimal code to pass
|
|
185
|
+
- Refactor: Improve while tests pass
|
|
186
|
+
|
|
187
|
+
### 4. Document Everything
|
|
188
|
+
**Future you needs to understand this.**
|
|
189
|
+
- Interview results
|
|
190
|
+
- Research findings
|
|
191
|
+
- API schemas
|
|
192
|
+
- Code examples
|
|
193
|
+
- Testing notes
|
|
194
|
+
|
|
195
|
+
### 5. Verify Environment
|
|
196
|
+
**Check API keys before starting.**
|
|
197
|
+
- Identify required services
|
|
198
|
+
- Verify keys exist
|
|
199
|
+
- Document setup
|
|
200
|
+
- Test connections
|
|
201
|
+
|
|
202
|
+
## Integration with Existing Tools
|
|
203
|
+
|
|
204
|
+
These commands work alongside:
|
|
205
|
+
- **`/plan`** - Create implementation checklist
|
|
206
|
+
- **`/gap`** - Find missing pieces
|
|
207
|
+
- **`/issue [url]`** - Start from GitHub issue
|
|
208
|
+
- **`/commit`** - AI-generated semantic commits
|
|
209
|
+
- **`/pr`** - Create pull request
|
|
210
|
+
|
|
211
|
+
## Why This Approach Works
|
|
212
|
+
|
|
213
|
+
### Problems with Previous Approach
|
|
214
|
+
ā Tests written without understanding purpose
|
|
215
|
+
ā Missing parameters from incomplete research
|
|
216
|
+
ā Failed tests due to missing API keys
|
|
217
|
+
ā No documentation of real-world usage
|
|
218
|
+
ā Mechanical testing without context
|
|
219
|
+
|
|
220
|
+
### Benefits of New Approach
|
|
221
|
+
ā
Deep understanding before coding
|
|
222
|
+
ā
Complete parameter coverage
|
|
223
|
+
ā
Environment verified upfront
|
|
224
|
+
ā
Documentation drives implementation
|
|
225
|
+
ā
Tests reflect actual usage patterns
|
|
226
|
+
ā
Consistent, repeatable process
|
|
227
|
+
ā
Nothing gets forgotten
|
|
228
|
+
|
|
229
|
+
## Getting Started
|
|
230
|
+
|
|
231
|
+
### First Time Setup
|
|
232
|
+
1. Review this README
|
|
233
|
+
2. Read `/src/v2/docs/AI_WORKFLOW.md`
|
|
234
|
+
3. Read `/src/v2/docs/Main Doc ā V2 Development Patterns.md`
|
|
235
|
+
4. Try `/api-create` with a simple endpoint
|
|
236
|
+
|
|
237
|
+
### For Each New Endpoint
|
|
238
|
+
```bash
|
|
239
|
+
# Quick automated approach
|
|
240
|
+
/api-create [endpoint-name]
|
|
241
|
+
|
|
242
|
+
# Or manual for learning
|
|
243
|
+
/api-interview [endpoint-name]
|
|
244
|
+
/api-research [library]
|
|
245
|
+
/api-env [endpoint-name]
|
|
246
|
+
/cycle [description]
|
|
247
|
+
/commit
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Checking Progress
|
|
251
|
+
```bash
|
|
252
|
+
/api-status --all # See all endpoints
|
|
253
|
+
/api-status [endpoint] # Specific endpoint
|
|
254
|
+
pnpm test:run # Verify tests pass
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Installation
|
|
258
|
+
|
|
259
|
+
Install via NPX command:
|
|
260
|
+
```bash
|
|
261
|
+
npx @hustle-together/api-dev-tools --scope=project
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
This installs:
|
|
265
|
+
- **Commands** in `.claude/commands/` (slash commands)
|
|
266
|
+
- **Hooks** in `.claude/hooks/` (Python enforcement scripts)
|
|
267
|
+
- **Settings** in `.claude/settings.json` (hook registration)
|
|
268
|
+
- **State template** in `.claude/api-dev-state.json` (progress tracking)
|
|
269
|
+
|
|
270
|
+
### Team-Wide Installation
|
|
271
|
+
|
|
272
|
+
Add to your project's `package.json`:
|
|
273
|
+
```json
|
|
274
|
+
{
|
|
275
|
+
"scripts": {
|
|
276
|
+
"postinstall": "npx @hustle-together/api-dev-tools --scope=project"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Now `npm install` or `pnpm install` automatically installs the tools for all team members.
|
|
282
|
+
|
|
283
|
+
## References
|
|
284
|
+
|
|
285
|
+
- **AI Workflow:** `/src/v2/docs/AI_WORKFLOW.md`
|
|
286
|
+
- **V2 Patterns:** `/src/v2/docs/Main Doc ā V2 Development Patterns.md`
|
|
287
|
+
- **AI SDK Catalog:** `/src/v2/docs/ai-sdk-catalog.json`
|
|
288
|
+
- **API Testing Plan:** `/src/v2/docs/API_TESTING_PLAN.md`
|
|
289
|
+
- **Implementation Status:** `/src/v2/docs/v2-api-implementation-status.md`
|
|
290
|
+
|
|
291
|
+
## Support
|
|
292
|
+
|
|
293
|
+
If commands aren't working:
|
|
294
|
+
1. Check that files exist in `.claude/commands/`
|
|
295
|
+
2. Verify command syntax matches usage examples
|
|
296
|
+
3. Review error messages for missing dependencies
|
|
297
|
+
4. Check that required docs exist in `/src/v2/docs/`
|
|
298
|
+
|
|
299
|
+
## Contributing
|
|
300
|
+
|
|
301
|
+
To improve these commands:
|
|
302
|
+
1. Edit markdown files in `.claude/commands/`
|
|
303
|
+
2. Update this README
|
|
304
|
+
3. Test with real endpoint implementation
|
|
305
|
+
4. Document learnings
|
|
306
|
+
5. Commit improvements
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
**Last Updated:** 2025-12-06
|
|
311
|
+
**Version:** 1.0.0
|
|
312
|
+
**Status:** Ready for use
|