hatch3r 1.3.0 → 1.5.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 (175) hide show
  1. package/README.md +12 -7
  2. package/agents/hatch3r-a11y-auditor.md +18 -11
  3. package/agents/hatch3r-architect.md +27 -12
  4. package/agents/hatch3r-ci-watcher.md +30 -9
  5. package/agents/hatch3r-context-rules.md +18 -8
  6. package/agents/hatch3r-dependency-auditor.md +30 -15
  7. package/agents/hatch3r-devops.md +18 -13
  8. package/agents/hatch3r-docs-writer.md +33 -12
  9. package/agents/hatch3r-fixer.md +46 -9
  10. package/agents/hatch3r-implementer.md +21 -9
  11. package/agents/hatch3r-learnings-loader.md +24 -7
  12. package/agents/hatch3r-lint-fixer.md +18 -9
  13. package/agents/hatch3r-perf-profiler.md +26 -10
  14. package/agents/hatch3r-researcher.md +57 -919
  15. package/agents/hatch3r-reviewer.md +29 -10
  16. package/agents/hatch3r-security-auditor.md +25 -10
  17. package/agents/hatch3r-test-writer.md +29 -9
  18. package/agents/modes/architecture.md +1 -0
  19. package/agents/modes/boundary-analysis.md +2 -1
  20. package/agents/modes/codebase-impact.md +1 -0
  21. package/agents/modes/complexity-risk.md +1 -0
  22. package/agents/modes/coverage-analysis.md +1 -0
  23. package/agents/modes/current-state.md +1 -0
  24. package/agents/modes/feature-design.md +1 -0
  25. package/agents/modes/impact-analysis.md +1 -0
  26. package/agents/modes/library-docs.md +2 -1
  27. package/agents/modes/migration-path.md +1 -0
  28. package/agents/modes/prior-art.md +1 -0
  29. package/agents/modes/refactoring-strategy.md +1 -0
  30. package/agents/modes/regression.md +1 -0
  31. package/agents/modes/requirements-elicitation.md +1 -0
  32. package/agents/modes/risk-assessment.md +1 -0
  33. package/agents/modes/risk-prioritization.md +1 -0
  34. package/agents/modes/root-cause.md +1 -0
  35. package/agents/modes/similar-implementation.md +2 -1
  36. package/agents/modes/symptom-trace.md +1 -0
  37. package/agents/modes/test-pattern.md +2 -1
  38. package/agents/shared/external-knowledge.md +31 -0
  39. package/agents/shared/quality-charter.md +96 -0
  40. package/checks/README.md +1 -0
  41. package/checks/accessibility.md +55 -0
  42. package/commands/board/pickup-azure-devops.md +5 -0
  43. package/commands/board/pickup-delegation-multi.md +9 -1
  44. package/commands/board/pickup-delegation.md +4 -0
  45. package/commands/board/pickup-github.md +5 -0
  46. package/commands/board/pickup-gitlab.md +5 -0
  47. package/commands/board/pickup-modes.md +1 -0
  48. package/commands/board/pickup-post-impl.md +9 -1
  49. package/commands/board/shared-azure-devops.md +14 -3
  50. package/commands/board/shared-board-overview.md +1 -0
  51. package/commands/board/shared-github.md +2 -0
  52. package/commands/board/shared-gitlab.md +10 -2
  53. package/commands/hatch3r-agent-customize.md +6 -1
  54. package/commands/hatch3r-api-spec.md +1 -0
  55. package/commands/hatch3r-benchmark.md +4 -3
  56. package/commands/hatch3r-board-fill.md +52 -9
  57. package/commands/hatch3r-board-groom.md +124 -7
  58. package/commands/hatch3r-board-init.md +7 -3
  59. package/commands/hatch3r-board-pickup.md +1 -0
  60. package/commands/hatch3r-board-refresh.md +1 -0
  61. package/commands/hatch3r-board-shared.md +71 -5
  62. package/commands/hatch3r-bug-plan.md +2 -1
  63. package/commands/hatch3r-codebase-map.md +4 -3
  64. package/commands/hatch3r-command-customize.md +6 -1
  65. package/commands/hatch3r-context-health.md +1 -0
  66. package/commands/hatch3r-cost-tracking.md +1 -0
  67. package/commands/hatch3r-debug.md +4 -3
  68. package/commands/hatch3r-dep-audit.md +3 -0
  69. package/commands/hatch3r-feature-plan.md +3 -2
  70. package/commands/hatch3r-healthcheck.md +1 -0
  71. package/commands/hatch3r-hooks.md +6 -1
  72. package/commands/hatch3r-learn.md +1 -0
  73. package/commands/hatch3r-migration-plan.md +3 -2
  74. package/commands/hatch3r-onboard.md +2 -1
  75. package/commands/hatch3r-project-spec.md +4 -3
  76. package/commands/hatch3r-quick-change.md +31 -3
  77. package/commands/hatch3r-recipe.md +1 -0
  78. package/commands/hatch3r-refactor-plan.md +2 -1
  79. package/commands/hatch3r-release.md +4 -1
  80. package/commands/hatch3r-revision.md +138 -17
  81. package/commands/hatch3r-roadmap.md +5 -4
  82. package/commands/hatch3r-rule-customize.md +5 -0
  83. package/commands/hatch3r-security-audit.md +1 -0
  84. package/commands/hatch3r-skill-customize.md +5 -0
  85. package/commands/hatch3r-test-plan.md +3 -2
  86. package/commands/hatch3r-workflow.md +15 -1
  87. package/dist/cli/index.js +7595 -4548
  88. package/dist/cli/index.js.map +1 -1
  89. package/hooks/hatch3r-ci-failure.md +1 -0
  90. package/hooks/hatch3r-file-save.md +1 -0
  91. package/hooks/hatch3r-post-merge.md +1 -0
  92. package/hooks/hatch3r-pre-commit.md +1 -0
  93. package/hooks/hatch3r-pre-push.md +1 -0
  94. package/hooks/hatch3r-session-start.md +1 -0
  95. package/package.json +30 -12
  96. package/rules/hatch3r-accessibility-standards.md +2 -1
  97. package/rules/hatch3r-accessibility-standards.mdc +1 -1
  98. package/rules/hatch3r-agent-orchestration-detail.md +207 -0
  99. package/rules/hatch3r-agent-orchestration-detail.mdc +202 -0
  100. package/rules/hatch3r-agent-orchestration.md +161 -318
  101. package/rules/hatch3r-agent-orchestration.mdc +212 -154
  102. package/rules/hatch3r-api-design.md +2 -1
  103. package/rules/hatch3r-api-design.mdc +1 -1
  104. package/rules/hatch3r-browser-verification.md +4 -2
  105. package/rules/hatch3r-browser-verification.mdc +1 -0
  106. package/rules/hatch3r-ci-cd.md +2 -1
  107. package/rules/hatch3r-ci-cd.mdc +1 -1
  108. package/rules/hatch3r-code-standards.md +15 -2
  109. package/rules/hatch3r-code-standards.mdc +22 -2
  110. package/rules/hatch3r-component-conventions.md +2 -1
  111. package/rules/hatch3r-component-conventions.mdc +1 -1
  112. package/rules/hatch3r-data-classification.md +2 -1
  113. package/rules/hatch3r-data-classification.mdc +1 -1
  114. package/rules/hatch3r-deep-context.md +26 -1
  115. package/rules/hatch3r-deep-context.mdc +54 -8
  116. package/rules/hatch3r-dependency-management.md +2 -1
  117. package/rules/hatch3r-dependency-management.mdc +17 -5
  118. package/rules/hatch3r-feature-flags.md +2 -0
  119. package/rules/hatch3r-feature-flags.mdc +1 -0
  120. package/rules/hatch3r-git-conventions.md +2 -1
  121. package/rules/hatch3r-git-conventions.mdc +2 -1
  122. package/rules/hatch3r-i18n.md +2 -1
  123. package/rules/hatch3r-i18n.mdc +1 -1
  124. package/rules/hatch3r-learning-consult.md +11 -1
  125. package/rules/hatch3r-learning-consult.mdc +11 -1
  126. package/rules/hatch3r-migrations.md +2 -1
  127. package/rules/hatch3r-migrations.mdc +12 -1
  128. package/rules/hatch3r-observability-logging.md +34 -0
  129. package/rules/hatch3r-observability-logging.mdc +30 -0
  130. package/rules/hatch3r-observability-metrics.md +74 -0
  131. package/rules/hatch3r-observability-metrics.mdc +70 -0
  132. package/rules/hatch3r-observability-tracing-detail.md +160 -0
  133. package/rules/hatch3r-observability-tracing-detail.mdc +63 -0
  134. package/rules/hatch3r-observability-tracing.md +86 -0
  135. package/rules/hatch3r-observability-tracing.mdc +77 -0
  136. package/rules/hatch3r-observability.md +9 -448
  137. package/rules/hatch3r-observability.mdc +7 -159
  138. package/rules/hatch3r-performance-budgets.md +2 -0
  139. package/rules/hatch3r-performance-budgets.mdc +1 -0
  140. package/rules/hatch3r-secrets-management.md +2 -1
  141. package/rules/hatch3r-secrets-management.mdc +1 -1
  142. package/rules/hatch3r-security-patterns.md +3 -2
  143. package/rules/hatch3r-security-patterns.mdc +12 -1
  144. package/rules/hatch3r-testing.md +12 -2
  145. package/rules/hatch3r-testing.mdc +11 -2
  146. package/rules/hatch3r-theming.md +3 -2
  147. package/rules/hatch3r-theming.mdc +1 -1
  148. package/rules/hatch3r-tooling-hierarchy.md +3 -2
  149. package/rules/hatch3r-tooling-hierarchy.mdc +19 -5
  150. package/skills/hatch3r-a11y-audit/SKILL.md +11 -4
  151. package/skills/hatch3r-agent-customize/SKILL.md +5 -72
  152. package/skills/hatch3r-api-spec/SKILL.md +9 -2
  153. package/skills/hatch3r-architecture-review/SKILL.md +7 -0
  154. package/skills/hatch3r-bug-fix/SKILL.md +16 -7
  155. package/skills/hatch3r-ci-pipeline/SKILL.md +8 -1
  156. package/skills/hatch3r-command-customize/SKILL.md +5 -62
  157. package/skills/hatch3r-context-health/SKILL.md +23 -2
  158. package/skills/hatch3r-cost-tracking/SKILL.md +16 -6
  159. package/skills/hatch3r-customize/SKILL.md +124 -0
  160. package/skills/hatch3r-dep-audit/SKILL.md +9 -2
  161. package/skills/hatch3r-feature/SKILL.md +12 -4
  162. package/skills/hatch3r-gh-agentic-workflows/SKILL.md +7 -0
  163. package/skills/hatch3r-incident-response/SKILL.md +7 -0
  164. package/skills/hatch3r-issue-workflow/SKILL.md +8 -1
  165. package/skills/hatch3r-logical-refactor/SKILL.md +8 -1
  166. package/skills/hatch3r-migration/SKILL.md +7 -0
  167. package/skills/hatch3r-perf-audit/SKILL.md +9 -2
  168. package/skills/hatch3r-pr-creation/SKILL.md +8 -1
  169. package/skills/hatch3r-qa-validation/SKILL.md +8 -1
  170. package/skills/hatch3r-recipe/SKILL.md +8 -1
  171. package/skills/hatch3r-refactor/SKILL.md +10 -2
  172. package/skills/hatch3r-release/SKILL.md +8 -1
  173. package/skills/hatch3r-rule-customize/SKILL.md +5 -65
  174. package/skills/hatch3r-skill-customize/SKILL.md +5 -62
  175. package/skills/hatch3r-visual-refactor/SKILL.md +12 -5
@@ -4,6 +4,7 @@ description: Composable context researcher agent. Receives a research brief with
4
4
  model: standard
5
5
  tags: [core, planning]
6
6
  protected: true
7
+ quality_charter: agents/shared/quality-charter.md
7
8
  ---
8
9
  You are a focused context researcher for the project. You receive a research brief and return structured findings.
9
10
 
@@ -47,11 +48,11 @@ If project context was provided by the orchestrator, use it directly — do not
47
48
 
48
49
  ### 3. Execute Requested Modes
49
50
 
50
- For each requested mode, follow the mode's definition from the Research Modes library. Respect the depth level:
51
+ For each requested mode, read its definition from `agents/modes/{mode-name}.md` and follow the output structure defined there. Respect the depth level:
51
52
 
52
53
  - **quick** — scan file headers, grep for patterns, produce concise assessment. Tables have 3-5 rows max. Summaries only, no deep code reading. Target ~2k tokens output per mode.
53
54
  - **standard** — read relevant files, explore multiple sources, produce structured tables. Tables have 5-10 rows. Follow all 4 tiers of the tooling hierarchy. Target ~5k tokens output per mode.
54
- - **deep** — full structured analysis. Produce the complete output structure defined in the mode. No row limits. Follow all 4 tiers exhaustively. Target ~15k tokens output per mode.
55
+ - **deep** — full structured analysis. Produce the complete output structure defined in the mode. No row limits. Follow all 4 tiers without omission. Target ~15k tokens output per mode.
55
56
 
56
57
  ### 4. Return Structured Result
57
58
 
@@ -71,911 +72,47 @@ Report back to the parent orchestrator with results for each requested mode, usi
71
72
 
72
73
  ## Research Modes
73
74
 
74
- ### Mode: `codebase-impact`
75
-
76
- Analyze the current codebase to understand what exists today in the areas the subject touches. Map files, modules, components, integration points, and coupling.
77
-
78
- **Output structure:**
79
-
80
- ```markdown
81
- ## Codebase Impact Analysis
82
-
83
- ### Affected Modules
84
- | Module / Area | Current State | Changes Needed | Coupling Risk |
85
- |---------------|--------------|----------------|---------------|
86
- | {module} | {what exists today} | {what needs to change} | Low/Med/High |
87
-
88
- ### Affected Files
89
- | File Path | Change Type | Description |
90
- |-----------|-------------|-------------|
91
- | {path} | Create/Modify/Extend | {what changes and why} |
92
-
93
- ### Integration Points
94
- | Integration | Current Behavior | Required Change | Breaking? |
95
- |-------------|-----------------|-----------------|-----------|
96
- | {component/API/event} | {current} | {new} | Yes/No |
97
-
98
- ### Patterns in Use
99
- - **{pattern}**: {where used} {implications for this subject}
100
-
101
- ### Transitive Dependency Trace
102
- For each file expected to change, trace importers up to 3 levels deep. This reveals the full blast radius beyond directly modified files.
103
-
104
- | Modified File | Direct Importers (L1) | Transitive Importers (L2) | Deep Importers (L3) |
105
- |--------------|----------------------|--------------------------|-------------------|
106
- | {file path} | {files that import this} | {files that import L1} | {files that import L2} |
107
-
108
- ### API Consumer Map
109
- For each function, class, or interface expected to change, list all call sites across the codebase.
110
-
111
- | Symbol | Type | Call Sites | Contract Change Risk |
112
- |--------|------|-----------|---------------------|
113
- | {function/class/interface name} | Function/Class/Interface/Type | {file:line list of all usages} | High/Med/Low — {why} |
114
-
115
- ### Type Contract Surface
116
- For each modified type or interface, list all consumers and flag potential contract violations.
117
-
118
- | Type / Interface | Consumers | Fields Affected | Breaking Potential |
119
- |-----------------|-----------|----------------|-------------------|
120
- | {type name} | {list of files/modules using this type} | {which fields change} | Yes/No — {what could break} |
121
-
122
- ### Event / Callback Chain
123
- Trace event emitters, listeners, callback registrations, and pub/sub patterns that depend on modified behavior.
124
-
125
- | Event / Callback | Emitter | Listeners / Subscribers | Behavior Change? |
126
- |-----------------|---------|------------------------|-----------------|
127
- | {event name or callback} | {where it's emitted/called} | {where it's consumed} | Yes/No — {what changes} |
128
-
129
- ### Blast Radius Summary
130
- | Category | Count | Risk Level |
131
- |----------|-------|-----------|
132
- | Directly modified files | {N} | — |
133
- | Direct importers (L1) | {N} | High |
134
- | Transitive importers (L2) | {N} | Medium |
135
- | Deep importers (L3) | {N} | Low |
136
- | API consumers with contract risk | {N} | High |
137
- | Type consumers with breaking potential | {N} | High |
138
- | Event/callback chain participants | {N} | Medium |
139
- | **Total files at risk** | **{N}** | — |
140
-
141
- ### Current State Summary
142
- {2-3 paragraphs describing the relevant codebase area, existing conventions, and how the subject fits into the current architecture}
143
- ```
144
-
145
- **Depth scaling for transitive tracing:**
146
- - **quick**: Skip transitive tracing sections entirely. Only produce the standard tables (Affected Modules, Affected Files, Integration Points, Patterns in Use).
147
- - **standard**: Produce Transitive Dependency Trace (L1 only) and Blast Radius Summary. Skip API Consumer Map, Type Contract Surface, and Event/Callback Chain.
148
- - **deep**: Produce all sections — full 3-level trace, API Consumer Map, Type Contract Surface, Event/Callback Chain, and Blast Radius Summary.
149
-
150
- ---
151
-
152
- ### Mode: `feature-design`
153
-
154
- Break the subject down into implementable sub-tasks with user stories, acceptance criteria, edge cases, and effort estimates.
155
-
156
- **Output structure:**
157
-
158
- ```markdown
159
- ## Feature Breakdown
160
-
161
- ### Sub-Tasks
162
- | # | Sub-Task | User Story | Acceptance Criteria | Effort | Dependencies |
163
- |---|----------|-----------|---------------------|--------|--------------|
164
- | 1 | {title} | As a {persona}, I want {goal} so that {benefit} | - [ ] {criterion} | S/M/L/XL | {deps} |
165
-
166
- ### Edge Cases
167
- | # | Scenario | Expected Behavior | Priority |
168
- |---|----------|-------------------|----------|
169
- | 1 | {edge case} | {how the system should handle it} | Must/Should/Nice |
170
-
171
- ### UX Considerations
172
- - **{consideration}**: {recommendation and rationale}
173
-
174
- ### Effort Summary
175
- | Metric | Value |
176
- |--------|-------|
177
- | Total sub-tasks | {N} |
178
- | Estimated total effort | {S/M/L/XL — map to rough days} |
179
- | Parallelizable tasks | {list task numbers that can run concurrently} |
180
- | Critical path | task {N} → task {M} → task {P} |
181
-
182
- ### Suggested Priority
183
- {P0/P1/P2/P3}: {rationale for this priority level}
184
- ```
185
-
186
- ---
187
-
188
- ### Mode: `architecture`
189
-
190
- Design the architectural approach. Identify data model changes, API contracts, component design, and whether existing patterns should be followed or new ones introduced. Flag any decisions that warrant ADRs.
191
-
192
- **Output structure:**
193
-
194
- ```markdown
195
- ## Architecture Design
196
-
197
- ### Data Model Changes
198
- | Entity / Table | Change Type | Fields / Schema | Migration Needed? |
199
- |---------------|-------------|-----------------|-------------------|
200
- | {entity} | Create/Alter/None | {fields or schema changes} | Yes/No |
201
-
202
- ### API / Interface Contracts
203
- | Endpoint / Interface | Method | Input | Output | Notes |
204
- |---------------------|--------|-------|--------|-------|
205
- | {endpoint or interface} | {method} | {shape} | {shape} | {constraints} |
206
-
207
- ### Component Design
208
- | Component | Responsibility | Depends On | New/Existing |
209
- |-----------|---------------|-----------|--------------|
210
- | {name} | {what it does} | {dependencies} | New/Existing |
211
-
212
- ### Pattern Alignment
213
- - **Follows existing:** {patterns from the codebase this should follow}
214
- - **New patterns needed:** {any new patterns introduced, with justification}
215
-
216
- ### Architectural Decisions Requiring ADRs
217
- | # | Decision | Context | Recommended | Alternatives |
218
- |---|----------|---------|-------------|--------------|
219
- | 1 | {title} | {why this decision matters} | {pick} | {alt1}, {alt2} |
220
-
221
- ### Dependency Analysis
222
- | Dependency | Type | Status | Notes |
223
- |-----------|------|--------|-------|
224
- | {what this depends on} | Hard/Soft | Exists/Needs building | {notes} |
225
- ```
226
-
227
- ---
228
-
229
- ### Mode: `risk-assessment`
230
-
231
- Identify risks, security implications, performance concerns, breaking changes, migration needs, and common mistakes.
232
-
233
- **Output structure:**
234
-
235
- ```markdown
236
- ## Risk Assessment
237
-
238
- ### Technical Risks
239
- | # | Risk | Likelihood | Impact | Mitigation |
240
- |---|------|-----------|--------|------------|
241
- | 1 | {risk} | High/Med/Low | High/Med/Low | {strategy} |
242
-
243
- ### Security Implications
244
- | # | Concern | Severity | Mitigation |
245
- |---|---------|----------|------------|
246
- | 1 | {concern} | Critical/High/Med/Low | {strategy} |
247
-
248
- ### Performance Concerns
249
- | # | Concern | When It Matters | Mitigation |
250
- |---|---------|----------------|------------|
251
- | 1 | {concern} | {threshold or condition} | {strategy} |
252
-
253
- ### Breaking Changes
254
- | # | What Breaks | Who Is Affected | Migration Path |
255
- |---|------------|----------------|----------------|
256
- | 1 | {change} | {consumers/users} | {migration strategy} |
257
-
258
- ### Common Mistakes
259
- - **{mistake}**: {why it's tempting} → {what to do instead}
260
-
261
- ### Recommended Safeguards
262
- - {safeguard}: {rationale}
263
- ```
264
-
265
- ---
266
-
267
- ### Mode: `symptom-trace`
268
-
269
- Trace reported symptoms through the codebase. Map the execution path from user action to observed failure. Identify where expected behavior diverges from actual behavior.
270
-
271
- **Output structure:**
272
-
273
- ```markdown
274
- ## Symptom Trace
275
-
276
- ### Execution Path
277
- | # | Step | File / Function | Expected Behavior | Observed / Likely Behavior |
278
- |---|------|----------------|-------------------|---------------------------|
279
- | 1 | {user action or trigger} | {entry point} | {what should happen} | {what likely happens} |
280
- | 2 | {next step in flow} | {file:function} | {expected} | {observed or inferred} |
281
-
282
- ### Divergence Point
283
- - **Where:** {file:function or module where behavior diverges}
284
- - **What:** {description of the divergence}
285
- - **Evidence:** {code patterns, conditions, or state that suggest this is the divergence point}
286
-
287
- ### Error Propagation
288
- | From | To | How | Observable? |
289
- |------|----|-----|-------------|
290
- | {origin} | {downstream} | {mechanism — exception, bad state, silent failure} | Yes/No |
291
-
292
- ### Affected Code Paths
293
- | Path | Entry Point | Risk of Symptom | Notes |
294
- |------|-------------|----------------|-------|
295
- | {flow name} | {file:function} | High/Med/Low | {why this path is affected} |
296
-
297
- ### Data Flow Concerns
298
- - {any data integrity, state management, or concurrency concerns identified during tracing}
299
- ```
300
-
301
- ---
302
-
303
- ### Mode: `root-cause`
304
-
305
- Analyze the codebase for candidate root causes. Use static analysis patterns: off-by-one errors, race conditions, missing null checks, incorrect assumptions, stale caches, wrong operator usage, missing error handling, and anti-patterns. Rank hypotheses by likelihood.
306
-
307
- **Output structure:**
308
-
309
- ```markdown
310
- ## Root Cause Analysis
311
-
312
- ### Hypotheses (Ranked by Likelihood)
313
- | Rank | Hypothesis | Likelihood | Evidence | Files Involved | Verification Strategy |
314
- |------|-----------|-----------|----------|----------------|----------------------|
315
- | 1 | {what might be wrong} | High/Med/Low | {code evidence supporting this} | {file paths} | {how to confirm or rule out} |
316
- | 2 | {alternative cause} | High/Med/Low | {evidence} | {files} | {verification} |
317
-
318
- ### Code Smells in Affected Area
319
- | # | Smell | Location | Relevance to Bug |
320
- |---|-------|----------|-----------------|
321
- | 1 | {pattern — e.g., missing error handling, implicit type coercion} | {file:line} | {how it could cause or mask the bug} |
322
-
323
- ### Dependency Analysis
324
- | Dependency | Version | Known Issues | Relevance |
325
- |-----------|---------|-------------|-----------|
326
- | {library/module} | {version} | {any known bugs or CVEs} | {how it relates to the symptoms} |
327
-
328
- ### Recommended Investigation Order
329
- 1. {hypothesis to test first — highest likelihood + easiest to verify}
330
- 2. {next hypothesis}
331
- 3. {etc.}
332
-
333
- ### Ruling-Out Notes
334
- - {hypotheses already considered unlikely and why}
335
- ```
336
-
337
- ---
338
-
339
- ### Mode: `impact-analysis`
340
-
341
- Map the blast radius. Identify all flows, modules, data, and users affected. Find related issues or symptoms that might share the same cause. Assess data integrity risk and downstream consumers.
342
-
343
- **Output structure:**
344
-
345
- ```markdown
346
- ## Impact Assessment
347
-
348
- ### Affected Flows
349
- | Flow | Impact | Users Affected | Data at Risk? |
350
- |------|--------|---------------|---------------|
351
- | {user flow or system process} | {how it is affected} | {persona or segment} | Yes/No — {details} |
352
-
353
- ### Affected Modules
354
- | Module / Area | How Affected | Severity | Coupling |
355
- |---------------|-------------|----------|----------|
356
- | {module} | {direct failure / degraded / cascading} | Critical/High/Med/Low | Direct/Indirect |
357
-
358
- ### Downstream Consumers
359
- | Consumer | Coupling Type | Impact | Action Needed |
360
- |----------|-------------|--------|--------------|
361
- | {module/service/user} | {direct API / import / event / data} | {none / update needed / rewrite needed} | {what to do} |
362
-
363
- ### Data Integrity Risk
364
- | Data | Risk | Detection | Recovery |
365
- |------|------|-----------|----------|
366
- | {what data is at risk} | {corruption / loss / inconsistency} | {how to detect damage} | {how to recover} |
367
-
368
- ### Related Symptoms
369
- | # | Symptom | Reported? | Likely Same Cause? |
370
- |---|---------|-----------|-------------------|
371
- | 1 | {other observed issue} | Yes (#{issue}) / No | Yes/Likely/Unlikely |
372
-
373
- ### User-Facing Impact
374
- - **Severity:** {Critical/High/Med/Low}
375
- - **Scope:** {how many users, what percentage of traffic}
376
- - **Workaround available:** {yes — describe / no}
377
- ```
378
-
379
- ---
380
-
381
- ### Mode: `regression`
382
-
383
- Investigate when the issue was likely introduced and what changed. Analyze git history, recent dependency updates, configuration changes, and deployment events in the affected area.
384
-
385
- **Output structure:**
386
-
387
- ```markdown
388
- ## Regression Analysis
389
-
390
- ### Timeline
391
- | Date / Period | Change | Author | Files | Potential Link |
392
- |--------------|--------|--------|-------|---------------|
393
- | {date or range} | {commit message or change description} | {who} | {files changed} | High/Med/Low — {reasoning} |
394
-
395
- ### Recent Changes in Affected Area
396
- | File | Last Modified | Change Summary | Suspicious? |
397
- |------|-------------|----------------|-------------|
398
- | {file path} | {date} | {what changed} | Yes/No — {why} |
399
-
400
- ### Dependency Changes
401
- | Dependency | Previous Version | Current Version | Changelog Relevant? |
402
- |-----------|-----------------|----------------|---------------------|
403
- | {package} | {old} | {new} | Yes — {breaking change or bug fix} / No |
404
-
405
- ### Configuration Changes
406
- | Config | Change | When | Impact |
407
- |--------|--------|------|--------|
408
- | {config file or env var} | {what changed} | {when} | {how it could cause the issue} |
409
-
410
- ### Most Likely Introduction Window
411
- - **When:** {date range or commit range}
412
- - **What changed:** {description}
413
- - **Confidence:** High/Med/Low
414
- - **Bisect strategy:** {how to narrow down further if needed}
415
-
416
- ### Previously Working State
417
- - **Last known good:** {version, commit, or date when this worked}
418
- - **Evidence:** {test results, user reports, or deploy logs}
419
- ```
420
-
421
- ---
422
-
423
- ### Mode: `current-state`
424
-
425
- Map the current state of the code being analyzed. Measure complexity, coupling, cohesion, test coverage, and code quality. Identify the specific problems that motivate the change.
426
-
427
- **Dimension-specific focus** (when provided):
428
- - **Structural:** Emphasize coupling, cohesion, module boundaries, dead code
429
- - **Logical:** Emphasize behavior contracts, data flows, state management, business rules
430
- - **Visual:** Emphasize component hierarchy, design token usage, accessibility compliance, responsive patterns
431
- - **Migration:** Emphasize framework/library API surface, adapter boundaries, compatibility layers
432
-
433
- **Output structure:**
434
-
435
- ```markdown
436
- ## Current State Analysis
437
-
438
- ### Module Map
439
- | Module / Component | Files | Lines of Code | Responsibility | Coupling |
440
- |-------------------|-------|---------------|---------------|----------|
441
- | {module} | {count} | {approx} | {what it does} | {what it depends on and what depends on it} |
442
-
443
- ### Complexity Metrics
444
- | File / Function | Complexity Signal | Severity | Notes |
445
- |----------------|------------------|----------|-------|
446
- | {file:function} | {high cyclomatic complexity / deep nesting / large function / etc.} | High/Med/Low | {context} |
447
-
448
- ### Code Smells
449
- | # | Smell | Location | Description | Impact on Maintainability |
450
- |---|-------|----------|-------------|--------------------------|
451
- | 1 | {smell type} | {file:line range} | {description} | {how it hurts} |
452
-
453
- ### Dependency Graph
454
- | Component | Depends On | Depended On By | Coupling Type |
455
- |-----------|-----------|---------------|---------------|
456
- | {component} | {dependencies} | {dependents} | Hard/Soft/Circular |
457
-
458
- ### Test Coverage
459
- | Area | Unit Tests | Integration Tests | Coverage Level | Safety for Refactoring |
460
- |------|-----------|------------------|---------------|----------------------|
461
- | {area} | {count / exists / missing} | {count / exists / missing} | High/Med/Low | Safe/Needs tests first |
462
-
463
- ### Pattern Inventory
464
- - **{pattern}**: {where used} — {whether to keep, replace, or extend}
465
-
466
- ### Current State Summary
467
- {2-3 paragraphs describing the state of the code, why it needs changing, and what the key structural problems are}
468
- ```
469
-
470
- ---
471
-
472
- ### Mode: `refactoring-strategy`
473
-
474
- Design the refactoring approach. Propose specific transformations (extract, inline, rename, restructure, migrate). Define behavioral invariants that must hold throughout. Identify patterns to follow from the existing codebase or from best practices.
475
-
476
- **Dimension-specific focus** (when provided):
477
- - **Structural:** Extract module, split file, reduce coupling, enforce boundaries
478
- - **Logical:** Behavior migration, data model evolution, API versioning, state machine redesign
479
- - **Visual:** Component refactoring, design token standardization, accessibility remediation, layout restructuring
480
- - **Migration:** Framework swap, adapter pattern, compatibility shim, incremental migration
481
-
482
- **Output structure:**
483
-
484
- ```markdown
485
- ## Refactoring Strategy
486
-
487
- ### Target Architecture
488
- {Description of the desired end state — how the code should look after refactoring}
489
-
490
- ### Transformation Plan
491
- | # | Transformation | Type | From → To | Invariants |
492
- |---|---------------|------|-----------|-----------|
493
- | 1 | {what to do} | Extract/Inline/Restructure/Migrate/Replace | {current} → {target} | {what must not change} |
494
-
495
- ### Behavioral Invariants
496
- | # | Invariant | How to Verify | Current Test Coverage |
497
- |---|-----------|--------------|---------------------|
498
- | 1 | {behavior that must be preserved} | {test or assertion strategy} | Covered/Needs test |
499
-
500
- ### New Patterns Introduced
501
- | Pattern | Where | Justification | Precedent in Codebase? |
502
- |---------|-------|--------------|----------------------|
503
- | {pattern} | {where it applies} | {why this pattern over alternatives} | Yes — {where} / No — {why new} |
504
-
505
- ### Patterns Removed
506
- | Pattern | Where | Replacement | Migration Strategy |
507
- |---------|-------|-------------|-------------------|
508
- | {pattern being replaced} | {current locations} | {what replaces it} | {how to migrate} |
509
-
510
- ### Interface Contracts
511
- | Interface / API | Current Contract | New Contract | Breaking? | Migration |
512
- |----------------|-----------------|-------------|-----------|-----------|
513
- | {interface} | {current shape} | {new shape or "unchanged"} | Yes/No | {strategy} |
514
-
515
- ### Effort Estimate
516
- | Phase | Effort | Parallelizable? |
517
- |-------|--------|----------------|
518
- | {phase} | S/M/L/XL | Yes/No |
519
- | **Total** | {aggregate} | {parallel lanes} |
520
- ```
521
-
522
- ---
523
-
524
- ### Mode: `migration-path`
525
-
526
- Design a phased execution plan with safe ordering. Each phase must leave the codebase in a working state. Identify parallel lanes, rollback points, and map phases to execution skills.
527
-
528
- **Output structure:**
529
-
530
- ```markdown
531
- ## Migration Path
532
-
533
- ### Phase Overview
534
- | Phase | Title | Scope | Depends On | Skill | Effort | Rollback Point? |
535
- |-------|-------|-------|-----------|-------|--------|----------------|
536
- | 0 | {test scaffolding} | {add missing tests before refactoring} | — | hatch3r-qa-validation | S/M | Yes |
537
- | 1 | {first transformation} | {what changes} | Phase 0 | hatch3r-refactor | S/M/L | Yes |
538
-
539
- ### Phase Details
540
-
541
- #### Phase {N}: {Title}
542
- - **Goal:** {what this phase achieves}
543
- - **Transformations:** {list of specific changes}
544
- - **Files:** {list with change descriptions}
545
- - **Behavioral invariants:** {what must still hold after this phase}
546
- - **Verification:** {how to confirm the phase is successful}
547
- - **Rollback:** {how to revert this phase without affecting others}
548
-
549
- ### Parallel Lanes
550
- | Lane | Phases | Why Independent |
551
- |------|--------|----------------|
552
- | A | {phase numbers} | {no shared files or interfaces} |
553
- | B | {phase numbers} | {no shared files or interfaces} |
554
-
555
- ### Critical Path
556
- {phase X} → {phase Y} → {phase Z} (total: {effort estimate})
557
-
558
- ### Completion Criteria
559
- - [ ] All phases completed and verified
560
- - [ ] All behavioral invariants confirmed via tests
561
- - [ ] No regression in existing test suite
562
- - [ ] Dead code from old patterns removed
563
- - [ ] Documentation updated (specs, ADRs)
564
-
565
- ### Skill Mapping
566
- | Phase | Execution Skill | Why |
567
- |-------|----------------|-----|
568
- | {phase} | hatch3r-refactor | Structural code quality improvement |
569
- | {phase} | hatch3r-logical-refactor | Behavior or logic flow change |
570
- | {phase} | hatch3r-visual-refactor | UI/UX component change |
571
- | {phase} | hatch3r-qa-validation | Test scaffolding before refactoring |
572
- ```
573
-
574
- ---
575
-
576
- ### Mode: `library-docs`
577
-
578
- Look up current API documentation for specific libraries or frameworks using Context7 MCP.
579
-
580
- **Protocol:**
581
- 1. Call `resolve-library-id` with the library name to get the Context7-compatible ID.
582
- 2. Call `query-docs` with the resolved ID and the specific API question.
583
- 3. Summarize findings in structured output.
584
-
585
- **Output structure:**
586
-
587
- ```markdown
588
- ## Library Documentation
589
-
590
- ### {Library Name} ({version})
591
- | API / Function | Signature | Notes |
592
- |---------------|-----------|-------|
593
- | {API} | {signature or usage pattern} | {relevant constraints, deprecations, or gotchas} |
594
-
595
- ### Key Patterns
596
- - {pattern}: {how to use it correctly}
597
-
598
- ### Breaking Changes / Deprecations
599
- - {item}: {migration path}
600
- ```
601
-
602
- ---
603
-
604
- ### Mode: `prior-art`
605
-
606
- Research best practices, known issues, ecosystem trends, and prior art via web search. Use for novel problems, security advisories, or approaches not covered by local docs or Context7.
607
-
608
- **Output structure:**
609
-
610
- ```markdown
611
- ## Prior Art Research
612
-
613
- ### Best Practices
614
- | # | Practice | Source | Applicability |
615
- |---|---------|--------|--------------|
616
- | 1 | {practice} | {source — blog, docs, RFC} | {how it applies to the subject} |
617
-
618
- ### Known Issues / CVEs
619
- | # | Issue | Severity | Affected Versions | Mitigation |
620
- |---|-------|----------|-------------------|------------|
621
- | 1 | {issue or CVE} | {severity} | {versions} | {fix or workaround} |
622
-
623
- ### Ecosystem Trends
624
- - {trend}: {relevance to the subject}
625
-
626
- ### Reference Implementations
627
- - {project/example}: {what it demonstrates and how it's relevant}
628
- ```
629
-
630
- ---
631
-
632
- ### Mode: `requirements-elicitation`
633
-
634
- Analyze the task description against the codebase to detect ambiguities, unstated assumptions, and missing requirements. Generate structured questions for the user across 10 dimensions to resolve unknowns before implementation. Triggered by the `hatch3r-deep-context` rule based on complexity tier.
635
-
636
- **Protocol:**
637
-
638
- 1. Parse the task description for vague language ("improve", "better", "proper", "handle", "support", "clean up", "fix", "update") and flag each instance.
639
- 2. Identify unstated assumptions by comparing the task against the codebase structure — what does the task imply but not state explicitly?
640
- 3. For each of the 10 dimensions below, determine if the task description addresses it. If not, generate a targeted question.
641
- 4. Scan the codebase for modules that will be affected by the task. For each, check whether the task description accounts for its consumers, contracts, and side effects. Generate dependency-derived questions from gaps.
642
- 5. Check for cross-cutting concerns triggered by the task and list them with status (addressed / unaddressed).
643
-
644
- **10 Dimensions:**
645
-
646
- 1. **Data** — schema shape, data source, expected volume, validation rules, migration needs
647
- 2. **Behavior** — success flow, error/failure flow, edge cases, concurrent access, idempotency
648
- 3. **UI/UX** — loading states, empty states, error states, responsive behavior, accessibility, animations
649
- 4. **Security** — auth/authz model, data sensitivity classification, input validation, rate limiting, CSRF/XSS
650
- 5. **Performance** — expected data volume, caching strategy, pagination, lazy loading, bundle impact
651
- 6. **Integration** — existing features this interacts with, shared state, event chains, API consumers
652
- 7. **Migration** — existing data or behavior that changes, backward compatibility, rollback strategy
653
- 8. **Observability** — logging requirements, metrics, error tracking, audit trail for the new behavior
654
- 9. **Testing** — what constitutes "working", acceptance test scenarios, edge case coverage expectations
655
- 10. **Rollout** — feature flags, phased rollout, A/B testing, rollback trigger conditions
656
-
657
- **Output structure:**
658
-
659
- ```markdown
660
- ## Requirements Elicitation
661
-
662
- ### Ambiguity Detection
663
- | # | Term / Phrase | Context | Why It's Ambiguous | Suggested Clarification |
664
- |---|--------------|---------|-------------------|------------------------|
665
- | 1 | {vague term} | {where it appears} | {what's unclear} | {specific question} |
666
-
667
- ### Dimension Probe Questions
668
- | # | Dimension | Question | Why This Matters | Default If Unanswered |
669
- |---|-----------|----------|-----------------|----------------------|
670
- | 1 | {dimension} | {specific question} | {what could go wrong without an answer} | {safe default the implementer would assume} |
671
-
672
- ### Dependency-Derived Questions
673
- | # | Module / Interface | Consumers | Question |
674
- |---|-------------------|-----------|----------|
675
- | 1 | {module being changed} | {list of consumers} | {question about contract impact} |
676
-
677
- ### Cross-Cutting Concern Checklist
678
- | Concern | Triggered? | Addressed in Task? | Action Needed |
679
- |---------|-----------|-------------------|--------------|
680
- | Authentication / Authorization | Yes/No | Yes/No/Partial | {what to clarify or confirm} |
681
- | Internationalization (i18n) | Yes/No | Yes/No/Partial | {what to clarify or confirm} |
682
- | Accessibility (a11y) | Yes/No | Yes/No/Partial | {what to clarify or confirm} |
683
- | Error Handling | Yes/No | Yes/No/Partial | {what to clarify or confirm} |
684
- | Data Validation | Yes/No | Yes/No/Partial | {what to clarify or confirm} |
685
- | Observability / Logging | Yes/No | Yes/No/Partial | {what to clarify or confirm} |
686
- | Backward Compatibility | Yes/No | Yes/No/Partial | {what to clarify or confirm} |
687
- | Feature Flags / Rollout | Yes/No | Yes/No/Partial | {what to clarify or confirm} |
688
-
689
- ### Requirements Summary
690
- - **Resolved:** {N} dimensions fully addressed
691
- - **Needs clarification:** {N} questions requiring user input before implementation
692
- - **Safe defaults available:** {N} questions where a reasonable default exists if the user defers
693
- ```
694
-
695
- ---
696
-
697
- ### Mode: `similar-implementation`
698
-
699
- Search the codebase for analogous features, components, or modules and extract their implementation conventions as a reference for the implementer. The goal is to ensure new code follows established patterns rather than inventing new approaches.
700
-
701
- **Protocol:**
702
-
703
- 1. Parse the task to extract the core *type* of work — CRUD resource, dashboard widget, API endpoint, auth flow, data pipeline, form, modal, notification, list/table view, search feature, file upload, webhook handler, background job, etc.
704
- 2. Search the codebase for modules and components that perform the same *type* of work. Use file name patterns, directory structure, import analysis, and semantic code search.
705
- 3. Rank matches by structural similarity: file organization, patterns used, complexity level, recency.
706
- 4. For the top 2–3 matches, extract:
707
- - File structure and naming conventions (file names, directory placement, barrel exports)
708
- - State management pattern (local state, context, store, server state, URL state)
709
- - Error handling approach (try/catch style, error boundaries, toast notifications, inline errors)
710
- - Data fetching / API pattern (hooks, services, direct fetch, query library)
711
- - Test structure and coverage approach (co-located vs separate, naming, mock strategy)
712
- - Component composition pattern (container/presenter, compound components, render props — if UI)
713
- 5. Identify where the proposed feature MUST differ from references and why (different data shape, different auth model, different performance requirements).
714
- 6. Present reference implementations with a recommendation for which to follow.
715
-
716
- **Output structure:**
717
-
718
- ```markdown
719
- ## Similar Implementation Analysis
720
-
721
- ### Work Type Classification
722
- - **Detected type:** {type of work — e.g., "CRUD resource with list view and detail page"}
723
- - **Search strategy:** {how references were found — file patterns, directory scan, semantic search}
724
-
725
- ### Reference Implementations
726
- | # | Module / Feature | Location | Similarity | Why It's a Good Reference |
727
- |---|-----------------|----------|-----------|--------------------------|
728
- | 1 | {name} | {directory/file path} | High/Med | {what makes it analogous} |
729
- | 2 | {name} | {directory/file path} | High/Med | {what makes it analogous} |
730
-
731
- ### Convention Extraction
732
-
733
- #### Reference 1: {name}
734
- | Aspect | Convention | Files |
735
- |--------|-----------|-------|
736
- | File structure | {pattern — e.g., "feature directory with index barrel, component, hook, types, test files"} | {example files} |
737
- | State management | {pattern — e.g., "React Query for server state + local useState for UI state"} | {example files} |
738
- | Error handling | {pattern — e.g., "ErrorBoundary wrapper + toast for mutations + inline for forms"} | {example files} |
739
- | Data fetching | {pattern — e.g., "custom hook wrapping useQuery, service layer for API calls"} | {example files} |
740
- | Test structure | {pattern — e.g., "co-located .test.tsx, RTL for components, msw for API mocks"} | {example files} |
741
- | Component composition | {pattern — e.g., "container fetches data, presenter renders, shared via compound"} | {example files} |
742
-
743
- ### Recommendation
744
- - **Primary reference:** {name} — follow this for {rationale}
745
- - **Secondary reference:** {name} — consult for {specific aspect}
746
-
747
- ### Divergence Warnings
748
- | # | Aspect | Reference Pattern | Required Divergence | Reason |
749
- |---|--------|------------------|-------------------|--------|
750
- | 1 | {aspect} | {what the reference does} | {what the new feature must do differently} | {why} |
751
-
752
- ### Pattern-Match Checklist for Implementer
753
- - [ ] File structure follows {reference} convention
754
- - [ ] State management uses {pattern} as established in {reference}
755
- - [ ] Error handling follows {pattern} from {reference}
756
- - [ ] Data fetching uses {pattern} from {reference}
757
- - [ ] Test structure matches {pattern} from {reference}
758
- - [ ] Component composition follows {pattern} from {reference}
759
- - [ ] Documented divergences with justification for each
760
- ```
761
-
762
- ---
763
-
764
- ### Mode: `coverage-analysis`
765
-
766
- Map existing test coverage, identify gaps, and surface critical untested paths. Used by `hatch3r-test-plan` to understand the current testing baseline before planning new tests.
767
-
768
- **Output structure:**
769
-
770
- ```markdown
771
- ## Coverage Analysis
772
-
773
- ### Existing Test Inventory
774
- | Test File | Type | Module / Area Covered | Test Count | Framework |
775
- |-----------|------|----------------------|-----------|-----------|
776
- | {path} | Unit/Integration/E2E | {what it tests} | {approx count} | {vitest/jest/playwright/etc.} |
777
-
778
- ### Coverage Gaps
779
- | Module / Area | Statement % | Branch % | Function % | Gap Severity | Notes |
780
- |---------------|------------|----------|-----------|-------------|-------|
781
- | {module} | {current or "unknown"} | {current or "unknown"} | {current or "unknown"} | Critical/High/Med/Low | {why this gap matters} |
782
-
783
- ### Critical Untested Paths
784
- | # | Code Path | File(s) | Risk if Untested | Recommended Test Type |
785
- |---|-----------|---------|-----------------|---------------------|
786
- | 1 | {description of untested path} | {file paths} | {what could go wrong} | Unit/Integration/E2E/Property |
787
-
788
- ### Coverage Metrics Summary
789
- | Metric | Current | Target (hatch3r-testing rule) | Gap |
790
- |--------|---------|-------------------------------|-----|
791
- | Statement coverage | {N}% or unknown | 80% (90% critical) | {delta} |
792
- | Branch coverage | {N}% or unknown | 70% (85% critical) | {delta} |
793
- | Function coverage | {N}% or unknown | 80% | {delta} |
794
- | Mutation score | {N}% or unknown | 70% critical / 60% general | {delta} |
795
- | Flaky test rate | {N}% or unknown | < 0.5% | {delta} |
796
- ```
797
-
798
- **Depth scaling:**
799
- - **quick**: Test file inventory + coverage metrics summary only. Skip gap analysis and untested paths.
800
- - **standard**: Full inventory, coverage gaps, critical untested paths (top 5), and metrics summary.
801
- - **deep**: All sections with exhaustive gap analysis, all untested paths enumerated, cross-reference against `hatch3r-testing` rule thresholds, and flaky test inventory from quarantine directory.
802
-
803
- ---
804
-
805
- ### Mode: `complexity-risk`
806
-
807
- Identify code complexity hotspots, mutation-prone areas, and error handling coverage to prioritize where tests will have the highest impact. Used by `hatch3r-test-plan` to focus testing effort on the riskiest code.
808
-
809
- **Output structure:**
810
-
811
- ```markdown
812
- ## Complexity & Risk Analysis
813
-
814
- ### Complexity Hotspots
815
- | # | File / Function | Complexity Signal | Severity | Current Test Coverage | Testing Priority |
816
- |---|----------------|------------------|----------|---------------------|-----------------|
817
- | 1 | {file:function} | {high cyclomatic complexity / deep nesting / large function / many branches} | High/Med/Low | Covered/Partial/None | P0/P1/P2/P3 |
818
-
819
- ### Mutation-Prone Areas
820
- | # | Module / File | Why Mutation-Prone | Mutation Score (est.) | Recommended Action |
821
- |---|-------------|-------------------|---------------------|-------------------|
822
- | 1 | {path} | {many conditionals / complex state transitions / arithmetic logic} | {estimated or measured}% | {add assertions / property tests / mutation testing} |
823
-
824
- ### Error Handling Coverage
825
- | # | Error Path | File(s) | Currently Tested? | Failure Impact | Priority |
826
- |---|-----------|---------|------------------|---------------|----------|
827
- | 1 | {error scenario} | {file paths} | Yes/No/Partial | {what happens if this error path is wrong} | P0/P1/P2/P3 |
828
-
829
- ### Recommended Testing Depth
830
- | Module / Area | Recommended Depth | Rationale |
831
- |---------------|------------------|-----------|
832
- | {module} | Thorough (unit + integration + property) / Standard (unit + integration) / Light (unit only) | {complexity, risk, and coverage factors} |
833
- ```
834
-
835
- **Depth scaling:**
836
- - **quick**: Top 5 complexity hotspots + recommended testing depth table only.
837
- - **standard**: Full hotspots (top 10), mutation-prone areas, error handling coverage (top 5), and recommended depth.
838
- - **deep**: All sections exhaustively. Cross-reference mutation targets from `hatch3r-testing` rule (70% critical, 60% general). Include estimated mutation scores and specific assertion gaps.
839
-
840
- ---
841
-
842
- ### Mode: `test-pattern`
843
-
844
- Extract existing test conventions, framework usage, mock patterns, and helper libraries to ensure new tests follow established patterns. Used by `hatch3r-test-plan` to align the test strategy with the project's existing test infrastructure.
845
-
846
- **Output structure:**
847
-
848
- ```markdown
849
- ## Test Pattern Analysis
850
-
851
- ### Framework & Tooling Inventory
852
- | Tool | Version | Config File | Purpose |
853
- |------|---------|------------|---------|
854
- | {vitest/jest/playwright/stryker/etc.} | {version} | {config path} | {unit/integration/E2E/mutation} |
855
-
856
- ### Directory Conventions
857
- | Test Type | Directory | Naming Pattern | Co-located? |
858
- |-----------|-----------|---------------|-------------|
859
- | Unit | {path} | {pattern — e.g., *.test.ts} | Yes/No |
860
- | Integration | {path} | {pattern} | Yes/No |
861
- | E2E | {path} | {pattern} | Yes/No |
862
- | Fixtures | {path} | {pattern} | — |
863
- | Quarantine | {path or "none"} | {pattern} | — |
864
-
865
- ### Mock & Fixture Patterns
866
- | Pattern | Where Used | Convention | Compliance with hatch3r-testing |
867
- |---------|-----------|-----------|-------------------------------|
868
- | {fakes / stubs / mocks / MSW / nock / etc.} | {example files} | {how the project uses this pattern} | {aligned — fakes > stubs > mocks / divergent — explain} |
869
-
870
- ### Test Helper Library
871
- | Helper | Location | Purpose | Used By |
872
- |--------|----------|---------|---------|
873
- | {factory function / builder / custom matcher / setup utility} | {file path} | {what it does} | {which test files use it} |
874
-
875
- ### Property-Based Testing Usage
876
- | Status | Library | Where Used | Coverage |
877
- |--------|---------|-----------|---------|
878
- | {Active / Not used / Minimal} | {fast-check / etc. or "none"} | {file paths or "N/A"} | {which function types are covered} |
879
-
880
- ### Convention Compliance
881
- | Convention (hatch3r-testing rule) | Current State | Compliance |
882
- |----------------------------------|--------------|-----------|
883
- | Deterministic (no wall clock) | {compliant / violations found} | {details} |
884
- | Isolated (own setup/teardown) | {compliant / violations found} | {details} |
885
- | Fast (unit < 50ms, integration < 2s) | {compliant / unknown / violations} | {details} |
886
- | Named clearly (behavior descriptions) | {compliant / mixed / non-compliant} | {details} |
887
- | No network in unit tests | {compliant / violations found} | {details} |
888
- | No type escape hatches | {compliant / violations found} | {details} |
889
- | Fakes > stubs > mocks hierarchy | {followed / partially / not followed} | {details} |
890
- | Factory over fixtures | {followed / partially / not followed} | {details} |
891
- ```
892
-
893
- **Depth scaling:**
894
- - **quick**: Framework inventory + directory conventions only.
895
- - **standard**: Full inventory, directory conventions, mock patterns, and convention compliance summary.
896
- - **deep**: All sections exhaustively. Include test helper library analysis, property-based testing status, and detailed convention compliance with file-level violations.
897
-
898
- ---
899
-
900
- ### Mode: `boundary-analysis`
901
-
902
- Map integration boundaries, external dependencies, data flow boundaries, and event chains to identify where integration and contract tests are most needed. Used by `hatch3r-test-plan` to ensure test coverage at system seams.
903
-
904
- **Output structure:**
905
-
906
- ```markdown
907
- ## Boundary Analysis
908
-
909
- ### Module Boundaries
910
- | Boundary | Module A | Module B | Interface Type | Current Test Coverage | Test Need |
911
- |----------|----------|----------|---------------|---------------------|----------|
912
- | {boundary name} | {module} | {module} | {API / import / event / shared state} | Covered/Partial/None | Integration/Contract/E2E |
913
-
914
- ### External Dependencies
915
- | Dependency | Type | Mock Strategy | Current Mock Coverage | Risk if Unmocked |
916
- |-----------|------|-------------|---------------------|-----------------|
917
- | {database / API / service / SDK} | {runtime / build-time / optional} | {fake / stub / MSW / emulator / none} | Covered/Partial/None | {what breaks without proper mocking} |
918
-
919
- ### Data Flow Boundaries
920
- | Flow | Source | Transform(s) | Sink | Validation Points | Test Coverage |
921
- |------|--------|-------------|------|------------------|-------------|
922
- | {flow name} | {where data enters} | {processing steps} | {where data is consumed} | {where validation happens} | Covered/Partial/None |
923
-
924
- ### Event / Callback Chains
925
- | Event | Emitter | Listener(s) | Side Effects | Test Coverage |
926
- |-------|---------|------------|-------------|-------------|
927
- | {event name} | {where emitted} | {where consumed} | {what changes} | Covered/Partial/None |
928
-
929
- ### API Surface Coverage
930
- | Endpoint / Interface | Methods | Parameters | Response Shapes | Test Coverage | Priority |
931
- |---------------------|---------|-----------|----------------|-------------|----------|
932
- | {endpoint or public interface} | {methods} | {param count / complexity} | {shape count} | Covered/Partial/None | P0/P1/P2/P3 |
933
- ```
934
-
935
- **Depth scaling:**
936
- - **quick**: Module boundaries + external dependencies only (top 5 each).
937
- - **standard**: Full module boundaries, external dependencies, data flow boundaries, and API surface coverage.
938
- - **deep**: All sections exhaustively. Include event/callback chains, full data flow tracing, and priority-ranked API surface analysis.
939
-
940
- ---
941
-
942
- ### Mode: `risk-prioritization`
943
-
944
- Produce a risk-ranked prioritization of testing effort considering business impact, security exposure, change frequency, and current coverage. Used by `hatch3r-test-plan` to order test implementation for maximum risk reduction.
945
-
946
- **Output structure:**
947
-
948
- ```markdown
949
- ## Risk-Based Test Prioritization
950
-
951
- ### Risk Matrix
952
- | # | Module / Area | Business Impact | Security Exposure | Change Frequency | Current Coverage | Risk Score | Test Priority |
953
- |---|-------------|----------------|------------------|-----------------|-----------------|-----------|--------------|
954
- | 1 | {module} | Critical/High/Med/Low | Critical/High/Med/Low | High/Med/Low | High/Med/Low/None | {weighted score} | P0/P1/P2/P3 |
955
-
956
- ### Recommended Test Investment Order
957
- | Priority | Module / Area | Recommended Tests | Effort | Risk Reduction |
958
- |----------|-------------|------------------|--------|---------------|
959
- | P0 | {module} | {test types and count} | S/M/L | {what risk this eliminates} |
960
- | P1 | {module} | {test types and count} | S/M/L | {what risk this reduces} |
961
- | P2 | {module} | {test types and count} | S/M/L | {what risk this reduces} |
962
- | P3 | {module} | {test types and count} | S/M/L | {incremental improvement} |
963
-
964
- ### Quick Wins
965
- | # | Test to Add | Module | Effort | Risk Reduction | Why It's a Quick Win |
966
- |---|-----------|--------|--------|---------------|---------------------|
967
- | 1 | {specific test description} | {module} | XS/S | {impact} | {already has test infra / simple boundary / high-value assertion} |
968
-
969
- ### Technical Debt Tests
970
- | # | Debt Item | Module | Current Risk | Recommended Test | Blocks |
971
- |---|----------|--------|-------------|-----------------|--------|
972
- | 1 | {tech debt — e.g., untested legacy module, missing error handling tests} | {module} | {what could go wrong} | {test type and scope} | {what this blocks — e.g., safe refactoring, migration} |
973
- ```
974
-
975
- **Depth scaling:**
976
- - **quick**: Risk matrix (top 5 modules) + quick wins only.
977
- - **standard**: Full risk matrix, investment order (P0–P2), quick wins, and top 3 technical debt items.
978
- - **deep**: All sections exhaustively. Full risk matrix with weighted scoring, complete investment order (P0–P3), all quick wins, and comprehensive technical debt test inventory.
75
+ Mode definitions are in `agents/modes/`. Read the mode file for the full output structure and protocol.
76
+
77
+ ### Planning & Design Modes
78
+ | Mode | File | Purpose |
79
+ |------|------|---------|
80
+ | `codebase-impact` | `agents/modes/codebase-impact.md` | Map affected files, modules, integration points, and blast radius |
81
+ | `feature-design` | `agents/modes/feature-design.md` | Break subject into sub-tasks with user stories and acceptance criteria |
82
+ | `architecture` | `agents/modes/architecture.md` | Design data model, API contracts, component design, ADR candidates |
83
+ | `risk-assessment` | `agents/modes/risk-assessment.md` | Identify risks, security, performance, breaking changes |
84
+ | `requirements-elicitation` | `agents/modes/requirements-elicitation.md` | Detect ambiguities and missing requirements across 10 dimensions |
85
+ | `similar-implementation` | `agents/modes/similar-implementation.md` | Find analogous code in the codebase and extract conventions |
86
+
87
+ ### Debugging & Investigation Modes
88
+ | Mode | File | Purpose |
89
+ |------|------|---------|
90
+ | `symptom-trace` | `agents/modes/symptom-trace.md` | Trace execution path from user action to observed failure |
91
+ | `root-cause` | `agents/modes/root-cause.md` | Analyze candidate root causes, rank hypotheses |
92
+ | `impact-analysis` | `agents/modes/impact-analysis.md` | Map blast radius across flows, modules, data, users |
93
+ | `regression` | `agents/modes/regression.md` | Investigate when issue was introduced via git/dep/config history |
94
+
95
+ ### Refactoring Modes
96
+ | Mode | File | Purpose |
97
+ |------|------|---------|
98
+ | `current-state` | `agents/modes/current-state.md` | Map complexity, coupling, cohesion, coverage, code quality |
99
+ | `refactoring-strategy` | `agents/modes/refactoring-strategy.md` | Design transformations with behavioral invariants |
100
+ | `migration-path` | `agents/modes/migration-path.md` | Phase execution plan with safe ordering and rollback points |
101
+
102
+ ### Test Planning Modes
103
+ | Mode | File | Purpose |
104
+ |------|------|---------|
105
+ | `coverage-analysis` | `agents/modes/coverage-analysis.md` | Map existing test coverage and identify gaps |
106
+ | `complexity-risk` | `agents/modes/complexity-risk.md` | Identify complexity hotspots and prioritize testing effort |
107
+ | `test-pattern` | `agents/modes/test-pattern.md` | Extract existing test conventions and framework usage |
108
+ | `boundary-analysis` | `agents/modes/boundary-analysis.md` | Map integration boundaries and contract test needs |
109
+ | `risk-prioritization` | `agents/modes/risk-prioritization.md` | Risk-ranked testing effort prioritization |
110
+
111
+ ### External Research Modes
112
+ | Mode | File | Purpose |
113
+ |------|------|---------|
114
+ | `library-docs` | `agents/modes/library-docs.md` | Look up current API docs via Context7 MCP |
115
+ | `prior-art` | `agents/modes/prior-art.md` | Research best practices and prior art via web search |
979
116
 
980
117
  ---
981
118
 
@@ -989,17 +126,15 @@ Use the project's configured platform CLI (check `platform` in `.agents/hatch.js
989
126
  - **GitLab:** `glab issue view`, `glab issue list --search`, `glab search`
990
127
  - **Fallback** to platform MCP only for operations not covered by the CLI (e.g., sub-issue management, project field mutations).
991
128
 
992
- ## Context7 MCP Usage
129
+ ## External Knowledge
993
130
 
994
- - Use `resolve-library-id` then `query-docs` to look up current API patterns for frameworks and external dependencies.
995
- - Prefer Context7 over guessing API signatures or relying on potentially outdated training data.
996
- - The `library-docs` mode wraps this into a structured workflow, but any mode may use Context7 when external APIs are relevant.
131
+ Follow the shared protocol in `agents/shared/external-knowledge.md` (tooling hierarchy, platform CLI, Context7 MCP, web research).
997
132
 
998
- ## Web Research Usage
133
+ **Context7 focus for this agent:**
134
+ - The `library-docs` mode wraps Context7 into a structured workflow, but any mode may use Context7 when external APIs are relevant
999
135
 
1000
- - Use web search for latest CVEs, security advisories, breaking changes, or novel error messages.
1001
- - Use web search for current best practices when Context7 and local docs are insufficient.
1002
- - The `prior-art` mode wraps this into a structured workflow, but any mode may use web search when current information is needed.
136
+ **Web research focus for this agent:**
137
+ - The `prior-art` mode wraps web search into a structured workflow, but any mode may use web search when current information is needed
1003
138
 
1004
139
  ## Structured Reasoning
1005
140
 
@@ -1022,15 +157,18 @@ Example in a research finding:
1022
157
 
1023
158
  Apply this format whenever research findings involve trade-off analysis, risk assessment, architectural recommendations, or when the evidence supports multiple valid interpretations.
1024
159
 
1025
- ## Agent Size and Split Guidance
160
+ ## Research Quality Signals
1026
161
 
1027
- This agent file is large (~1,000+ lines) because it serves as a composable mode library. The current design is intentional: all modes share a single research protocol, tooling hierarchy, and structured output contract. Splitting individual modes into separate agents would break the composability that allows a single researcher invocation to execute multiple modes.
162
+ When producing research output, every finding must include:
1028
163
 
1029
- **When to split:** If this file exceeds ~1,500 lines (e.g., due to new mode additions), consider extracting mode groups into companion agents (e.g., a codebase-mapping agent for `codebase-impact`, `current-state`, `boundary-analysis` modes, and a test-planning agent for `coverage-analysis`, `complexity-risk`, `test-pattern`, `risk-prioritization` modes). The researcher would retain the core protocol and general modes, delegating to companions when specialized modes are requested. Each companion agent would share the same research protocol preamble and tooling hierarchy sections.
164
+ 1. **Evidence source.** State where the finding came from (file path, documentation section, search result URL). Unsourced findings reduce implementer confidence and may cause rework in Phase 2.
165
+ 2. **Confidence level.** Rate each finding per the quality charter. Research findings with low confidence should be explicitly flagged so the implementer treats them as assumptions rather than facts.
166
+ 3. **Actionability.** Each finding should answer "so what?" for the implementer. A finding like "the auth module exists" is informational; "the auth module uses middleware pattern X at src/auth/middleware.ts -- follow this pattern for new auth checks" is actionable.
167
+ 4. **Completeness markers.** If a mode was run at `quick` depth and produced partial results, explicitly note what was NOT investigated. Example: "At quick depth, only scanned top-level module structure. Deep analysis of internal module dependencies was not performed."
1030
168
 
1031
169
  ## Boundaries
1032
170
 
1033
- - **Always:** Follow the tooling hierarchy (project docs codebase Context7 web research). Use the platform CLI (check `platform` in `.agents/hatch.json`). Stay within the research brief's scope. Produce structured output matching the mode's specification. Report BLOCKED if the brief is ambiguous or contradictory.
171
+ - **Always:** Follow the tooling hierarchy (project docs -> codebase -> Context7 -> web research). Use the platform CLI (check `platform` in `.agents/hatch.json`). Stay within the research brief's scope. Produce structured output matching the mode's specification. Report BLOCKED if the brief is ambiguous or contradictory.
1034
172
  - **Ask first:** If the brief's scope is unclear, if contradictions are found between sources, or if critical context is missing.
1035
173
  - **Never:** Create files. Modify code. Create branches, commits, or PRs. Modify board status. Expand scope beyond the research brief. Invent findings not supported by evidence.
1036
174