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,450 @@
1
+ # Code Review Reference
2
+
3
+ Detailed checklists, classification matrices, and agent prompts for the code review skill.
4
+
5
+ ---
6
+
7
+ ## Review Checklists
8
+
9
+ ### Security Review Checklist
10
+
11
+ **Authentication & Authorization:**
12
+ - [ ] Proper auth checks before sensitive operations
13
+ - [ ] No privilege escalation vulnerabilities
14
+ - [ ] Session management is secure
15
+
16
+ **Injection Prevention:**
17
+ - [ ] SQL queries use parameterized statements
18
+ - [ ] XSS prevention (output encoding)
19
+ - [ ] Command injection prevention (input validation)
20
+
21
+ **Data Protection:**
22
+ - [ ] No hardcoded secrets or credentials
23
+ - [ ] Sensitive data properly encrypted
24
+ - [ ] PII handled according to policy
25
+
26
+ **Input Validation:**
27
+ - [ ] All user inputs validated
28
+ - [ ] Proper sanitization before use
29
+ - [ ] Safe deserialization practices
30
+
31
+ ### Performance Review Checklist
32
+
33
+ **Database Operations:**
34
+ - [ ] No N+1 query patterns
35
+ - [ ] Efficient use of indexes
36
+ - [ ] Proper pagination for large datasets
37
+ - [ ] Connection pooling in place
38
+
39
+ **Computation:**
40
+ - [ ] Efficient algorithms (no O(n^2) when O(n) possible)
41
+ - [ ] Proper caching for expensive operations
42
+ - [ ] No unnecessary recomputations
43
+
44
+ **Resource Management:**
45
+ - [ ] No memory leaks
46
+ - [ ] Proper cleanup of resources
47
+ - [ ] Async operations where appropriate
48
+ - [ ] No blocking operations in event loops
49
+
50
+ ### Quality Review Checklist
51
+
52
+ **Code Structure:**
53
+ - [ ] Single responsibility principle
54
+ - [ ] Functions are focused (< 20 lines ideal)
55
+ - [ ] No deep nesting (< 4 levels)
56
+ - [ ] DRY - no duplicated logic
57
+
58
+ **Naming & Clarity:**
59
+ - [ ] Intention-revealing names
60
+ - [ ] Consistent terminology
61
+ - [ ] Self-documenting code
62
+ - [ ] Comments explain "why", not "what"
63
+
64
+ **Error Handling:**
65
+ - [ ] Errors handled at appropriate level
66
+ - [ ] Specific error messages
67
+ - [ ] No swallowed exceptions
68
+ - [ ] Proper error propagation
69
+
70
+ **Project Standards:**
71
+ - [ ] Follows coding conventions
72
+ - [ ] Consistent with existing patterns
73
+ - [ ] Proper file organization
74
+ - [ ] Type safety (if applicable)
75
+
76
+ ### Test Coverage Checklist
77
+
78
+ **Coverage:**
79
+ - [ ] Happy path tested
80
+ - [ ] Error cases tested
81
+ - [ ] Edge cases tested
82
+ - [ ] Boundary conditions tested
83
+
84
+ **Test Quality:**
85
+ - [ ] Tests are independent
86
+ - [ ] Tests are deterministic (not flaky)
87
+ - [ ] Proper assertions (not just "no error")
88
+ - [ ] Mocking at appropriate boundaries
89
+
90
+ **Test Organization:**
91
+ - [ ] Tests match code structure
92
+ - [ ] Clear test names
93
+ - [ ] Proper setup/teardown
94
+ - [ ] Integration tests where needed
95
+
96
+ ---
97
+
98
+ ## Severity & Confidence Classification
99
+
100
+ ### Severity Levels
101
+
102
+ | Level | Definition | Action |
103
+ |-------|------------|--------|
104
+ | **CRITICAL** | Security vulnerability, data loss risk, or system crash | **Must fix before merge** |
105
+ | **HIGH** | Significant bug, performance issue, or breaking change | **Should fix before merge** |
106
+ | **MEDIUM** | Code quality issue, maintainability concern, or missing test | **Consider fixing** |
107
+ | **LOW** | Style preference, minor improvement, or suggestion | **Nice to have** |
108
+
109
+ ### Confidence Levels
110
+
111
+ | Level | Definition | Usage |
112
+ |-------|------------|-------|
113
+ | **HIGH** | Clear violation of established pattern or security rule | Present as definite issue |
114
+ | **MEDIUM** | Likely issue but context-dependent | Present as probable concern |
115
+ | **LOW** | Potential improvement, may not be applicable | Present as suggestion |
116
+
117
+ ### Classification Matrix
118
+
119
+ | Finding Type | Severity | Confidence | Priority |
120
+ |--------------|----------|------------|----------|
121
+ | SQL Injection | CRITICAL | HIGH | Immediate |
122
+ | XSS Vulnerability | CRITICAL | HIGH | Immediate |
123
+ | Hardcoded Secret | CRITICAL | HIGH | Immediate |
124
+ | N+1 Query | HIGH | HIGH | Before merge |
125
+ | Missing Auth Check | CRITICAL | MEDIUM | Before merge |
126
+ | No Input Validation | MEDIUM | HIGH | Should fix |
127
+ | Long Function | LOW | HIGH | Nice to have |
128
+ | Missing Test | MEDIUM | MEDIUM | Should fix |
129
+
130
+ ---
131
+
132
+ ## Agent Prompt Templates
133
+
134
+ ### Security Reviewer
135
+
136
+ ```
137
+ FOCUS: Security review of the provided code changes
138
+ - Identify authentication/authorization issues
139
+ - Check for injection vulnerabilities (SQL, XSS, command, LDAP)
140
+ - Look for hardcoded secrets or credentials
141
+ - Verify input validation and sanitization
142
+ - Check for insecure data handling (encryption, PII)
143
+ - Review session management
144
+ - Check for CSRF vulnerabilities in forms
145
+
146
+ EXCLUDE: Performance optimization, code style, or architectural patterns
147
+
148
+ CONTEXT:
149
+ - Files changed: [list]
150
+ - Changes: [the diff or code]
151
+ - Full file context: [surrounding code]
152
+
153
+ OUTPUT: Security findings in this format:
154
+ FINDING:
155
+ - severity: CRITICAL | HIGH | MEDIUM | LOW
156
+ - confidence: HIGH | MEDIUM | LOW
157
+ - title: Brief title (max 40 chars)
158
+ - location: file:line
159
+ - issue: One sentence describing what's wrong
160
+ - fix: Actionable recommendation
161
+ - code_example: (Optional, for CRITICAL/HIGH)
162
+
163
+ SUCCESS: All security concerns identified with remediation steps
164
+ TERMINATION: Analysis complete OR code context insufficient
165
+ ```
166
+
167
+ ### Performance Reviewer
168
+
169
+ ```
170
+ FOCUS: Performance review of the provided code changes
171
+ - Identify N+1 query patterns
172
+ - Check for unnecessary re-renders or recomputations
173
+ - Look for blocking operations in async code
174
+ - Identify memory leaks or resource cleanup issues
175
+ - Check algorithm complexity (avoid O(n^2) when O(n) possible)
176
+ - Review caching opportunities
177
+ - Check for proper pagination
178
+
179
+ EXCLUDE: Security vulnerabilities, code style, or naming conventions
180
+
181
+ CONTEXT:
182
+ - Files changed: [list]
183
+ - Changes: [the diff or code]
184
+ - Full file context: [surrounding code]
185
+
186
+ OUTPUT: Performance findings in this format:
187
+ FINDING:
188
+ - severity: CRITICAL | HIGH | MEDIUM | LOW
189
+ - confidence: HIGH | MEDIUM | LOW
190
+ - title: Brief title (max 40 chars)
191
+ - location: file:line
192
+ - issue: One sentence describing what's wrong
193
+ - fix: Optimization strategy
194
+
195
+ SUCCESS: All performance concerns identified with optimization strategies
196
+ TERMINATION: Analysis complete OR code context insufficient
197
+ ```
198
+
199
+ ### Quality Reviewer
200
+
201
+ ```
202
+ FOCUS: Code quality review of the provided code changes
203
+ - Check adherence to project coding standards
204
+ - Identify code smells (long methods, duplication, complexity)
205
+ - Verify proper error handling
206
+ - Check naming conventions and code clarity
207
+ - Identify missing or inadequate documentation
208
+ - Verify consistent patterns with existing codebase
209
+ - Check for proper abstractions
210
+
211
+ EXCLUDE: Security vulnerabilities or performance optimization
212
+
213
+ CONTEXT:
214
+ - Files changed: [list]
215
+ - Changes: [the diff or code]
216
+ - Full file context: [surrounding code]
217
+ - Project standards: [from CLAUDE.md, .editorconfig]
218
+
219
+ OUTPUT: Quality findings in this format:
220
+ FINDING:
221
+ - severity: CRITICAL | HIGH | MEDIUM | LOW
222
+ - confidence: HIGH | MEDIUM | LOW
223
+ - title: Brief title (max 40 chars)
224
+ - location: file:line
225
+ - issue: One sentence describing what's wrong
226
+ - fix: Improvement suggestion
227
+
228
+ SUCCESS: All quality concerns identified with clear improvements
229
+ TERMINATION: Analysis complete OR code context insufficient
230
+ ```
231
+
232
+ ### Test Coverage Reviewer
233
+
234
+ ```
235
+ FOCUS: Test coverage review of the provided code changes
236
+ - Identify new code paths that need tests
237
+ - Check if existing tests cover the changes
238
+ - Look for test quality issues (flaky, incomplete assertions)
239
+ - Verify edge cases are covered
240
+ - Check for proper mocking at boundaries
241
+ - Identify integration test needs
242
+ - Verify test naming and organization
243
+
244
+ EXCLUDE: Implementation details not related to testing
245
+
246
+ CONTEXT:
247
+ - Files changed: [list]
248
+ - Changes: [the diff or code]
249
+ - Full file context: [surrounding code]
250
+ - Related test files: [existing tests]
251
+
252
+ OUTPUT: Test coverage findings in this format:
253
+ FINDING:
254
+ - severity: CRITICAL | HIGH | MEDIUM | LOW
255
+ - confidence: HIGH | MEDIUM | LOW
256
+ - title: Brief title (max 40 chars)
257
+ - location: file:line
258
+ - issue: One sentence describing what's wrong
259
+ - fix: Suggested test case with code example
260
+
261
+ SUCCESS: All testing gaps identified with specific test recommendations
262
+ TERMINATION: Analysis complete OR code context insufficient
263
+ ```
264
+
265
+ ### Simplification Reviewer
266
+
267
+ ```
268
+ FOCUS: Complexity review - aggressively challenge unnecessary complexity
269
+ - Identify YAGNI violations (You Aren't Gonna Need It)
270
+ - Find over-engineered solutions
271
+ - Spot premature abstractions
272
+ - Look for dead code paths
273
+ - Challenge "clever" code that should be obvious
274
+ - Find unnecessary indirection
275
+ - Identify code that could be deleted
276
+
277
+ EXCLUDE: Security vulnerabilities or performance optimization
278
+
279
+ CONTEXT:
280
+ - Files changed: [list]
281
+ - Changes: [the diff or code]
282
+ - Full file context: [surrounding code]
283
+
284
+ OUTPUT: Simplification findings in this format:
285
+ FINDING:
286
+ - severity: CRITICAL | HIGH | MEDIUM | LOW
287
+ - confidence: HIGH | MEDIUM | LOW
288
+ - title: Brief title (max 40 chars)
289
+ - location: file:line
290
+ - issue: Why this is more complex than needed
291
+ - fix: Simpler alternative
292
+
293
+ SUCCESS: All complexity issues identified with simpler alternatives
294
+ TERMINATION: Analysis complete OR code context insufficient
295
+ ```
296
+
297
+ ---
298
+
299
+ ## Synthesis Protocol
300
+
301
+ ### Deduplication Algorithm
302
+
303
+ #### Algorithm Steps
304
+
305
+ ```
306
+ deduplicate(findings: Finding[]) -> Finding[] {
307
+ findings
308
+ |> groupBy(f => f.location) // Step 1: Group
309
+ |> merge(group => { // Step 2: Merge
310
+ severity: max(group.severities),
311
+ descriptions: combine(group.descriptions),
312
+ perspectives: union(group.perspectives)
313
+ })
314
+ |> sortBy(severity DESC, confidence DESC, filePath ASC) // Step 3: Sort
315
+ |> assignIds(prefix: severity letter, start: 1) // Step 4: Assign IDs
316
+ }
317
+ ```
318
+
319
+ #### Step 1: Group by Location
320
+
321
+ Group findings by `location` field. Two findings overlap if their file:line ranges are within **5 lines** of each other.
322
+
323
+ | Finding A Location | Finding B Location | Overlap? |
324
+ |---|---|---|
325
+ | `auth/service.ts:42` | `auth/service.ts:44` | Yes (2 lines apart) |
326
+ | `auth/service.ts:42` | `auth/service.ts:48` | No (6 lines apart) |
327
+ | `auth/service.ts:42-50` | `auth/service.ts:47` | Yes (within range) |
328
+ | `auth/service.ts:42` | `api/routes.ts:42` | No (different files) |
329
+
330
+ #### Step 2: Merge Overlapping Findings
331
+
332
+ For each group of overlapping findings, produce a single merged finding:
333
+
334
+ | Field | Merge Rule |
335
+ |-------|-----------|
336
+ | severity | `max()` -- keep the highest severity from any finding in the group |
337
+ | confidence | `max()` -- keep the highest confidence |
338
+ | title | Use the title from the highest-severity finding |
339
+ | location | Use the most specific location (narrowest line range) |
340
+ | finding | Combine descriptions from all perspectives, labeled by perspective |
341
+ | recommendation | Use the most actionable recommendation; append complementary recommendations from other perspectives |
342
+ | diff | Keep the most complete diff; prefer diffs from the highest-severity finding |
343
+ | principle | Union of all principles cited |
344
+ | perspectives | List all perspectives that flagged this location |
345
+
346
+ **Conflict Resolution**: When two findings in the same group have equal severity but different recommendations:
347
+ - If recommendations are complementary (address different aspects), combine them
348
+ - If recommendations conflict (suggest opposite approaches), keep the one from the more specialized perspective (e.g., Security > Quality for auth-related code)
349
+
350
+ #### Step 3: Sort
351
+
352
+ Sort merged findings by:
353
+ 1. Severity: CRITICAL > HIGH > MEDIUM > LOW
354
+ 2. Confidence: HIGH > MEDIUM > LOW (tiebreaker)
355
+ 3. File path: Alphabetical ASC (secondary tiebreaker)
356
+
357
+ #### Step 4: Assign IDs
358
+
359
+ Assign sequential IDs using severity-letter prefix:
360
+ - CRITICAL findings: C1, C2, C3, ...
361
+ - HIGH findings: H1, H2, H3, ...
362
+ - MEDIUM findings: M1, M2, M3, ...
363
+ - LOW findings: L1, L2, L3, ...
364
+
365
+ #### Merged Finding Example
366
+
367
+ ```
368
+ Before dedup:
369
+ Finding A (Security): severity=CRITICAL, location=src/api/search.ts:34, "SQL injection risk"
370
+ Finding B (Performance): severity=HIGH, location=src/api/search.ts:35, "Unvalidated input causes DoS"
371
+
372
+ After dedup:
373
+ Finding C1: severity=CRITICAL, location=src/api/search.ts:34-35
374
+ perspectives: [Security, Performance]
375
+ finding:
376
+ - Security: SQL injection risk via unescaped user input
377
+ - Performance: Unvalidated input could trigger expensive queries (DoS)
378
+ recommendation: Add input validation and use parameterized queries
379
+ principle: OWASP Injection Prevention
380
+ ```
381
+
382
+ ### Grouping
383
+
384
+ Group findings for readability:
385
+ 1. **By Severity** (Critical -> Low) - default
386
+ 2. **By File** (for file-focused reviews)
387
+ 3. **By Category** (for category-focused reports)
388
+
389
+ ---
390
+
391
+ ## Example Findings
392
+
393
+ ### Critical Security Finding
394
+
395
+ ```
396
+ [Security] **SQL Injection Vulnerability** (CRITICAL)
397
+ Location: `src/api/users.ts:45`
398
+ Confidence: HIGH
399
+ Issue: User input directly interpolated into SQL query
400
+ Fix: Use parameterized queries
401
+
402
+ - const result = db.query(`SELECT * FROM users WHERE id = ${req.params.id}`)
403
+ + const result = db.query('SELECT * FROM users WHERE id = $1', [req.params.id])
404
+ ```
405
+
406
+ ### High Performance Finding
407
+
408
+ ```
409
+ [Performance] **N+1 Query Pattern** (HIGH)
410
+ Location: `src/services/orders.ts:78-85`
411
+ Confidence: HIGH
412
+ Issue: Each order fetches its items in a separate query
413
+ Fix: Use eager loading or batch fetch
414
+
415
+ - const orders = await Order.findAll()
416
+ - for (const order of orders) {
417
+ - order.items = await OrderItem.findByOrderId(order.id)
418
+ - }
419
+ + const orders = await Order.findAll({ include: [OrderItem] })
420
+ ```
421
+
422
+ ### Medium Quality Finding
423
+
424
+ ```
425
+ [Quality] **Function Exceeds Recommended Length** (MEDIUM)
426
+ Location: `src/utils/validator.ts:23-89`
427
+ Confidence: HIGH
428
+ Issue: Function is 66 lines, exceeding 20-line recommendation
429
+ Fix: Extract validation logic into separate focused functions
430
+
431
+ Suggested breakdown:
432
+ - validateEmail() - lines 25-40
433
+ - validatePhone() - lines 42-55
434
+ - validateAddress() - lines 57-85
435
+ ```
436
+
437
+ ### Low Suggestion
438
+
439
+ ```
440
+ [Testing] **Edge Case Not Tested** (LOW)
441
+ Location: `src/utils/date.ts:12` (formatDate function)
442
+ Confidence: MEDIUM
443
+ Issue: No test for invalid date input
444
+ Fix: Add test case for null/undefined/invalid dates
445
+
446
+ it('should handle invalid date input', () => {
447
+ expect(formatDate(null)).toBe('')
448
+ expect(formatDate('invalid')).toBe('')
449
+ })
450
+ ```
@@ -0,0 +1,139 @@
1
+ ---
2
+ name: codebase-analysis
3
+ description: "Provides methodology for discovering and documenting business rules, technical patterns, and system interfaces through iterative analysis cycles with multiple perspectives"
4
+ license: MIT
5
+ compatibility: opencode
6
+ metadata:
7
+ category: analysis
8
+ version: "1.0"
9
+ ---
10
+
11
+ # Codebase Analysis
12
+
13
+ Roleplay as an analysis orchestrator that discovers and documents business rules, technical patterns, and system interfaces.
14
+
15
+ CodebaseAnalysis {
16
+ Activation {
17
+ Discovering business rules, domain logic, workflows
18
+ Mapping technical architecture and patterns
19
+ Identifying security models and auth flows
20
+ Finding performance optimization opportunities
21
+ Understanding external integrations and APIs
22
+ }
23
+
24
+ Constraints {
25
+ 1. Launch parallel agents for comprehensive analysis
26
+ 2. Select perspectives based on focus area
27
+ 3. Present ALL agent findings completely - never summarize
28
+ 4. Wait for user confirmation between cycles
29
+ 5. Persist findings to appropriate docs/ locations
30
+ }
31
+
32
+ OutputLocations {
33
+ Findings persisted based on content type:
34
+ - `docs/domain/` -- Business rules, domain logic, workflows
35
+ - `docs/patterns/` -- Technical patterns, architectural solutions
36
+ - `docs/interfaces/` -- API contracts, service integrations
37
+ - `docs/research/` -- General research findings, exploration notes
38
+ }
39
+
40
+ AnalysisPerspectives {
41
+ | Perspective | Intent | What to Discover |
42
+ |-------------|--------|------------------|
43
+ | **Business** | Understand domain logic | Business rules, validation logic, workflows, state machines, domain entities |
44
+ | **Technical** | Map architecture | Design patterns, conventions, module structure, dependency patterns |
45
+ | **Security** | Identify security model | Auth flows, authorization rules, data protection, input validation |
46
+ | **Performance** | Find optimization opportunities | Bottlenecks, caching patterns, query patterns, resource usage |
47
+ | **Integration** | Map external boundaries | External APIs, webhooks, data flows, third-party services |
48
+ }
49
+
50
+ FocusAreaMapping {
51
+ Evaluate top-to-bottom. First match wins.
52
+
53
+ | IF input matches | THEN launch |
54
+ |---|---|
55
+ | "business" or "domain" | Business perspective |
56
+ | "technical" or "architecture" | Technical perspective |
57
+ | "security" | Security perspective |
58
+ | "performance" | Performance perspective |
59
+ | "integration" or "api" | Integration perspective |
60
+ | Empty or broad request | All relevant perspectives |
61
+ }
62
+
63
+ IterativeDiscoveryCycles {
64
+ ForEachCycle {
65
+ Step1_Discovery {
66
+ Launch specialist agents for applicable perspectives.
67
+
68
+ For each perspective, describe the analysis intent:
69
+
70
+ ```
71
+ Analyze codebase for [PERSPECTIVE]:
72
+
73
+ CONTEXT:
74
+ - Target: [code area to analyze]
75
+ - Scope: [module/feature boundaries]
76
+ - Existing docs: [relevant documentation]
77
+
78
+ FOCUS: [What this perspective discovers - from table above]
79
+
80
+ OUTPUT: Findings formatted as:
81
+ **[Category]**
82
+ Discovery: [What was found]
83
+ Evidence: `file:line` references
84
+ Documentation: [Suggested doc content]
85
+ Location: [Where to persist: docs/domain/, docs/patterns/, docs/interfaces/]
86
+ ```
87
+ }
88
+
89
+ Step2_Synthesize {
90
+ Collect findings
91
+ Deduplicate overlapping discoveries
92
+ Group by output location
93
+ }
94
+
95
+ CycleSelfCheck {
96
+ Ask yourself each cycle:
97
+ 1. Have I identified ALL activities needed for this area?
98
+ 2. Have I launched parallel specialist agents to investigate?
99
+ 3. Have I updated documentation according to category rules?
100
+ 4. Have I presented COMPLETE agent responses (not summaries)?
101
+ 5. Have I received user confirmation before next cycle?
102
+ 6. Are there more areas that need investigation?
103
+ 7. Should I continue or wait for user input?
104
+ }
105
+
106
+ Step3_Review {
107
+ Present ALL agent findings (complete responses)
108
+ Wait for user confirmation
109
+ }
110
+
111
+ Step4_Persist {
112
+ Optional: Ask if user wants to save to appropriate docs/ location
113
+ See OutputLocations for paths
114
+ }
115
+ }
116
+ }
117
+
118
+ AnalysisSummaryFormat {
119
+ ```
120
+ ## Analysis: [area]
121
+
122
+ ### Discoveries
123
+
124
+ **[Category]**
125
+ - [pattern/rule name] - [description]
126
+ - Evidence: [file:line references]
127
+
128
+ ### Documentation
129
+
130
+ - [docs/path/file.md] - [what was documented]
131
+
132
+ ### Open Questions
133
+
134
+ - [unresolved items for future investigation]
135
+ ```
136
+
137
+ Offer documentation options: Save to docs/, Skip, or Export as markdown.
138
+ }
139
+ }