@sienklogic/plan-build-run 2.0.0 → 2.0.2

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