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,461 @@
1
+ # Reference: Monitoring Patterns
2
+
3
+ ## Overview
4
+
5
+ Implementation patterns for metrics collection, distributed tracing, alerting configuration, and SLO management across different technology stacks and monitoring platforms.
6
+
7
+ ## Quick Reference
8
+
9
+ | Pattern | Use Case | Complexity |
10
+ |---------|----------|------------|
11
+ | RED Method | Request-driven services | Low |
12
+ | USE Method | Resource monitoring | Low |
13
+ | Four Golden Signals | General service health | Low |
14
+ | Multi-window alerting | SLO-based alerting | Medium |
15
+ | Trace context propagation | Distributed tracing | Medium |
16
+ | Exemplars | Metric-to-trace correlation | Medium |
17
+ | Synthetic monitoring | Proactive availability | Medium |
18
+
19
+ ## Metric Collection Patterns
20
+
21
+ ### RED Method (Request-driven services)
22
+
23
+ Monitor three key metrics for every service:
24
+
25
+ ```
26
+ Rate: requests per second
27
+ Errors: failed requests per second
28
+ Duration: distribution of request latency
29
+ ```
30
+
31
+ **When to use:** Microservices, APIs, web applications
32
+
33
+ **Implementation:**
34
+ ```
35
+ # Prometheus-style metrics
36
+ http_requests_total{method, endpoint, status}
37
+ http_request_duration_seconds{method, endpoint}
38
+ http_request_errors_total{method, endpoint, error_type}
39
+ ```
40
+
41
+ ### USE Method (Resources)
42
+
43
+ Monitor three aspects for every resource:
44
+
45
+ ```
46
+ Utilization: percentage of resource capacity in use
47
+ Saturation: degree to which resource has queued work
48
+ Errors: count of error events
49
+ ```
50
+
51
+ **When to use:** CPU, memory, disk, network, database connections
52
+
53
+ **Example metrics:**
54
+ ```
55
+ CPU:
56
+ Utilization: cpu_usage_percent
57
+ Saturation: load_average, runnable_processes
58
+ Errors: hardware_errors (rare)
59
+
60
+ Memory:
61
+ Utilization: memory_used_percent
62
+ Saturation: swap_usage, oom_kills
63
+ Errors: memory_errors (rare)
64
+
65
+ Disk:
66
+ Utilization: disk_used_percent
67
+ Saturation: io_queue_depth, io_wait
68
+ Errors: disk_errors
69
+ ```
70
+
71
+ ### Four Golden Signals (Google SRE)
72
+
73
+ ```
74
+ Latency: time to service a request
75
+ Traffic: demand on the system
76
+ Errors: rate of failed requests
77
+ Saturation: how full the service is
78
+ ```
79
+
80
+ **Relationship to RED/USE:**
81
+ - Latency = Duration from RED
82
+ - Traffic = Rate from RED
83
+ - Errors = Errors from both methods
84
+ - Saturation = Saturation from USE
85
+
86
+ ## Distributed Tracing Patterns
87
+
88
+ ### Context Propagation
89
+
90
+ Pass trace context through all service calls:
91
+
92
+ ```
93
+ Trace Context Headers:
94
+ - traceparent: version-trace_id-parent_id-flags
95
+ - tracestate: vendor-specific data
96
+
97
+ Example:
98
+ traceparent: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
99
+ tracestate: congo=t61rcWkgMzE
100
+ ```
101
+
102
+ **Propagation checklist:**
103
+ - HTTP headers (W3C Trace Context standard)
104
+ - Message queue metadata
105
+ - Database query comments
106
+ - Background job context
107
+ - Cross-region calls
108
+
109
+ ### Span Best Practices
110
+
111
+ ```
112
+ Span naming:
113
+ - HTTP: METHOD /path (GET /users/{id})
114
+ - Database: db.operation table (SELECT users)
115
+ - Queue: queue.operation name (PUBLISH orders)
116
+
117
+ Required attributes:
118
+ - service.name
119
+ - operation.name
120
+ - span.kind (server, client, producer, consumer)
121
+
122
+ Optional context:
123
+ - user.id (sanitized)
124
+ - request.id
125
+ - error.message (on failure)
126
+ ```
127
+
128
+ ### Sampling Strategies
129
+
130
+ | Strategy | Description | Use Case |
131
+ |----------|-------------|----------|
132
+ | Head-based | Decide at trace start | High throughput |
133
+ | Tail-based | Decide after trace complete | Error investigation |
134
+ | Rate-limited | Fixed traces per second | Cost control |
135
+ | Priority | Sample important paths more | Critical flows |
136
+
137
+ **Tail-based sampling rules:**
138
+ ```
139
+ Always sample if:
140
+ - Error occurred in any span
141
+ - Latency exceeded threshold
142
+ - Important user or endpoint
143
+ - Random selection (baseline)
144
+ ```
145
+
146
+ ## SLO Implementation Patterns
147
+
148
+ ### SLO Configuration
149
+
150
+ ```
151
+ Service: payment-api
152
+ SLO: 99.9% availability over 30 days
153
+
154
+ SLI specification:
155
+ Numerator: successful requests (2xx, 3xx)
156
+ Denominator: all requests (excluding health checks)
157
+ Measurement: server-side metrics
158
+
159
+ Alert thresholds:
160
+ - 1h window, 2% budget burn: page immediately
161
+ - 6h window, 5% budget burn: page immediately
162
+ - 3d window, 10% budget burn: create ticket
163
+ ```
164
+
165
+ ### Multi-Window, Multi-Burn-Rate Alert Config
166
+
167
+ ```
168
+ # Fast burn alert (catches acute issues)
169
+ alert: SLOFastBurn
170
+ expr: |
171
+ (
172
+ sum(rate(http_request_errors_total[1h]))
173
+ /
174
+ sum(rate(http_requests_total[1h]))
175
+ ) > (14.4 * 0.001)
176
+ AND
177
+ (
178
+ sum(rate(http_request_errors_total[5m]))
179
+ /
180
+ sum(rate(http_requests_total[5m]))
181
+ ) > (14.4 * 0.001)
182
+ severity: critical
183
+
184
+ # Slow burn alert (catches gradual degradation)
185
+ alert: SLOSlowBurn
186
+ expr: |
187
+ (
188
+ sum(rate(http_request_errors_total[6h]))
189
+ /
190
+ sum(rate(http_requests_total[6h]))
191
+ ) > (6 * 0.001)
192
+ AND
193
+ (
194
+ sum(rate(http_request_errors_total[3d]))
195
+ /
196
+ sum(rate(http_requests_total[3d]))
197
+ ) > (1 * 0.001)
198
+ severity: warning
199
+ ```
200
+
201
+ ### Error Budget Calculation
202
+
203
+ ```
204
+ Monthly error budget for 99.9% SLO:
205
+ Budget = (1 - 0.999) * 30 days * 24 hours * 60 minutes
206
+ Budget = 0.001 * 43200 minutes = 43.2 minutes
207
+
208
+ Current consumption:
209
+ Consumed = (bad_minutes / total_minutes) * 100
210
+ Remaining = Budget - Consumed
211
+
212
+ Burn rate:
213
+ Burn rate = (actual_error_rate / error_budget_rate)
214
+ If burn rate > 1: consuming budget faster than allowed
215
+ ```
216
+
217
+ ## Alerting Patterns
218
+
219
+ ### Alert Template
220
+
221
+ ```
222
+ Alert: ServiceErrorRateHigh
223
+ Summary: {{ $labels.service }} error rate above threshold
224
+ Description: |
225
+ Service {{ $labels.service }} is experiencing {{ $value }}% error rate
226
+ over the last 5 minutes. Normal baseline is < 0.1%.
227
+
228
+ Impact: Users may be experiencing failures on {{ $labels.endpoint }}
229
+
230
+ Runbook: https://runbooks.example.com/service-errors
231
+ Dashboard: https://grafana.example.com/d/service-overview
232
+
233
+ Labels:
234
+ severity: critical
235
+ team: platform
236
+
237
+ Annotations:
238
+ dashboard: https://grafana.example.com/d/service-overview
239
+ runbook: https://runbooks.example.com/service-errors
240
+ ```
241
+
242
+ ### Alert Routing
243
+
244
+ ```
245
+ Routes by severity:
246
+ critical:
247
+ - PagerDuty (wake people up)
248
+ - Slack #incidents (visibility)
249
+ warning:
250
+ - Slack #alerts (triage queue)
251
+ - Create ticket (tracking)
252
+ info:
253
+ - Slack #monitoring (awareness)
254
+ - No action required
255
+
256
+ Routes by team:
257
+ team=platform -> platform-oncall
258
+ team=payments -> payments-oncall
259
+ team=frontend -> frontend-oncall
260
+ ```
261
+
262
+ ### Silence and Maintenance Windows
263
+
264
+ ```
265
+ Planned maintenance:
266
+ - Schedule silence before maintenance
267
+ - Include reason and expected duration
268
+ - Notify affected teams
269
+ - Remove silence after completion
270
+
271
+ Incident response:
272
+ - Silence noisy alerts during investigation
273
+ - Document reason for silence
274
+ - Set expiration (max 4 hours)
275
+ - Review silences daily
276
+ ```
277
+
278
+ ## Log Patterns
279
+
280
+ ### Structured Log Format
281
+
282
+ ```json
283
+ {
284
+ "timestamp": "2024-01-15T10:30:00.123Z",
285
+ "level": "ERROR",
286
+ "service": "payment-api",
287
+ "version": "1.2.3",
288
+ "environment": "production",
289
+ "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
290
+ "span_id": "00f067aa0ba902b7",
291
+ "message": "Payment processing failed",
292
+ "error": {
293
+ "type": "PaymentDeclined",
294
+ "message": "Insufficient funds",
295
+ "code": "INSUFFICIENT_FUNDS"
296
+ },
297
+ "context": {
298
+ "user_id": "usr_abc123",
299
+ "request_id": "req_xyz789",
300
+ "amount_cents": 5000,
301
+ "currency": "USD"
302
+ },
303
+ "duration_ms": 234
304
+ }
305
+ ```
306
+
307
+ ### Log Level Guidelines
308
+
309
+ | Level | When to Use | Alertable |
310
+ |-------|-------------|-----------|
311
+ | FATAL | Application cannot continue | Yes |
312
+ | ERROR | Operation failed, user impacted | Yes |
313
+ | WARN | Degraded but functional | Monitor rate |
314
+ | INFO | Significant business events | No |
315
+ | DEBUG | Detailed troubleshooting | No |
316
+
317
+ ### Log Retention Strategy
318
+
319
+ ```
320
+ Retention tiers:
321
+ Hot (searchable): 7 days
322
+ Warm (queryable): 30 days
323
+ Cold (archived): 90 days
324
+ Deleted: after 90 days
325
+
326
+ Exception:
327
+ Security logs: 1 year minimum
328
+ Compliance logs: per regulatory requirement
329
+ Error logs: 30 days hot
330
+ ```
331
+
332
+ ## Dashboard Patterns
333
+
334
+ ### Service Overview Dashboard
335
+
336
+ ```
337
+ Row 1: Key SLOs
338
+ - Availability SLO gauge (current vs target)
339
+ - Error budget remaining gauge
340
+ - SLO trend over time
341
+
342
+ Row 2: Traffic and Errors
343
+ - Request rate graph
344
+ - Error rate graph (by type)
345
+ - Success/failure ratio
346
+
347
+ Row 3: Latency
348
+ - p50, p95, p99 latency over time
349
+ - Latency distribution histogram
350
+ - Slow endpoints table
351
+
352
+ Row 4: Dependencies
353
+ - Downstream service health
354
+ - Database connection pool
355
+ - Cache hit rate
356
+ ```
357
+
358
+ ### Incident Investigation Dashboard
359
+
360
+ ```
361
+ Row 1: Timeline
362
+ - Events overlay (deploys, alerts, incidents)
363
+ - Error rate spike correlation
364
+ - Change log entries
365
+
366
+ Row 2: Deep Dive
367
+ - Error breakdown by type
368
+ - Affected endpoints
369
+ - Affected users (count, not identifiable)
370
+
371
+ Row 3: Resources
372
+ - CPU, memory, disk usage
373
+ - Pod/instance health
374
+ - Network I/O
375
+
376
+ Row 4: Traces
377
+ - Slow trace examples
378
+ - Error trace examples
379
+ - Trace search link
380
+ ```
381
+
382
+ ## Synthetic Monitoring Patterns
383
+
384
+ ### Availability Checks
385
+
386
+ ```
387
+ Check types:
388
+ - HTTP endpoint availability
389
+ - SSL certificate expiration
390
+ - DNS resolution
391
+ - TCP port connectivity
392
+
393
+ Configuration:
394
+ Frequency: 1 minute
395
+ Locations: multiple regions
396
+ Timeout: 10 seconds
397
+ Retries: 1 before alerting
398
+ ```
399
+
400
+ ### User Journey Checks
401
+
402
+ ```
403
+ Critical paths to monitor:
404
+ - Login flow
405
+ - Checkout process
406
+ - Core API operations
407
+ - Key user workflows
408
+
409
+ Implementation:
410
+ - Headless browser for UI
411
+ - API calls for backend
412
+ - Assert on response content
413
+ - Measure each step timing
414
+ ```
415
+
416
+ ## Incident Response Patterns
417
+
418
+ ### Severity Levels
419
+
420
+ | Level | Impact | Response | Example |
421
+ |-------|--------|----------|---------|
422
+ | SEV1 | Complete outage | All hands, exec notification | Site down |
423
+ | SEV2 | Significant degradation | On-call + backup | 50% errors |
424
+ | SEV3 | Minor impact | On-call investigation | Slow responses |
425
+ | SEV4 | No user impact | Next business day | Warning alerts |
426
+
427
+ ### Postmortem Template
428
+
429
+ ```
430
+ Incident Summary:
431
+ - Duration: Start to resolution
432
+ - Impact: Users/requests affected
433
+ - Root cause: One sentence
434
+
435
+ Timeline:
436
+ - Detection time and method
437
+ - Key investigation steps
438
+ - Resolution actions
439
+
440
+ Root Cause Analysis:
441
+ - What failed and why
442
+ - Contributing factors
443
+ - Why detection took X minutes
444
+
445
+ Action Items:
446
+ - Prevent recurrence (P0)
447
+ - Improve detection (P1)
448
+ - Improve recovery (P2)
449
+
450
+ Lessons Learned:
451
+ - What went well
452
+ - What could improve
453
+ - Follow-up items
454
+ ```
455
+
456
+ ## External Resources
457
+
458
+ - [Google SRE Book - Monitoring](https://sre.google/sre-book/monitoring-distributed-systems/)
459
+ - [OpenTelemetry Specification](https://opentelemetry.io/docs/specs/)
460
+ - [Prometheus Best Practices](https://prometheus.io/docs/practices/)
461
+ - [Datadog Monitoring Guide](https://www.datadoghq.com/blog/monitoring-101-collecting-data/)
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: pattern-detection
3
+ description: "Identify existing codebase patterns (naming conventions, architectural patterns, testing patterns) to maintain consistency."
4
+ license: MIT
5
+ compatibility: opencode
6
+ metadata:
7
+ category: analysis
8
+ version: "1.0"
9
+ ---
10
+
11
+ # Pattern Detection
12
+
13
+ Roleplay as a pattern recognition specialist identifying existing codebase patterns to maintain consistency in all code generation and review.
14
+
15
+ PatternDetection {
16
+ Activation {
17
+ - Before writing new code to ensure consistency with existing patterns
18
+ - During code review to verify alignment with established conventions
19
+ - When onboarding to understand project-specific practices
20
+ - Before refactoring to preserve intentional design decisions
21
+ }
22
+
23
+ Constraints {
24
+ 1. Follow existing patterns even if imperfect - Consistency trumps personal preference
25
+ 2. Document deviations explicitly - When breaking patterns intentionally, explain why
26
+ 3. Pattern changes require migration - Don't introduce new patterns without updating existing code
27
+ 4. Check tests for patterns too - Test code often reveals expected conventions
28
+ 5. Prefer explicit over implicit - When patterns are unclear, ask or document assumptions
29
+ }
30
+
31
+ CoreMethodology {
32
+ PatternDiscoveryProcess {
33
+ 1. Survey representative files: Read 3-5 files of the type you will create or modify
34
+ 2. Identify recurring structures: Note repeated patterns in naming, organization, imports
35
+ 3. Verify intentionality: Check if patterns are documented or consistently applied
36
+ 4. Apply discovered patterns: Use the same conventions in new code
37
+ }
38
+
39
+ PriorityOrderForPatternSources {
40
+ 1. Existing code in the same module/feature - Most authoritative
41
+ 2. Project style guides or CONTRIBUTING.md - Explicit documentation
42
+ 3. Test files - Often reveal expected patterns and naming
43
+ 4. Similar files in adjacent modules - Fallback when no direct examples exist
44
+ }
45
+ }
46
+
47
+ NamingConventionRecognition {
48
+ FileNamingPatterns {
49
+ Detect and follow the project's file naming style:
50
+
51
+ | Pattern | Example | Common In |
52
+ |---------|---------|-----------|
53
+ | kebab-case | `user-profile.ts` | Node.js, Vue, Angular |
54
+ | PascalCase | `UserProfile.tsx` | React components |
55
+ | snake_case | `user_profile.py` | Python |
56
+ | camelCase | `userProfile.js` | Legacy JS, Java |
57
+ }
58
+
59
+ FunctionMethodNaming {
60
+ Identify the project's verb conventions:
61
+ - **get** vs **fetch** vs **retrieve** for data access
62
+ - **create** vs **add** vs **new** for creation
63
+ - **update** vs **set** vs **modify** for mutations
64
+ - **delete** vs **remove** vs **destroy** for deletion
65
+ - **is/has/can/should** prefixes for booleans
66
+ }
67
+
68
+ VariableNaming {
69
+ Detect pluralization and specificity patterns:
70
+ - Singular vs plural for collections (`user` vs `users` vs `userList`)
71
+ - Hungarian notation presence (`strName`, `iCount`)
72
+ - Private member indicators (`_private`, `#private`, `mPrivate`)
73
+ }
74
+ }
75
+
76
+ ArchitecturalPatternRecognition {
77
+ LayerIdentification {
78
+ Recognize how the codebase separates concerns:
79
+
80
+ ```
81
+ COMMON LAYERING PATTERNS:
82
+ - MVC: controllers/, models/, views/
83
+ - Clean Architecture: domain/, application/, infrastructure/
84
+ - Hexagonal: core/, adapters/, ports/
85
+ - Feature-based: features/auth/, features/billing/
86
+ - Type-based: components/, services/, utils/
87
+ ```
88
+ }
89
+
90
+ DependencyDirection {
91
+ Identify import patterns that reveal architecture:
92
+ - Which modules import from which (dependency flow)
93
+ - Shared vs feature-specific code boundaries
94
+ - Framework code vs application code separation
95
+ }
96
+
97
+ StateManagementPatterns {
98
+ Recognize how state flows through the application:
99
+ - Global stores (Redux, Vuex, MobX patterns)
100
+ - React Context usage patterns
101
+ - Service layer patterns for backend state
102
+ - Event-driven vs request-response patterns
103
+ }
104
+ }
105
+
106
+ TestingPatternRecognition {
107
+ TestOrganization {
108
+ Identify how tests are structured:
109
+
110
+ | Pattern | Structure | Example |
111
+ |---------|-----------|---------|
112
+ | Co-located | `src/user.ts`, `src/user.test.ts` | Common in modern JS/TS |
113
+ | Mirror tree | `src/user.ts`, `tests/src/user.test.ts` | Traditional, Java-style |
114
+ | Feature-based | `src/user/`, `src/user/__tests__/` | React, organized features |
115
+ }
116
+
117
+ TestNamingConventions {
118
+ Detect the project's test description style:
119
+ - **BDD style**: `it('should return user when found')`
120
+ - **Descriptive**: `test('getUser returns user when id exists')`
121
+ - **Function-focused**: `test_get_user_returns_user_when_found`
122
+ }
123
+
124
+ TestStructurePatterns {
125
+ Recognize Arrange-Act-Assert or Given-When-Then patterns:
126
+ - Setup block conventions (beforeEach, fixtures, factories)
127
+ - Assertion style (expect vs assert vs should)
128
+ - Mock/stub patterns (jest.mock vs sinon vs manual)
129
+ }
130
+ }
131
+
132
+ CodeOrganizationPatterns {
133
+ ImportOrganization {
134
+ Identify import ordering and grouping:
135
+
136
+ ```
137
+ COMMON IMPORT PATTERNS:
138
+ 1. External packages first, internal modules second
139
+ 2. Grouped by type (React, libraries, local)
140
+ 3. Alphabetized within groups
141
+ 4. Absolute imports vs relative imports preference
142
+ ```
143
+ }
144
+
145
+ ExportPatterns {
146
+ Recognize module boundary conventions:
147
+ - Default exports vs named exports preference
148
+ - Barrel files (index.ts re-exports) presence
149
+ - Public API definition patterns
150
+ }
151
+
152
+ CommentAndDocumentationPatterns {
153
+ Identify documentation conventions:
154
+ - JSDoc/TSDoc presence and style
155
+ - Inline comment frequency and style
156
+ - README conventions per module/feature
157
+ }
158
+ }
159
+
160
+ AntiPatternsToAvoid {
161
+ - Mixing naming conventions in the same codebase
162
+ - Introducing new architectural patterns without team consensus
163
+ - Assuming patterns from other projects apply here
164
+ - Ignoring test patterns when writing implementation
165
+ - Creating "special" files that don't follow established structure
166
+ }
167
+ }
168
+
169
+ ## References
170
+
171
+ - [common-patterns.md](examples/common-patterns.md) - Concrete examples of pattern recognition in action