@sienklogic/plan-build-run 2.54.0 → 2.55.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 (127) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +1 -1
  3. package/plugins/codex-pbr/agents/audit.md +223 -0
  4. package/plugins/codex-pbr/agents/codebase-mapper.md +196 -0
  5. package/plugins/codex-pbr/agents/debugger.md +245 -0
  6. package/plugins/codex-pbr/agents/dev-sync.md +142 -0
  7. package/plugins/codex-pbr/agents/executor.md +429 -0
  8. package/plugins/codex-pbr/agents/general.md +131 -0
  9. package/plugins/codex-pbr/agents/integration-checker.md +178 -0
  10. package/plugins/codex-pbr/agents/plan-checker.md +253 -0
  11. package/plugins/codex-pbr/agents/planner.md +343 -0
  12. package/plugins/codex-pbr/agents/researcher.md +253 -0
  13. package/plugins/codex-pbr/agents/synthesizer.md +183 -0
  14. package/plugins/codex-pbr/agents/verifier.md +352 -0
  15. package/plugins/codex-pbr/commands/audit.md +5 -0
  16. package/plugins/codex-pbr/commands/begin.md +5 -0
  17. package/plugins/codex-pbr/commands/build.md +5 -0
  18. package/plugins/codex-pbr/commands/config.md +5 -0
  19. package/plugins/codex-pbr/commands/continue.md +5 -0
  20. package/plugins/codex-pbr/commands/dashboard.md +5 -0
  21. package/plugins/codex-pbr/commands/debug.md +5 -0
  22. package/plugins/codex-pbr/commands/discuss.md +5 -0
  23. package/plugins/codex-pbr/commands/do.md +5 -0
  24. package/plugins/codex-pbr/commands/explore.md +5 -0
  25. package/plugins/codex-pbr/commands/health.md +5 -0
  26. package/plugins/codex-pbr/commands/help.md +5 -0
  27. package/plugins/codex-pbr/commands/import.md +5 -0
  28. package/plugins/codex-pbr/commands/milestone.md +5 -0
  29. package/plugins/codex-pbr/commands/note.md +5 -0
  30. package/plugins/codex-pbr/commands/pause.md +5 -0
  31. package/plugins/codex-pbr/commands/plan.md +5 -0
  32. package/plugins/codex-pbr/commands/quick.md +5 -0
  33. package/plugins/codex-pbr/commands/resume.md +5 -0
  34. package/plugins/codex-pbr/commands/review.md +5 -0
  35. package/plugins/codex-pbr/commands/scan.md +5 -0
  36. package/plugins/codex-pbr/commands/setup.md +5 -0
  37. package/plugins/codex-pbr/commands/status.md +5 -0
  38. package/plugins/codex-pbr/commands/statusline.md +5 -0
  39. package/plugins/codex-pbr/commands/test.md +5 -0
  40. package/plugins/codex-pbr/commands/todo.md +5 -0
  41. package/plugins/codex-pbr/commands/undo.md +5 -0
  42. package/plugins/codex-pbr/references/agent-contracts.md +324 -0
  43. package/plugins/codex-pbr/references/agent-teams.md +54 -0
  44. package/plugins/codex-pbr/references/common-bug-patterns.md +13 -0
  45. package/plugins/codex-pbr/references/config-reference.md +552 -0
  46. package/plugins/codex-pbr/references/continuation-format.md +212 -0
  47. package/plugins/codex-pbr/references/deviation-rules.md +112 -0
  48. package/plugins/codex-pbr/references/git-integration.md +256 -0
  49. package/plugins/codex-pbr/references/integration-patterns.md +117 -0
  50. package/plugins/codex-pbr/references/model-profiles.md +99 -0
  51. package/plugins/codex-pbr/references/model-selection.md +31 -0
  52. package/plugins/codex-pbr/references/pbr-tools-cli.md +400 -0
  53. package/plugins/codex-pbr/references/plan-authoring.md +246 -0
  54. package/plugins/codex-pbr/references/plan-format.md +313 -0
  55. package/plugins/codex-pbr/references/questioning.md +235 -0
  56. package/plugins/codex-pbr/references/reading-verification.md +127 -0
  57. package/plugins/codex-pbr/references/signal-files.md +41 -0
  58. package/plugins/codex-pbr/references/stub-patterns.md +160 -0
  59. package/plugins/codex-pbr/references/ui-formatting.md +444 -0
  60. package/plugins/codex-pbr/references/wave-execution.md +95 -0
  61. package/plugins/codex-pbr/skills/audit/SKILL.md +346 -0
  62. package/plugins/codex-pbr/skills/begin/SKILL.md +800 -0
  63. package/plugins/codex-pbr/skills/build/SKILL.md +958 -0
  64. package/plugins/codex-pbr/skills/config/SKILL.md +267 -0
  65. package/plugins/codex-pbr/skills/continue/SKILL.md +172 -0
  66. package/plugins/codex-pbr/skills/dashboard/SKILL.md +44 -0
  67. package/plugins/codex-pbr/skills/debug/SKILL.md +530 -0
  68. package/plugins/codex-pbr/skills/discuss/SKILL.md +355 -0
  69. package/plugins/codex-pbr/skills/do/SKILL.md +68 -0
  70. package/plugins/codex-pbr/skills/explore/SKILL.md +407 -0
  71. package/plugins/codex-pbr/skills/health/SKILL.md +300 -0
  72. package/plugins/codex-pbr/skills/help/SKILL.md +229 -0
  73. package/plugins/codex-pbr/skills/import/SKILL.md +538 -0
  74. package/plugins/codex-pbr/skills/milestone/SKILL.md +620 -0
  75. package/plugins/codex-pbr/skills/note/SKILL.md +215 -0
  76. package/plugins/codex-pbr/skills/pause/SKILL.md +258 -0
  77. package/plugins/codex-pbr/skills/plan/SKILL.md +650 -0
  78. package/plugins/codex-pbr/skills/quick/SKILL.md +417 -0
  79. package/plugins/codex-pbr/skills/resume/SKILL.md +403 -0
  80. package/plugins/codex-pbr/skills/review/SKILL.md +669 -0
  81. package/plugins/codex-pbr/skills/scan/SKILL.md +325 -0
  82. package/plugins/codex-pbr/skills/setup/SKILL.md +169 -0
  83. package/plugins/codex-pbr/skills/shared/commit-planning-docs.md +35 -0
  84. package/plugins/codex-pbr/skills/shared/config-loading.md +102 -0
  85. package/plugins/codex-pbr/skills/shared/context-budget.md +77 -0
  86. package/plugins/codex-pbr/skills/shared/context-loader-task.md +86 -0
  87. package/plugins/codex-pbr/skills/shared/digest-select.md +79 -0
  88. package/plugins/codex-pbr/skills/shared/domain-probes.md +125 -0
  89. package/plugins/codex-pbr/skills/shared/error-reporting.md +59 -0
  90. package/plugins/codex-pbr/skills/shared/gate-prompts.md +388 -0
  91. package/plugins/codex-pbr/skills/shared/phase-argument-parsing.md +45 -0
  92. package/plugins/codex-pbr/skills/shared/revision-loop.md +81 -0
  93. package/plugins/codex-pbr/skills/shared/state-update.md +169 -0
  94. package/plugins/codex-pbr/skills/shared/universal-anti-patterns.md +43 -0
  95. package/plugins/codex-pbr/skills/status/SKILL.md +449 -0
  96. package/plugins/codex-pbr/skills/statusline/SKILL.md +149 -0
  97. package/plugins/codex-pbr/skills/test/SKILL.md +210 -0
  98. package/plugins/codex-pbr/skills/todo/SKILL.md +281 -0
  99. package/plugins/codex-pbr/skills/undo/SKILL.md +172 -0
  100. package/plugins/codex-pbr/templates/CONTEXT.md.tmpl +52 -0
  101. package/plugins/codex-pbr/templates/INTEGRATION-REPORT.md.tmpl +167 -0
  102. package/plugins/codex-pbr/templates/RESEARCH-SUMMARY.md.tmpl +97 -0
  103. package/plugins/codex-pbr/templates/ROADMAP.md.tmpl +47 -0
  104. package/plugins/codex-pbr/templates/SUMMARY-complex.md.tmpl +95 -0
  105. package/plugins/codex-pbr/templates/SUMMARY-minimal.md.tmpl +48 -0
  106. package/plugins/codex-pbr/templates/SUMMARY.md.tmpl +81 -0
  107. package/plugins/codex-pbr/templates/VERIFICATION-DETAIL.md.tmpl +117 -0
  108. package/plugins/codex-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  109. package/plugins/codex-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  110. package/plugins/codex-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  111. package/plugins/codex-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  112. package/plugins/codex-pbr/templates/codebase/STACK.md.tmpl +78 -0
  113. package/plugins/codex-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  114. package/plugins/codex-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  115. package/plugins/codex-pbr/templates/continue-here.md.tmpl +73 -0
  116. package/plugins/codex-pbr/templates/pr-body.md.tmpl +22 -0
  117. package/plugins/codex-pbr/templates/prompt-partials/phase-project-context.md.tmpl +37 -0
  118. package/plugins/codex-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  119. package/plugins/codex-pbr/templates/research/STACK.md.tmpl +71 -0
  120. package/plugins/codex-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  121. package/plugins/codex-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  122. package/plugins/codex-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  123. package/plugins/codex-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  124. package/plugins/copilot-pbr/plugin.json +1 -1
  125. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  126. package/plugins/jules-pbr/AGENTS.md +600 -0
  127. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
@@ -0,0 +1,530 @@
1
+ ---
2
+ name: debug
3
+ description: "Systematic debugging with hypothesis testing. Persistent across sessions."
4
+ ---
5
+
6
+ **STOP — DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's plugin system. Using the Read tool on this SKILL.md file wastes ~7,600 tokens. Begin executing Step 1 immediately.**
7
+
8
+ ## Step 0 — Immediate Output
9
+
10
+ **Before ANY tool calls**, display this banner:
11
+
12
+ ```
13
+ ╔══════════════════════════════════════════════════════════════╗
14
+ ║ PLAN-BUILD-RUN ► DEBUGGING ║
15
+ ╚══════════════════════════════════════════════════════════════╝
16
+ ```
17
+
18
+ Then proceed to Step 1.
19
+
20
+ # $pbr-debug — Systematic Debugging
21
+
22
+ You are running the **debug** skill. Your job is to run a structured, hypothesis-driven debugging session that persists across conversations. You track every hypothesis, test, and finding in a debug file so work is never lost.
23
+
24
+ This skill **spawns Task(subagent_type: "pbr:debugger")** for investigation work.
25
+
26
+ ---
27
+
28
+ ## Context Budget
29
+
30
+ Reference: `skills/shared/context-budget.md` for the universal orchestrator rules.
31
+
32
+ Additionally for this skill:
33
+ - **Never** perform investigation work yourself — delegate ALL analysis to the debugger subagent
34
+ - **Minimize** reading debug file content — read only the latest hypothesis and result section
35
+ - **Delegate** all code reading, hypothesis testing, and fix attempts to the debugger subagent
36
+
37
+ ---
38
+
39
+ ## Core Principle
40
+
41
+ **Debug systematically, not randomly.** Every investigation step must have a hypothesis, a test, and a recorded result. No "let me just try this" — every action has a reason and is documented.
42
+
43
+ ---
44
+
45
+ ## Flow
46
+
47
+ ### Step 1: Ensure Debug Directory Exists
48
+
49
+ Before any file operations, ensure both directories exist by running:
50
+
51
+ ```bash
52
+ mkdir -p .planning/debug
53
+ ```
54
+
55
+ This handles the case where neither `.planning/` nor `.planning/debug/` exist yet (debug can be run before other skills that create `.planning/`). Do NOT skip this step — writing files to a non-existent directory will fail.
56
+
57
+ ### Step 2: Check for Active Debug Sessions
58
+
59
+ **Load depth profile:** Run `node ${PLUGIN_ROOT}/scripts/pbr-tools.js config resolve-depth` to get `debug.max_hypothesis_rounds`. If the command fails (no config.json or CLI error), default to 5 rounds. Initialize a round counter at 0. This counter increments each time a continuation debugger is spawned.
60
+
61
+ Scan `.planning/debug/` for existing debug files:
62
+
63
+ ```
64
+ .planning/debug/
65
+ {NNN}-{slug}.md # Each debug session is a file
66
+ ```
67
+
68
+ Read each file's frontmatter to check status:
69
+ - `status: gathering` — collecting symptoms from user
70
+ - `status: investigating` — testing hypotheses
71
+ - `status: fixing` — applying fix
72
+ - `status: verifying` — confirming fix works
73
+ - `status: resolved` — session complete
74
+
75
+ **If active sessions found:**
76
+
77
+ Use the **debug-session-select** pattern from `skills/shared/gate-prompts.md`:
78
+ question: "Found active debug sessions. Which would you like?"
79
+
80
+ Generate options dynamically from active sessions:
81
+ - Each active session becomes an option: label "#{NNN}: {title}", description "Started {date}, last: {last hypothesis}"
82
+ - Always include "New session" as the last option: description "Start a fresh debug investigation"
83
+ - If more than 3 active sessions exist, show only the 3 most recent plus "New session" (max 4 options)
84
+
85
+ Handle responses:
86
+ - If user selects an existing session: go to **Resume Flow** (Step 3b)
87
+ - If user selects "New session": go to **New Session Flow** (Step 3a)
88
+ - If user types a session number not in the list: look it up and resume it
89
+
90
+ **If no active sessions found:**
91
+ - Go to **New Session Flow** (Step 3a)
92
+
93
+ ### Step 3a: New Session Flow
94
+
95
+ #### Gather Symptoms
96
+
97
+ If `$ARGUMENTS` is provided and descriptive:
98
+ - Use it as the initial issue description
99
+ - Still ask targeted follow-up questions
100
+
101
+ If `$ARGUMENTS` is empty or minimal:
102
+ - Ask the user for symptoms
103
+
104
+ **Symptom gathering questions** (ask as plain text — these are freeform, do NOT use AskUserQuestion):
105
+
106
+ 1. **Expected behavior**: "What should happen?"
107
+ 2. **Actual behavior**: "What actually happens? Include error messages if any."
108
+ 3. **Reproduction**: "How do you trigger this? Steps to reproduce?"
109
+ 4. **Onset**: "When did this start? Did anything change recently (new code, dependency update, config change)?"
110
+ 5. **Scope**: "Does this affect everything or just specific cases? Any patterns?"
111
+
112
+ **Optional follow-ups** (ask if relevant):
113
+ - "What have you already tried?"
114
+ - "Does this happen in all environments (dev, prod, test)?"
115
+ - "Any relevant log output?"
116
+
117
+ #### Generate Session ID
118
+
119
+ 1. Scan `.planning/debug/` for existing files
120
+ 2. Extract NNN prefixes
121
+ 3. Next number = highest + 1 (start at 001)
122
+ 4. Generate slug from issue title (same rules as quick task slugs)
123
+
124
+ #### Create Debug File
125
+
126
+ Create `.planning/debug/{NNN}-{slug}.md`:
127
+
128
+ ```markdown
129
+ ---
130
+ id: "{NNN}"
131
+ title: "{issue title}"
132
+ status: gathering
133
+ created: "{ISO date}"
134
+ updated: "{ISO date}"
135
+ severity: "{critical|high|medium|low}"
136
+ category: "{runtime|build|test|config|integration|unknown}"
137
+ ---
138
+
139
+ # Debug Session: {title}
140
+
141
+ ## Symptoms
142
+
143
+ **Expected:** {expected behavior}
144
+ **Actual:** {actual behavior}
145
+ **Reproduction:** {steps}
146
+ **Onset:** {when it started}
147
+ **Scope:** {affected areas}
148
+
149
+ ## Environment
150
+
151
+ - OS: {detected or reported}
152
+ - Runtime: {node version, python version, etc.}
153
+ - Relevant config: {any config that matters}
154
+
155
+ ## Investigation Log
156
+
157
+ ### Round 1 (automated)
158
+
159
+ {This section is filled by debugger}
160
+
161
+ ## Hypotheses
162
+
163
+ | # | Hypothesis | Status | Evidence |
164
+ |---|-----------|--------|----------|
165
+ | 1 | {hypothesis} | {testing/confirmed/rejected} | {evidence} |
166
+
167
+ ## Root Cause
168
+
169
+ {Filled when found}
170
+
171
+ ## Fix Applied
172
+
173
+ {Filled when fixed}
174
+
175
+ ## Timeline
176
+
177
+ - {ISO date}: Session created
178
+ ```
179
+
180
+ #### Spawn Debugger
181
+
182
+ Display to the user: `◐ Spawning debugger...`
183
+
184
+ Spawn `Task(subagent_type: "pbr:debugger")` with the prompt template.
185
+
186
+ Read `skills/debug/templates/initial-investigation-prompt.md.tmpl` for the spawn prompt. Fill in the `{NNN}`, `{slug}`, and symptom placeholders with values from the debug file created above.
187
+
188
+ ### Step 3b: Resume Flow
189
+
190
+ 1. Read the debug file content
191
+ 2. Parse the investigation log and hypotheses table
192
+ 3. Display to user:
193
+
194
+ ```
195
+ Resuming debug session #{NNN}: {title}
196
+
197
+ Last state:
198
+ - Hypotheses tested: {N}
199
+ - Confirmed: {list or "none yet"}
200
+ - Rejected: {list}
201
+ - Current lead: {most promising hypothesis}
202
+
203
+ Continuing investigation...
204
+ ```
205
+
206
+ 4. **Increment the round counter** (resuming counts as a new round). Display to the user: `◐ Spawning debugger (resuming session #{NNN}, round {N})...`
207
+
208
+ Spawn `Task(subagent_type: "pbr:debugger")` with the continuation prompt template.
209
+
210
+ Read `skills/debug/templates/continuation-prompt.md.tmpl` for the spawn prompt. Fill in the `{NNN}`, `{slug}`, and `{paste investigation log...}` placeholders with data from the debug file.
211
+
212
+ ### Step 4: Handle Debugger Results
213
+
214
+ When the debugger agent completes, first check for completion markers in the Task() output before routing:
215
+
216
+ | Marker in Task() Output | Route To |
217
+ |--------------------------|----------|
218
+ | `## DEBUG COMPLETE` | ROOT CAUSE FOUND + FIX path |
219
+ | `## ROOT CAUSE FOUND` | ROOT CAUSE FOUND (no fix) path |
220
+ | `## DEBUG SESSION PAUSED` | CHECKPOINT path |
221
+ | No marker found | INCONCLUSIVE path |
222
+
223
+ **Spot-check:** Before routing, verify `.planning/debug/{NNN}-{slug}.md` exists and was recently updated (modified timestamp is newer than the Task() spawn time). If the debug file was not updated, warn: `⚠ Debug file not updated by agent — results may be incomplete.`
224
+
225
+ Display: `✓ Debug session complete — {N} hypotheses tested` (read the hypothesis count from the debug file's Hypotheses table).
226
+
227
+ The debugger returns one of four outcomes:
228
+
229
+ #### ROOT CAUSE FOUND + FIX
230
+
231
+ ```
232
+ Root cause identified: {cause}
233
+ Fix applied: {description}
234
+ Commit: {hash}
235
+ ```
236
+
237
+ Actions:
238
+ 1. Update debug file:
239
+ - Set `status: resolved`
240
+ - Fill "Root Cause" section
241
+ - Fill "Fix Applied" section
242
+ - Add timeline entry
243
+ 2. Update STATE.md if it has a Debug Sessions section
244
+ 3. Report to user with branded output:
245
+
246
+ ```
247
+ ╔══════════════════════════════════════════════════════════════╗
248
+ ║ PLAN-BUILD-RUN ► BUG RESOLVED ✓ ║
249
+ ╚══════════════════════════════════════════════════════════════╝
250
+
251
+ **Session #{NNN}:** {title}
252
+ **Root cause:** {cause}
253
+ **Fix:** {description}
254
+ **Commit:** {hash}
255
+
256
+
257
+
258
+ ╔══════════════════════════════════════════════════════════════╗
259
+ ║ ▶ NEXT UP ║
260
+ ╚══════════════════════════════════════════════════════════════╝
261
+
262
+ **Continue your workflow** — the bug is fixed
263
+
264
+ `$pbr-status`
265
+
266
+ <sub>`/clear` first → fresh context window</sub>
267
+
268
+
269
+
270
+ **Also available:**
271
+ - `$pbr-continue` — execute next logical step
272
+ - `$pbr-review {N}` — verify the current phase
273
+
274
+
275
+ ```
276
+
277
+ #### ROOT CAUSE FOUND (no fix)
278
+
279
+ Used when the debugger was invoked with `find_root_cause_only` or when the fix is too complex for auto-application.
280
+
281
+ ```
282
+ Root cause identified: {cause}
283
+ Suggested fix: {approach}
284
+ ```
285
+
286
+ Actions:
287
+ 1. Update debug file:
288
+ - Set `status: resolved`
289
+ - Fill "Root Cause" section
290
+ - Add suggested fix to notes
291
+ 2. Suggest next steps to user:
292
+
293
+ ```
294
+
295
+
296
+ ╔══════════════════════════════════════════════════════════════╗
297
+ ║ ▶ NEXT UP ║
298
+ ╚══════════════════════════════════════════════════════════════╝
299
+
300
+ **Apply the fix** — root cause identified, fix needed
301
+
302
+ `$pbr-quick {fix description}`
303
+
304
+ <sub>`/clear` first → fresh context window</sub>
305
+
306
+
307
+
308
+ **Also available:**
309
+ - `$pbr-plan` — for complex fixes that need planning
310
+ - `$pbr-status` — see project status
311
+
312
+
313
+ ```
314
+
315
+ #### CHECKPOINT
316
+
317
+ The debugger found something but needs user input or more investigation.
318
+
319
+ ```
320
+ Investigation progress:
321
+ - Tested: {hypotheses tested}
322
+ - Found: {key finding}
323
+ - Need: {what's needed to continue}
324
+ ```
325
+
326
+ Actions:
327
+ 1. Update debug file with findings so far
328
+ 2. Present checkpoint to user
329
+ 3. Use the **debug-checkpoint** pattern from `skills/shared/gate-prompts.md`:
330
+ question: "Investigation has reached a checkpoint. How should we proceed?"
331
+
332
+ Handle responses:
333
+ - "Continue": **Increment the round counter** (e.g., round 1 becomes round 2). Then display `◐ Spawning debugger (continuing investigation, round {N})...` and spawn another `Task(subagent_type: "pbr:debugger")` with updated context from the debug file
334
+ - "More info": **Increment the round counter.** Ask the user freeform what additional context they have, then update the debug file and spawn another debugger
335
+ - "New approach": **Increment the round counter.** Ask the user freeform what alternative angle to try, then update hypotheses and spawn another debugger
336
+
337
+ #### INCONCLUSIVE
338
+
339
+ The debugger exhausted its hypotheses without finding the root cause.
340
+
341
+ ```
342
+ Investigation exhausted:
343
+ - Tested: {all hypotheses}
344
+ - Rejected: {list}
345
+ - Remaining unknowns: {list}
346
+ ```
347
+
348
+ Actions:
349
+ 1. Update debug file with all findings
350
+ 2. Report to user:
351
+ - What was tested and eliminated
352
+ - What remains unknown
353
+ - Suggested next investigation approaches:
354
+ - Different reproduction steps
355
+ - Log-level debugging
356
+ - Environment comparison
357
+ - Bisect (git bisect to find the breaking commit)
358
+ - External help (stack overflow, docs)
359
+ 3. Keep session active for future resumption
360
+
361
+ ---
362
+
363
+ ## Debugger Investigation Protocol
364
+
365
+ The debugger agent follows this protocol internally:
366
+
367
+ ### Hypothesis-Driven Investigation
368
+
369
+ ```
370
+ 1. OBSERVE: Read error messages, logs, code around the failure point
371
+ 2. HYPOTHESIZE: "The most likely cause is X because Y"
372
+ 3. PREDICT: "If X is the cause, then test Z should show W"
373
+ 4. TEST: Execute test Z
374
+ 5. EVALUATE:
375
+ - Result matches prediction → hypothesis supported → investigate deeper
376
+ - Result contradicts → hypothesis rejected → try next hypothesis
377
+ - Result is unexpected → new information → form new hypothesis
378
+ ```
379
+
380
+ ### Investigation Techniques
381
+
382
+ | Technique | When to Use |
383
+ |-----------|------------|
384
+ | **Stack trace analysis** | Error with stack trace available |
385
+ | **Code path tracing** | Logic error, wrong behavior |
386
+ | **Log injection** | Need to see runtime values |
387
+ | **Binary search** | Know it worked before, need to find when it broke |
388
+ | **Isolation** | Complex system, need to narrow scope |
389
+ | **Comparison** | Works in one case, fails in another |
390
+ | **Dependency audit** | Recent dependency changes |
391
+ | **Config diff** | Works in one environment, not another |
392
+
393
+ ### Evidence Quality
394
+
395
+ | Quality | Description | Action |
396
+ |---------|-------------|--------|
397
+ | **Strong** | Directly proves/disproves hypothesis | Record and move on |
398
+ | **Moderate** | Suggests but doesn't prove | Record, seek corroboration |
399
+ | **Weak** | Tangentially related | Note but don't base decisions on it |
400
+ | **Misleading** | Red herring | Record as eliminated, explain why |
401
+
402
+ ### Hypothesis Round Limit
403
+
404
+ The maximum number of investigation rounds is controlled by the depth profile's `debug.max_hypothesis_rounds` setting:
405
+ - `quick`: 3 rounds (fast, surface-level investigation)
406
+ - `standard`: 5 rounds (default)
407
+ - `comprehensive`: 10 rounds (deep investigation)
408
+
409
+ The orchestrator tracks the round count. Before spawning each continuation debugger (Step 4 "CHECKPOINT" -> "Continue"), increment the round counter. If the counter reaches the limit:
410
+ - Do NOT spawn another debugger
411
+ - Present to user: "Debug session has reached the hypothesis round limit ({N} rounds for {depth} mode). Options:"
412
+
413
+ Use AskUserQuestion:
414
+ question: "Reached {N}-round hypothesis limit. How should we proceed?"
415
+ header: "Debug Limit"
416
+ options:
417
+ - label: "Extend" description: "Allow {N} more rounds (doubles the limit)"
418
+ - label: "Wrap up" description: "Record findings so far and close the session"
419
+ - label: "Escalate" description: "Save context for manual debugging"
420
+
421
+ - If "Extend": double the limit and continue
422
+ - If "Wrap up": update debug file `status: resolved` with `resolution: abandoned`, record all findings, suggest next steps
423
+ - If "Escalate": write a detailed handoff document to the debug file with all hypotheses, evidence, and suggested manual investigation steps
424
+
425
+ ---
426
+
427
+ ## Debug File Management
428
+
429
+ ### Lifecycle
430
+
431
+ ```
432
+ gathering → investigating → fixing → verifying → resolved
433
+ (any non-resolved) → resolved (with resolution: abandoned, if 7+ days stale)
434
+ (any non-resolved) → (same) (resumed after pause)
435
+ ```
436
+
437
+ ### Staleness Detection
438
+
439
+ When scanning for active sessions, check the `updated` date. If more than 7 days old:
440
+ - Set `status: resolved` with `resolution: abandoned` in frontmatter
441
+ - Still offer to resume, but warn: "This session is {N} days old. Context may have changed."
442
+
443
+ ### Cleanup
444
+
445
+ Old resolved debug files can accumulate. They serve as a knowledge base for similar issues. Do NOT auto-delete them.
446
+
447
+ ---
448
+
449
+ ## State Integration
450
+
451
+ Update STATE.md Debug Sessions section (create if needed):
452
+
453
+ ```markdown
454
+ ### Debug Sessions
455
+
456
+ | # | Issue | Status | Root Cause |
457
+ |---|-------|--------|------------|
458
+ | 001 | Login timeout | resolved | DB connection pool exhausted |
459
+ | 002 | CSS not loading | active | investigating |
460
+ ```
461
+
462
+ ---
463
+
464
+ ## Git Integration
465
+
466
+ Reference: `skills/shared/commit-planning-docs.md` for the standard commit pattern.
467
+
468
+ If `planning.commit_docs: true` in config.json:
469
+ - New session: `docs(planning): open debug session {NNN} - {slug}`
470
+ - Resolution: `docs(planning): resolve debug session {NNN} - {root cause summary}`
471
+ - Fix commits use standard format: `fix({scope}): {description}`
472
+
473
+ ---
474
+
475
+ ## Edge Cases
476
+
477
+ ### User provides a stack trace or error in arguments
478
+ - Parse it as the "Actual behavior" symptom
479
+ - Extract key information: error type, file, line number
480
+ - Use this to form initial hypotheses immediately
481
+
482
+ ### Debugger agent fails
483
+ If the debugger Task() fails or returns an error, display:
484
+ ```
485
+ ╔══════════════════════════════════════════════════════════════╗
486
+ ║ ERROR ║
487
+ ╚══════════════════════════════════════════════════════════════╝
488
+
489
+ Debugger agent failed for session #{NNN}.
490
+
491
+ **To fix:**
492
+ - Check the debug file at `.planning/debug/{NNN}-{slug}.md` for partial findings
493
+ - Re-run with `$pbr-debug` to resume the session
494
+ - If the issue persists, try a fresh session with different symptom details
495
+ ```
496
+
497
+ ### Issue is in a dependency (not user code)
498
+ - Document which dependency and version
499
+ - Check if there's a known issue (search patterns in node_modules, site-packages, etc.)
500
+ - Suggest: update dependency, pin version, or work around
501
+
502
+ ### Issue is intermittent
503
+ - Note intermittency in symptoms
504
+ - Suggest: run multiple times, add timing/logging, check for race conditions
505
+ - Investigation must account for non-deterministic reproduction
506
+
507
+ ### Multiple issues interacting
508
+ - If investigation reveals multiple separate issues, split into separate debug sessions
509
+ - Create additional debug files
510
+ - Track each independently
511
+
512
+ ### Fix would be a breaking change
513
+ - Report the root cause but DO NOT auto-apply the fix
514
+ - Present the trade-offs to the user
515
+ - Let the user decide how to proceed
516
+
517
+ ---
518
+
519
+ ## Anti-Patterns
520
+
521
+ 1. **DO NOT** skip hypothesis formation — every test must have a reason
522
+ 2. **DO NOT** make random changes hoping something works
523
+ 3. **DO NOT** ignore failed hypotheses — record why they failed
524
+ 4. **DO NOT** exceed the depth profile's `debug.max_hypothesis_rounds` limit without user confirmation (default: 5 for standard mode)
525
+ 5. **DO NOT** fix the symptom instead of the root cause
526
+ 6. **DO NOT** auto-apply fixes for breaking changes
527
+ 7. **DO NOT** delete debug files — they're a knowledge base
528
+ 8. **DO NOT** combine multiple bugs into one debug session
529
+ 9. **DO NOT** skip updating the debug file after each investigation round
530
+ 10. **DO NOT** start a new session when an active one covers the same issue