opencode-metis 0.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.
Files changed (156) hide show
  1. package/README.md +140 -0
  2. package/dist/cli.cjs +63 -0
  3. package/dist/mcp-server.cjs +51 -0
  4. package/dist/plugin.cjs +4 -0
  5. package/dist/worker.cjs +224 -0
  6. package/opencode/agent/the-analyst/feature-prioritization.md +66 -0
  7. package/opencode/agent/the-analyst/market-research.md +77 -0
  8. package/opencode/agent/the-analyst/project-coordination.md +81 -0
  9. package/opencode/agent/the-analyst/requirements-analysis.md +77 -0
  10. package/opencode/agent/the-architect/compatibility-review.md +138 -0
  11. package/opencode/agent/the-architect/complexity-review.md +137 -0
  12. package/opencode/agent/the-architect/quality-review.md +67 -0
  13. package/opencode/agent/the-architect/security-review.md +127 -0
  14. package/opencode/agent/the-architect/system-architecture.md +119 -0
  15. package/opencode/agent/the-architect/system-documentation.md +83 -0
  16. package/opencode/agent/the-architect/technology-research.md +85 -0
  17. package/opencode/agent/the-chief.md +79 -0
  18. package/opencode/agent/the-designer/accessibility-implementation.md +101 -0
  19. package/opencode/agent/the-designer/design-foundation.md +74 -0
  20. package/opencode/agent/the-designer/interaction-architecture.md +75 -0
  21. package/opencode/agent/the-designer/user-research.md +70 -0
  22. package/opencode/agent/the-meta-agent.md +155 -0
  23. package/opencode/agent/the-platform-engineer/ci-cd-pipelines.md +109 -0
  24. package/opencode/agent/the-platform-engineer/containerization.md +106 -0
  25. package/opencode/agent/the-platform-engineer/data-architecture.md +81 -0
  26. package/opencode/agent/the-platform-engineer/dependency-review.md +144 -0
  27. package/opencode/agent/the-platform-engineer/deployment-automation.md +81 -0
  28. package/opencode/agent/the-platform-engineer/infrastructure-as-code.md +107 -0
  29. package/opencode/agent/the-platform-engineer/performance-tuning.md +82 -0
  30. package/opencode/agent/the-platform-engineer/pipeline-engineering.md +81 -0
  31. package/opencode/agent/the-platform-engineer/production-monitoring.md +105 -0
  32. package/opencode/agent/the-qa-engineer/exploratory-testing.md +66 -0
  33. package/opencode/agent/the-qa-engineer/performance-testing.md +81 -0
  34. package/opencode/agent/the-qa-engineer/quality-assurance.md +77 -0
  35. package/opencode/agent/the-qa-engineer/test-execution.md +66 -0
  36. package/opencode/agent/the-software-engineer/api-development.md +78 -0
  37. package/opencode/agent/the-software-engineer/component-development.md +79 -0
  38. package/opencode/agent/the-software-engineer/concurrency-review.md +141 -0
  39. package/opencode/agent/the-software-engineer/domain-modeling.md +66 -0
  40. package/opencode/agent/the-software-engineer/performance-optimization.md +113 -0
  41. package/opencode/command/analyze.md +149 -0
  42. package/opencode/command/constitution.md +178 -0
  43. package/opencode/command/debug.md +194 -0
  44. package/opencode/command/document.md +178 -0
  45. package/opencode/command/implement.md +225 -0
  46. package/opencode/command/refactor.md +207 -0
  47. package/opencode/command/review.md +229 -0
  48. package/opencode/command/simplify.md +267 -0
  49. package/opencode/command/specify.md +191 -0
  50. package/opencode/command/validate.md +224 -0
  51. package/opencode/skill/accessibility-design/SKILL.md +566 -0
  52. package/opencode/skill/accessibility-design/checklists/wcag-checklist.md +435 -0
  53. package/opencode/skill/agent-coordination/SKILL.md +224 -0
  54. package/opencode/skill/api-contract-design/SKILL.md +550 -0
  55. package/opencode/skill/api-contract-design/templates/graphql-schema-template.md +818 -0
  56. package/opencode/skill/api-contract-design/templates/rest-api-template.md +417 -0
  57. package/opencode/skill/architecture-design/SKILL.md +160 -0
  58. package/opencode/skill/architecture-design/examples/architecture-examples.md +170 -0
  59. package/opencode/skill/architecture-design/template.md +749 -0
  60. package/opencode/skill/architecture-design/validation.md +99 -0
  61. package/opencode/skill/architecture-selection/SKILL.md +522 -0
  62. package/opencode/skill/architecture-selection/examples/adrs/001-example-adr.md +71 -0
  63. package/opencode/skill/architecture-selection/examples/architecture-patterns.md +239 -0
  64. package/opencode/skill/bug-diagnosis/SKILL.md +235 -0
  65. package/opencode/skill/code-quality-review/SKILL.md +337 -0
  66. package/opencode/skill/code-quality-review/examples/anti-patterns.md +629 -0
  67. package/opencode/skill/code-quality-review/reference.md +322 -0
  68. package/opencode/skill/code-review/SKILL.md +363 -0
  69. package/opencode/skill/code-review/reference.md +450 -0
  70. package/opencode/skill/codebase-analysis/SKILL.md +139 -0
  71. package/opencode/skill/codebase-navigation/SKILL.md +227 -0
  72. package/opencode/skill/codebase-navigation/examples/exploration-patterns.md +263 -0
  73. package/opencode/skill/coding-conventions/SKILL.md +178 -0
  74. package/opencode/skill/coding-conventions/checklists/accessibility-checklist.md +176 -0
  75. package/opencode/skill/coding-conventions/checklists/performance-checklist.md +154 -0
  76. package/opencode/skill/coding-conventions/checklists/security-checklist.md +127 -0
  77. package/opencode/skill/constitution-validation/SKILL.md +315 -0
  78. package/opencode/skill/constitution-validation/examples/CONSTITUTION.md +202 -0
  79. package/opencode/skill/constitution-validation/reference/rule-patterns.md +328 -0
  80. package/opencode/skill/constitution-validation/template.md +115 -0
  81. package/opencode/skill/context-preservation/SKILL.md +445 -0
  82. package/opencode/skill/data-modeling/SKILL.md +385 -0
  83. package/opencode/skill/data-modeling/templates/schema-design-template.md +268 -0
  84. package/opencode/skill/deployment-pipeline-design/SKILL.md +579 -0
  85. package/opencode/skill/deployment-pipeline-design/templates/pipeline-template.md +633 -0
  86. package/opencode/skill/documentation-extraction/SKILL.md +259 -0
  87. package/opencode/skill/documentation-sync/SKILL.md +431 -0
  88. package/opencode/skill/domain-driven-design/SKILL.md +509 -0
  89. package/opencode/skill/domain-driven-design/examples/ddd-patterns.md +688 -0
  90. package/opencode/skill/domain-driven-design/reference.md +465 -0
  91. package/opencode/skill/drift-detection/SKILL.md +383 -0
  92. package/opencode/skill/drift-detection/reference.md +340 -0
  93. package/opencode/skill/error-recovery/SKILL.md +162 -0
  94. package/opencode/skill/error-recovery/examples/error-patterns.md +484 -0
  95. package/opencode/skill/feature-prioritization/SKILL.md +419 -0
  96. package/opencode/skill/feature-prioritization/examples/rice-template.md +139 -0
  97. package/opencode/skill/feature-prioritization/reference.md +256 -0
  98. package/opencode/skill/git-workflow/SKILL.md +453 -0
  99. package/opencode/skill/implementation-planning/SKILL.md +215 -0
  100. package/opencode/skill/implementation-planning/examples/phase-examples.md +217 -0
  101. package/opencode/skill/implementation-planning/template.md +220 -0
  102. package/opencode/skill/implementation-planning/validation.md +88 -0
  103. package/opencode/skill/implementation-verification/SKILL.md +272 -0
  104. package/opencode/skill/knowledge-capture/SKILL.md +265 -0
  105. package/opencode/skill/knowledge-capture/reference/knowledge-capture.md +402 -0
  106. package/opencode/skill/knowledge-capture/reference.md +444 -0
  107. package/opencode/skill/knowledge-capture/templates/domain-template.md +325 -0
  108. package/opencode/skill/knowledge-capture/templates/interface-template.md +255 -0
  109. package/opencode/skill/knowledge-capture/templates/pattern-template.md +144 -0
  110. package/opencode/skill/observability-design/SKILL.md +291 -0
  111. package/opencode/skill/observability-design/references/monitoring-patterns.md +461 -0
  112. package/opencode/skill/pattern-detection/SKILL.md +171 -0
  113. package/opencode/skill/pattern-detection/examples/common-patterns.md +359 -0
  114. package/opencode/skill/performance-analysis/SKILL.md +266 -0
  115. package/opencode/skill/performance-analysis/references/profiling-tools.md +499 -0
  116. package/opencode/skill/requirements-analysis/SKILL.md +139 -0
  117. package/opencode/skill/requirements-analysis/examples/good-prd.md +66 -0
  118. package/opencode/skill/requirements-analysis/template.md +177 -0
  119. package/opencode/skill/requirements-analysis/validation.md +69 -0
  120. package/opencode/skill/requirements-elicitation/SKILL.md +518 -0
  121. package/opencode/skill/requirements-elicitation/examples/interview-questions.md +226 -0
  122. package/opencode/skill/requirements-elicitation/examples/user-stories.md +414 -0
  123. package/opencode/skill/safe-refactoring/SKILL.md +312 -0
  124. package/opencode/skill/safe-refactoring/reference/code-smells.md +347 -0
  125. package/opencode/skill/security-assessment/SKILL.md +421 -0
  126. package/opencode/skill/security-assessment/checklists/security-review-checklist.md +285 -0
  127. package/opencode/skill/specification-management/SKILL.md +143 -0
  128. package/opencode/skill/specification-management/readme-template.md +32 -0
  129. package/opencode/skill/specification-management/reference.md +115 -0
  130. package/opencode/skill/specification-management/spec.py +229 -0
  131. package/opencode/skill/specification-validation/SKILL.md +397 -0
  132. package/opencode/skill/specification-validation/reference/3cs-framework.md +306 -0
  133. package/opencode/skill/specification-validation/reference/ambiguity-detection.md +132 -0
  134. package/opencode/skill/specification-validation/reference/constitution-validation.md +301 -0
  135. package/opencode/skill/specification-validation/reference/drift-detection.md +383 -0
  136. package/opencode/skill/task-delegation/SKILL.md +607 -0
  137. package/opencode/skill/task-delegation/examples/file-coordination.md +495 -0
  138. package/opencode/skill/task-delegation/examples/parallel-research.md +337 -0
  139. package/opencode/skill/task-delegation/examples/sequential-build.md +504 -0
  140. package/opencode/skill/task-delegation/reference.md +825 -0
  141. package/opencode/skill/tech-stack-detection/SKILL.md +89 -0
  142. package/opencode/skill/tech-stack-detection/references/framework-signatures.md +598 -0
  143. package/opencode/skill/technical-writing/SKILL.md +190 -0
  144. package/opencode/skill/technical-writing/templates/adr-template.md +205 -0
  145. package/opencode/skill/technical-writing/templates/system-doc-template.md +380 -0
  146. package/opencode/skill/test-design/SKILL.md +464 -0
  147. package/opencode/skill/test-design/examples/test-pyramid.md +724 -0
  148. package/opencode/skill/testing/SKILL.md +213 -0
  149. package/opencode/skill/testing/examples/test-pyramid.md +724 -0
  150. package/opencode/skill/user-insight-synthesis/SKILL.md +576 -0
  151. package/opencode/skill/user-insight-synthesis/templates/research-plan-template.md +217 -0
  152. package/opencode/skill/user-research/SKILL.md +508 -0
  153. package/opencode/skill/user-research/examples/interview-questions.md +265 -0
  154. package/opencode/skill/user-research/examples/personas.md +267 -0
  155. package/opencode/skill/vibe-security/SKILL.md +654 -0
  156. package/package.json +45 -0
@@ -0,0 +1,504 @@
1
+ # Example: Sequential Build Delegation
2
+
3
+ This example shows how to coordinate dependent implementation tasks that must execute sequentially.
4
+
5
+ ## Scenario
6
+
7
+ **User Request:** "Implement JWT authentication for our REST API"
8
+
9
+ ## Task Decomposition
10
+
11
+ ```
12
+ Original Task: Implement JWT authentication for REST API
13
+
14
+ Activities Identified:
15
+ 1. Design authentication database schema
16
+ - Expertise: Database design
17
+ - Output: Schema design document
18
+ - Dependencies: None
19
+
20
+ 2. Create database migration
21
+ - Expertise: Database implementation
22
+ - Output: Migration files
23
+ - Dependencies: Activity 1 (schema design)
24
+
25
+ 3. Implement authentication middleware
26
+ - Expertise: Backend development
27
+ - Output: JWT middleware code
28
+ - Dependencies: Activity 2 (tables must exist)
29
+
30
+ 4. Create auth endpoints (login/logout)
31
+ - Expertise: Backend development
32
+ - Output: Auth routes and controllers
33
+ - Dependencies: Activity 3 (middleware needed)
34
+
35
+ 5. Add tests for auth flow
36
+ - Expertise: Test automation
37
+ - Output: Integration tests
38
+ - Dependencies: Activity 4 (endpoints must work)
39
+
40
+ Execution Strategy: Sequential
41
+ Reasoning: Each activity depends on the previous one's output. No parallelization possible in this chain.
42
+
43
+ Dependency Chain: 1 → 2 → 3 → 4 → 5
44
+ ```
45
+
46
+ ## Agent Prompts Generated
47
+
48
+ ### Agent 1: Schema Design (First)
49
+
50
+ ```
51
+ DISCOVERY_FIRST: Before starting, understand the environment:
52
+ - Check existing database structure: ls migrations/ or db/schema/
53
+ - Identify database system: PostgreSQL, MySQL, SQLite?
54
+ - Review existing table patterns: user-related tables
55
+ - Note naming conventions: snake_case, camelCase, PascalCase?
56
+
57
+ FOCUS: Design database schema for JWT authentication
58
+ - Users table (if not exists) with email, password_hash
59
+ - Sessions table for active JWT tokens
60
+ - Include created_at, updated_at timestamps
61
+ - Design appropriate indexes for performance
62
+ - Plan foreign key relationships
63
+
64
+ EXCLUDE:
65
+ - Don't create the migration yet (next task)
66
+ - Don't implement OAuth tables (separate feature)
67
+ - Don't modify existing user table if it exists
68
+ - Don't add two-factor auth tables (not in scope)
69
+
70
+ CONTEXT: Building JWT authentication for REST API.
71
+ - From security requirements: bcrypt hashing, cost factor 12
72
+ - Session expiry: 24 hours
73
+ - Email must be unique
74
+ - Follow project database conventions exactly
75
+
76
+ OUTPUT: Schema design document at docs/patterns/auth-database-schema.md
77
+ - Table definitions with column types
78
+ - Indexes and constraints
79
+ - Foreign key relationships
80
+ - Example data
81
+
82
+ SUCCESS: Schema designed and documented
83
+ - All required fields included
84
+ - Performance indexes identified
85
+ - Follows project conventions
86
+ - Ready for migration implementation
87
+
88
+ TERMINATION:
89
+ - Design complete and documented
90
+ - Blocked by missing existing schema info
91
+ ```
92
+
93
+ ### Agent 2: Database Migration (After Agent 1)
94
+
95
+ ```
96
+ DISCOVERY_FIRST: Before starting, understand the environment:
97
+ - Check migration system: Knex, Sequelize, TypeORM, raw SQL?
98
+ - Find migration directory location
99
+ - Review existing migration file format
100
+ - Note up/down pattern used
101
+
102
+ FOCUS: Create database migration for authentication tables
103
+ - Implement users table from schema design
104
+ - Implement sessions table from schema design
105
+ - Add all indexes from schema design
106
+ - Create both up (create) and down (drop) migrations
107
+ - Follow migration naming conventions
108
+
109
+ EXCLUDE:
110
+ - Don't run the migration yet (separate step)
111
+ - Don't seed data (separate concern)
112
+ - Don't modify existing migrations
113
+ - Don't add tables not in schema design
114
+
115
+ CONTEXT: Implementing schema designed in previous step.
116
+ - Schema document: docs/patterns/auth-database-schema.md
117
+ - Tables: users (email, password_hash, created_at, updated_at)
118
+ - Tables: sessions (id, user_id, token_hash, expires_at, created_at)
119
+ - Indexes: users.email (unique), sessions.token_hash, sessions.user_id
120
+
121
+ OUTPUT: Migration file at [DISCOVERED_MIGRATION_PATH]/[timestamp]_create_auth_tables.js
122
+ - Up migration creates tables and indexes
123
+ - Down migration drops tables cleanly
124
+ - Follows project migration format
125
+
126
+ SUCCESS: Migration created and ready to run
127
+ - Matches schema design exactly
128
+ - Both up and down work correctly
129
+ - Follows project patterns
130
+ - No syntax errors
131
+
132
+ TERMINATION:
133
+ - Migration file created successfully
134
+ - Blocked by unclear migration system
135
+ - Migration format doesn't match project (document issue)
136
+ ```
137
+
138
+ ### Agent 3: JWT Middleware (After Agent 2)
139
+
140
+ ```
141
+ DISCOVERY_FIRST: Before starting, understand the environment:
142
+ - Find existing middleware location: src/middleware/ or app/middleware/?
143
+ - Check JWT library in use: jsonwebtoken, jose, other?
144
+ - Review existing middleware patterns
145
+ - Note error handling style used
146
+
147
+ FOCUS: Implement JWT authentication middleware
148
+ - Verify JWT token from Authorization header
149
+ - Decode and validate token
150
+ - Check token against sessions table (not blacklisted)
151
+ - Attach user object to request
152
+ - Handle missing/invalid/expired tokens appropriately
153
+
154
+ EXCLUDE:
155
+ - Don't implement login/logout endpoints (next task)
156
+ - Don't implement token refresh (not in scope)
157
+ - Don't add rate limiting (separate concern)
158
+ - Don't implement permission checking (just authentication)
159
+
160
+ CONTEXT: JWT middleware for REST API authentication.
161
+ - JWT secret: from environment variable JWT_SECRET
162
+ - Token expiry: 24 hours
163
+ - Sessions table: check if token_hash exists and not expired
164
+ - Error responses: 401 for invalid/missing token
165
+ - Follow project error handling patterns
166
+
167
+ OUTPUT: Middleware file at [DISCOVERED_LOCATION]/auth.middleware.ts
168
+ - verifyJWT function (main middleware)
169
+ - Helper functions (decode, validate, etc.)
170
+ - Error handling for all cases
171
+ - TypeScript types if applicable
172
+
173
+ SUCCESS: Middleware implemented and ready to use
174
+ - Verifies JWT correctly
175
+ - Checks session validity
176
+ - Attaches user to request
177
+ - Handles all error cases
178
+ - Follows project patterns
179
+
180
+ TERMINATION:
181
+ - Middleware complete
182
+ - Blocked by missing JWT library
183
+ - Database connection pattern unclear
184
+ ```
185
+
186
+ ### Agent 4: Auth Endpoints (After Agent 3)
187
+
188
+ ```
189
+ DISCOVERY_FIRST: Before starting, understand the environment:
190
+ - Find routes directory: src/routes/ or app/routes/?
191
+ - Check router library: Express, Fastify, Koa?
192
+ - Review existing route patterns
193
+ - Note controller/handler organization
194
+
195
+ FOCUS: Implement authentication endpoints
196
+ - POST /api/auth/login (email, password → JWT token)
197
+ - POST /api/auth/logout (invalidate current session)
198
+ - Use auth middleware from previous step
199
+ - Create sessions table entry on login
200
+ - Remove sessions table entry on logout
201
+
202
+ EXCLUDE:
203
+ - Don't implement registration (separate feature)
204
+ - Don't implement password reset (separate feature)
205
+ - Don't add OAuth endpoints (separate feature)
206
+ - Don't implement GET /me endpoint (separate task)
207
+
208
+ CONTEXT: Auth endpoints using JWT middleware implemented in previous step.
209
+ - Middleware location: [from Agent 3 OUTPUT]
210
+ - Login validates: email format, password against bcrypt hash
211
+ - Login creates: session entry, JWT token with user_id claim
212
+ - Logout requires: valid JWT (use middleware)
213
+ - Logout invalidates: session entry in database
214
+
215
+ OUTPUT:
216
+ - Routes file at [DISCOVERED_LOCATION]/auth.routes.ts
217
+ - Controller file at [DISCOVERED_LOCATION]/auth.controller.ts
218
+ - Follow project route organization pattern
219
+
220
+ SUCCESS: Endpoints implemented and functional
221
+ - Login validates credentials correctly
222
+ - Login returns valid JWT
223
+ - Logout requires authentication
224
+ - Logout invalidates session
225
+ - All errors handled appropriately
226
+ - Follows project patterns
227
+
228
+ TERMINATION:
229
+ - Endpoints complete
230
+ - Blocked by unclear auth middleware interface
231
+ - bcrypt usage pattern unclear
232
+ ```
233
+
234
+ ### Agent 5: Integration Tests (After Agent 4)
235
+
236
+ ```
237
+ DISCOVERY_FIRST: Before starting, understand the environment:
238
+ - Find test directory: tests/, __tests__/, spec/?
239
+ - Identify test framework: Jest, Mocha, Vitest?
240
+ - Review existing test patterns
241
+ - Note test database setup approach
242
+
243
+ FOCUS: Create integration tests for authentication flow
244
+ - Test successful login (valid credentials → JWT returned)
245
+ - Test failed login (invalid credentials → 401)
246
+ - Test logout (valid JWT → session invalidated)
247
+ - Test protected route with valid JWT (→ 200)
248
+ - Test protected route with invalid JWT (→ 401)
249
+ - Test protected route with no JWT (→ 401)
250
+
251
+ EXCLUDE:
252
+ - Don't test registration (not implemented)
253
+ - Don't test password reset (not implemented)
254
+ - Don't unit test internal functions (integration tests only)
255
+ - Don't test OAuth flows (not implemented)
256
+
257
+ CONTEXT: Testing JWT authentication implemented in previous steps.
258
+ - Endpoints: POST /api/auth/login, POST /api/auth/logout
259
+ - Middleware: JWT verification from auth.middleware.ts
260
+ - Test database: Use test database, clean between tests
261
+ - Follow project testing patterns exactly
262
+
263
+ OUTPUT: Test file at [DISCOVERED_LOCATION]/auth.integration.test.ts
264
+ - All test cases listed in FOCUS
265
+ - Setup and teardown (database, test user)
266
+ - Clear test descriptions
267
+ - Assertions verify correct behavior
268
+
269
+ SUCCESS: Complete test coverage for auth flow
270
+ - All tests pass
271
+ - Tests are independent (can run in any order)
272
+ - Database cleanup works correctly
273
+ - Follows project test patterns
274
+ - Coverage includes happy path and error cases
275
+
276
+ TERMINATION:
277
+ - Tests complete and passing
278
+ - Blocked by test framework unclear
279
+ - Test database setup pattern unclear
280
+ ```
281
+
282
+ ## Execution Flow
283
+
284
+ ### Phase 1: Schema Design (Agent 1)
285
+
286
+ ```
287
+ 🚀 Launching Agent 1: Schema Design
288
+
289
+ Status: RUNNING
290
+ Time: 15 minutes
291
+
292
+ Agent 1: COMPLETE ✅
293
+ Output: docs/patterns/auth-database-schema.md
294
+
295
+ Deliverables:
296
+ - Users table design (5 columns + indexes)
297
+ - Sessions table design (5 columns + indexes)
298
+ - Foreign key relationship documented
299
+ - Performance considerations noted
300
+
301
+ Validation: ✅ Ready for migration implementation
302
+ ```
303
+
304
+ ### Phase 2: Database Migration (Agent 2)
305
+
306
+ ```
307
+ 🚀 Launching Agent 2: Database Migration
308
+ Dependencies: Agent 1 complete ✅
309
+
310
+ Context provided:
311
+ - Schema document from Agent 1
312
+ - Table definitions and indexes
313
+
314
+ Status: RUNNING
315
+ Time: 20 minutes
316
+
317
+ Agent 2: COMPLETE ✅
318
+ Output: migrations/20250124120000_create_auth_tables.js
319
+
320
+ Deliverables:
321
+ - Up migration creates both tables
322
+ - Down migration drops cleanly
323
+ - All indexes included
324
+ - Follows Knex migration pattern
325
+
326
+ Validation: ✅ Ready for middleware implementation
327
+ ```
328
+
329
+ ### Phase 3: JWT Middleware (Agent 3)
330
+
331
+ ```
332
+ 🚀 Launching Agent 3: JWT Middleware
333
+ Dependencies: Agent 2 complete ✅
334
+
335
+ Context provided:
336
+ - Migration created tables
337
+ - Database schema known
338
+
339
+ Status: RUNNING
340
+ Time: 30 minutes
341
+
342
+ Agent 3: COMPLETE ✅
343
+ Output: src/middleware/auth.middleware.ts
344
+
345
+ Deliverables:
346
+ - verifyJWT middleware function
347
+ - Token validation logic
348
+ - Session checking against database
349
+ - Error handling for all cases
350
+
351
+ Validation: ✅ Ready for endpoint implementation
352
+ ```
353
+
354
+ ### Phase 4: Auth Endpoints (Agent 4)
355
+
356
+ ```
357
+ 🚀 Launching Agent 4: Auth Endpoints
358
+ Dependencies: Agent 3 complete ✅
359
+
360
+ Context provided:
361
+ - Middleware from Agent 3
362
+ - Function signatures and usage
363
+
364
+ Status: RUNNING
365
+ Time: 35 minutes
366
+
367
+ Agent 4: COMPLETE ✅
368
+ Output:
369
+ - src/routes/auth.routes.ts
370
+ - src/controllers/auth.controller.ts
371
+
372
+ Deliverables:
373
+ - POST /api/auth/login endpoint
374
+ - POST /api/auth/logout endpoint
375
+ - Integration with middleware
376
+ - Error responses
377
+
378
+ Validation: ✅ Ready for testing
379
+ ```
380
+
381
+ ### Phase 5: Integration Tests (Agent 5)
382
+
383
+ ```
384
+ 🚀 Launching Agent 5: Integration Tests
385
+ Dependencies: Agent 4 complete ✅
386
+
387
+ Context provided:
388
+ - All endpoints from Agent 4
389
+ - Middleware from Agent 3
390
+ - Expected behavior
391
+
392
+ Status: RUNNING
393
+ Time: 25 minutes
394
+
395
+ Agent 5: COMPLETE ✅
396
+ Output: tests/integration/auth.test.ts
397
+
398
+ Deliverables:
399
+ - 6 integration tests
400
+ - Database setup/teardown
401
+ - All tests passing ✅
402
+ - 95% coverage of auth flow
403
+
404
+ Validation: ✅ Feature complete and tested
405
+ ```
406
+
407
+ ## Results
408
+
409
+ ### Total Time: 125 minutes (sequential)
410
+
411
+ **Sequential necessary:** Each task depends on previous
412
+ **No parallelization possible** in this dependency chain
413
+
414
+ ### Context Accumulation
415
+
416
+ Each agent received growing context:
417
+
418
+ - Agent 1: Fresh start
419
+ - Agent 2: Agent 1's schema design
420
+ - Agent 3: Agent 2's migration + Agent 1's schema
421
+ - Agent 4: Agent 3's middleware + all prior context
422
+ - Agent 5: All previous implementations
423
+
424
+ ### Deliverables
425
+
426
+ ```
427
+ 📁 Project structure:
428
+ ├── docs/patterns/
429
+ │ └── auth-database-schema.md (Agent 1)
430
+ ├── migrations/
431
+ │ └── 20250124120000_create_auth_tables.js (Agent 2)
432
+ ├── src/
433
+ │ ├── middleware/
434
+ │ │ └── auth.middleware.ts (Agent 3)
435
+ │ ├── routes/
436
+ │ │ └── auth.routes.ts (Agent 4)
437
+ │ └── controllers/
438
+ │ └── auth.controller.ts (Agent 4)
439
+ └── tests/integration/
440
+ └── auth.test.ts (Agent 5)
441
+ ```
442
+
443
+ ## Lessons Learned
444
+
445
+ ### What Worked Well
446
+
447
+ ✅ **Clear dependency chain:** Each agent knew exactly what it needed
448
+ ✅ **Context accumulation:** Prior outputs informed each subsequent agent
449
+ ✅ **DISCOVERY_FIRST:** Ensured consistency with project patterns
450
+ ✅ **Validation at each step:** Caught issues before they propagated
451
+
452
+ ### Challenges Encountered
453
+
454
+ ⚠️ **Agent 2 Issue:** Initial migration didn't match project format
455
+ - **Solution:** Retry with more specific Knex pattern in CONTEXT
456
+ - **Lesson:** DISCOVERY_FIRST examples critical
457
+
458
+ ⚠️ **Agent 3 Issue:** Used wrong JWT library (jose instead of jsonwebtoken)
459
+ - **Solution:** More explicit in EXCLUDE and CONTEXT
460
+ - **Lesson:** Specify exact libraries when project uses specific ones
461
+
462
+ ⚠️ **Agent 5 Issue:** Tests didn't clean up database properly
463
+ - **Solution:** Retry with explicit teardown requirements
464
+ - **Lesson:** Test isolation must be explicit in SUCCESS criteria
465
+
466
+ ### Improvements for Next Time
467
+
468
+ 1. **Specify exact libraries** in CONTEXT (don't assume agent will discover)
469
+ 2. **Include output of previous agent** verbatim in next agent's CONTEXT
470
+ 3. **Validation step between agents** to catch issues before next dependency
471
+ 4. **Checkpoint approach:** Allow user to review after each agent before launching next
472
+
473
+ ## Reusable Template
474
+
475
+ This pattern works for any sequential build:
476
+
477
+ ```
478
+ 1. Identify dependency chain (what depends on what)
479
+ 2. Order activities by dependencies
480
+ 3. Each agent's CONTEXT includes prior agent outputs
481
+ 4. Launch sequentially, validate each before next
482
+ 5. Accumulate context as you go
483
+ ```
484
+
485
+ **Use when:**
486
+ - Building implementation layers (DB → Logic → API → UI)
487
+ - Pipeline-style workflows (Design → Build → Test → Deploy)
488
+ - Learning workflows (Research → Design → Implement → Validate)
489
+ - Any task where B genuinely needs A's output
490
+
491
+ ## Comparison: What If We Tried Parallel?
492
+
493
+ **Attempted parallel (would fail):**
494
+
495
+ ```
496
+ Agent 2 (Migration): Needs Agent 1's schema design → BLOCKED
497
+ Agent 3 (Middleware): Needs Agent 2's tables to exist → BLOCKED
498
+ Agent 4 (Endpoints): Needs Agent 3's middleware → BLOCKED
499
+ Agent 5 (Tests): Needs Agent 4's endpoints → BLOCKED
500
+
501
+ Result: All agents blocked or produce incorrect results
502
+ ```
503
+
504
+ **Lesson:** Don't force parallelization when dependencies exist. Sequential is correct here.