codingbuddy-rules 2.0.0 → 2.2.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 (42) hide show
  1. package/.ai-rules/adapters/antigravity.md +83 -3
  2. package/.ai-rules/adapters/claude-code.md +288 -5
  3. package/.ai-rules/adapters/codex.md +57 -0
  4. package/.ai-rules/adapters/cursor.md +172 -94
  5. package/.ai-rules/adapters/kiro.md +70 -4
  6. package/.ai-rules/adapters/opencode-skills.md +16 -16
  7. package/.ai-rules/adapters/opencode.md +107 -16
  8. package/.ai-rules/adapters/q.md +61 -4
  9. package/.ai-rules/agents/README.md +56 -0
  10. package/.ai-rules/agents/accessibility-specialist.json +1 -1
  11. package/.ai-rules/agents/act-mode.json +34 -34
  12. package/.ai-rules/agents/agent-architect.json +2 -2
  13. package/.ai-rules/agents/architecture-specialist.json +1 -1
  14. package/.ai-rules/agents/backend-developer.json +1 -1
  15. package/.ai-rules/agents/code-quality-specialist.json +1 -1
  16. package/.ai-rules/agents/code-reviewer.json +70 -0
  17. package/.ai-rules/agents/data-engineer.json +376 -0
  18. package/.ai-rules/agents/devops-engineer.json +6 -6
  19. package/.ai-rules/agents/documentation-specialist.json +1 -1
  20. package/.ai-rules/agents/eval-mode.json +52 -33
  21. package/.ai-rules/agents/frontend-developer.json +1 -1
  22. package/.ai-rules/agents/i18n-specialist.json +393 -0
  23. package/.ai-rules/agents/mobile-developer.json +355 -0
  24. package/.ai-rules/agents/performance-specialist.json +1 -1
  25. package/.ai-rules/agents/plan-mode.json +25 -25
  26. package/.ai-rules/agents/security-specialist.json +1 -1
  27. package/.ai-rules/agents/seo-specialist.json +1 -1
  28. package/.ai-rules/agents/solution-architect.json +2 -2
  29. package/.ai-rules/agents/technical-planner.json +2 -2
  30. package/.ai-rules/agents/test-strategy-specialist.json +1 -1
  31. package/.ai-rules/agents/tooling-engineer.json +202 -0
  32. package/.ai-rules/agents/ui-ux-designer.json +1 -1
  33. package/.ai-rules/checklists/accessibility.json +132 -0
  34. package/.ai-rules/checklists/code-quality.json +97 -0
  35. package/.ai-rules/checklists/index.json +47 -0
  36. package/.ai-rules/checklists/performance.json +97 -0
  37. package/.ai-rules/checklists/security.json +119 -0
  38. package/.ai-rules/checklists/seo.json +97 -0
  39. package/.ai-rules/checklists/testing.json +97 -0
  40. package/.ai-rules/rules/core.md +200 -2
  41. package/.ai-rules/skills/api-design/SKILL.md +459 -0
  42. package/package.json +1 -1
@@ -0,0 +1,459 @@
1
+ ---
2
+ name: api-design
3
+ description: Use when designing REST or GraphQL APIs - covers OpenAPI spec, resource design, versioning, and documentation
4
+ ---
5
+
6
+ # API Design
7
+
8
+ ## Overview
9
+
10
+ Design APIs that are consistent, predictable, and well-documented. This skill covers REST and GraphQL API design patterns.
11
+
12
+ **Core principle:** APIs are contracts. Once published, breaking changes are expensive.
13
+
14
+ ## When to Use
15
+
16
+ **Use this skill:**
17
+ - Designing new API endpoints
18
+ - Refactoring existing APIs
19
+ - Adding versioning strategy
20
+ - Creating OpenAPI/GraphQL specifications
21
+ - Standardizing error responses
22
+
23
+ **Not needed for:**
24
+ - Internal function signatures
25
+ - Database schema design (use data-engineer agent)
26
+
27
+ ## REST API Design
28
+
29
+ ### Resource Naming
30
+
31
+ ```
32
+ ✅ Good ❌ Bad
33
+ -----------------------------------------
34
+ GET /users GET /getUsers
35
+ GET /users/{id} GET /user?id=123
36
+ POST /users POST /createUser
37
+ PUT /users/{id} POST /updateUser
38
+ DELETE /users/{id} GET /deleteUser/{id}
39
+ GET /users/{id}/orders GET /getUserOrders
40
+ ```
41
+
42
+ **Rules:**
43
+ - Use nouns, not verbs (HTTP method is the verb)
44
+ - Plural for collections: `/users` not `/user`
45
+ - Hierarchical for relationships: `/users/{id}/orders`
46
+ - Lowercase, hyphen-separated: `/user-profiles` not `/userProfiles`
47
+
48
+ ### HTTP Methods
49
+
50
+ | Method | Purpose | Idempotent | Safe |
51
+ |--------|---------|------------|------|
52
+ | GET | Retrieve resource | Yes | Yes |
53
+ | POST | Create resource | No | No |
54
+ | PUT | Replace resource | Yes | No |
55
+ | PATCH | Partial update | Yes* | No |
56
+ | DELETE | Remove resource | Yes | No |
57
+
58
+ *PATCH is idempotent if using JSON Patch/Merge Patch format.
59
+
60
+ ### Status Codes
61
+
62
+ ```
63
+ 2xx Success
64
+ -----------------------------------------
65
+ 200 OK - GET/PUT/PATCH success, body contains data
66
+ 201 Created - POST success, Location header has URL
67
+ 204 No Content - DELETE success, no body
68
+
69
+ 4xx Client Error
70
+ -----------------------------------------
71
+ 400 Bad Request - Invalid input (validation failed)
72
+ 401 Unauthorized - Authentication required
73
+ 403 Forbidden - Authenticated but not allowed
74
+ 404 Not Found - Resource doesn't exist
75
+ 409 Conflict - State conflict (duplicate, version mismatch)
76
+ 422 Unprocessable - Valid syntax but semantic error
77
+
78
+ 5xx Server Error
79
+ -----------------------------------------
80
+ 500 Internal Error - Unexpected server error
81
+ 502 Bad Gateway - Upstream service failed
82
+ 503 Unavailable - Temporary overload
83
+ ```
84
+
85
+ ### Standard Response Format
86
+
87
+ **Success Response:**
88
+ ```json
89
+ {
90
+ "data": {
91
+ "id": "123",
92
+ "name": "Example"
93
+ },
94
+ "meta": {
95
+ "requestId": "abc-123",
96
+ "timestamp": "2024-01-15T10:30:00Z"
97
+ }
98
+ }
99
+ ```
100
+
101
+ **Collection Response:**
102
+ ```json
103
+ {
104
+ "data": [
105
+ { "id": "1", "name": "First" },
106
+ { "id": "2", "name": "Second" }
107
+ ],
108
+ "meta": {
109
+ "total": 100,
110
+ "page": 1,
111
+ "pageSize": 20,
112
+ "hasNext": true
113
+ }
114
+ }
115
+ ```
116
+
117
+ **Error Response:**
118
+ ```json
119
+ {
120
+ "error": {
121
+ "code": "VALIDATION_ERROR",
122
+ "message": "Invalid input data",
123
+ "details": [
124
+ { "field": "email", "message": "Invalid email format" }
125
+ ]
126
+ },
127
+ "meta": {
128
+ "requestId": "abc-123",
129
+ "timestamp": "2024-01-15T10:30:00Z"
130
+ }
131
+ }
132
+ ```
133
+
134
+ ### Versioning Strategies
135
+
136
+ | Strategy | Example | Pros | Cons |
137
+ |----------|---------|------|------|
138
+ | URI Path | `/v1/users` | Clear, cacheable | URL changes |
139
+ | Header | `Accept: application/vnd.api+json;version=1` | Clean URLs | Hidden |
140
+ | Query Param | `/users?version=1` | Easy to test | Pollutes params |
141
+
142
+ **Recommended:** URI Path versioning for simplicity and clarity.
143
+
144
+ ```
145
+ /v1/users # Version 1
146
+ /v2/users # Version 2 (breaking changes)
147
+ ```
148
+
149
+ **When to increment version:**
150
+ - Removing fields
151
+ - Changing field types
152
+ - Renaming fields
153
+ - Changing behavior
154
+
155
+ **Non-breaking (no version bump):**
156
+ - Adding new optional fields
157
+ - Adding new endpoints
158
+ - Adding new optional parameters
159
+
160
+ ### OpenAPI Specification
161
+
162
+ ```yaml
163
+ openapi: 3.1.0
164
+ info:
165
+ title: User API
166
+ version: 1.0.0
167
+ description: User management endpoints
168
+
169
+ paths:
170
+ /users:
171
+ get:
172
+ summary: List users
173
+ operationId: listUsers
174
+ parameters:
175
+ - name: page
176
+ in: query
177
+ schema:
178
+ type: integer
179
+ default: 1
180
+ - name: pageSize
181
+ in: query
182
+ schema:
183
+ type: integer
184
+ default: 20
185
+ maximum: 100
186
+ responses:
187
+ '200':
188
+ description: Success
189
+ content:
190
+ application/json:
191
+ schema:
192
+ $ref: '#/components/schemas/UserListResponse'
193
+ post:
194
+ summary: Create user
195
+ operationId: createUser
196
+ requestBody:
197
+ required: true
198
+ content:
199
+ application/json:
200
+ schema:
201
+ $ref: '#/components/schemas/CreateUserRequest'
202
+ responses:
203
+ '201':
204
+ description: Created
205
+ headers:
206
+ Location:
207
+ schema:
208
+ type: string
209
+ content:
210
+ application/json:
211
+ schema:
212
+ $ref: '#/components/schemas/UserResponse'
213
+ '400':
214
+ description: Validation error
215
+ content:
216
+ application/json:
217
+ schema:
218
+ $ref: '#/components/schemas/ErrorResponse'
219
+
220
+ components:
221
+ schemas:
222
+ User:
223
+ type: object
224
+ required:
225
+ - id
226
+ - email
227
+ properties:
228
+ id:
229
+ type: string
230
+ format: uuid
231
+ email:
232
+ type: string
233
+ format: email
234
+ name:
235
+ type: string
236
+ createdAt:
237
+ type: string
238
+ format: date-time
239
+
240
+ ErrorResponse:
241
+ type: object
242
+ required:
243
+ - error
244
+ properties:
245
+ error:
246
+ type: object
247
+ required:
248
+ - code
249
+ - message
250
+ properties:
251
+ code:
252
+ type: string
253
+ message:
254
+ type: string
255
+ details:
256
+ type: array
257
+ items:
258
+ type: object
259
+ properties:
260
+ field:
261
+ type: string
262
+ message:
263
+ type: string
264
+ ```
265
+
266
+ ## GraphQL API Design
267
+
268
+ ### Schema Design
269
+
270
+ ```graphql
271
+ type Query {
272
+ user(id: ID!): User
273
+ users(filter: UserFilter, pagination: Pagination): UserConnection!
274
+ }
275
+
276
+ type Mutation {
277
+ createUser(input: CreateUserInput!): CreateUserPayload!
278
+ updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
279
+ deleteUser(id: ID!): DeleteUserPayload!
280
+ }
281
+
282
+ type User {
283
+ id: ID!
284
+ email: String!
285
+ name: String
286
+ orders(first: Int, after: String): OrderConnection!
287
+ createdAt: DateTime!
288
+ }
289
+
290
+ # Relay-style connection for pagination
291
+ type UserConnection {
292
+ edges: [UserEdge!]!
293
+ pageInfo: PageInfo!
294
+ totalCount: Int!
295
+ }
296
+
297
+ type UserEdge {
298
+ cursor: String!
299
+ node: User!
300
+ }
301
+
302
+ type PageInfo {
303
+ hasNextPage: Boolean!
304
+ hasPreviousPage: Boolean!
305
+ startCursor: String
306
+ endCursor: String
307
+ }
308
+
309
+ # Input types
310
+ input CreateUserInput {
311
+ email: String!
312
+ name: String
313
+ }
314
+
315
+ # Payload types with union for errors
316
+ type CreateUserPayload {
317
+ user: User
318
+ errors: [UserError!]
319
+ }
320
+
321
+ type UserError {
322
+ field: String
323
+ message: String!
324
+ code: String!
325
+ }
326
+ ```
327
+
328
+ ### N+1 Query Prevention
329
+
330
+ ```typescript
331
+ // ❌ Bad: N+1 queries
332
+ const resolvers = {
333
+ User: {
334
+ orders: async (user) => {
335
+ // Called once per user - N queries
336
+ return db.orders.findByUserId(user.id);
337
+ }
338
+ }
339
+ };
340
+
341
+ // ✅ Good: DataLoader batching
342
+ import DataLoader from 'dataloader';
343
+
344
+ const orderLoader = new DataLoader(async (userIds) => {
345
+ // Single batched query
346
+ const orders = await db.orders.findByUserIds(userIds);
347
+ return userIds.map(id => orders.filter(o => o.userId === id));
348
+ });
349
+
350
+ const resolvers = {
351
+ User: {
352
+ orders: async (user) => orderLoader.load(user.id)
353
+ }
354
+ };
355
+ ```
356
+
357
+ ### Query Complexity Limiting
358
+
359
+ ```typescript
360
+ // Prevent expensive queries
361
+ const complexityConfig = {
362
+ maximumComplexity: 1000,
363
+ scalarCost: 1,
364
+ objectCost: 10,
365
+ listFactor: 10, // Multiply by list size
366
+ };
367
+
368
+ // Example: users(first: 100) { orders(first: 50) { ... } }
369
+ // Complexity: 10 + (100 * (10 + (50 * 10))) = 51,010 (rejected)
370
+ ```
371
+
372
+ ## Rate Limiting
373
+
374
+ ### Headers
375
+
376
+ ```http
377
+ HTTP/1.1 200 OK
378
+ X-RateLimit-Limit: 100
379
+ X-RateLimit-Remaining: 95
380
+ X-RateLimit-Reset: 1704067200
381
+
382
+ # When exceeded
383
+ HTTP/1.1 429 Too Many Requests
384
+ Retry-After: 60
385
+ ```
386
+
387
+ ### Strategies
388
+
389
+ | Strategy | Description | Use Case |
390
+ |----------|-------------|----------|
391
+ | Fixed Window | X requests per minute | Simple APIs |
392
+ | Sliding Window | Rolling window | More accurate |
393
+ | Token Bucket | Refill tokens over time | Burst-friendly |
394
+ | Leaky Bucket | Constant output rate | Smooth traffic |
395
+
396
+ ## API Gateway Patterns
397
+
398
+ ```
399
+ Client → API Gateway → Microservices
400
+
401
+ - Authentication
402
+ - Rate Limiting
403
+ - Request Routing
404
+ - Response Caching
405
+ - Request/Response Transform
406
+ - Circuit Breaker
407
+ ```
408
+
409
+ ## Documentation Checklist
410
+
411
+ Before shipping an API:
412
+
413
+ - [ ] OpenAPI/GraphQL schema complete
414
+ - [ ] All error codes documented
415
+ - [ ] Authentication described
416
+ - [ ] Rate limits documented
417
+ - [ ] Example requests/responses
418
+ - [ ] Changelog for versions
419
+ - [ ] SDK/client libraries linked
420
+ - [ ] Postman/Insomnia collection
421
+
422
+ ## Common Mistakes
423
+
424
+ | Mistake | Fix |
425
+ |---------|-----|
426
+ | Verbs in URLs | Use nouns: `/users` not `/getUsers` |
427
+ | Inconsistent naming | Pick one: camelCase or snake_case |
428
+ | Missing pagination | Always paginate lists |
429
+ | No error codes | Use machine-readable codes |
430
+ | Breaking changes | Version the API |
431
+ | Missing rate limits | Protect against abuse |
432
+ | N+1 in GraphQL | Use DataLoader |
433
+ | No request IDs | Add for debugging |
434
+
435
+ ## Quick Reference
436
+
437
+ ```
438
+ REST
439
+ ────────────────────────────────────
440
+ GET /resources List all
441
+ GET /resources/{id} Get one
442
+ POST /resources Create
443
+ PUT /resources/{id} Replace
444
+ PATCH /resources/{id} Update
445
+ DELETE /resources/{id} Remove
446
+
447
+ GraphQL
448
+ ────────────────────────────────────
449
+ Query Read operations
450
+ Mutation Write operations
451
+ Subscription Real-time updates
452
+
453
+ Connections (Relay)
454
+ ────────────────────────────────────
455
+ edges List of edge objects
456
+ node The actual object
457
+ cursor Pagination cursor
458
+ pageInfo hasNextPage, etc.
459
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codingbuddy-rules",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "AI coding rules for consistent practices across AI assistants",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",