@codihaus/claude-skills 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/README.md +167 -0
- package/bin/cli.js +58 -0
- package/package.json +46 -0
- package/skills/_quality-attributes.md +392 -0
- package/skills/_registry.md +189 -0
- package/skills/debrief/SKILL.md +647 -0
- package/skills/debrief/references/change-request-template.md +124 -0
- package/skills/debrief/references/file-patterns.md +173 -0
- package/skills/debrief/references/group-codes.md +72 -0
- package/skills/debrief/references/research-queries.md +106 -0
- package/skills/debrief/references/use-case-template.md +141 -0
- package/skills/debrief/scripts/generate_questionnaire.py +195 -0
- package/skills/dev-arch/SKILL.md +747 -0
- package/skills/dev-changelog/SKILL.md +378 -0
- package/skills/dev-coding/SKILL.md +470 -0
- package/skills/dev-coding-backend/SKILL.md +361 -0
- package/skills/dev-coding-frontend/SKILL.md +534 -0
- package/skills/dev-coding-frontend/references/nextjs.md +477 -0
- package/skills/dev-review/SKILL.md +548 -0
- package/skills/dev-scout/SKILL.md +723 -0
- package/skills/dev-scout/references/feature-patterns.md +210 -0
- package/skills/dev-scout/references/file-patterns.md +252 -0
- package/skills/dev-scout/references/tech-detection.md +211 -0
- package/skills/dev-scout/scripts/scout-analyze.sh +280 -0
- package/skills/dev-specs/SKILL.md +577 -0
- package/skills/dev-specs/references/checklist.md +176 -0
- package/skills/dev-specs/references/spec-templates.md +460 -0
- package/skills/dev-test/SKILL.md +364 -0
- package/skills/utils/diagram/SKILL.md +205 -0
- package/skills/utils/diagram/references/common-errors.md +305 -0
- package/skills/utils/diagram/references/diagram-types.md +636 -0
- package/skills/utils/docs-graph/SKILL.md +204 -0
- package/skills/utils/gemini/SKILL.md +292 -0
- package/skills/utils/gemini/scripts/gemini-scan.py +340 -0
- package/skills/utils/gemini/scripts/setup.sh +169 -0
- package/src/commands/add.js +64 -0
- package/src/commands/doctor.js +179 -0
- package/src/commands/init.js +251 -0
- package/src/commands/list.js +88 -0
- package/src/commands/remove.js +60 -0
- package/src/commands/update.js +72 -0
- package/src/index.js +26 -0
- package/src/utils/config.js +272 -0
- package/src/utils/deps.js +599 -0
- package/src/utils/skills.js +253 -0
- package/templates/CLAUDE.md.template +58 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dev-coding-backend
|
|
3
|
+
description: Backend implementation patterns and workflows
|
|
4
|
+
version: 1.2.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /dev-coding-backend - Backend Implementation
|
|
8
|
+
|
|
9
|
+
> **Skill Awareness**: See `skills/_registry.md` for all available skills.
|
|
10
|
+
> - **Loaded by**: `/dev-coding` when API/schema work needed
|
|
11
|
+
> - **References**: Load tech-specific from `references/` (directus.md, prisma.md, etc.)
|
|
12
|
+
> - **After**: Frontend uses API contract documented here
|
|
13
|
+
> - **After**: `/dev-test` auto-runs to verify API via network requests
|
|
14
|
+
|
|
15
|
+
Backend-specific patterns for API, schema, and data layer implementation.
|
|
16
|
+
|
|
17
|
+
## When Loaded
|
|
18
|
+
|
|
19
|
+
This skill is loaded by `/dev-coding` when:
|
|
20
|
+
- Spec requires API endpoints
|
|
21
|
+
- Spec requires schema/database changes
|
|
22
|
+
- Spec requires backend logic
|
|
23
|
+
|
|
24
|
+
## Workflow
|
|
25
|
+
|
|
26
|
+
### Step 1: Understand Backend Requirements
|
|
27
|
+
|
|
28
|
+
From the UC spec, extract:
|
|
29
|
+
|
|
30
|
+
```markdown
|
|
31
|
+
## Backend Requirements Checklist
|
|
32
|
+
|
|
33
|
+
[ ] Schema changes needed?
|
|
34
|
+
- New collections/tables
|
|
35
|
+
- New fields on existing
|
|
36
|
+
- Relations to add
|
|
37
|
+
|
|
38
|
+
[ ] API endpoints needed?
|
|
39
|
+
- Method + Path
|
|
40
|
+
- Request body
|
|
41
|
+
- Response shape
|
|
42
|
+
- Auth required?
|
|
43
|
+
|
|
44
|
+
[ ] Business logic?
|
|
45
|
+
- Validation rules
|
|
46
|
+
- Calculations
|
|
47
|
+
- Side effects (emails, notifications)
|
|
48
|
+
|
|
49
|
+
[ ] External integrations?
|
|
50
|
+
- Third-party APIs
|
|
51
|
+
- Webhooks
|
|
52
|
+
- File storage
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Step 2: Schema First (if needed)
|
|
56
|
+
|
|
57
|
+
**Order matters:** Schema before API
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
1. Design schema based on spec
|
|
61
|
+
2. Create/modify collections or tables
|
|
62
|
+
3. Set up relations
|
|
63
|
+
4. Configure permissions/roles
|
|
64
|
+
5. Verify schema is correct
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Verification:**
|
|
68
|
+
```bash
|
|
69
|
+
# For Directus - check collection exists
|
|
70
|
+
curl "$DIRECTUS_URL/items/{collection}?limit=1" \
|
|
71
|
+
-H "Authorization: Bearer $TOKEN"
|
|
72
|
+
|
|
73
|
+
# For Prisma - run migration
|
|
74
|
+
npx prisma migrate dev
|
|
75
|
+
|
|
76
|
+
# For SQL - verify table
|
|
77
|
+
psql -c "\\d {table_name}"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Step 3: API Implementation
|
|
81
|
+
|
|
82
|
+
**For each endpoint in spec:**
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
1. Create route/handler file
|
|
86
|
+
2. Implement request parsing
|
|
87
|
+
3. Add validation
|
|
88
|
+
4. Implement business logic
|
|
89
|
+
5. Handle errors
|
|
90
|
+
6. Return response
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Follow project patterns** (from scout):
|
|
94
|
+
- File location (routes/, api/, controllers/)
|
|
95
|
+
- Naming convention
|
|
96
|
+
- Error handling pattern
|
|
97
|
+
- Response format
|
|
98
|
+
|
|
99
|
+
### Step 4: API Patterns
|
|
100
|
+
|
|
101
|
+
#### REST Conventions
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
GET /api/{resource} → List
|
|
105
|
+
GET /api/{resource}/:id → Get one
|
|
106
|
+
POST /api/{resource} → Create
|
|
107
|
+
PUT /api/{resource}/:id → Update (full)
|
|
108
|
+
PATCH /api/{resource}/:id → Update (partial)
|
|
109
|
+
DELETE /api/{resource}/:id → Delete
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Request Validation
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// Always validate input
|
|
116
|
+
const schema = z.object({
|
|
117
|
+
email: z.string().email(),
|
|
118
|
+
password: z.string().min(8),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const result = schema.safeParse(req.body);
|
|
122
|
+
if (!result.success) {
|
|
123
|
+
return res.status(400).json({
|
|
124
|
+
error: 'Validation failed',
|
|
125
|
+
details: result.error.issues
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
#### Error Handling
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// Consistent error format
|
|
134
|
+
{
|
|
135
|
+
"error": "Error message for client",
|
|
136
|
+
"code": "ERROR_CODE",
|
|
137
|
+
"details": {} // Optional additional info
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// HTTP status codes
|
|
141
|
+
200 - Success
|
|
142
|
+
201 - Created
|
|
143
|
+
400 - Bad request (validation)
|
|
144
|
+
401 - Unauthorized
|
|
145
|
+
403 - Forbidden
|
|
146
|
+
404 - Not found
|
|
147
|
+
409 - Conflict
|
|
148
|
+
500 - Server error
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
#### Authentication Check
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// Verify auth before processing
|
|
155
|
+
if (!req.user) {
|
|
156
|
+
return res.status(401).json({ error: 'Unauthorized' });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Check permissions
|
|
160
|
+
if (!req.user.permissions.includes('create:posts')) {
|
|
161
|
+
return res.status(403).json({ error: 'Forbidden' });
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Step 5: Verification
|
|
166
|
+
|
|
167
|
+
**Test each endpoint:**
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Test with curl
|
|
171
|
+
curl -X POST http://localhost:3000/api/auth/login \
|
|
172
|
+
-H "Content-Type: application/json" \
|
|
173
|
+
-d '{"email":"test@test.com","password":"password123"}'
|
|
174
|
+
|
|
175
|
+
# Expected: 200 with token
|
|
176
|
+
# Or: 401 with error message
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Verification checklist:**
|
|
180
|
+
```
|
|
181
|
+
[ ] Endpoint responds
|
|
182
|
+
[ ] Correct status codes
|
|
183
|
+
[ ] Response matches spec
|
|
184
|
+
[ ] Validation rejects bad input
|
|
185
|
+
[ ] Auth required endpoints reject anonymous
|
|
186
|
+
[ ] Error messages are helpful but not leaky
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Step 6: Document for Frontend
|
|
190
|
+
|
|
191
|
+
After backend complete, document what frontend needs:
|
|
192
|
+
|
|
193
|
+
```markdown
|
|
194
|
+
## API Ready for Frontend
|
|
195
|
+
|
|
196
|
+
### POST /api/auth/login
|
|
197
|
+
- **Auth**: None (public)
|
|
198
|
+
- **Request**: `{ email: string, password: string }`
|
|
199
|
+
- **Success (200)**: `{ token: string, user: { id, email, name } }`
|
|
200
|
+
- **Errors**:
|
|
201
|
+
- 400: Invalid input
|
|
202
|
+
- 401: Invalid credentials
|
|
203
|
+
|
|
204
|
+
### GET /api/users/me
|
|
205
|
+
- **Auth**: Bearer token required
|
|
206
|
+
- **Request**: None
|
|
207
|
+
- **Success (200)**: `{ id, email, name, role }`
|
|
208
|
+
- **Errors**:
|
|
209
|
+
- 401: No/invalid token
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Step 7: Hand Off to Testing
|
|
213
|
+
|
|
214
|
+
After full implementation (backend + frontend), `/dev-coding` auto-triggers `/dev-test` which:
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
1. Navigate to UI (triggers API calls)
|
|
218
|
+
2. Capture network requests
|
|
219
|
+
3. Check for 4xx/5xx responses
|
|
220
|
+
4. Report API failures
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**What /dev-test catches for backend:**
|
|
224
|
+
- 400 Bad Request (validation failures)
|
|
225
|
+
- 401 Unauthorized (auth issues)
|
|
226
|
+
- 403 Forbidden (permission issues)
|
|
227
|
+
- 404 Not Found (wrong endpoints)
|
|
228
|
+
- 500 Server Error (backend bugs)
|
|
229
|
+
- CORS errors (misconfigured)
|
|
230
|
+
- Timeout errors (slow queries)
|
|
231
|
+
|
|
232
|
+
**Example test failure:**
|
|
233
|
+
```markdown
|
|
234
|
+
[Network] POST /api/auth/login returned 500
|
|
235
|
+
Response: {"error":"Internal server error"}
|
|
236
|
+
Likely cause: Database connection or missing env var
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Common Patterns
|
|
240
|
+
|
|
241
|
+
### Database Query Patterns
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
// Pagination
|
|
245
|
+
const page = parseInt(req.query.page) || 1;
|
|
246
|
+
const limit = parseInt(req.query.limit) || 10;
|
|
247
|
+
const offset = (page - 1) * limit;
|
|
248
|
+
|
|
249
|
+
const items = await db.items.findMany({
|
|
250
|
+
skip: offset,
|
|
251
|
+
take: limit,
|
|
252
|
+
orderBy: { createdAt: 'desc' }
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// Filtering
|
|
256
|
+
const where = {};
|
|
257
|
+
if (req.query.status) {
|
|
258
|
+
where.status = req.query.status;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Include relations
|
|
262
|
+
const post = await db.posts.findUnique({
|
|
263
|
+
where: { id },
|
|
264
|
+
include: { author: true, comments: true }
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Transaction Pattern
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
// When multiple operations must succeed together
|
|
272
|
+
await db.$transaction(async (tx) => {
|
|
273
|
+
const user = await tx.users.create({ data: userData });
|
|
274
|
+
await tx.profiles.create({ data: { userId: user.id } });
|
|
275
|
+
await tx.settings.create({ data: { userId: user.id } });
|
|
276
|
+
return user;
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Soft Delete Pattern
|
|
281
|
+
|
|
282
|
+
```typescript
|
|
283
|
+
// Don't actually delete, mark as deleted
|
|
284
|
+
await db.posts.update({
|
|
285
|
+
where: { id },
|
|
286
|
+
data: {
|
|
287
|
+
deletedAt: new Date(),
|
|
288
|
+
status: 'deleted'
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// Query excludes deleted
|
|
293
|
+
const posts = await db.posts.findMany({
|
|
294
|
+
where: { deletedAt: null }
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Security Checklist
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
[ ] Input validated before use
|
|
302
|
+
[ ] SQL/NoSQL injection prevented (use parameterized queries)
|
|
303
|
+
[ ] Auth checked on protected routes
|
|
304
|
+
[ ] Permissions verified for actions
|
|
305
|
+
[ ] Sensitive data not logged
|
|
306
|
+
[ ] Passwords hashed (never plain text)
|
|
307
|
+
[ ] Rate limiting on auth endpoints
|
|
308
|
+
[ ] CORS configured correctly
|
|
309
|
+
[ ] No secrets in code (use env vars)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Debugging
|
|
313
|
+
|
|
314
|
+
### API Not Responding
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
# Check if server running
|
|
318
|
+
curl http://localhost:3000/health
|
|
319
|
+
|
|
320
|
+
# Check logs
|
|
321
|
+
tail -f logs/server.log
|
|
322
|
+
|
|
323
|
+
# Check port in use
|
|
324
|
+
lsof -i :3000
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Database Issues
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
# Check connection
|
|
331
|
+
npx prisma db pull # Prisma
|
|
332
|
+
psql -c "SELECT 1" # PostgreSQL
|
|
333
|
+
|
|
334
|
+
# Check migrations
|
|
335
|
+
npx prisma migrate status
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Auth Issues
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
# Test token validity
|
|
342
|
+
curl http://localhost:3000/api/users/me \
|
|
343
|
+
-H "Authorization: Bearer $TOKEN"
|
|
344
|
+
|
|
345
|
+
# Decode JWT (for debugging only)
|
|
346
|
+
echo $TOKEN | cut -d. -f2 | base64 -d
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Tech-Specific References
|
|
350
|
+
|
|
351
|
+
Load additional patterns based on detected tech:
|
|
352
|
+
|
|
353
|
+
| Tech | Reference File |
|
|
354
|
+
|------|---------------|
|
|
355
|
+
| Directus | `references/directus.md` |
|
|
356
|
+
| Node/Express | `references/node.md` |
|
|
357
|
+
| Prisma | `references/prisma.md` |
|
|
358
|
+
| PostgreSQL | `references/postgresql.md` |
|
|
359
|
+
| Supabase | `references/supabase.md` |
|
|
360
|
+
|
|
361
|
+
These files contain tech-specific patterns, gotchas, and best practices. Add them as your projects use different stacks.
|