@sienklogic/plan-build-run 2.0.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 (221) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/CLAUDE.md +149 -0
  3. package/LICENSE +21 -0
  4. package/README.md +247 -0
  5. package/dashboard/bin/cli.js +25 -0
  6. package/dashboard/package.json +34 -0
  7. package/dashboard/public/.gitkeep +0 -0
  8. package/dashboard/public/css/layout.css +406 -0
  9. package/dashboard/public/css/status-colors.css +98 -0
  10. package/dashboard/public/js/htmx-title.js +5 -0
  11. package/dashboard/public/js/sidebar-toggle.js +20 -0
  12. package/dashboard/src/app.js +78 -0
  13. package/dashboard/src/middleware/errorHandler.js +52 -0
  14. package/dashboard/src/middleware/notFoundHandler.js +9 -0
  15. package/dashboard/src/repositories/planning.repository.js +128 -0
  16. package/dashboard/src/routes/events.routes.js +40 -0
  17. package/dashboard/src/routes/index.routes.js +31 -0
  18. package/dashboard/src/routes/pages.routes.js +195 -0
  19. package/dashboard/src/server.js +42 -0
  20. package/dashboard/src/services/dashboard.service.js +222 -0
  21. package/dashboard/src/services/phase.service.js +167 -0
  22. package/dashboard/src/services/project.service.js +57 -0
  23. package/dashboard/src/services/roadmap.service.js +171 -0
  24. package/dashboard/src/services/sse.service.js +58 -0
  25. package/dashboard/src/services/todo.service.js +254 -0
  26. package/dashboard/src/services/watcher.service.js +48 -0
  27. package/dashboard/src/views/coming-soon.ejs +11 -0
  28. package/dashboard/src/views/error.ejs +13 -0
  29. package/dashboard/src/views/index.ejs +5 -0
  30. package/dashboard/src/views/layout.ejs +1 -0
  31. package/dashboard/src/views/partials/dashboard-content.ejs +77 -0
  32. package/dashboard/src/views/partials/footer.ejs +3 -0
  33. package/dashboard/src/views/partials/head.ejs +21 -0
  34. package/dashboard/src/views/partials/header.ejs +12 -0
  35. package/dashboard/src/views/partials/layout-bottom.ejs +15 -0
  36. package/dashboard/src/views/partials/layout-top.ejs +8 -0
  37. package/dashboard/src/views/partials/phase-content.ejs +181 -0
  38. package/dashboard/src/views/partials/phases-content.ejs +117 -0
  39. package/dashboard/src/views/partials/roadmap-content.ejs +142 -0
  40. package/dashboard/src/views/partials/sidebar.ejs +38 -0
  41. package/dashboard/src/views/partials/todo-create-content.ejs +53 -0
  42. package/dashboard/src/views/partials/todo-detail-content.ejs +38 -0
  43. package/dashboard/src/views/partials/todos-content.ejs +53 -0
  44. package/dashboard/src/views/phase-detail.ejs +5 -0
  45. package/dashboard/src/views/phases.ejs +5 -0
  46. package/dashboard/src/views/roadmap.ejs +5 -0
  47. package/dashboard/src/views/todo-create.ejs +5 -0
  48. package/dashboard/src/views/todo-detail.ejs +5 -0
  49. package/dashboard/src/views/todos.ejs +5 -0
  50. package/package.json +57 -0
  51. package/plugins/pbr/.claude-plugin/plugin.json +13 -0
  52. package/plugins/pbr/UI-CONSISTENCY-GAPS.md +61 -0
  53. package/plugins/pbr/agents/codebase-mapper.md +271 -0
  54. package/plugins/pbr/agents/debugger.md +281 -0
  55. package/plugins/pbr/agents/executor.md +407 -0
  56. package/plugins/pbr/agents/general.md +164 -0
  57. package/plugins/pbr/agents/integration-checker.md +141 -0
  58. package/plugins/pbr/agents/plan-checker.md +280 -0
  59. package/plugins/pbr/agents/planner.md +358 -0
  60. package/plugins/pbr/agents/researcher.md +363 -0
  61. package/plugins/pbr/agents/synthesizer.md +230 -0
  62. package/plugins/pbr/agents/verifier.md +454 -0
  63. package/plugins/pbr/commands/begin.md +5 -0
  64. package/plugins/pbr/commands/build.md +5 -0
  65. package/plugins/pbr/commands/config.md +5 -0
  66. package/plugins/pbr/commands/continue.md +5 -0
  67. package/plugins/pbr/commands/debug.md +5 -0
  68. package/plugins/pbr/commands/discuss.md +5 -0
  69. package/plugins/pbr/commands/explore.md +5 -0
  70. package/plugins/pbr/commands/health.md +5 -0
  71. package/plugins/pbr/commands/help.md +5 -0
  72. package/plugins/pbr/commands/import.md +5 -0
  73. package/plugins/pbr/commands/milestone.md +5 -0
  74. package/plugins/pbr/commands/note.md +5 -0
  75. package/plugins/pbr/commands/pause.md +5 -0
  76. package/plugins/pbr/commands/plan.md +5 -0
  77. package/plugins/pbr/commands/quick.md +5 -0
  78. package/plugins/pbr/commands/resume.md +5 -0
  79. package/plugins/pbr/commands/review.md +5 -0
  80. package/plugins/pbr/commands/scan.md +5 -0
  81. package/plugins/pbr/commands/setup.md +5 -0
  82. package/plugins/pbr/commands/status.md +5 -0
  83. package/plugins/pbr/commands/todo.md +5 -0
  84. package/plugins/pbr/contexts/dev.md +27 -0
  85. package/plugins/pbr/contexts/research.md +28 -0
  86. package/plugins/pbr/contexts/review.md +36 -0
  87. package/plugins/pbr/hooks/hooks.json +183 -0
  88. package/plugins/pbr/references/agent-anti-patterns.md +24 -0
  89. package/plugins/pbr/references/agent-interactions.md +134 -0
  90. package/plugins/pbr/references/agent-teams.md +54 -0
  91. package/plugins/pbr/references/checkpoints.md +157 -0
  92. package/plugins/pbr/references/common-bug-patterns.md +13 -0
  93. package/plugins/pbr/references/continuation-format.md +212 -0
  94. package/plugins/pbr/references/deviation-rules.md +112 -0
  95. package/plugins/pbr/references/git-integration.md +226 -0
  96. package/plugins/pbr/references/integration-patterns.md +117 -0
  97. package/plugins/pbr/references/model-profiles.md +99 -0
  98. package/plugins/pbr/references/model-selection.md +31 -0
  99. package/plugins/pbr/references/pbr-rules.md +193 -0
  100. package/plugins/pbr/references/plan-authoring.md +181 -0
  101. package/plugins/pbr/references/plan-format.md +283 -0
  102. package/plugins/pbr/references/planning-config.md +213 -0
  103. package/plugins/pbr/references/questioning.md +214 -0
  104. package/plugins/pbr/references/reading-verification.md +127 -0
  105. package/plugins/pbr/references/stub-patterns.md +160 -0
  106. package/plugins/pbr/references/subagent-coordination.md +119 -0
  107. package/plugins/pbr/references/ui-formatting.md +399 -0
  108. package/plugins/pbr/references/verification-patterns.md +198 -0
  109. package/plugins/pbr/references/wave-execution.md +95 -0
  110. package/plugins/pbr/scripts/auto-continue.js +80 -0
  111. package/plugins/pbr/scripts/check-dangerous-commands.js +136 -0
  112. package/plugins/pbr/scripts/check-doc-sprawl.js +102 -0
  113. package/plugins/pbr/scripts/check-phase-boundary.js +196 -0
  114. package/plugins/pbr/scripts/check-plan-format.js +270 -0
  115. package/plugins/pbr/scripts/check-roadmap-sync.js +252 -0
  116. package/plugins/pbr/scripts/check-skill-workflow.js +262 -0
  117. package/plugins/pbr/scripts/check-state-sync.js +476 -0
  118. package/plugins/pbr/scripts/check-subagent-output.js +144 -0
  119. package/plugins/pbr/scripts/config-schema.json +251 -0
  120. package/plugins/pbr/scripts/context-budget-check.js +287 -0
  121. package/plugins/pbr/scripts/event-handler.js +151 -0
  122. package/plugins/pbr/scripts/event-logger.js +92 -0
  123. package/plugins/pbr/scripts/hook-logger.js +76 -0
  124. package/plugins/pbr/scripts/hooks-schema.json +79 -0
  125. package/plugins/pbr/scripts/log-subagent.js +152 -0
  126. package/plugins/pbr/scripts/log-tool-failure.js +88 -0
  127. package/plugins/pbr/scripts/pbr-tools.js +1301 -0
  128. package/plugins/pbr/scripts/post-write-dispatch.js +66 -0
  129. package/plugins/pbr/scripts/post-write-quality.js +207 -0
  130. package/plugins/pbr/scripts/pre-bash-dispatch.js +56 -0
  131. package/plugins/pbr/scripts/pre-write-dispatch.js +62 -0
  132. package/plugins/pbr/scripts/progress-tracker.js +228 -0
  133. package/plugins/pbr/scripts/session-cleanup.js +254 -0
  134. package/plugins/pbr/scripts/status-line.js +285 -0
  135. package/plugins/pbr/scripts/suggest-compact.js +119 -0
  136. package/plugins/pbr/scripts/task-completed.js +45 -0
  137. package/plugins/pbr/scripts/track-context-budget.js +119 -0
  138. package/plugins/pbr/scripts/validate-commit.js +200 -0
  139. package/plugins/pbr/scripts/validate-plugin-structure.js +172 -0
  140. package/plugins/pbr/skills/begin/SKILL.md +545 -0
  141. package/plugins/pbr/skills/begin/templates/PROJECT.md.tmpl +33 -0
  142. package/plugins/pbr/skills/begin/templates/REQUIREMENTS.md.tmpl +18 -0
  143. package/plugins/pbr/skills/begin/templates/STATE.md.tmpl +49 -0
  144. package/plugins/pbr/skills/begin/templates/config.json.tmpl +63 -0
  145. package/plugins/pbr/skills/begin/templates/researcher-prompt.md.tmpl +19 -0
  146. package/plugins/pbr/skills/begin/templates/roadmap-prompt.md.tmpl +30 -0
  147. package/plugins/pbr/skills/begin/templates/synthesis-prompt.md.tmpl +16 -0
  148. package/plugins/pbr/skills/build/SKILL.md +962 -0
  149. package/plugins/pbr/skills/config/SKILL.md +241 -0
  150. package/plugins/pbr/skills/continue/SKILL.md +127 -0
  151. package/plugins/pbr/skills/debug/SKILL.md +489 -0
  152. package/plugins/pbr/skills/debug/templates/continuation-prompt.md.tmpl +16 -0
  153. package/plugins/pbr/skills/debug/templates/initial-investigation-prompt.md.tmpl +27 -0
  154. package/plugins/pbr/skills/discuss/SKILL.md +338 -0
  155. package/plugins/pbr/skills/discuss/templates/CONTEXT.md.tmpl +61 -0
  156. package/plugins/pbr/skills/discuss/templates/decision-categories.md +9 -0
  157. package/plugins/pbr/skills/explore/SKILL.md +362 -0
  158. package/plugins/pbr/skills/health/SKILL.md +186 -0
  159. package/plugins/pbr/skills/health/templates/check-pattern.md.tmpl +30 -0
  160. package/plugins/pbr/skills/health/templates/output-format.md.tmpl +63 -0
  161. package/plugins/pbr/skills/help/SKILL.md +140 -0
  162. package/plugins/pbr/skills/import/SKILL.md +490 -0
  163. package/plugins/pbr/skills/milestone/SKILL.md +673 -0
  164. package/plugins/pbr/skills/milestone/templates/audit-report.md.tmpl +48 -0
  165. package/plugins/pbr/skills/milestone/templates/stats-file.md.tmpl +30 -0
  166. package/plugins/pbr/skills/note/SKILL.md +212 -0
  167. package/plugins/pbr/skills/pause/SKILL.md +235 -0
  168. package/plugins/pbr/skills/pause/templates/continue-here.md.tmpl +71 -0
  169. package/plugins/pbr/skills/plan/SKILL.md +628 -0
  170. package/plugins/pbr/skills/plan/decimal-phase-calc.md +98 -0
  171. package/plugins/pbr/skills/plan/templates/checker-prompt.md.tmpl +21 -0
  172. package/plugins/pbr/skills/plan/templates/gap-closure-prompt.md.tmpl +32 -0
  173. package/plugins/pbr/skills/plan/templates/planner-prompt.md.tmpl +38 -0
  174. package/plugins/pbr/skills/plan/templates/researcher-prompt.md.tmpl +19 -0
  175. package/plugins/pbr/skills/plan/templates/revision-prompt.md.tmpl +23 -0
  176. package/plugins/pbr/skills/quick/SKILL.md +335 -0
  177. package/plugins/pbr/skills/resume/SKILL.md +388 -0
  178. package/plugins/pbr/skills/review/SKILL.md +652 -0
  179. package/plugins/pbr/skills/review/templates/debugger-prompt.md.tmpl +60 -0
  180. package/plugins/pbr/skills/review/templates/gap-planner-prompt.md.tmpl +40 -0
  181. package/plugins/pbr/skills/review/templates/verifier-prompt.md.tmpl +115 -0
  182. package/plugins/pbr/skills/scan/SKILL.md +269 -0
  183. package/plugins/pbr/skills/scan/templates/mapper-prompt.md.tmpl +201 -0
  184. package/plugins/pbr/skills/setup/SKILL.md +227 -0
  185. package/plugins/pbr/skills/shared/commit-planning-docs.md +35 -0
  186. package/plugins/pbr/skills/shared/config-loading.md +102 -0
  187. package/plugins/pbr/skills/shared/context-budget.md +40 -0
  188. package/plugins/pbr/skills/shared/context-loader-task.md +86 -0
  189. package/plugins/pbr/skills/shared/digest-select.md +79 -0
  190. package/plugins/pbr/skills/shared/domain-probes.md +125 -0
  191. package/plugins/pbr/skills/shared/error-reporting.md +79 -0
  192. package/plugins/pbr/skills/shared/gate-prompts.md +388 -0
  193. package/plugins/pbr/skills/shared/phase-argument-parsing.md +45 -0
  194. package/plugins/pbr/skills/shared/progress-display.md +53 -0
  195. package/plugins/pbr/skills/shared/revision-loop.md +81 -0
  196. package/plugins/pbr/skills/shared/state-loading.md +62 -0
  197. package/plugins/pbr/skills/shared/state-update.md +161 -0
  198. package/plugins/pbr/skills/shared/universal-anti-patterns.md +33 -0
  199. package/plugins/pbr/skills/status/SKILL.md +353 -0
  200. package/plugins/pbr/skills/todo/SKILL.md +181 -0
  201. package/plugins/pbr/templates/CONTEXT.md.tmpl +52 -0
  202. package/plugins/pbr/templates/INTEGRATION-REPORT.md.tmpl +151 -0
  203. package/plugins/pbr/templates/RESEARCH-SUMMARY.md.tmpl +97 -0
  204. package/plugins/pbr/templates/ROADMAP.md.tmpl +40 -0
  205. package/plugins/pbr/templates/SUMMARY.md.tmpl +81 -0
  206. package/plugins/pbr/templates/VERIFICATION-DETAIL.md.tmpl +116 -0
  207. package/plugins/pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  208. package/plugins/pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  209. package/plugins/pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  210. package/plugins/pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  211. package/plugins/pbr/templates/codebase/STACK.md.tmpl +78 -0
  212. package/plugins/pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  213. package/plugins/pbr/templates/codebase/TESTING.md.tmpl +107 -0
  214. package/plugins/pbr/templates/continue-here.md.tmpl +73 -0
  215. package/plugins/pbr/templates/prompt-partials/phase-project-context.md.tmpl +37 -0
  216. package/plugins/pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  217. package/plugins/pbr/templates/research/STACK.md.tmpl +71 -0
  218. package/plugins/pbr/templates/research/SUMMARY.md.tmpl +112 -0
  219. package/plugins/pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  220. package/plugins/pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  221. package/plugins/pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
@@ -0,0 +1,489 @@
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
@@ -0,0 +1,16 @@
1
+ <!-- Source: skills/debug/SKILL.md | Purpose: Spawn prompt for continuation debugger investigation -->
2
+ You are debugger. Continue investigating the following issue.
3
+
4
+ Debug file: .planning/debug/{NNN}-{slug}.md
5
+ Mode: continuation
6
+
7
+ Previous findings:
8
+ {paste investigation log and hypotheses from the debug file}
9
+
10
+ Instructions:
11
+ 1. Read the debug file for full context
12
+ 2. Review what's already been tested
13
+ 3. Formulate NEW hypotheses based on prior findings
14
+ 4. Continue systematic investigation
15
+ 5. Update the debug file
16
+ 6. Return: ROOT_CAUSE_FOUND, CHECKPOINT, or INCONCLUSIVE
@@ -0,0 +1,27 @@
1
+ <!-- Source: skills/debug/SKILL.md | Purpose: Spawn prompt for initial debugger investigation -->
2
+ You are debugger. Investigate the following issue systematically.
3
+
4
+ Debug file: .planning/debug/{NNN}-{slug}.md
5
+ Mode: initial_investigation
6
+
7
+ Symptoms:
8
+ - Expected: {expected}
9
+ - Actual: {actual}
10
+ - Reproduction: {steps}
11
+ - Onset: {onset}
12
+ - Scope: {scope}
13
+
14
+ Instructions:
15
+ 1. Read the debug file for full context
16
+ 2. Formulate 2-3 initial hypotheses based on symptoms
17
+ 3. For each hypothesis:
18
+ a. State what you're testing and why
19
+ b. Design a specific test (command, code inspection, log check)
20
+ c. Execute the test
21
+ d. Record the result (confirmed, rejected, inconclusive)
22
+ 4. Update the debug file with findings
23
+ 5. Return one of:
24
+ - ROOT_CAUSE_FOUND: {cause} + FIX: {what to change}
25
+ - ROOT_CAUSE_FOUND: {cause} (if find_root_cause_only mode)
26
+ - CHECKPOINT: {what was found, what to investigate next}
27
+ - INCONCLUSIVE: {findings so far, suggested next approaches}