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,825 @@
1
+ # Agent Delegation Skill Reference
2
+
3
+ Complete reference for advanced delegation patterns, edge cases, and optimization strategies.
4
+
5
+ ## Advanced Decomposition Patterns
6
+
7
+ ### Multi-Level Decomposition
8
+
9
+ For very complex tasks, decompose in layers:
10
+
11
+ **Layer 1: High-Level Activities**
12
+ ```
13
+ Task: Build e-commerce checkout flow
14
+
15
+ Activities:
16
+ 1. Frontend checkout interface
17
+ 2. Backend payment processing
18
+ 3. Order fulfillment system
19
+ 4. Email notifications
20
+ ```
21
+
22
+ **Layer 2: Sub-Activity Decomposition**
23
+
24
+ Take Activity 2 and decompose further:
25
+ ```
26
+ Activity: Backend payment processing
27
+
28
+ Sub-activities:
29
+ 2.1 Stripe API integration
30
+ 2.2 Payment validation logic
31
+ 2.3 Transaction database schema
32
+ 2.4 Refund handling
33
+ ```
34
+
35
+ **Execution Strategy:**
36
+ - Layer 1: Mixed (some parallel, some sequential)
37
+ - Layer 2: Decompose only when agent starts Activity 2
38
+ - Don't decompose all layers upfront (overwhelming)
39
+
40
+ ### Dependency Graph Decomposition
41
+
42
+ For complex dependency chains:
43
+
44
+ ```
45
+ Task: Deploy new microservice
46
+
47
+ Activity Map:
48
+ A: Write service code
49
+ B: Write unit tests (depends on A)
50
+ C: Create Docker image (depends on A)
51
+ D: Write integration tests (depends on A, C)
52
+ E: Deploy to staging (depends on B, C, D)
53
+ F: Run smoke tests (depends on E)
54
+ G: Deploy to production (depends on F)
55
+
56
+ Execution Groups:
57
+ Group 1: A (sequential)
58
+ Group 2: B, C (parallel after A)
59
+ Group 3: D (sequential after Group 2)
60
+ Group 4: E (sequential after Group 3)
61
+ Group 5: F (sequential after E)
62
+ Group 6: G (sequential after F)
63
+ ```
64
+
65
+ **Pattern:** Identify critical path, parallelize where possible.
66
+
67
+ ### Expertise-Based Decomposition
68
+
69
+ When multiple domains are involved:
70
+
71
+ ```
72
+ Task: Add real-time chat feature
73
+
74
+ Decompose by expertise:
75
+ 1. UI/UX design (design expertise)
76
+ 2. Frontend component (React expertise)
77
+ 3. WebSocket server (Backend expertise)
78
+ 4. Message persistence (Database expertise)
79
+ 5. Security review (Security expertise)
80
+ 6. Performance testing (Performance expertise)
81
+
82
+ Execution:
83
+ - Phase 1: Activity 1 (sequential)
84
+ - Phase 2: Activities 2-4 (parallel, informed by Activity 1)
85
+ - Phase 3: Activities 5-6 (parallel review after Phase 2)
86
+ ```
87
+
88
+ ## Advanced Parallel Patterns
89
+
90
+ ### Fan-Out/Fan-In Pattern
91
+
92
+ Parallel expansion followed by sequential consolidation:
93
+
94
+ ```
95
+ Start
96
+
97
+ [Activity 1]
98
+
99
+ ┌─────┼─────┐
100
+ ↓ ↓ ↓
101
+ [A2] [A3] [A4] ← Fan-out (parallel)
102
+ ↓ ↓ ↓
103
+ └─────┼─────┘
104
+
105
+ [Synthesize] ← Fan-in (sequential)
106
+
107
+ Done
108
+ ```
109
+
110
+ **Example:** Competitive analysis
111
+ - Fan-out: Analyze competitors A, B, C in parallel
112
+ - Fan-in: Synthesize findings into unified strategy
113
+
114
+ ### Pipeline Pattern
115
+
116
+ Sequential groups where each group can be parallel:
117
+
118
+ ```
119
+ Stage 1: Research (parallel within stage)
120
+ - Market research
121
+ - Competitive analysis
122
+ - User interviews
123
+
124
+ Stage 2: Design (parallel within stage)
125
+ - UI mockups
126
+ - API design
127
+ - Database schema
128
+
129
+ Stage 3: Implementation (parallel within stage)
130
+ - Frontend build
131
+ - Backend build
132
+ - Database setup
133
+ ```
134
+
135
+ **Pattern:** Stages are sequential, activities within each stage are parallel.
136
+
137
+ ### MapReduce Pattern
138
+
139
+ Parallel processing with aggregation:
140
+
141
+ ```
142
+ Map Phase (parallel):
143
+ Agent 1: Process dataset chunk 1
144
+ Agent 2: Process dataset chunk 2
145
+ Agent 3: Process dataset chunk 3
146
+ Agent 4: Process dataset chunk 4
147
+
148
+ Reduce Phase (sequential):
149
+ Aggregate all results into final output
150
+ ```
151
+
152
+ **Example:** Code analysis across modules
153
+ - Map: Each agent analyzes one module
154
+ - Reduce: Aggregate findings into project-wide report
155
+
156
+ ## Advanced Template Patterns
157
+
158
+ ### Context Accumulation Pattern
159
+
160
+ For sequential tasks, accumulate context:
161
+
162
+ ```
163
+ Agent 1:
164
+ CONTEXT: Fresh start, no prior context
165
+ OUTPUT: Result A
166
+
167
+ Agent 2:
168
+ CONTEXT:
169
+ - Prior results: [Result A from Agent 1]
170
+ - Build on: [Specific insights from A]
171
+ OUTPUT: Result B (informed by A)
172
+
173
+ Agent 3:
174
+ CONTEXT:
175
+ - Prior results: [Result A, Result B]
176
+ - Conflicts to resolve: [Any conflicts between A and B]
177
+ - Build on: [Insights from both]
178
+ OUTPUT: Result C (synthesizes A and B)
179
+ ```
180
+
181
+ **Key:** Each agent gets relevant prior outputs, not everything.
182
+
183
+ ### Constraint Propagation Pattern
184
+
185
+ Cascade constraints through dependent tasks:
186
+
187
+ ```
188
+ Agent 1 (Schema Design):
189
+ SUCCESS:
190
+ - Uses PostgreSQL (project standard)
191
+ - Follows naming: snake_case tables
192
+ - All tables have created_at, updated_at
193
+
194
+ Agent 2 (API Implementation, depends on Agent 1):
195
+ CONTEXT:
196
+ - Database constraints from Agent 1:
197
+ * PostgreSQL only
198
+ * snake_case table names
199
+ * created_at/updated_at in all tables
200
+ - Must match schema exactly
201
+ ```
202
+
203
+ **Pattern:** SUCCESS criteria from earlier tasks become CONTEXT constraints for later ones.
204
+
205
+ ### Specification Reference Pattern
206
+
207
+ For implementation tasks, reference specs explicitly:
208
+
209
+ ```
210
+ FOCUS: Implement user registration endpoint
211
+
212
+ CONTEXT:
213
+ - PRD Section 3.1.2: User registration requirements
214
+ - SDD Section 4.2: API endpoint specifications
215
+ - SDD Section 5.3: Database schema for users table
216
+ - PLAN Phase 2, Task 3: Implementation checklist
217
+
218
+ SDD_REQUIREMENTS:
219
+ - Endpoint: POST /api/auth/register
220
+ - Request body: { email, password, name }
221
+ - Response: { user_id, token }
222
+ - Validation: Email format, password strength (8+ chars)
223
+ - Security: Bcrypt hashing (cost 12)
224
+
225
+ SPECIFICATION_CHECK: Must match SDD Section 4.2 exactly
226
+ ```
227
+
228
+ **Pattern:** Explicit spec references prevent context drift.
229
+
230
+ ## File Coordination Advanced Strategies
231
+
232
+ ### Timestamp-Based Uniqueness
233
+
234
+ When paths might collide, add timestamps:
235
+
236
+ ```
237
+ Agent 1 OUTPUT: logs/analysis-${TIMESTAMP}.md
238
+ Agent 2 OUTPUT: logs/research-${TIMESTAMP}.md
239
+ Agent 3 OUTPUT: logs/synthesis-${TIMESTAMP}.md
240
+
241
+ where TIMESTAMP = ISO 8601 format
242
+ ```
243
+
244
+ **Result:** No collisions even if agents run simultaneously.
245
+
246
+ ### Directory Hierarchy Assignment
247
+
248
+ Assign each agent a subdirectory:
249
+
250
+ ```
251
+ Agent 1 OUTPUT: results/agent-1/findings.md
252
+ Agent 2 OUTPUT: results/agent-2/findings.md
253
+ Agent 3 OUTPUT: results/agent-3/findings.md
254
+ ```
255
+
256
+ **Result:** Each agent owns a directory, filenames can repeat.
257
+
258
+ ### Atomic File Creation Pattern
259
+
260
+ For critical files, ensure atomic creation:
261
+
262
+ ```
263
+ OUTPUT: Create file at exact path: docs/patterns/auth.md
264
+ - If file exists, FAIL and report (don't overwrite)
265
+ - Use atomic write (temp file + rename)
266
+ - Verify write succeeded before marking complete
267
+ ```
268
+
269
+ **Pattern:** Prevents race conditions and corruption.
270
+
271
+ ### Merge Strategy Pattern
272
+
273
+ When multiple agents create similar content:
274
+
275
+ ```
276
+ Strategy: Sequential merge
277
+
278
+ Agent 1: Create base document
279
+ Agent 2: Read base, add section 2
280
+ Agent 3: Read base + section 2, add section 3
281
+
282
+ Each agent:
283
+ DISCOVERY_FIRST: Read current state of document
284
+ FOCUS: Add my section without modifying others
285
+ OUTPUT: Updated document with my section added
286
+ ```
287
+
288
+ **Pattern:** Sequential additions to shared document.
289
+
290
+ ## Scope Validation Advanced Patterns
291
+
292
+ ### Severity-Based Acceptance
293
+
294
+ Categorize scope creep by severity:
295
+
296
+ **Minor (Auto-accept):**
297
+ - Variable name improvements
298
+ - Comment additions
299
+ - Whitespace formatting
300
+ - Import organization
301
+
302
+ **Medium (Review):**
303
+ - Small refactors related to task
304
+ - Additional error handling
305
+ - Logging additions
306
+ - Documentation updates
307
+
308
+ **Major (Reject):**
309
+ - New features
310
+ - Architecture changes
311
+ - Dependency additions
312
+ - Breaking changes
313
+
314
+ ### Value-Based Exception Handling
315
+
316
+ Sometimes scope creep is valuable:
317
+
318
+ ```
319
+ Agent delivered:
320
+ ✅ Required: Authentication endpoint
321
+ ⚠️ Extra: Rate limiting on endpoint (not requested)
322
+
323
+ Analysis:
324
+ - Extra work: Rate limiting
325
+ - In EXCLUDE? No (not explicitly excluded)
326
+ - Valuable? Yes (security best practice)
327
+ - Risky? No (standard pattern)
328
+ - Increases scope? Minimally
329
+
330
+ Decision: 🟡 ACCEPT with note
331
+ "Agent proactively added rate limiting for security.
332
+ Aligns with best practices, accepting this valuable addition."
333
+ ```
334
+
335
+ **Pattern:** Auto-accept valuable, low-risk extras that align with project goals.
336
+
337
+ ### Specification Drift Detection
338
+
339
+ For implement tasks, detect drift from specs:
340
+
341
+ ```
342
+ Validation:
343
+ 1. Check FOCUS matches PLAN task description
344
+ 2. Check implementation matches SDD requirements
345
+ 3. Check business logic matches PRD rules
346
+
347
+ Drift detected if:
348
+ - Implementation differs from SDD design
349
+ - Business rules differ from PRD
350
+ - Features not in PLAN added
351
+
352
+ Report:
353
+ 📊 Specification Alignment: 85%
354
+ ✅ Aligned: [aspects that match]
355
+ ⚠️ Deviations: [aspects that differ]
356
+ 🔴 Critical drift: [major misalignments]
357
+ ```
358
+
359
+ ## Retry Strategy Advanced Patterns
360
+
361
+ ### Progressive Refinement
362
+
363
+ Refine template progressively across retries:
364
+
365
+ **Attempt 1 (Failed - too vague):**
366
+ ```
367
+ FOCUS: Add caching
368
+ ```
369
+
370
+ **Attempt 2 (Failed - still ambiguous):**
371
+ ```
372
+ FOCUS: Add Redis caching for API responses
373
+ EXCLUDE: Don't cache user-specific data
374
+ ```
375
+
376
+ **Attempt 3 (Success - specific enough):**
377
+ ```
378
+ FOCUS: Add Redis caching for public API endpoints
379
+ - Cache GET requests only
380
+ - TTL: 5 minutes
381
+ - Key format: api:endpoint:params:hash
382
+ - Invalidate on POST/PUT/DELETE to same resource
383
+
384
+ EXCLUDE:
385
+ - Don't cache authenticated user requests
386
+ - Don't cache admin endpoints
387
+ - Don't implement cache warming
388
+ - Don't add Redis cluster setup (single node for now)
389
+
390
+ CONTEXT:
391
+ - Redis already configured: localhost:6379
392
+ - Use ioredis client
393
+ - Follow caching pattern: docs/patterns/caching-strategy.md
394
+ ```
395
+
396
+ **Pattern:** Each retry adds specificity based on previous failure.
397
+
398
+ ### Agent Type Rotation
399
+
400
+ If specialist fails, try different angle:
401
+
402
+ ```
403
+ Attempt 1: Backend specialist
404
+ - Focused on technical implementation
405
+ - Failed: Too technical, missed user experience
406
+
407
+ Attempt 2: UX specialist
408
+ - Focused on user flows
409
+ - Failed: Too high-level, missed technical constraints
410
+
411
+ Attempt 3: Product specialist
412
+ - Balanced user needs with technical reality
413
+ - Success: Right blend of perspectives
414
+ ```
415
+
416
+ **Pattern:** Rotate expertise angle based on failure mode.
417
+
418
+ ### Scope Reduction Strategy
419
+
420
+ If task too complex, reduce scope progressively:
421
+
422
+ ```
423
+ Attempt 1 (Failed - too much):
424
+ FOCUS: Build complete authentication system
425
+ - Registration, login, logout, password reset
426
+ - OAuth integration
427
+ - Two-factor authentication
428
+
429
+ Attempt 2 (Failed - still complex):
430
+ FOCUS: Build basic authentication
431
+ - Registration, login, logout
432
+
433
+ Attempt 3 (Success - minimal):
434
+ FOCUS: Build login endpoint only
435
+ - POST /auth/login
436
+ - Email + password validation
437
+ - Return JWT token
438
+ ```
439
+
440
+ **Pattern:** Reduce scope until agent succeeds, then expand incrementally.
441
+
442
+ ## Edge Cases and Solutions
443
+
444
+ ### Edge Case 1: Circular Dependencies
445
+
446
+ **Problem:** Agent A needs Agent B's output, Agent B needs Agent A's output
447
+
448
+ **Detection:**
449
+ ```
450
+ Activity A depends on B
451
+ Activity B depends on A
452
+ → Circular dependency detected
453
+ ```
454
+
455
+ **Solutions:**
456
+
457
+ 1. **Break the cycle:**
458
+ ```
459
+ Original:
460
+ A (needs B) ↔ B (needs A)
461
+
462
+ Refactored:
463
+ C (shared foundation) → A (builds on C) → B (builds on A)
464
+ ```
465
+
466
+ 2. **Iterative approach:**
467
+ ```
468
+ Round 1: A (with assumptions about B)
469
+ Round 2: B (using Round 1 A)
470
+ Round 3: A (refined with actual B)
471
+ ```
472
+
473
+ 3. **Merge activities:**
474
+ ```
475
+ Single agent handles both A and B together
476
+ (They're too coupled to separate)
477
+ ```
478
+
479
+ ### Edge Case 2: Dynamic Dependencies
480
+
481
+ **Problem:** Don't know dependencies until runtime
482
+
483
+ **Example:**
484
+ ```
485
+ Task: Analyze codebase
486
+
487
+ Don't know which modules exist until discovery
488
+ Can't plan parallel structure upfront
489
+ ```
490
+
491
+ **Solution - Two-phase approach:**
492
+
493
+ **Phase 1: Discovery (sequential)**
494
+ ```
495
+ Agent 1: Discover project structure
496
+ OUTPUT: List of modules
497
+
498
+ Result: [moduleA, moduleB, moduleC, moduleD]
499
+ ```
500
+
501
+ **Phase 2: Analysis (parallel, dynamic)**
502
+ ```
503
+ For each module in result:
504
+ Launch analysis agent
505
+
506
+ Agent A: Analyze moduleA
507
+ Agent B: Analyze moduleB
508
+ Agent C: Analyze moduleC
509
+ Agent D: Analyze moduleD
510
+ ```
511
+
512
+ **Pattern:** Sequential discovery, dynamic parallel execution.
513
+
514
+ ### Edge Case 3: Partial Agent Availability
515
+
516
+ **Problem:** Some specialist agents unavailable
517
+
518
+ **Example:**
519
+ ```
520
+ Planned:
521
+ - Frontend specialist (available)
522
+ - Backend specialist (available)
523
+ - DevOps specialist (NOT AVAILABLE)
524
+ ```
525
+
526
+ **Solution - Fallback delegation:**
527
+
528
+ ```
529
+ If specialist unavailable:
530
+ 1. Try broader domain agent (general-purpose)
531
+ 2. Try sequential breakdown (smaller tasks)
532
+ 3. Handle directly if simple enough
533
+ 4. Escalate to user if critical
534
+ ```
535
+
536
+ **Example execution:**
537
+ ```
538
+ DevOps work:
539
+ Attempt 1: DevOps specialist → UNAVAILABLE
540
+ Attempt 2: Backend specialist with DevOps context → SUCCESS
541
+ Reasoning: Backend specialist has some DevOps overlap
542
+ ```
543
+
544
+ ### Edge Case 4: Agent Response Conflicts
545
+
546
+ **Problem:** Parallel agents return conflicting recommendations
547
+
548
+ **Example:**
549
+ ```
550
+ Agent 1 (Security): "Use bcrypt with cost 14 (maximum security)"
551
+ Agent 2 (Performance): "Use bcrypt with cost 10 (reasonable security, better performance)"
552
+ ```
553
+
554
+ **Solution - Conflict resolution:**
555
+
556
+ **1. Present to user:**
557
+ ```
558
+ ⚠️ Agent Conflict Detected
559
+
560
+ Topic: Bcrypt cost factor
561
+ Agent 1 (Security): Cost 14 (maximize security)
562
+ Agent 2 (Performance): Cost 10 (balance security/performance)
563
+
564
+ Trade-off:
565
+ - Cost 14: ~200ms hashing time, highest security
566
+ - Cost 10: ~50ms hashing time, strong security
567
+
568
+ Recommendation needed: Which priority matters more?
569
+ ```
570
+
571
+ **2. Specification arbitration:**
572
+ ```
573
+ Check specs:
574
+ - SDD Section 5.2: "Use bcrypt cost factor 12"
575
+ → Use specification value (12)
576
+ → Both agents adjusted to match spec
577
+ ```
578
+
579
+ **3. Synthesis agent:**
580
+ ```
581
+ Launch Agent 3 (Architect):
582
+ FOCUS: Resolve conflict between security and performance recommendations
583
+ CONTEXT:
584
+ - Security recommendation: cost 14
585
+ - Performance recommendation: cost 10
586
+ - Trade-offs: [details]
587
+ OUTPUT: Final recommendation with reasoning
588
+ ```
589
+
590
+ ### Edge Case 5: Resource Constraints
591
+
592
+ **Problem:** Can't launch all parallel agents simultaneously (rate limits, memory, etc.)
593
+
594
+ **Solution - Batched parallel execution:**
595
+
596
+ ```
597
+ Activities: [A1, A2, A3, A4, A5, A6, A7, A8]
598
+ Constraint: Maximum 3 parallel agents
599
+
600
+ Execution:
601
+ Batch 1: A1, A2, A3 (parallel)
602
+ → Wait for completion
603
+ Batch 2: A4, A5, A6 (parallel)
604
+ → Wait for completion
605
+ Batch 3: A7, A8 (parallel)
606
+ → Complete
607
+ ```
608
+
609
+ **Pattern:** Maintain parallelism within constraints.
610
+
611
+ ## Performance Optimization
612
+
613
+ ### Minimize Context Size
614
+
615
+ Don't pass everything to every agent:
616
+
617
+ ❌ **Bad - Full context:**
618
+ ```
619
+ CONTEXT:
620
+ - Entire PRD (50 pages)
621
+ - Entire SDD (40 pages)
622
+ - All prior agent outputs (30 pages)
623
+ ```
624
+
625
+ ✅ **Good - Relevant context:**
626
+ ```
627
+ CONTEXT:
628
+ - PRD Section 3.2 (User authentication requirements)
629
+ - SDD Section 4.1 (API endpoint design)
630
+ - Prior output: Authentication flow diagram from Agent 1
631
+ ```
632
+
633
+ **Pattern:** Extract only relevant portions, reference docs by section.
634
+
635
+ ### Parallel Batching
636
+
637
+ Group related parallel tasks:
638
+
639
+ ```
640
+ Don't:
641
+ Launch 20 individual research agents
642
+
643
+ Do:
644
+ Launch 4 research agents, each handles 5 topics
645
+ ```
646
+
647
+ **Benefits:**
648
+ - Fewer coordination overhead
649
+ - Better context utilization
650
+ - Faster overall completion
651
+
652
+ ### Early Termination
653
+
654
+ Build termination conditions into templates:
655
+
656
+ ```
657
+ TERMINATION:
658
+ - Completed successfully
659
+ - Blocked by missing dependency X
660
+ - Information not publicly available
661
+ - Maximum 3 attempts reached
662
+ - ERROR: [specific error conditions]
663
+ ```
664
+
665
+ **Pattern:** Let agents fail fast instead of hanging.
666
+
667
+ ## Integration with Other Skills
668
+
669
+ ### With Documentation Skill
670
+
671
+ When agents discover patterns:
672
+
673
+ ```
674
+ Agent completes task
675
+
676
+ Discovers reusable pattern
677
+
678
+ Documentation skill activates
679
+
680
+ Pattern documented in docs/patterns/
681
+
682
+ Reported back to orchestrator
683
+ ```
684
+
685
+ **Coordination:** Agent-delegation creates prompts, documentation skill handles pattern storage.
686
+
687
+ ### With Specification Review Skill
688
+
689
+ For implementation tasks:
690
+
691
+ ```
692
+ Agent completes implementation
693
+
694
+ Agent-delegation validates scope
695
+
696
+ Specification review skill validates against PRD/SDD
697
+
698
+ Both validations pass → Complete
699
+ ```
700
+
701
+ **Coordination:** Agent-delegation handles scope, spec-review handles alignment.
702
+
703
+ ### With Quality Gates Skill
704
+
705
+ At phase boundaries:
706
+
707
+ ```
708
+ Phase completes
709
+
710
+ Agent-delegation confirms all tasks done
711
+
712
+ Quality gates skill runs DOD checks
713
+
714
+ Both pass → Proceed to next phase
715
+ ```
716
+
717
+ **Coordination:** Agent-delegation manages execution, quality-gates validates quality.
718
+
719
+ ## Debugging Failed Delegations
720
+
721
+ ### Symptom: Agents ignore EXCLUDE
722
+
723
+ **Diagnosis:**
724
+ - EXCLUDE too vague
725
+ - Agent sees value in excluded work
726
+ - Conflict between FOCUS and EXCLUDE
727
+
728
+ **Fix:**
729
+ ```
730
+ Before:
731
+ EXCLUDE: Don't add extra features
732
+
733
+ After:
734
+ EXCLUDE: Do not add these specific features:
735
+ - OAuth integration (separate task)
736
+ - Password reset flow (separate task)
737
+ - Two-factor authentication (not in scope)
738
+ Any feature not explicitly in FOCUS is out of scope.
739
+ ```
740
+
741
+ ### Symptom: Parallel agents conflict
742
+
743
+ **Diagnosis:**
744
+ - Hidden shared state
745
+ - File path collision
746
+ - Dependency not identified
747
+
748
+ **Fix:**
749
+ ```
750
+ Review parallel safety checklist:
751
+ - Independent tasks? → Check dependencies again
752
+ - Unique file paths? → Verify OUTPUT sections
753
+ - No shared state? → Identify what's shared
754
+
755
+ If any fail → Make sequential or coordinate better
756
+ ```
757
+
758
+ ### Symptom: Sequential too slow
759
+
760
+ **Diagnosis:**
761
+ - False dependencies
762
+ - Over-cautious sequencing
763
+ - Could be parallel with coordination
764
+
765
+ **Fix:**
766
+ ```
767
+ Re-analyze dependencies:
768
+ - Must Task B use Task A's output? → True dependency
769
+ - Could Task B assume Task A's approach? → False dependency
770
+
771
+ If false dependency:
772
+ → Make parallel with coordinated assumptions
773
+ ```
774
+
775
+ ### Symptom: Template too complex
776
+
777
+ **Diagnosis:**
778
+ - Too many constraints
779
+ - Context overload
780
+ - Agent confused by detail
781
+
782
+ **Fix:**
783
+ ```
784
+ Simplify:
785
+ 1. Keep FOCUS to essentials
786
+ 2. Move details to CONTEXT
787
+ 3. Provide examples instead of rules
788
+
789
+ Before (overwhelming):
790
+ FOCUS: [20 lines of detailed requirements]
791
+
792
+ After (simplified):
793
+ FOCUS: [2 lines of core task]
794
+ CONTEXT: [Details and constraints]
795
+ ```
796
+
797
+ ## Best Practices Summary
798
+
799
+ 1. **Decompose by activities**, not roles
800
+ 2. **Parallel by default**, sequential only when necessary
801
+ 3. **Explicit FOCUS/EXCLUDE**, no ambiguity
802
+ 4. **Unique file paths**, verify before launching
803
+ 5. **Minimal context**, only relevant information
804
+ 6. **Auto-accept safe changes**, review architectural ones
805
+ 7. **Maximum 3 retries**, then escalate
806
+ 8. **Early termination**, fail fast when blocked
807
+ 9. **Validate scope**, check FOCUS/EXCLUDE adherence
808
+ 10. **Document patterns**, activate documentation skill when discovered
809
+
810
+ ## Common Patterns Quick Reference
811
+
812
+ | Pattern | When to Use | Structure |
813
+ |---------|-------------|-----------|
814
+ | Fan-Out/Fan-In | Parallel research → synthesis | Parallel → Sequential |
815
+ | Pipeline | Stages with parallel within | Sequential stages, parallel tasks |
816
+ | MapReduce | Large dataset processing | Parallel map → Sequential reduce |
817
+ | Progressive Refinement | Retry with more detail | Retry N adds specificity |
818
+ | Batched Parallel | Resource constraints | Groups of parallel tasks |
819
+ | Context Accumulation | Sequential with learning | Each task gets prior outputs |
820
+ | Constraint Propagation | Dependent implementations | SUCCESS → next CONTEXT |
821
+ | Specification Reference | Implementation tasks | Explicit PRD/SDD references |
822
+
823
+ ---
824
+
825
+ This reference covers advanced scenarios beyond the main skill. Load this when dealing with complex coordination, optimization, or edge cases.