gsdd-cli 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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +528 -0
  3. package/agents/DISTILLATION.md +306 -0
  4. package/agents/README.md +53 -0
  5. package/agents/debugger.md +82 -0
  6. package/agents/executor.md +394 -0
  7. package/agents/integration-checker.md +318 -0
  8. package/agents/mapper.md +103 -0
  9. package/agents/planner.md +296 -0
  10. package/agents/researcher.md +84 -0
  11. package/agents/roadmapper.md +296 -0
  12. package/agents/synthesizer.md +236 -0
  13. package/agents/verifier.md +337 -0
  14. package/bin/adapters/agents.mjs +33 -0
  15. package/bin/adapters/claude.mjs +145 -0
  16. package/bin/adapters/codex.mjs +58 -0
  17. package/bin/adapters/index.mjs +20 -0
  18. package/bin/adapters/opencode.mjs +237 -0
  19. package/bin/gsdd.mjs +102 -0
  20. package/bin/lib/cli-utils.mjs +28 -0
  21. package/bin/lib/health.mjs +248 -0
  22. package/bin/lib/init.mjs +379 -0
  23. package/bin/lib/manifest.mjs +134 -0
  24. package/bin/lib/models.mjs +379 -0
  25. package/bin/lib/phase.mjs +237 -0
  26. package/bin/lib/rendering.mjs +95 -0
  27. package/bin/lib/templates.mjs +207 -0
  28. package/distilled/DESIGN.md +1286 -0
  29. package/distilled/README.md +169 -0
  30. package/distilled/SKILL.md +85 -0
  31. package/distilled/templates/agents.block.md +90 -0
  32. package/distilled/templates/agents.md +13 -0
  33. package/distilled/templates/auth-matrix.md +78 -0
  34. package/distilled/templates/codebase/architecture.md +110 -0
  35. package/distilled/templates/codebase/concerns.md +95 -0
  36. package/distilled/templates/codebase/conventions.md +193 -0
  37. package/distilled/templates/codebase/stack.md +96 -0
  38. package/distilled/templates/delegates/mapper-arch.md +26 -0
  39. package/distilled/templates/delegates/mapper-concerns.md +27 -0
  40. package/distilled/templates/delegates/mapper-quality.md +28 -0
  41. package/distilled/templates/delegates/mapper-tech.md +25 -0
  42. package/distilled/templates/delegates/plan-checker.md +55 -0
  43. package/distilled/templates/delegates/researcher-architecture.md +30 -0
  44. package/distilled/templates/delegates/researcher-features.md +30 -0
  45. package/distilled/templates/delegates/researcher-pitfalls.md +30 -0
  46. package/distilled/templates/delegates/researcher-stack.md +30 -0
  47. package/distilled/templates/delegates/researcher-synthesizer.md +31 -0
  48. package/distilled/templates/research/architecture.md +57 -0
  49. package/distilled/templates/research/features.md +23 -0
  50. package/distilled/templates/research/pitfalls.md +46 -0
  51. package/distilled/templates/research/stack.md +45 -0
  52. package/distilled/templates/research/summary.md +67 -0
  53. package/distilled/templates/roadmap.md +62 -0
  54. package/distilled/templates/spec.md +110 -0
  55. package/distilled/workflows/audit-milestone.md +220 -0
  56. package/distilled/workflows/execute.md +270 -0
  57. package/distilled/workflows/map-codebase.md +246 -0
  58. package/distilled/workflows/new-project.md +418 -0
  59. package/distilled/workflows/pause.md +121 -0
  60. package/distilled/workflows/plan.md +383 -0
  61. package/distilled/workflows/progress.md +199 -0
  62. package/distilled/workflows/quick.md +187 -0
  63. package/distilled/workflows/resume.md +152 -0
  64. package/distilled/workflows/verify.md +307 -0
  65. package/package.json +45 -0
@@ -0,0 +1,306 @@
1
+ # GSDD Role Distillation Ledger
2
+
3
+ Evidence map from each of the 9 canonical GSDD roles to their GSD sources, with keep/strip/why rationale. This ledger documents why each role exists in its current form and what GSD content was distilled or merged.
4
+
5
+ ---
6
+
7
+ ## 1. Mapper
8
+
9
+ **Canonical role:** `agents/mapper.md`
10
+
11
+ **GSD source:** `agents/_archive/gsd-codebase-mapper.md`
12
+
13
+ **Merger type:** Kept-as-is (function scope preserved, output contract simplified)
14
+
15
+ **Kept from GSD:**
16
+ - Mandatory initial-read discipline for context files
17
+ - 4 focus areas (tech, arch, quality, concerns)
18
+ - Output contract with artifact names and downstream consumers
19
+ - Core algorithm: parse → explore → fill template → write → confirm
20
+
21
+ **Stripped from GSD:**
22
+ - Multi-file codebase output reduced to 4-file standard (see D1)
23
+ - Validator-pass patterns (GSDD trusts agent reads, not file validation)
24
+
25
+ **Gained in GSDD:**
26
+ - Explicit "Downstream Consumers" section (shows who uses mapper output)
27
+ - Clear guidance on prescriptive vs. descriptive output (helps agents write better code)
28
+
29
+ **Rationale:** Mapper is the lowest-level, most stable role. Its core job (explore + document) hasn't changed, but the output set shrank from 7 files to 4 files per D1 (lean context decision). The agent role contract itself needed no substantive changes.
30
+
31
+ ---
32
+
33
+ ## 2. Researcher
34
+
35
+ **Canonical role:** `agents/researcher.md`
36
+
37
+ **GSD sources:** `agents/_archive/gsd-project-researcher.md` + `agents/_archive/gsd-phase-researcher.md` (merged)
38
+
39
+ **Merger type:** Merged (same algorithm, different scope parameter)
40
+
41
+ **Kept from GSD:**
42
+ - Mandatory initial-read discipline
43
+ - Research scope (project vs. phase)
44
+ - Research mode (ecosystem, feasibility, comparison)
45
+ - Core algorithm: receive scope → identify domains → execute tool hierarchy → verify → write → return structured result
46
+ - Quality guarantees (training data = hypothesis, honest reporting, investigation not confirmation, confidence levels on every finding)
47
+ - Research pitfalls and prevention strategies
48
+
49
+ **Stripped from GSD:**
50
+ - Separate role contracts for project-researcher and phase-researcher (merged into one with scope parameter)
51
+ - Tool-specific shell commands (kept portable tool contracts instead)
52
+
53
+ **Gained in GSDD:**
54
+ - Explicit "Scope" table showing scope × trigger × focus × output location
55
+ - Clear statement: "Same algorithm, different scope. The scope is a context input, not a different role."
56
+
57
+ **Rationale:** The GSD original had two roles (project and phase researcher) that followed the identical algorithm but with a scope parameter. GSDD merged them into one canonical role taking scope as input, reducing the role count from 11 to 9 while preserving all leverage. This is the clean merger mentioned in D2.
58
+
59
+ ---
60
+
61
+ ## 3. Synthesizer
62
+
63
+ **Canonical role:** `agents/synthesizer.md`
64
+
65
+ **GSD source:** `agents/_archive/gsd-research-synthesizer.md` (with recovery hardening from PR #15)
66
+
67
+ **Merger type:** Kept-as-is (hardened in 2026-03-13)
68
+
69
+ **Kept from GSD:**
70
+ - Mandatory initial-read discipline
71
+ - Input contract: all 4 research files (STACK, FEATURES, ARCHITECTURE, PITFALLS)
72
+ - Output contract: SUMMARY.md with executive summary, key findings, roadmap implications, confidence/gaps
73
+ - Downstream consumer (roadmapper) and what it needs
74
+ - 6-step execution flow: read → synthesize → extract → derive → assess → write
75
+
76
+ **Stripped from GSD:**
77
+ - Conditional skip logic (kept mandatory synthesizer per D5 original decision)
78
+ - Vendor-specific output formatting
79
+
80
+ **Gained in GSDD (PR #15 hardening):**
81
+ - Explicit required files list with blocked-return pattern (do not guess from partial context, return blocked status naming missing file)
82
+ - "Be opinionated" guidance to roadmapper
83
+ - Stronger structured-return contract
84
+
85
+ **Rationale:** Synthesizer is a thin single-step role with no merge or extraction needed. It was hardened in PR #15 to restore explicit structure and completion discipline, but the core function and leverage remained unchanged from GSD.
86
+
87
+ ---
88
+
89
+ ## 4. Planner
90
+
91
+ **Canonical role:** `agents/planner.md`
92
+
93
+ **GSD sources:** `agents/_archive/gsd-planner.md` + `agents/_archive/gsd-plan-checker.md` (merged)
94
+
95
+ **Merger type:** Merged (orchestration ownership transferred to native adapters)
96
+
97
+ **Kept from GSD:**
98
+ - Mandatory initial-read discipline
99
+ - Phase goal decomposition and dependency graphs
100
+ - Goal-backward verification (must-haves, artifacts, key links)
101
+ - Planner responsibility and scope
102
+ - Input contract (SPEC, ROADMAP, codebase context, prior phase artifacts)
103
+ - Output contract (PLAN.md with frontmatter, objective, context references, typed tasks)
104
+
105
+ **Stripped from GSD:**
106
+ - Separate plan-checker role (now a delegate at `distilled/templates/delegates/plan-checker.md`)
107
+ - GSD's native 3-cycle verification loop (embedded in planner) → moved to native adapter surfaces (Claude skill, OpenCode command, Codex agent)
108
+ - Vendor-specific fresh-context orchestration logic
109
+
110
+ **Gained in GSDD:**
111
+ - Explicit scope boundary: "plan-scoped, does not own verification or milestone audit"
112
+ - Goal-backward section with 4 clear questions
113
+ - Planning process section with concrete steps
114
+ - Reference to plan-checker delegate for fresh-context review
115
+ - Reduced-assurance fallback mode description (when no independent checker runs)
116
+
117
+ **Rationale:** GSD's plan-checker was a separate role running a 3-cycle revision loop. GSDD merged planner and plan-checker into a single portable contract, but preserved the adversarial review concept through native adapter surfaces. The portable workflow describes the reduced-assurance fallback. This is the high-impact merger from D2 with full tradeoff documentation.
118
+
119
+ ---
120
+
121
+ ## 5. Roadmapper
122
+
123
+ **Canonical role:** `agents/roadmapper.md`
124
+
125
+ **GSD source:** `agents/_archive/gsd-roadmapper.md` (with recovery hardening from PR #15)
126
+
127
+ **Merger type:** Kept-as-is (hardened in 2026-03-13)
128
+
129
+ **Kept from GSD:**
130
+ - Mandatory initial-read discipline
131
+ - Bounded section structure (phases, requirements, success criteria, coverage validation)
132
+ - Explicit coverage validation
133
+ - Parse-critical artifact contract
134
+ - Structured return modes
135
+ - Checklist-driven completion
136
+
137
+ **Stripped from GSD:**
138
+ - Template-path references (output lives in `.planning/ROADMAP.md`)
139
+ - Commit steps (GSDD handles git separately)
140
+ - Vendor-specific file conventions
141
+
142
+ **Gained in GSDD (PR #15 hardening):**
143
+ - Explicit `.planning/ROADMAP.md` ownership contract
144
+ - Explicit `[ ]` / `[-]` / `[x]` status grammar
145
+ - Concrete `ROADMAP CREATED` artifact example
146
+ - Hard boundary: "this role does not settle the separate ROADMAP/STATE lifecycle seam"
147
+
148
+ **Rationale:** Roadmapper was over-distilled in the initial extraction; PR #15 recovered visible structure and completion discipline. The core role and leverage were intact; hardening just restored the guardrails that improve compliance.
149
+
150
+ ---
151
+
152
+ ## 6. Executor
153
+
154
+ **Canonical role:** `agents/executor.md`
155
+
156
+ **GSD source:** `agents/_archive/gsd-executor.md` (with substantial hardening from PR #16)
157
+
158
+ **Merger type:** Kept-as-is (hardened significantly in 2026-03-13)
159
+
160
+ **Kept from GSD:**
161
+ - Plan-scoped execution discipline
162
+ - Task implementation and deviation handling
163
+ - Git action recording without repo-specific naming assumptions
164
+ - Checkpoint protocol
165
+ - Completion summary
166
+ - State update responsibility
167
+
168
+ **Stripped from GSD:**
169
+ - Bash recipe patterns and shell-specific guidance
170
+ - Tool-specific directory naming conventions
171
+
172
+ **Gained in GSDD (PR #16 hardening):**
173
+ - Explicit scope boundary with 6 things executor does NOT own
174
+ - Clearer deviation rules with priority order (auto-fix bugs first)
175
+ - Success criteria confirmation requirement
176
+ - Verify quality checks now live inside task_completeness (runnable, fast, ordered)
177
+ - Stronger commitment to documented deviations
178
+
179
+ **Rationale:** Executor is the most complex role, with the broadest deviation surface. PR #16 audit recovered substantive guardrails: explicit scope boundaries, rule priority, and verification discipline. The ~150-line executor contract expanded to ~400 lines because the detail prevents misalignment, not because the job changed.
180
+
181
+ ---
182
+
183
+ ## 7. Verifier
184
+
185
+ **Canonical role:** `agents/verifier.md`
186
+
187
+ **GSD source:** `agents/_archive/gsd-verifier.md` (with selective hardening from D2)
188
+
189
+ **Merger type:** Kept-as-is (scope preserved; cross-phase audit extracted separately)
190
+
191
+ **Kept from GSD:**
192
+ - Phase-level goal-backward verification
193
+ - Exists/Substantive/Wired gate
194
+ - Anti-pattern scan
195
+ - Output contract with compact base fields (phase, verified, status, score)
196
+ - Verification-report structure
197
+
198
+ **Stripped from GSD:**
199
+ - Cross-phase integration audit scope (extracted as separate role + workflow)
200
+ - GSD's narrative all-encompassing verification
201
+
202
+ **Gained in GSDD:**
203
+ - Richer structured verifier findings (re_verification, gaps, human_verification) when material
204
+ - Explicit boundaries: "phase-scoped only, cross-phase integration is a separate concern"
205
+ - D2 cross-reference: why integration-checker exists as a separate role
206
+
207
+ **Rationale:** Verifier's phase-level job is unchanged. The extraction of integration-checker as a separate milestone surface (D2, PR #12) made verifier smaller and clearer. Phase verification and milestone integration audit are now distinct concerns with explicit handoff points.
208
+
209
+ ---
210
+
211
+ ## 8. Integration-Checker
212
+
213
+ **Canonical role:** `agents/integration-checker.md`
214
+
215
+ **GSD source:** `agents/_archive/gsd-integration-checker.md` (with structural recovery in PR #12 and systemic hardening in PR #15)
216
+
217
+ **Merger type:** Extracted as standalone role (cross-phase scope differs structurally from phase verification)
218
+
219
+ **Kept from GSD:**
220
+ - Mandatory initial-read discipline
221
+ - Cross-phase wiring verification (exports → imports, APIs → consumers, forms → handlers, data → display)
222
+ - E2E flow tracing
223
+ - Typed structured return
224
+ - Checklist-driven completion
225
+
226
+ **Stripped from GSD (intentional):**
227
+ - Framework-specific Bash recipes
228
+ - Hardcoded path assumptions
229
+ - File-extension-specific grep flags
230
+ - Tool-specific details that don't survive vendor-agnostic distillation
231
+
232
+ **Gained in GSDD:**
233
+ - PR #12: explicit section boundaries, stronger structured output, cleaner split between role contract and milestone workflow
234
+ - PR #15: recovered compliance guardrails, restored mandatory read enforcement, explicit auth-protection verification
235
+ - D2 reference: structural difference from phase verifier
236
+ - New in D21 (PR #35): Step 4a matrix-driven auth verification (if AUTH_MATRIX.md exists)
237
+
238
+ **Rationale:** GSD's integration-checker was a separate surface but lived in the shadows of the main role contracts. PR #12 extracted it fully; PR #15 recovered its substantive guardrails. The role is different from verifier because it owns milestone scope (all-phase wiring) vs. phase scope (phase goal). This is the cleanest separation in D2.
239
+
240
+ ---
241
+
242
+ ## 9. Debugger
243
+
244
+ **Canonical role:** `agents/debugger.md`
245
+
246
+ **GSD source:** `agents/_archive/gsd-debugger.md` (no changes)
247
+
248
+ **Merger type:** Kept-as-is (unchanged)
249
+
250
+ **Kept from GSD:**
251
+ - Systematic debugging methodology
252
+ - Hypothesis formulation and testing
253
+ - State persistence across context resets
254
+ - Structured checkpoint protocol
255
+ - Deviation handling
256
+
257
+ **Stripped from GSD:** (nothing significant)
258
+ - Minor tool path references
259
+
260
+ **Gained in GSDD:** (nothing)
261
+ - The role is kept as-is for compatibility
262
+
263
+ **Rationale:** Debugger is a standalone utility role with no dependencies on other roles. It was preserved exactly as-is from GSD because it works and has no vendor lock-in. It's used ad-hoc when agents encounter failures, not as part of the main workflow pipeline.
264
+
265
+ ---
266
+
267
+ ## Summary: Merger Table (from D2)
268
+
269
+ | Canonical role | Absorbs from GSD | Merger criteria |
270
+ |---|---|---|
271
+ | `mapper.md` | `gsd-codebase-mapper.md` | Kept-as-is; output set changed per D1 (7 → 4 files) |
272
+ | `researcher.md` | `gsd-project-researcher.md` + `gsd-phase-researcher.md` | Scope parameter instead of separate role |
273
+ | `synthesizer.md` | `gsd-research-synthesizer.md` | Kept-as-is; hardened in PR #15 |
274
+ | `planner.md` | `gsd-planner.md` + `gsd-plan-checker.md` | Orchestration ownership moved to native adapters; portable checker-delegate created |
275
+ | `roadmapper.md` | `gsd-roadmapper.md` | Kept-as-is; hardened in PR #15 |
276
+ | `executor.md` | `gsd-executor.md` | Kept-as-is; heavily hardened in PR #16 |
277
+ | `verifier.md` | `gsd-verifier.md` | Kept-as-is; cross-phase audit extracted to integration-checker |
278
+ | `integration-checker.md` | `gsd-integration-checker.md` | Extracted as standalone; recovered in PR #12, hardened in PR #15 |
279
+ | `debugger.md` | `gsd-debugger.md` | Kept-as-is; no changes |
280
+
281
+ **Result:** 11 GSD roles → 9 GSDD canonical roles (2 mergers: researcher, planner). 1 extraction: integration-checker moved from embedded to standalone. Total leverage preserved, role count reduced.
282
+
283
+ ---
284
+
285
+ ## Evidence and Context
286
+
287
+ - GSD sources: `agents/_archive/gsd-*.md`
288
+ - GSDD canonical roles: `agents/*.md` (all except `_archive/`)
289
+ - Design decisions: `distilled/DESIGN.md` (D1, D2)
290
+ - PR history:
291
+ - PR #9: Delegate extraction
292
+ - PR #12: Integration-checker extraction and lifecycle contract seam
293
+ - PR #14-17: Systemic role-contract hardening and leverage recovery
294
+ - PR #35: OWASP authorization matrix integration into integration-checker
295
+
296
+ ---
297
+
298
+ ## Maintenance
299
+
300
+ This ledger is updated when:
301
+
302
+ 1. A canonical role contract changes significantly (update the "Kept"/"Stripped"/"Gained" sections)
303
+ 2. A GSD role is merged into or extracted from a canonical role (update the merger table)
304
+ 3. New evidence surfaces that changes the distillation rationale (update with citation)
305
+
306
+ Do not add speculative content. Every entry must reference actual source files and PRs that contain evidence.
@@ -0,0 +1,53 @@
1
+ # Canonical Role Library
2
+
3
+ Vendor-agnostic role contracts for GSDD's agent architecture.
4
+
5
+ ## Two-Layer Architecture
6
+
7
+ | Layer | Location | Purpose |
8
+ |-------|----------|---------|
9
+ | **Roles** (this directory) | `agents/*.md` | Durable contracts: identity, inputs, outputs, algorithm, guarantees |
10
+ | **Delegates** | `distilled/templates/delegates/*.md` | Task-specific wrappers: scoped instructions that reference a role |
11
+
12
+ Roles define what an agent is. Delegates define what an agent does in a specific workflow context.
13
+
14
+ ## Lifecycle Roles
15
+
16
+ | Role | File | Absorbs From (GSD) |
17
+ |------|------|---------------------|
18
+ | Mapper | `mapper.md` | `gsd-codebase-mapper.md` |
19
+ | Researcher | `researcher.md` | `gsd-project-researcher.md` + `gsd-phase-researcher.md` |
20
+ | Synthesizer | `synthesizer.md` | `gsd-research-synthesizer.md` |
21
+ | Planner | `planner.md` | `gsd-planner.md` + `gsd-plan-checker.md` |
22
+ | Executor | `executor.md` | `gsd-executor.md` |
23
+ | Verifier | `verifier.md` | `gsd-verifier.md` |
24
+ | Roadmapper | `roadmapper.md` | `gsd-roadmapper.md` |
25
+
26
+ ## Audit Roles
27
+
28
+ | Role | File | Absorbs From (GSD) |
29
+ |------|------|--------------------|
30
+ | Integration Checker | `integration-checker.md` | `gsd-integration-checker.md` |
31
+
32
+ ## Utility Roles
33
+
34
+ | Role | File | Note |
35
+ |------|------|------|
36
+ | Debugger | `debugger.md` | Not part of core lifecycle. Standalone diagnostic utility. |
37
+
38
+ ## Runtime Distribution
39
+
40
+ `gsdd init` copies all role contracts (excluding this README) from `agents/` into `.planning/templates/roles/` in the consumer project. This gives consumer projects a portable, self-contained copy of the role library with no hard dependency on the GSDD framework repo at runtime.
41
+
42
+ - **Single source of truth:** `agents/*.md` in this repo. Consumer copies are generated, not edited.
43
+ - **Delegates reference the local copy:** `distilled/templates/delegates/*.md` point to `.planning/templates/roles/<role>.md`, not back to this repo.
44
+ - **Idempotent:** `gsdd init` skips the copy if `.planning/templates/roles/` already exists.
45
+ - **Updates:** `gsdd update --templates` re-copies from latest framework sources with hash-based modification detection.
46
+
47
+ Verifier note:
48
+ - `verifier.md` is phase-scoped.
49
+ - The milestone integration-audit surface exists as `distilled/workflows/audit-milestone.md` with its own `integration-checker.md` role contract. It is not absorbed into the verifier.
50
+
51
+ ## Archive
52
+
53
+ `_archive/` contains the original 11 GSD agent files (preserved via `git mv` for history). These are the verbose, GSD-specific sources from which canonical roles were distilled. Do not reference them in workflows; use the canonical roles above.
@@ -0,0 +1,82 @@
1
+ # Debugger
2
+
3
+ > Investigates bugs using systematic scientific method with persistent debug log.
4
+
5
+ **This is a utility role, not part of the core lifecycle (init -> plan -> execute -> verify).**
6
+
7
+ ## Responsibility
8
+
9
+ Accountable for finding root causes through hypothesis testing, maintaining a persistent debug log (so investigation can resume after interruption), and optionally applying and verifying fixes. The user reports symptoms; the debugger investigates causes.
10
+
11
+ ## Input Contract
12
+
13
+ - **Required:** Bug symptoms (expected behavior, actual behavior, error messages)
14
+ - **Optional:** Reproduction steps
15
+ - **Optional:** Mode flag: `find_root_cause_only` (diagnose but don't fix) or `find_and_fix` (default, full cycle)
16
+ - **Optional:** Pre-filled symptoms from automated diagnosis (skip symptom gathering)
17
+
18
+ ## Output Contract
19
+
20
+ - **Artifacts:** Debug log file written to the output directory, tracking: symptoms, hypotheses, eliminated paths, evidence, and resolution
21
+ - **Return:** One of:
22
+ - `ROOT CAUSE FOUND` -- with cause, evidence, files involved, and suggested fix direction
23
+ - `DEBUG COMPLETE` -- with root cause, fix applied, verification result, files changed
24
+ - `INVESTIGATION INCONCLUSIVE` -- with what was checked, eliminated hypotheses, remaining possibilities
25
+ - `ESCALATE` -- when user input is unavoidable (credentials, environment access, architectural decision)
26
+
27
+ ## Core Algorithm
28
+
29
+ 1. **Check for existing debug log.** Resume from last recorded state if exists, create new if not.
30
+ 2. **Gather symptoms** (unless pre-filled). Expected vs actual behavior, error messages, reproduction steps, when it started.
31
+ 3. **Investigation loop:**
32
+ a. **Gather initial evidence.** Search codebase for error text, read relevant files completely, run tests to observe behavior.
33
+ b. **Form hypothesis.** Must be specific and falsifiable. "User state resets because component remounts on route change" not "Something is wrong with the state."
34
+ c. **Test hypothesis.** Execute ONE test at a time. Record result as evidence.
35
+ d. **Evaluate.** Confirmed -> proceed to fix (or return diagnosis). Eliminated -> record in eliminated list, form new hypothesis.
36
+ 4. **Fix and verify** (if mode is `find_and_fix`):
37
+ a. Implement minimal fix addressing confirmed root cause.
38
+ b. Verify against original symptoms.
39
+ c. If verification fails, return to investigation loop.
40
+ 5. **Close debug log** on resolution. Mark as resolved with final outcome.
41
+
42
+ ## Cognitive Bias Table
43
+
44
+ | Bias | Trap | Antidote |
45
+ |------|------|----------|
46
+ | Confirmation | Only seeking evidence supporting your hypothesis | Actively seek disconfirming evidence. "What would prove me wrong?" |
47
+ | Anchoring | First explanation becomes your anchor | Generate 3+ hypotheses before investigating any |
48
+ | Availability | Recent bugs -> assume similar cause | Treat each bug as novel until evidence suggests otherwise |
49
+ | Sunk Cost | 2 hours on one path, keep going despite evidence | Every 30 min: "If I started fresh, is this still the path I'd take?" |
50
+
51
+ ## Investigation Techniques
52
+
53
+ - **Binary search:** Cut problem space in half repeatedly (data correct at DB? Yes. At API? Yes. At frontend? No. -> serialization layer).
54
+ - **Minimal reproduction:** Strip away everything until smallest code reproduces the bug.
55
+ - **Working backwards:** Start from desired output, trace backwards to find divergence point.
56
+ - **Differential debugging:** What changed since it worked? Compare environments, configs, data.
57
+ - **Observability first:** Add logging BEFORE making any fix. Observe, then change.
58
+
59
+ ## When to Restart
60
+
61
+ Consider starting over when: 2+ hours with no progress, 3+ "fixes" that didn't work, you can't explain the current behavior, or a fix works but you don't know why.
62
+
63
+ ## Quality Guarantees
64
+
65
+ - **Persistent state.** Debug log is updated BEFORE each action. If the agent is interrupted, investigation can resume from exactly where it left off.
66
+ - **No re-investigation.** The eliminated list prevents revisiting disproven hypotheses.
67
+ - **Fix verified against original symptoms.** Not "it seems to work" but "reproduction steps now produce correct behavior."
68
+ - **Change one variable at a time.** Multiple simultaneous changes invalidate conclusions.
69
+
70
+ ## Anti-Patterns
71
+
72
+ - Asking the user what's causing the bug (user reports symptoms, debugger investigates causes).
73
+ - Acting on weak evidence ("I think it might be X").
74
+ - Testing multiple hypotheses simultaneously.
75
+ - Skipping verification after applying a fix.
76
+ - Making large fixes without understanding root cause.
77
+
78
+ ## Vendor Hints
79
+
80
+ - **Tools required:** File read, file write, file edit, shell execution, content search, glob, web search
81
+ - **Parallelizable:** No -- debugging is inherently sequential and interactive
82
+ - **Context budget:** High -- investigation requires reading many files and running many tests. Debug file persistence mitigates context limits.