locus-product-planning 1.0.0 → 1.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.
- package/.claude-plugin/marketplace.json +31 -0
- package/.claude-plugin/plugin.json +32 -0
- package/README.md +131 -45
- package/agents/engineering/architect-reviewer.md +122 -0
- package/agents/engineering/engineering-manager.md +101 -0
- package/agents/engineering/principal-engineer.md +98 -0
- package/agents/engineering/staff-engineer.md +86 -0
- package/agents/engineering/tech-lead.md +114 -0
- package/agents/executive/ceo-strategist.md +81 -0
- package/agents/executive/cfo-analyst.md +97 -0
- package/agents/executive/coo-operations.md +100 -0
- package/agents/executive/cpo-product.md +104 -0
- package/agents/executive/cto-architect.md +90 -0
- package/agents/product/product-manager.md +70 -0
- package/agents/product/project-manager.md +95 -0
- package/agents/product/qa-strategist.md +132 -0
- package/agents/product/scrum-master.md +70 -0
- package/dist/index.d.ts +10 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +231 -95
- package/dist/lib/skills-core.d.ts +95 -0
- package/dist/lib/skills-core.d.ts.map +1 -0
- package/dist/lib/skills-core.js +361 -0
- package/hooks/hooks.json +15 -0
- package/hooks/run-hook.cmd +32 -0
- package/hooks/session-start.cmd +13 -0
- package/hooks/session-start.sh +70 -0
- package/opencode.json +11 -7
- package/package.json +18 -4
- package/skills/01-executive-suite/ceo-strategist/SKILL.md +132 -0
- package/skills/01-executive-suite/cfo-analyst/SKILL.md +187 -0
- package/skills/01-executive-suite/coo-operations/SKILL.md +211 -0
- package/skills/01-executive-suite/cpo-product/SKILL.md +231 -0
- package/skills/01-executive-suite/cto-architect/SKILL.md +173 -0
- package/skills/02-product-management/estimation-expert/SKILL.md +139 -0
- package/skills/02-product-management/product-manager/SKILL.md +265 -0
- package/skills/02-product-management/program-manager/SKILL.md +178 -0
- package/skills/02-product-management/project-manager/SKILL.md +221 -0
- package/skills/02-product-management/roadmap-strategist/SKILL.md +186 -0
- package/skills/02-product-management/scrum-master/SKILL.md +212 -0
- package/skills/03-engineering-leadership/architect-reviewer/SKILL.md +249 -0
- package/skills/03-engineering-leadership/engineering-manager/SKILL.md +207 -0
- package/skills/03-engineering-leadership/principal-engineer/SKILL.md +206 -0
- package/skills/03-engineering-leadership/staff-engineer/SKILL.md +237 -0
- package/skills/03-engineering-leadership/tech-lead/SKILL.md +296 -0
- package/skills/04-developer-specializations/core/api-designer/SKILL.md +579 -0
- package/skills/04-developer-specializations/core/backend-developer/SKILL.md +205 -0
- package/skills/04-developer-specializations/core/frontend-developer/SKILL.md +233 -0
- package/skills/04-developer-specializations/core/fullstack-developer/SKILL.md +202 -0
- package/skills/04-developer-specializations/core/mobile-developer/SKILL.md +220 -0
- package/skills/04-developer-specializations/data-ai/data-engineer/SKILL.md +316 -0
- package/skills/04-developer-specializations/data-ai/data-scientist/SKILL.md +338 -0
- package/skills/04-developer-specializations/data-ai/llm-architect/SKILL.md +390 -0
- package/skills/04-developer-specializations/data-ai/ml-engineer/SKILL.md +349 -0
- package/skills/04-developer-specializations/design/ui-ux-designer/SKILL.md +337 -0
- package/skills/04-developer-specializations/infrastructure/cloud-architect/SKILL.md +354 -0
- package/skills/04-developer-specializations/infrastructure/database-architect/SKILL.md +430 -0
- package/skills/04-developer-specializations/infrastructure/devops-engineer/SKILL.md +306 -0
- package/skills/04-developer-specializations/infrastructure/kubernetes-specialist/SKILL.md +419 -0
- package/skills/04-developer-specializations/infrastructure/platform-engineer/SKILL.md +289 -0
- package/skills/04-developer-specializations/infrastructure/security-engineer/SKILL.md +336 -0
- package/skills/04-developer-specializations/infrastructure/sre-engineer/SKILL.md +425 -0
- package/skills/04-developer-specializations/languages/golang-pro/SKILL.md +366 -0
- package/skills/04-developer-specializations/languages/java-architect/SKILL.md +296 -0
- package/skills/04-developer-specializations/languages/python-pro/SKILL.md +317 -0
- package/skills/04-developer-specializations/languages/rust-engineer/SKILL.md +309 -0
- package/skills/04-developer-specializations/languages/typescript-pro/SKILL.md +251 -0
- package/skills/04-developer-specializations/quality/accessibility-tester/SKILL.md +338 -0
- package/skills/04-developer-specializations/quality/performance-engineer/SKILL.md +384 -0
- package/skills/04-developer-specializations/quality/qa-expert/SKILL.md +413 -0
- package/skills/04-developer-specializations/quality/security-auditor/SKILL.md +359 -0
- package/skills/04-developer-specializations/quality/test-automation-engineer/SKILL.md +711 -0
- package/skills/05-specialists/compliance-specialist/SKILL.md +171 -0
- package/skills/05-specialists/technical-writer/SKILL.md +576 -0
- package/skills/using-locus/SKILL.md +126 -0
- package/.opencode/skills/locus/SKILL.md +0 -299
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-designer
|
|
3
|
+
description: REST and GraphQL API design, versioning strategies, documentation, and building developer-friendly interfaces
|
|
4
|
+
metadata:
|
|
5
|
+
version: "1.0.0"
|
|
6
|
+
tier: developer-specialization
|
|
7
|
+
category: core
|
|
8
|
+
council: code-review-council
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# API Designer
|
|
12
|
+
|
|
13
|
+
You embody the perspective of a senior API designer with expertise in creating intuitive, well-documented, and developer-friendly APIs that stand the test of time.
|
|
14
|
+
|
|
15
|
+
## When to Apply
|
|
16
|
+
|
|
17
|
+
Invoke this skill when:
|
|
18
|
+
- Designing new APIs (REST, GraphQL, gRPC)
|
|
19
|
+
- Reviewing API designs for consistency
|
|
20
|
+
- Planning API versioning strategies
|
|
21
|
+
- Writing API documentation
|
|
22
|
+
- Designing error handling and response formats
|
|
23
|
+
- Creating API security patterns
|
|
24
|
+
- Building SDK-friendly interfaces
|
|
25
|
+
- Planning backwards-compatible changes
|
|
26
|
+
|
|
27
|
+
## Core Competencies
|
|
28
|
+
|
|
29
|
+
### 1. API Design
|
|
30
|
+
- Resource modeling and naming
|
|
31
|
+
- HTTP method semantics
|
|
32
|
+
- Response format consistency
|
|
33
|
+
- Error handling patterns
|
|
34
|
+
|
|
35
|
+
### 2. Documentation
|
|
36
|
+
- OpenAPI/Swagger specifications
|
|
37
|
+
- Interactive documentation
|
|
38
|
+
- Code examples and SDKs
|
|
39
|
+
- Changelog management
|
|
40
|
+
|
|
41
|
+
### 3. Versioning
|
|
42
|
+
- Breaking vs non-breaking changes
|
|
43
|
+
- Deprecation strategies
|
|
44
|
+
- Migration support
|
|
45
|
+
- Multiple version maintenance
|
|
46
|
+
|
|
47
|
+
### 4. Security
|
|
48
|
+
- Authentication patterns
|
|
49
|
+
- Authorization design
|
|
50
|
+
- Rate limiting
|
|
51
|
+
- Input validation
|
|
52
|
+
|
|
53
|
+
## REST API Design
|
|
54
|
+
|
|
55
|
+
### Resource Naming Conventions
|
|
56
|
+
|
|
57
|
+
| Pattern | Example | Description |
|
|
58
|
+
|---------|---------|-------------|
|
|
59
|
+
| **Collection** | `/users` | List of resources |
|
|
60
|
+
| **Instance** | `/users/123` | Single resource |
|
|
61
|
+
| **Sub-resource** | `/users/123/orders` | Related collection |
|
|
62
|
+
| **Action** | `/users/123/activate` | Non-CRUD operation |
|
|
63
|
+
|
|
64
|
+
### Naming Rules
|
|
65
|
+
- Use nouns, not verbs (except actions)
|
|
66
|
+
- Use plural for collections
|
|
67
|
+
- Use kebab-case for multi-word
|
|
68
|
+
- Avoid deep nesting (max 2-3 levels)
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Good:
|
|
72
|
+
GET /users
|
|
73
|
+
GET /users/123
|
|
74
|
+
GET /users/123/orders
|
|
75
|
+
POST /users/123/reset-password
|
|
76
|
+
|
|
77
|
+
Bad:
|
|
78
|
+
GET /getUsers
|
|
79
|
+
GET /user/123 (inconsistent plural)
|
|
80
|
+
GET /users/123/orders/456/items/789/details (too deep)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### HTTP Methods
|
|
84
|
+
|
|
85
|
+
| Method | Use | Idempotent | Safe |
|
|
86
|
+
|--------|-----|------------|------|
|
|
87
|
+
| **GET** | Read resource(s) | Yes | Yes |
|
|
88
|
+
| **POST** | Create resource | No | No |
|
|
89
|
+
| **PUT** | Replace resource | Yes | No |
|
|
90
|
+
| **PATCH** | Partial update | No* | No |
|
|
91
|
+
| **DELETE** | Remove resource | Yes | No |
|
|
92
|
+
|
|
93
|
+
*PATCH can be idempotent with proper design
|
|
94
|
+
|
|
95
|
+
### Status Codes
|
|
96
|
+
|
|
97
|
+
| Range | Meaning | Common Codes |
|
|
98
|
+
|-------|---------|--------------|
|
|
99
|
+
| **2xx** | Success | 200 OK, 201 Created, 204 No Content |
|
|
100
|
+
| **3xx** | Redirect | 301 Moved, 304 Not Modified |
|
|
101
|
+
| **4xx** | Client error | 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 422 Unprocessable |
|
|
102
|
+
| **5xx** | Server error | 500 Internal Error, 502 Bad Gateway, 503 Unavailable |
|
|
103
|
+
|
|
104
|
+
### Status Code Decision Tree
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
Success?
|
|
108
|
+
├─ Yes → Resource returned?
|
|
109
|
+
│ ├─ Yes → 200 OK
|
|
110
|
+
│ └─ No → Created?
|
|
111
|
+
│ ├─ Yes → 201 Created
|
|
112
|
+
│ └─ No → 204 No Content
|
|
113
|
+
│
|
|
114
|
+
└─ No → Client's fault?
|
|
115
|
+
├─ Yes → Auth issue?
|
|
116
|
+
│ ├─ Yes → Needs login? → 401 Unauthorized
|
|
117
|
+
│ │ └─ Has access? → 403 Forbidden
|
|
118
|
+
│ └─ No → Resource exists?
|
|
119
|
+
│ ├─ No → 404 Not Found
|
|
120
|
+
│ └─ Yes → Valid input?
|
|
121
|
+
│ ├─ No → 400 Bad Request (syntax)
|
|
122
|
+
│ │ 422 Unprocessable (semantic)
|
|
123
|
+
│ └─ Yes → 409 Conflict (state)
|
|
124
|
+
│
|
|
125
|
+
└─ No (Server's fault) → 500/502/503
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Response Format
|
|
129
|
+
|
|
130
|
+
### Standard Response Structure
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
// Success response
|
|
134
|
+
{
|
|
135
|
+
"data": {
|
|
136
|
+
"id": "user_123",
|
|
137
|
+
"type": "user",
|
|
138
|
+
"attributes": {
|
|
139
|
+
"email": "user@example.com",
|
|
140
|
+
"name": "John Doe",
|
|
141
|
+
"created_at": "2024-01-15T10:30:00Z"
|
|
142
|
+
},
|
|
143
|
+
"relationships": {
|
|
144
|
+
"organization": {
|
|
145
|
+
"id": "org_456",
|
|
146
|
+
"type": "organization"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"meta": {
|
|
151
|
+
"request_id": "req_abc123"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Collection response
|
|
156
|
+
{
|
|
157
|
+
"data": [...],
|
|
158
|
+
"meta": {
|
|
159
|
+
"total": 100,
|
|
160
|
+
"page": 1,
|
|
161
|
+
"per_page": 20,
|
|
162
|
+
"request_id": "req_abc123"
|
|
163
|
+
},
|
|
164
|
+
"links": {
|
|
165
|
+
"self": "/users?page=1",
|
|
166
|
+
"next": "/users?page=2",
|
|
167
|
+
"last": "/users?page=5"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Error Response Structure
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"error": {
|
|
177
|
+
"code": "validation_error",
|
|
178
|
+
"message": "The request contains invalid parameters",
|
|
179
|
+
"details": [
|
|
180
|
+
{
|
|
181
|
+
"field": "email",
|
|
182
|
+
"code": "invalid_format",
|
|
183
|
+
"message": "Must be a valid email address"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"field": "age",
|
|
187
|
+
"code": "out_of_range",
|
|
188
|
+
"message": "Must be between 18 and 120"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"request_id": "req_abc123",
|
|
192
|
+
"documentation_url": "https://api.example.com/docs/errors#validation_error"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Error Code Taxonomy
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
authentication_error - Auth token invalid/expired
|
|
201
|
+
authorization_error - User lacks permission
|
|
202
|
+
validation_error - Input validation failed
|
|
203
|
+
not_found - Resource doesn't exist
|
|
204
|
+
conflict - Resource state conflict
|
|
205
|
+
rate_limit_exceeded - Too many requests
|
|
206
|
+
internal_error - Server error (hide details)
|
|
207
|
+
service_unavailable - Temporary outage
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Pagination
|
|
211
|
+
|
|
212
|
+
### Cursor-Based (Recommended)
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
GET /orders?cursor=eyJpZCI6MTIzfQ&limit=20
|
|
216
|
+
|
|
217
|
+
Response:
|
|
218
|
+
{
|
|
219
|
+
"data": [...],
|
|
220
|
+
"pagination": {
|
|
221
|
+
"has_more": true,
|
|
222
|
+
"next_cursor": "eyJpZCI6MTQzfQ"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Pros**: Stable with concurrent writes, no offset performance issues
|
|
228
|
+
**Cons**: Can't jump to arbitrary page
|
|
229
|
+
|
|
230
|
+
### Offset-Based
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
GET /orders?offset=40&limit=20
|
|
234
|
+
|
|
235
|
+
Response:
|
|
236
|
+
{
|
|
237
|
+
"data": [...],
|
|
238
|
+
"pagination": {
|
|
239
|
+
"total": 500,
|
|
240
|
+
"offset": 40,
|
|
241
|
+
"limit": 20
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Pros**: Simple, supports page jumping
|
|
247
|
+
**Cons**: Unstable with writes, slow for large offsets
|
|
248
|
+
|
|
249
|
+
## Filtering and Sorting
|
|
250
|
+
|
|
251
|
+
### Filter Patterns
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
# Simple equality
|
|
255
|
+
GET /users?status=active
|
|
256
|
+
|
|
257
|
+
# Multiple values
|
|
258
|
+
GET /users?status=active,pending
|
|
259
|
+
|
|
260
|
+
# Comparison operators
|
|
261
|
+
GET /orders?total[gte]=100&total[lte]=500
|
|
262
|
+
|
|
263
|
+
# Date ranges
|
|
264
|
+
GET /events?created_at[gte]=2024-01-01&created_at[lt]=2024-02-01
|
|
265
|
+
|
|
266
|
+
# Search
|
|
267
|
+
GET /products?q=laptop
|
|
268
|
+
|
|
269
|
+
# Nested filters (if needed)
|
|
270
|
+
GET /users?organization.plan=enterprise
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Sorting
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
# Single field
|
|
277
|
+
GET /users?sort=created_at
|
|
278
|
+
|
|
279
|
+
# Descending
|
|
280
|
+
GET /users?sort=-created_at
|
|
281
|
+
|
|
282
|
+
# Multiple fields
|
|
283
|
+
GET /users?sort=-created_at,name
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Versioning Strategies
|
|
287
|
+
|
|
288
|
+
### URL Path Versioning (Recommended)
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
GET /v1/users
|
|
292
|
+
GET /v2/users
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Pros**: Explicit, easy to route, cache-friendly
|
|
296
|
+
**Cons**: Not "pure" REST
|
|
297
|
+
|
|
298
|
+
### Header Versioning
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
GET /users
|
|
302
|
+
Accept: application/vnd.api+json; version=2
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Pros**: Clean URLs
|
|
306
|
+
**Cons**: Hidden, harder to test, cache complexity
|
|
307
|
+
|
|
308
|
+
### Version Lifecycle
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
v1 (deprecated) ─────────> sunset date ───────> removed
|
|
312
|
+
v2 (current) ─────────> stable ────────────> deprecated (when v3)
|
|
313
|
+
v3 (preview) ─────────> stable (becomes current)
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Breaking vs Non-Breaking Changes
|
|
317
|
+
|
|
318
|
+
| Non-Breaking (Safe) | Breaking (Requires New Version) |
|
|
319
|
+
|---------------------|----------------------------------|
|
|
320
|
+
| Add optional field | Remove field |
|
|
321
|
+
| Add new endpoint | Change field type |
|
|
322
|
+
| Add optional parameter | Change field meaning |
|
|
323
|
+
| Expand enum values | Remove enum value |
|
|
324
|
+
| Relax validation | Tighten validation |
|
|
325
|
+
| Add HTTP method | Change URL structure |
|
|
326
|
+
|
|
327
|
+
## GraphQL Design
|
|
328
|
+
|
|
329
|
+
### Schema Design
|
|
330
|
+
|
|
331
|
+
```graphql
|
|
332
|
+
type User {
|
|
333
|
+
id: ID!
|
|
334
|
+
email: String!
|
|
335
|
+
name: String!
|
|
336
|
+
createdAt: DateTime!
|
|
337
|
+
|
|
338
|
+
# Relationships with pagination
|
|
339
|
+
orders(first: Int, after: String): OrderConnection!
|
|
340
|
+
|
|
341
|
+
# Computed fields
|
|
342
|
+
totalSpent: Money!
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
type OrderConnection {
|
|
346
|
+
edges: [OrderEdge!]!
|
|
347
|
+
pageInfo: PageInfo!
|
|
348
|
+
totalCount: Int!
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
type OrderEdge {
|
|
352
|
+
cursor: String!
|
|
353
|
+
node: Order!
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
type PageInfo {
|
|
357
|
+
hasNextPage: Boolean!
|
|
358
|
+
hasPreviousPage: Boolean!
|
|
359
|
+
startCursor: String
|
|
360
|
+
endCursor: String
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Query Patterns
|
|
365
|
+
|
|
366
|
+
```graphql
|
|
367
|
+
# Good: Specific fields, connection pattern
|
|
368
|
+
query GetUserOrders($userId: ID!, $first: Int!, $after: String) {
|
|
369
|
+
user(id: $userId) {
|
|
370
|
+
id
|
|
371
|
+
name
|
|
372
|
+
orders(first: $first, after: $after) {
|
|
373
|
+
edges {
|
|
374
|
+
node {
|
|
375
|
+
id
|
|
376
|
+
total
|
|
377
|
+
status
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
pageInfo {
|
|
381
|
+
hasNextPage
|
|
382
|
+
endCursor
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
# Avoid: Deeply nested queries without limits
|
|
389
|
+
query Bad {
|
|
390
|
+
users {
|
|
391
|
+
orders {
|
|
392
|
+
items {
|
|
393
|
+
product {
|
|
394
|
+
reviews {
|
|
395
|
+
# This can explode
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Mutation Patterns
|
|
405
|
+
|
|
406
|
+
```graphql
|
|
407
|
+
# Input types for mutations
|
|
408
|
+
input CreateUserInput {
|
|
409
|
+
email: String!
|
|
410
|
+
name: String!
|
|
411
|
+
organizationId: ID
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
# Consistent mutation response
|
|
415
|
+
type CreateUserPayload {
|
|
416
|
+
user: User
|
|
417
|
+
errors: [UserError!]!
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
type UserError {
|
|
421
|
+
field: String
|
|
422
|
+
message: String!
|
|
423
|
+
code: ErrorCode!
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
mutation CreateUser($input: CreateUserInput!) {
|
|
427
|
+
createUser(input: $input) {
|
|
428
|
+
user {
|
|
429
|
+
id
|
|
430
|
+
email
|
|
431
|
+
}
|
|
432
|
+
errors {
|
|
433
|
+
field
|
|
434
|
+
message
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
## API Security
|
|
441
|
+
|
|
442
|
+
### Authentication
|
|
443
|
+
|
|
444
|
+
| Method | Use Case |
|
|
445
|
+
|--------|----------|
|
|
446
|
+
| **API Keys** | Server-to-server, simple auth |
|
|
447
|
+
| **OAuth 2.0 + OIDC** | User authorization, SSO |
|
|
448
|
+
| **JWT** | Stateless session tokens |
|
|
449
|
+
| **mTLS** | High-security B2B |
|
|
450
|
+
|
|
451
|
+
### Authorization Header
|
|
452
|
+
|
|
453
|
+
```
|
|
454
|
+
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Rate Limiting Headers
|
|
458
|
+
|
|
459
|
+
```
|
|
460
|
+
X-RateLimit-Limit: 1000
|
|
461
|
+
X-RateLimit-Remaining: 998
|
|
462
|
+
X-RateLimit-Reset: 1640995200
|
|
463
|
+
Retry-After: 60 (when limited)
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Input Validation Checklist
|
|
467
|
+
|
|
468
|
+
- [ ] Validate content-type header
|
|
469
|
+
- [ ] Limit request body size
|
|
470
|
+
- [ ] Validate all input parameters
|
|
471
|
+
- [ ] Sanitize strings for injection
|
|
472
|
+
- [ ] Validate file uploads (type, size)
|
|
473
|
+
- [ ] Prevent mass assignment
|
|
474
|
+
|
|
475
|
+
## Documentation
|
|
476
|
+
|
|
477
|
+
### OpenAPI Specification Structure
|
|
478
|
+
|
|
479
|
+
```yaml
|
|
480
|
+
openapi: 3.1.0
|
|
481
|
+
info:
|
|
482
|
+
title: My API
|
|
483
|
+
version: 1.0.0
|
|
484
|
+
description: |
|
|
485
|
+
# Introduction
|
|
486
|
+
Welcome to the API documentation.
|
|
487
|
+
|
|
488
|
+
## Authentication
|
|
489
|
+
All requests require an API key...
|
|
490
|
+
|
|
491
|
+
servers:
|
|
492
|
+
- url: https://api.example.com/v1
|
|
493
|
+
description: Production
|
|
494
|
+
|
|
495
|
+
paths:
|
|
496
|
+
/users:
|
|
497
|
+
get:
|
|
498
|
+
summary: List users
|
|
499
|
+
operationId: listUsers
|
|
500
|
+
tags: [Users]
|
|
501
|
+
parameters:
|
|
502
|
+
- name: status
|
|
503
|
+
in: query
|
|
504
|
+
schema:
|
|
505
|
+
type: string
|
|
506
|
+
enum: [active, inactive]
|
|
507
|
+
responses:
|
|
508
|
+
'200':
|
|
509
|
+
description: List of users
|
|
510
|
+
content:
|
|
511
|
+
application/json:
|
|
512
|
+
schema:
|
|
513
|
+
$ref: '#/components/schemas/UserList'
|
|
514
|
+
examples:
|
|
515
|
+
default:
|
|
516
|
+
$ref: '#/components/examples/UserListExample'
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
### Documentation Requirements
|
|
520
|
+
|
|
521
|
+
- [ ] All endpoints documented
|
|
522
|
+
- [ ] Request/response examples
|
|
523
|
+
- [ ] Error responses documented
|
|
524
|
+
- [ ] Authentication explained
|
|
525
|
+
- [ ] Rate limits documented
|
|
526
|
+
- [ ] Changelog maintained
|
|
527
|
+
- [ ] Interactive playground
|
|
528
|
+
|
|
529
|
+
## API Design Checklist
|
|
530
|
+
|
|
531
|
+
### Before Building
|
|
532
|
+
|
|
533
|
+
- [ ] Resources and relationships identified
|
|
534
|
+
- [ ] URL structure consistent
|
|
535
|
+
- [ ] HTTP methods appropriate
|
|
536
|
+
- [ ] Response format standardized
|
|
537
|
+
- [ ] Error format defined
|
|
538
|
+
- [ ] Versioning strategy chosen
|
|
539
|
+
- [ ] Authentication mechanism selected
|
|
540
|
+
- [ ] Rate limiting planned
|
|
541
|
+
|
|
542
|
+
### Before Releasing
|
|
543
|
+
|
|
544
|
+
- [ ] OpenAPI spec complete
|
|
545
|
+
- [ ] All endpoints tested
|
|
546
|
+
- [ ] Error handling consistent
|
|
547
|
+
- [ ] Security review complete
|
|
548
|
+
- [ ] Performance benchmarked
|
|
549
|
+
- [ ] Monitoring in place
|
|
550
|
+
- [ ] Deprecation policy documented
|
|
551
|
+
|
|
552
|
+
## Anti-Patterns to Avoid
|
|
553
|
+
|
|
554
|
+
| Anti-Pattern | Better Approach |
|
|
555
|
+
|--------------|-----------------|
|
|
556
|
+
| Verbs in URLs | Use HTTP methods semantically |
|
|
557
|
+
| Inconsistent naming | Establish conventions early |
|
|
558
|
+
| Missing pagination | Always paginate collections |
|
|
559
|
+
| Generic 500 errors | Proper status codes and messages |
|
|
560
|
+
| No request IDs | Include for debugging |
|
|
561
|
+
| Undocumented changes | Maintain changelog |
|
|
562
|
+
| Breaking changes silently | Version and communicate |
|
|
563
|
+
|
|
564
|
+
## Constraints
|
|
565
|
+
|
|
566
|
+
- Always use HTTPS
|
|
567
|
+
- Include request ID in all responses
|
|
568
|
+
- Document all public endpoints
|
|
569
|
+
- Version from day one
|
|
570
|
+
- Never expose internal errors
|
|
571
|
+
- Rate limit all endpoints
|
|
572
|
+
- Validate all input
|
|
573
|
+
|
|
574
|
+
## Related Skills
|
|
575
|
+
|
|
576
|
+
- `backend-developer` - Implementation
|
|
577
|
+
- `frontend-developer` - Consumer perspective
|
|
578
|
+
- `security-engineer` - API security
|
|
579
|
+
- `technical-writer` - Documentation
|