bobs-workshop 0.3.2 → 3.1.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 +2 -2
- package/README.md +199 -210
- package/bin/bobs-workshop.js +109 -0
- package/config/agents.json +27 -0
- package/dist/plugins/bobs-workshop.js +34 -0
- package/dist/tools/background-agent/cancel.d.ts +3 -0
- package/dist/tools/background-agent/cancel.d.ts.map +1 -0
- package/dist/tools/background-agent/cancel.js +52 -0
- package/dist/tools/background-agent/concurrency.d.ts +15 -0
- package/dist/tools/background-agent/concurrency.d.ts.map +1 -0
- package/dist/tools/background-agent/concurrency.js +61 -0
- package/dist/tools/background-agent/index.d.ts +8 -0
- package/dist/tools/background-agent/index.d.ts.map +1 -0
- package/dist/tools/background-agent/index.js +7 -0
- package/dist/tools/background-agent/launch.d.ts +6 -0
- package/dist/tools/background-agent/launch.d.ts.map +1 -0
- package/dist/tools/background-agent/launch.js +33 -0
- package/dist/tools/background-agent/list.d.ts +7 -0
- package/dist/tools/background-agent/list.d.ts.map +1 -0
- package/dist/tools/background-agent/list.js +40 -0
- package/dist/tools/background-agent/manager.d.ts +29 -0
- package/dist/tools/background-agent/manager.d.ts.map +1 -0
- package/dist/tools/background-agent/manager.js +377 -0
- package/dist/tools/background-agent/output.d.ts +3 -0
- package/dist/tools/background-agent/output.d.ts.map +1 -0
- package/dist/tools/background-agent/output.js +41 -0
- package/dist/tools/background-agent/types.d.ts +46 -0
- package/dist/tools/background-agent/types.d.ts.map +1 -0
- package/dist/tools/background-agent/types.js +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +8 -0
- package/dist/tools/manual/index.d.ts +3 -0
- package/dist/tools/manual/index.d.ts.map +1 -0
- package/dist/tools/manual/index.js +2 -0
- package/dist/tools/manual/manual-update.d.ts +4 -0
- package/dist/tools/manual/manual-update.d.ts.map +1 -0
- package/dist/tools/manual/manual-update.js +190 -0
- package/dist/tools/manual/verify-manual.d.ts +4 -0
- package/dist/tools/manual/verify-manual.d.ts.map +1 -0
- package/dist/tools/manual/verify-manual.js +46 -0
- package/package.json +35 -67
- package/postinstall.js +190 -0
- package/src/agents/alice.md +466 -0
- package/src/agents/bob-rev.md +493 -0
- package/src/agents/bob-send.md +277 -0
- package/src/agents/bob.md +442 -0
- package/src/agents/trace.md +451 -0
- package/src/plugins/bobs-workshop.ts +45 -0
- package/src/skills/api-patterns/SKILL.md +376 -0
- package/src/skills/architecture/SKILL.md +271 -0
- package/src/skills/bobs-workshop/performance/icon.svg +3 -0
- package/src/skills/brainstorming/SKILL.md +210 -0
- package/src/skills/clean-code/SKILL.md +151 -0
- package/src/skills/code-review-checklist/SKILL.md +220 -0
- package/src/skills/database-design/SKILL.md +271 -0
- package/src/skills/exploration/SKILL.md +257 -0
- package/src/skills/frontend-ui-ux/SKILL.md +78 -0
- package/src/skills/git-master/SKILL.md +1105 -0
- package/src/skills/performance/SKILL.md +144 -0
- package/src/skills/performance/icon.svg +3 -0
- package/src/skills/plan-writing/SKILL.md +225 -0
- package/src/skills/security/SKILL.md +410 -0
- package/src/skills/simplification/SKILL.md +238 -0
- package/src/skills/systematic-debugging/SKILL.md +175 -0
- package/src/skills/testing-patterns/SKILL.md +305 -0
- package/src/skills/verification/SKILL.md +286 -0
- package/src/tools/background-agent/cancel.ts +67 -0
- package/src/tools/background-agent/concurrency.ts +71 -0
- package/src/tools/background-agent/index.ts +7 -0
- package/src/tools/background-agent/launch.ts +39 -0
- package/src/tools/background-agent/list.ts +50 -0
- package/src/tools/background-agent/manager.ts +455 -0
- package/src/tools/background-agent/output.ts +57 -0
- package/src/tools/background-agent/types.ts +55 -0
- package/src/tools/index.ts +8 -0
- package/src/tools/manual/index.ts +2 -0
- package/src/tools/manual/manual-update.ts +197 -0
- package/src/tools/manual/verify-manual.ts +55 -0
- package/uninstall.js +64 -0
- package/Claude.md +0 -162
- package/bin/bobs-mcp-server.js +0 -11
- package/bin/bobs-mcp.js +0 -130
- package/dist/api/taskLogger.js +0 -106
- package/dist/api/taskLogger.js.map +0 -1
- package/dist/cli/checker.js +0 -401
- package/dist/cli/checker.js.map +0 -1
- package/dist/cli/cleanup.js +0 -131
- package/dist/cli/cleanup.js.map +0 -1
- package/dist/cli/debug.js +0 -157
- package/dist/cli/debug.js.map +0 -1
- package/dist/cli/health.js +0 -97
- package/dist/cli/health.js.map +0 -1
- package/dist/cli/setup.js +0 -81
- package/dist/cli/setup.js.map +0 -1
- package/dist/cli/workshop.js +0 -42
- package/dist/cli/workshop.js.map +0 -1
- package/dist/dashboard/server.js +0 -1203
- package/dist/dashboard/server.js.map +0 -1
- package/dist/index.js +0 -960
- package/dist/index.js.map +0 -1
- package/dist/prompts/architect.js +0 -221
- package/dist/prompts/architect.js.map +0 -1
- package/dist/prompts/debugger.js +0 -257
- package/dist/prompts/debugger.js.map +0 -1
- package/dist/prompts/engineer.js +0 -249
- package/dist/prompts/engineer.js.map +0 -1
- package/dist/prompts/orchestrator.js +0 -304
- package/dist/prompts/orchestrator.js.map +0 -1
- package/dist/prompts/reviewer.js +0 -289
- package/dist/prompts/reviewer.js.map +0 -1
- package/dist/services/activitySummarizer.js +0 -388
- package/dist/services/activitySummarizer.js.map +0 -1
- package/dist/services/changeValidator.js +0 -396
- package/dist/services/changeValidator.js.map +0 -1
- package/dist/services/claudeOrchestrator.js +0 -343
- package/dist/services/claudeOrchestrator.js.map +0 -1
- package/dist/services/fileMonitor.js +0 -250
- package/dist/services/fileMonitor.js.map +0 -1
- package/dist/services/implementationSummarizer.js +0 -306
- package/dist/services/implementationSummarizer.js.map +0 -1
- package/dist/services/liveMonitor.js +0 -315
- package/dist/services/liveMonitor.js.map +0 -1
- package/dist/services/mcpAuditLogger.js +0 -104
- package/dist/services/mcpAuditLogger.js.map +0 -1
- package/dist/services/mcpLogger.js +0 -223
- package/dist/services/mcpLogger.js.map +0 -1
- package/dist/services/tmuxManager.js +0 -541
- package/dist/services/tmuxManager.js.map +0 -1
- package/dist/tools/approvalTools.js +0 -244
- package/dist/tools/approvalTools.js.map +0 -1
- package/dist/tools/autoDebugger.js +0 -147
- package/dist/tools/autoDebugger.js.map +0 -1
- package/dist/tools/cleanupService.js +0 -221
- package/dist/tools/cleanupService.js.map +0 -1
- package/dist/tools/dashboardTools.js +0 -342
- package/dist/tools/dashboardTools.js.map +0 -1
- package/dist/tools/developmentNudges.js +0 -336
- package/dist/tools/developmentNudges.js.map +0 -1
- package/dist/tools/gitTools.js +0 -741
- package/dist/tools/gitTools.js.map +0 -1
- package/dist/tools/orchestratorTools.js +0 -832
- package/dist/tools/orchestratorTools.js.map +0 -1
- package/dist/tools/searchCache.js +0 -64
- package/dist/tools/searchCache.js.map +0 -1
- package/dist/tools/searchTools.js +0 -1107
- package/dist/tools/searchTools.js.map +0 -1
- package/dist/tools/semgrep-patterns.js +0 -296
- package/dist/tools/semgrep-patterns.js.map +0 -1
- package/dist/tools/specTools.js +0 -332
- package/dist/tools/specTools.js.map +0 -1
- package/dist/tools/structural/__tests__/orchestrator.test.js +0 -61
- package/dist/tools/structural/__tests__/orchestrator.test.js.map +0 -1
- package/dist/tools/structural/cache.js +0 -226
- package/dist/tools/structural/cache.js.map +0 -1
- package/dist/tools/structural/engines/python/index.js +0 -118
- package/dist/tools/structural/engines/python/index.js.map +0 -1
- package/dist/tools/structural/engines/typescript/__tests__/typescript-engine.test.js +0 -97
- package/dist/tools/structural/engines/typescript/__tests__/typescript-engine.test.js.map +0 -1
- package/dist/tools/structural/engines/typescript/analyzer.js +0 -433
- package/dist/tools/structural/engines/typescript/analyzer.js.map +0 -1
- package/dist/tools/structural/engines/typescript/index.js +0 -381
- package/dist/tools/structural/engines/typescript/index.js.map +0 -1
- package/dist/tools/structural/engines/typescript/utils.js +0 -279
- package/dist/tools/structural/engines/typescript/utils.js.map +0 -1
- package/dist/tools/structural/index.js +0 -248
- package/dist/tools/structural/index.js.map +0 -1
- package/dist/tools/structural/types.js +0 -18
- package/dist/tools/structural/types.js.map +0 -1
- package/dist/tools/tmuxTools.js +0 -100
- package/dist/tools/tmuxTools.js.map +0 -1
- package/dist/tools/workRecorder.js +0 -215
- package/dist/tools/workRecorder.js.map +0 -1
- package/dist/tools/worktreeTools.js +0 -705
- package/dist/tools/worktreeTools.js.map +0 -1
- package/dist/utils/__tests__/integration.test.js +0 -57
- package/dist/utils/__tests__/integration.test.js.map +0 -1
- package/dist/utils/__tests__/serverDetection.test.js +0 -151
- package/dist/utils/__tests__/serverDetection.test.js.map +0 -1
- package/dist/utils/errorHandling.js +0 -336
- package/dist/utils/errorHandling.js.map +0 -1
- package/dist/utils/processManager.js +0 -172
- package/dist/utils/processManager.js.map +0 -1
- package/dist/utils/reliability.js +0 -263
- package/dist/utils/reliability.js.map +0 -1
- package/dist/utils/responseFormatter.js +0 -250
- package/dist/utils/responseFormatter.js.map +0 -1
- package/dist/utils/serverDetection.js +0 -133
- package/dist/utils/serverDetection.js.map +0 -1
- package/dist/utils/specMigration.js +0 -105
- package/dist/utils/specMigration.js.map +0 -1
- package/dist/validation/schemas.js +0 -299
- package/dist/validation/schemas.js.map +0 -1
- package/public/.well-known/mcp/manifest.json +0 -473
- package/public/index.html +0 -3157
- package/public/index.html.backup +0 -2805
- package/public/index.html.backup2 +0 -1292
- package/scripts/cleanup-system-logs.ts +0 -121
- package/scripts/init-workspace.js +0 -63
- package/scripts/install-search-tools.js +0 -116
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-patterns
|
|
3
|
+
description: API design principles and decision-making. REST vs GraphQL vs tRPC selection, response formats, versioning, pagination.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Design Patterns
|
|
7
|
+
|
|
8
|
+
> Design principles for building scalable, maintainable APIs.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## API Style Selection
|
|
13
|
+
|
|
14
|
+
### When to Use Each Style
|
|
15
|
+
|
|
16
|
+
| API Style | Best For | Pros | Cons |
|
|
17
|
+
|-----------|-----------|-------|-------|
|
|
18
|
+
| **REST** | Public APIs, general purpose, caching important | Simple, standard, cacheable | Over-fetching/under-fetching, multiple requests |
|
|
19
|
+
| **GraphQL** | Complex data needs, mobile clients, flexible queries | Single request, no over-fetching | Complex, caching harder, learning curve |
|
|
20
|
+
| **tRPC** | Full-stack TypeScript, internal APIs | Type-safe, minimal boilerplate | TypeScript-only, less standard |
|
|
21
|
+
| **gRPC** | Internal microservices, high performance | Fast, streaming, typed | Protocol buffers, HTTP/2 required |
|
|
22
|
+
|
|
23
|
+
### Selection Framework
|
|
24
|
+
|
|
25
|
+
```markdown
|
|
26
|
+
## Decision: Which API Style?
|
|
27
|
+
|
|
28
|
+
### Questions
|
|
29
|
+
1. **Public or Internal?** (Public → REST/GraphQL, Internal → tRPC/gRPC)
|
|
30
|
+
2. **Client flexibility needed?** (High → GraphQL, Low → REST)
|
|
31
|
+
3. **Type safety critical?** (Yes → tRPC/gRPC, No → REST/GraphQL)
|
|
32
|
+
4. **Performance critical?** (Yes → gRPC, No → REST)
|
|
33
|
+
5. **Team expertise?** (What does team know?)
|
|
34
|
+
|
|
35
|
+
### Decision Matrix
|
|
36
|
+
| Factor | REST | GraphQL | tRPC | gRPC |
|
|
37
|
+
|--------|-------|----------|-------|-------|
|
|
38
|
+
| Simplicity | ✅ High | ⚠️ Medium | ✅ High | ⚠️ Medium |
|
|
39
|
+
| Type Safety | ❌ Low | ⚠️ Medium | ✅ High | ✅ High |
|
|
40
|
+
| Performance | ⚠️ Medium | ⚠️ Medium | ✅ High | ✅ High |
|
|
41
|
+
| Ecosystem | ✅ Large | ✅ Large | ⚠️ Growing | ✅ Large |
|
|
42
|
+
| Caching | ✅ Easy | ❌ Hard | ❌ Hard | ⚠️ Medium |
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## REST API Best Practices
|
|
48
|
+
|
|
49
|
+
### Resource Naming
|
|
50
|
+
|
|
51
|
+
| Rule | Example |
|
|
52
|
+
|------|---------|
|
|
53
|
+
| **Use nouns, not verbs** | ✅ `/users`, ❌ `/getUsers` |
|
|
54
|
+
| **Plural nouns** | ✅ `/users`, ❌ `/user` |
|
|
55
|
+
| **Nest resources** | ✅ `/users/123/posts`, ❌ `/posts?user=123` |
|
|
56
|
+
| **Lowercase with hyphens** | ✅ `/user-preferences`, ❌ `/userPreferences` |
|
|
57
|
+
|
|
58
|
+
### HTTP Methods
|
|
59
|
+
|
|
60
|
+
| Method | Use | Safe | Idempotent |
|
|
61
|
+
|--------|-----|-------|------------|
|
|
62
|
+
| **GET** | Read resources | ✅ Yes | ✅ Yes |
|
|
63
|
+
| **POST** | Create resource | ❌ No | ❌ No |
|
|
64
|
+
| **PUT** | Replace resource | ❌ No | ✅ Yes |
|
|
65
|
+
| **PATCH** | Partial update | ❌ No | ❌ No |
|
|
66
|
+
| **DELETE** | Delete resource | ❌ No | ✅ Yes |
|
|
67
|
+
|
|
68
|
+
### Status Codes
|
|
69
|
+
|
|
70
|
+
| Code | Meaning | When to Use |
|
|
71
|
+
|------|----------|-------------|
|
|
72
|
+
| **200 OK** | Success | GET, PUT, DELETE successful |
|
|
73
|
+
| **201 Created** | Resource created | POST successful |
|
|
74
|
+
| **204 No Content** | Success, no body | DELETE successful |
|
|
75
|
+
| **400 Bad Request** | Invalid input | Client error |
|
|
76
|
+
| **401 Unauthorized** | Not authenticated | Missing/expired token |
|
|
77
|
+
| **403 Forbidden** | No permission | Authenticated but not allowed |
|
|
78
|
+
| **404 Not Found** | Resource missing | Invalid ID |
|
|
79
|
+
| **409 Conflict** | Conflict | Duplicate resource |
|
|
80
|
+
| **422 Unprocessable** | Validation error | Data validation failed |
|
|
81
|
+
| **429 Too Many** | Rate limited | Exceeded rate limit |
|
|
82
|
+
| **500 Internal Server** | Server error | Bug on server |
|
|
83
|
+
|
|
84
|
+
### Request/Response Format
|
|
85
|
+
|
|
86
|
+
**Request:**
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"user": {
|
|
90
|
+
"name": "John",
|
|
91
|
+
"email": "john@example.com"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Response (Success):**
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"data": {
|
|
100
|
+
"user": {
|
|
101
|
+
"id": "123",
|
|
102
|
+
"name": "John",
|
|
103
|
+
"email": "john@example.com",
|
|
104
|
+
"createdAt": "2024-01-01T00:00:00Z"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Response (Error):**
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"error": {
|
|
114
|
+
"code": "VALIDATION_ERROR",
|
|
115
|
+
"message": "Invalid email address",
|
|
116
|
+
"details": [
|
|
117
|
+
{
|
|
118
|
+
"field": "email",
|
|
119
|
+
"message": "Must be a valid email"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Pagination
|
|
129
|
+
|
|
130
|
+
### Pagination Strategies
|
|
131
|
+
|
|
132
|
+
| Strategy | Best For | Pros | Cons |
|
|
133
|
+
|-----------|-----------|-------|-------|
|
|
134
|
+
| **Offset/Limit** | Simple apps, small datasets | Simple, standard | Slow with large offsets |
|
|
135
|
+
| **Cursor-based** | Infinite scroll, large datasets | Fast, efficient | No random access |
|
|
136
|
+
| **Page-based** | Paginated lists | Simple | Gaps on deletes |
|
|
137
|
+
|
|
138
|
+
### Offset/Limit (Simple)
|
|
139
|
+
|
|
140
|
+
```http
|
|
141
|
+
GET /users?page=1&limit=20
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"data": [...],
|
|
147
|
+
"meta": {
|
|
148
|
+
"page": 1,
|
|
149
|
+
"limit": 20,
|
|
150
|
+
"total": 100,
|
|
151
|
+
"totalPages": 5
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Cursor-based (Efficient)
|
|
157
|
+
|
|
158
|
+
```http
|
|
159
|
+
GET /users?limit=20&cursor=abc123
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"data": [...],
|
|
165
|
+
"meta": {
|
|
166
|
+
"hasNext": true,
|
|
167
|
+
"nextCursor": "def456"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Versioning
|
|
175
|
+
|
|
176
|
+
### Versioning Strategies
|
|
177
|
+
|
|
178
|
+
| Strategy | Best For | Example |
|
|
179
|
+
|-----------|-----------|---------|
|
|
180
|
+
| **URL Path** | Multiple versions supported | `/v1/users`, `/v2/users` |
|
|
181
|
+
| **Query Parameter** | Testing, feature flags | `/users?version=v2` |
|
|
182
|
+
| **Header** | API gateway routing | `Accept: application/vnd.api.v2+json` |
|
|
183
|
+
|
|
184
|
+
### Best Practice: URL Path
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
/api/v1/users
|
|
188
|
+
/api/v2/users
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Guidelines:**
|
|
192
|
+
- Use URL path versioning (most standard)
|
|
193
|
+
- Support previous version for 6-12 months
|
|
194
|
+
- Deprecate with warning header: `X-Deprecated: true`
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Authentication & Authorization
|
|
199
|
+
|
|
200
|
+
### Auth Strategies
|
|
201
|
+
|
|
202
|
+
| Strategy | Best For | Tools |
|
|
203
|
+
|-----------|-----------|--------|
|
|
204
|
+
| **JWT** | Stateless, scalable | NextAuth, Auth0, custom |
|
|
205
|
+
| **Session** | Traditional web apps | Express-session, Passport |
|
|
206
|
+
| **API Keys** | Service-to-service | Custom, cloud provider |
|
|
207
|
+
| **OAuth2** | Third-party login | NextAuth, Auth0 |
|
|
208
|
+
|
|
209
|
+
### Implementation Pattern
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
// Middleware example
|
|
213
|
+
function authMiddleware(req, res, next) {
|
|
214
|
+
const token = req.headers.authorization?.split(' ')[1];
|
|
215
|
+
if (!token) return res.status(401).json({ error: 'Unauthorized' });
|
|
216
|
+
|
|
217
|
+
const decoded = verifyToken(token);
|
|
218
|
+
req.user = decoded;
|
|
219
|
+
next();
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Error Handling
|
|
226
|
+
|
|
227
|
+
### Error Response Format
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"error": {
|
|
232
|
+
"code": "VALIDATION_ERROR",
|
|
233
|
+
"message": "Request validation failed",
|
|
234
|
+
"details": [
|
|
235
|
+
{
|
|
236
|
+
"field": "email",
|
|
237
|
+
"message": "Invalid email format"
|
|
238
|
+
}
|
|
239
|
+
],
|
|
240
|
+
"requestId": "req_abc123"
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Error Codes
|
|
246
|
+
|
|
247
|
+
| Category | Codes | Format |
|
|
248
|
+
|----------|--------|--------|
|
|
249
|
+
| **Validation** | VALIDATION_ERROR, INVALID_INPUT | CAPITAL_SNAKE_CASE |
|
|
250
|
+
| **Auth** | UNAUTHORIZED, FORBIDDEN, TOKEN_EXPIRED | CAPITAL_SNAKE_CASE |
|
|
251
|
+
| **Not Found** | RESOURCE_NOT_FOUND, USER_NOT_FOUND | CAPITAL_SNAKE_CASE |
|
|
252
|
+
| **Server** | INTERNAL_ERROR, DATABASE_ERROR | CAPITAL_SNAKE_CASE |
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Rate Limiting
|
|
257
|
+
|
|
258
|
+
### Rate Limiting Strategies
|
|
259
|
+
|
|
260
|
+
| Strategy | Best For | Pros | Cons |
|
|
261
|
+
|-----------|-----------|-------|-------|
|
|
262
|
+
| **Fixed Window** | Simple rate limiting | Simple, but bursty |
|
|
263
|
+
| **Sliding Window** | Smooth rate limiting | Accurate, but complex |
|
|
264
|
+
| **Token Bucket** | API rate limiting | Smooth, flexible |
|
|
265
|
+
| **Leaky Bucket** | Data rate limiting | Constant rate |
|
|
266
|
+
|
|
267
|
+
### Response Headers
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
X-RateLimit-Limit: 100
|
|
271
|
+
X-RateLimit-Remaining: 95
|
|
272
|
+
X-RateLimit-Reset: 1640995200
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Documentation
|
|
278
|
+
|
|
279
|
+
### API Documentation Tools
|
|
280
|
+
|
|
281
|
+
| Tool | Best For | Features |
|
|
282
|
+
|------|-----------|----------|
|
|
283
|
+
| **OpenAPI (Swagger)** | REST APIs | Auto-generated docs, testing |
|
|
284
|
+
| **GraphQL Playground** | GraphQL APIs | Interactive queries, schema |
|
|
285
|
+
| **tRPC Playground** | tRPC APIs | Type-safe testing |
|
|
286
|
+
| **Postman** | Manual testing | Collections, environments |
|
|
287
|
+
|
|
288
|
+
### Documentation Must-Haves
|
|
289
|
+
|
|
290
|
+
- [ ] Endpoint URLs and methods
|
|
291
|
+
- [ ] Request/response examples
|
|
292
|
+
- [ ] Authentication requirements
|
|
293
|
+
- [ ] Error codes and meanings
|
|
294
|
+
- [ ] Rate limits
|
|
295
|
+
- [ ] Version information
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Bob's Workshop Integration
|
|
300
|
+
|
|
301
|
+
This skill is used by **alice (architect)** agent during PLAN phase and **bob-eng (engineer)** during BUILD phase.
|
|
302
|
+
|
|
303
|
+
### MANUAL Integration
|
|
304
|
+
|
|
305
|
+
Add API section to MANUAL:
|
|
306
|
+
```markdown
|
|
307
|
+
## 🏗️ Architecture Analysis
|
|
308
|
+
|
|
309
|
+
### API Design
|
|
310
|
+
|
|
311
|
+
#### API Style Selection
|
|
312
|
+
- **Style:** [REST / GraphQL / tRPC / gRPC]
|
|
313
|
+
- **Rationale:** [Why this style?]
|
|
314
|
+
- **Framework:** [Express / Fastify / Next.js API / tRPC / etc.]
|
|
315
|
+
|
|
316
|
+
#### API Structure
|
|
317
|
+
|
|
318
|
+
**Endpoints:**
|
|
319
|
+
| Method | Endpoint | Description | Auth |
|
|
320
|
+
|--------|-----------|-------------|-------|
|
|
321
|
+
| GET | /api/v1/users | List users | Required |
|
|
322
|
+
| GET | /api/v1/users/:id | Get user | Required |
|
|
323
|
+
| POST | /api/v1/users | Create user | Required |
|
|
324
|
+
| PUT | /api/v1/users/:id | Update user | Required |
|
|
325
|
+
| DELETE | /api/v1/users/:id | Delete user | Required |
|
|
326
|
+
|
|
327
|
+
#### Authentication
|
|
328
|
+
- **Strategy:** [JWT / Session / OAuth2 / API Keys]
|
|
329
|
+
- **Middleware:** [Custom / NextAuth / Passport / etc.]
|
|
330
|
+
- **Token Expiry:** [1 hour / 24 hours / 7 days]
|
|
331
|
+
|
|
332
|
+
#### Rate Limiting
|
|
333
|
+
- **Strategy:** [Fixed Window / Sliding Window / Token Bucket]
|
|
334
|
+
- **Limits:** [100 requests per 15 minutes]
|
|
335
|
+
- **Headers:** `X-RateLimit-Limit`, `X-RateLimit-Remaining`
|
|
336
|
+
|
|
337
|
+
#### Error Handling
|
|
338
|
+
- **Format:** Standard error object with code, message, details
|
|
339
|
+
- **Codes:** VALIDATION_ERROR, UNAUTHORIZED, FORBIDDEN, NOT_FOUND, INTERNAL_ERROR
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Implementation Tasks
|
|
343
|
+
|
|
344
|
+
```markdown
|
|
345
|
+
#### API-001: User Endpoints
|
|
346
|
+
- [ ] Create GET /api/v1/users → Verify: Returns paginated list
|
|
347
|
+
- [ ] Create GET /api/v1/users/:id → Verify: Returns single user
|
|
348
|
+
- [ ] Create POST /api/v1/users → Verify: Creates user, returns 201
|
|
349
|
+
- [ ] Add auth middleware → Verify: Protects endpoints
|
|
350
|
+
- [ ] Add validation → Verify: Returns 422 on invalid input
|
|
351
|
+
|
|
352
|
+
#### API-002: Error Handling
|
|
353
|
+
- [ ] Create error middleware → Verify: Returns standard error format
|
|
354
|
+
- [ ] Add error codes → Verify: All errors have codes
|
|
355
|
+
- [ ] Add request ID → Verify: Each request has unique ID
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Testing Strategy
|
|
359
|
+
|
|
360
|
+
```markdown
|
|
361
|
+
#### API-TEST-001: API Tests
|
|
362
|
+
- [ ] Test all endpoints → Verify: Return correct status codes
|
|
363
|
+
- [ ] Test authentication → Verify: Unauthenticated requests return 401
|
|
364
|
+
- [ ] Test authorization → Verify: Unauthorized requests return 403
|
|
365
|
+
- [ ] Test validation → Verify: Invalid input returns 422
|
|
366
|
+
- [ ] Test rate limiting → Verify: Exceeding limit returns 429
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Handoff Format
|
|
370
|
+
|
|
371
|
+
```markdown
|
|
372
|
+
## 🤝 Agent Handoffs
|
|
373
|
+
|
|
374
|
+
🤝 alice: API designed - REST with JWT auth
|
|
375
|
+
🤝 alice → bob-eng: API spec ready, proceeding to implementation
|
|
376
|
+
```
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture
|
|
3
|
+
description: Architectural decision-making framework. Requirements analysis, trade-off evaluation, ADR documentation.
|
|
4
|
+
metadata:
|
|
5
|
+
recommended_for: alice
|
|
6
|
+
category: architecture
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Architecture Decision Framework
|
|
10
|
+
|
|
11
|
+
> "Requirements drive architecture. Trade-offs inform decisions. ADRs capture rationale."
|
|
12
|
+
|
|
13
|
+
## 🎯 Selective Reading Rule
|
|
14
|
+
|
|
15
|
+
**Read ONLY files relevant to the request!** Check the content map, find what you need.
|
|
16
|
+
|
|
17
|
+
| File | Description | When to Read |
|
|
18
|
+
|------|-------------|--------------|
|
|
19
|
+
| `context-discovery.md` | Questions to ask, project classification | Starting architecture design |
|
|
20
|
+
| `trade-off-analysis.md` | ADR templates, trade-off framework | Documenting decisions |
|
|
21
|
+
| `pattern-selection.md` | Decision trees, anti-patterns | Choosing patterns |
|
|
22
|
+
| `examples.md` | MVP, SaaS, Enterprise examples | Reference implementations |
|
|
23
|
+
| `patterns-reference.md` | Quick lookup for patterns | Pattern comparison |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🔗 Related Skills
|
|
28
|
+
|
|
29
|
+
| Skill | Use For |
|
|
30
|
+
|-------|---------|
|
|
31
|
+
| `@skills/database-design` | Database schema design |
|
|
32
|
+
| `@skills/api-patterns` | API design patterns |
|
|
33
|
+
| `@skills/deployment-procedures` | Deployment architecture |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Core Principle
|
|
38
|
+
|
|
39
|
+
**"Simplicity is the ultimate sophistication."**
|
|
40
|
+
|
|
41
|
+
- Start simple
|
|
42
|
+
- Add complexity ONLY when proven necessary
|
|
43
|
+
- You can always add patterns later
|
|
44
|
+
- Removing complexity is MUCH harder than adding it
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Validation Checklist
|
|
49
|
+
|
|
50
|
+
Before finalizing architecture:
|
|
51
|
+
|
|
52
|
+
- [ ] Requirements clearly understood
|
|
53
|
+
- [ ] Constraints identified
|
|
54
|
+
- [ ] Each decision has trade-off analysis
|
|
55
|
+
- [ ] Simpler alternatives considered
|
|
56
|
+
- [ ] ADRs written for significant decisions
|
|
57
|
+
- [ ] Team expertise matches chosen patterns
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Architecture Decision Record (ADR) Template
|
|
62
|
+
|
|
63
|
+
```markdown
|
|
64
|
+
# ADR-[number]: [Title]
|
|
65
|
+
|
|
66
|
+
## Status
|
|
67
|
+
- [ ] Proposed
|
|
68
|
+
- [ ] Accepted
|
|
69
|
+
- [ ] Deprecated
|
|
70
|
+
- [ ] Superseded by [ADR-number]
|
|
71
|
+
|
|
72
|
+
## Context
|
|
73
|
+
- What is the issue we're facing?
|
|
74
|
+
- What is the problem we're trying to solve?
|
|
75
|
+
- What are the constraints we're working with?
|
|
76
|
+
|
|
77
|
+
## Decision
|
|
78
|
+
- What did we decide?
|
|
79
|
+
- What is the solution?
|
|
80
|
+
- What pattern/approach did we choose?
|
|
81
|
+
|
|
82
|
+
## Consequences
|
|
83
|
+
- **Positive**: What are the benefits?
|
|
84
|
+
- **Negative**: What are the drawbacks?
|
|
85
|
+
- **Risks**: What could go wrong?
|
|
86
|
+
- **Alternatives considered**: What did we NOT choose and why?
|
|
87
|
+
|
|
88
|
+
## References
|
|
89
|
+
- Links to relevant documentation
|
|
90
|
+
- Links to similar decisions
|
|
91
|
+
- Links to external resources
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Trade-off Analysis Framework
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
## Decision: [What are we deciding?]
|
|
100
|
+
|
|
101
|
+
### Options
|
|
102
|
+
| Option | Description | Pros | Cons | Complexity | Time |
|
|
103
|
+
|--------|-------------|-------|-------|------------|------|
|
|
104
|
+
| A | [Description] | [+] | [-] | Low/Med/High | Fast/Med/Slow |
|
|
105
|
+
| B | [Description] | [+] | [-] | Low/Med/High | Fast/Med/Slow |
|
|
106
|
+
|
|
107
|
+
### Criteria
|
|
108
|
+
- Performance requirements
|
|
109
|
+
- Development time
|
|
110
|
+
- Maintainability
|
|
111
|
+
- Team expertise
|
|
112
|
+
- Scalability needs
|
|
113
|
+
- Budget constraints
|
|
114
|
+
|
|
115
|
+
### Decision
|
|
116
|
+
**Chosen:** [Option A/B]
|
|
117
|
+
**Rationale:**
|
|
118
|
+
- Primary driver: [Reason]
|
|
119
|
+
- Secondary drivers: [Reasons]
|
|
120
|
+
- Trade-offs accepted: [What we're giving up]
|
|
121
|
+
|
|
122
|
+
### Success Metrics
|
|
123
|
+
- [ ] How will we measure success?
|
|
124
|
+
- [ ] What indicates this was the right choice?
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Common Architectural Patterns
|
|
130
|
+
|
|
131
|
+
### When to Use Each Pattern
|
|
132
|
+
|
|
133
|
+
| Pattern | Best For | Complexity | Scalability |
|
|
134
|
+
|---------|-----------|-------------|--------------|
|
|
135
|
+
| **Monolith** | Small teams, rapid development | Low | Limited |
|
|
136
|
+
| **Modular Monolith** | Medium teams, growing complexity | Medium | Good |
|
|
137
|
+
| **Microservices** | Large teams, multiple domains | High | Excellent |
|
|
138
|
+
| **Serverless** | Event-driven, variable load | Medium | Auto-scales |
|
|
139
|
+
| **Event-Driven** | Async processing, loose coupling | High | Excellent |
|
|
140
|
+
|
|
141
|
+
### Pattern Selection Questions
|
|
142
|
+
|
|
143
|
+
1. **Team Size**: How many developers? (Small → Monolith, Large → Microservices)
|
|
144
|
+
2. **Complexity**: How many domains? (Few → Monolith, Many → Services)
|
|
145
|
+
3. **Load**: Expected traffic? (Low → Monolith, High → Scaled)
|
|
146
|
+
4. **Time to Market**: How fast do we need to ship? (Fast → Monolith, Slower → Services)
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Anti-Patterns
|
|
151
|
+
|
|
152
|
+
| ❌ Don't | ✅ Do |
|
|
153
|
+
|----------|-------|
|
|
154
|
+
| Start with microservices | Start with monolith, split when needed |
|
|
155
|
+
| Use complex patterns because "cool" | Use simplest solution that works |
|
|
156
|
+
| Ignore team expertise | Match patterns to team's skills |
|
|
157
|
+
| Make premature optimizations | Optimize when you have data |
|
|
158
|
+
| Skip ADR documentation | Document significant decisions |
|
|
159
|
+
| Choose without trade-offs | Always analyze alternatives |
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Bob's Workshop Integration
|
|
164
|
+
|
|
165
|
+
This skill is used by **alice (architect)** agent during PLAN phase.
|
|
166
|
+
|
|
167
|
+
### MANUAL Integration
|
|
168
|
+
|
|
169
|
+
Add architecture section to MANUAL:
|
|
170
|
+
```markdown
|
|
171
|
+
## 🏗️ Architecture Analysis
|
|
172
|
+
|
|
173
|
+
### Project Classification
|
|
174
|
+
- **Type:** [MVP / SaaS / Enterprise / Internal Tool]
|
|
175
|
+
- **Scale:** [Small / Medium / Large]
|
|
176
|
+
- **Team:** [Solo / Small team / Large team]
|
|
177
|
+
- **Constraints:** [Technical / Time / Budget / Legal]
|
|
178
|
+
|
|
179
|
+
### Architecture Decisions
|
|
180
|
+
|
|
181
|
+
| Decision | ADR # | Pattern | Rationale | Trade-offs |
|
|
182
|
+
|----------|---------|----------|------------|-------------|
|
|
183
|
+
| [Tech Stack] | ADR-001 | [Pattern] | [Why] | [Accepted] |
|
|
184
|
+
| [Database] | ADR-002 | [Pattern] | [Why] | [Accepted] |
|
|
185
|
+
| [API Design] | ADR-003 | [Pattern] | [Why] | [Accepted] |
|
|
186
|
+
|
|
187
|
+
### System Components
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
[Component Diagram]
|
|
191
|
+
┌─────────────┐ ┌─────────────┐
|
|
192
|
+
│ Frontend │─────▶│ API │
|
|
193
|
+
└─────────────┘ └─────────────┘
|
|
194
|
+
│
|
|
195
|
+
▼
|
|
196
|
+
┌─────────────┐
|
|
197
|
+
│ Database │
|
|
198
|
+
└─────────────┘
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Technology Stack
|
|
202
|
+
- **Frontend:** [Framework, Language, Libraries]
|
|
203
|
+
- **Backend:** [Framework, Language, Runtime]
|
|
204
|
+
- **Database:** [Type, ORM, Migration Tool]
|
|
205
|
+
- **Infrastructure:** [Cloud, CI/CD, Monitoring]
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### ADR Documentation
|
|
209
|
+
|
|
210
|
+
For each significant decision, create ADR:
|
|
211
|
+
```markdown
|
|
212
|
+
## ADR-001: Choose PostgreSQL as Primary Database
|
|
213
|
+
|
|
214
|
+
### Context
|
|
215
|
+
- Need for relational data model
|
|
216
|
+
- ACID compliance required for transactions
|
|
217
|
+
- Team has PostgreSQL experience
|
|
218
|
+
|
|
219
|
+
### Decision
|
|
220
|
+
- Use PostgreSQL 15+
|
|
221
|
+
- Use Prisma as ORM
|
|
222
|
+
- Use Liquibase for migrations
|
|
223
|
+
|
|
224
|
+
### Consequences
|
|
225
|
+
- **Positive**: Team expertise, ACID guarantees, rich ecosystem
|
|
226
|
+
- **Negative**: Requires maintenance, scaling requires planning
|
|
227
|
+
- **Risks**: Connection pooling, index optimization
|
|
228
|
+
- **Alternatives Considered**: MySQL (less familiar), MongoDB (not relational)
|
|
229
|
+
|
|
230
|
+
### Success Metrics
|
|
231
|
+
- [ ] Queries < 100ms for 95th percentile
|
|
232
|
+
- [ ] Supports 10x traffic growth without major changes
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Validation Checklist
|
|
236
|
+
|
|
237
|
+
Before proceeding to implementation:
|
|
238
|
+
- [ ] Requirements clearly understood
|
|
239
|
+
- [ ] Constraints identified
|
|
240
|
+
- [ ] Each decision has trade-off analysis
|
|
241
|
+
- [ ] Simpler alternatives considered
|
|
242
|
+
- [ ] ADRs written for significant decisions
|
|
243
|
+
- [ ] Team expertise matches chosen patterns
|
|
244
|
+
|
|
245
|
+
### Handoff Format
|
|
246
|
+
|
|
247
|
+
```markdown
|
|
248
|
+
## 🤝 Agent Handoffs
|
|
249
|
+
|
|
250
|
+
🤝 alice: Architecture complete - 5 ADRs documented
|
|
251
|
+
🤝 alice → bob-eng: MANUAL ready - proceeding to BUILD phase
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Design Patterns
|
|
257
|
+
|
|
258
|
+
When design tradeoffs arise:
|
|
259
|
+
|
|
260
|
+
1. **Compare architecture patterns** - Evaluate each option against requirements
|
|
261
|
+
2. **Suggest modular compositions** - Prefer loose coupling, high cohesion
|
|
262
|
+
3. **Evaluate coupling/cohesion** - Minimize dependencies, group related concerns
|
|
263
|
+
|
|
264
|
+
### Design Decision Framework
|
|
265
|
+
|
|
266
|
+
| Question | What to Evaluate |
|
|
267
|
+
|----------|------------------|
|
|
268
|
+
| What are the components? | Identify clear boundaries |
|
|
269
|
+
| How do they communicate? | Define interfaces and contracts |
|
|
270
|
+
| What are the dependencies? | Minimize and make explicit |
|
|
271
|
+
| How to handle failure? | Design for resilience |
|