pan-wizard 3.33.0 → 3.34.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 (197) hide show
  1. package/README.md +23 -20
  2. package/agents/pan-conductor.md +17 -16
  3. package/agents/pan-counterfactual.md +2 -2
  4. package/agents/pan-debugger.md +27 -8
  5. package/agents/pan-design-checker.md +1 -1
  6. package/agents/pan-designer.md +2 -2
  7. package/agents/pan-distiller.md +3 -3
  8. package/agents/pan-document_code.md +14 -14
  9. package/agents/pan-executor.md +12 -8
  10. package/agents/pan-experiment-runner.md +8 -7
  11. package/agents/pan-integration-checker.md +2 -2
  12. package/agents/pan-knowledge.md +1 -1
  13. package/agents/pan-meta-reviewer.md +3 -3
  14. package/agents/pan-optimizer.md +39 -43
  15. package/agents/pan-phase-researcher.md +8 -8
  16. package/agents/pan-plan-checker.md +30 -28
  17. package/agents/pan-planner.md +54 -43
  18. package/agents/pan-previewer.md +1 -1
  19. package/agents/pan-project-researcher.md +11 -11
  20. package/agents/pan-release.md +1 -1
  21. package/agents/pan-research-synthesizer.md +2 -2
  22. package/agents/pan-reviewer.md +24 -2
  23. package/agents/pan-roadmapper.md +15 -14
  24. package/agents/pan-verifier.md +32 -24
  25. package/bin/install-lib.cjs +58 -23
  26. package/bin/install.js +47 -1
  27. package/commands/pan/army.md +15 -11
  28. package/commands/pan/assumptions.md +2 -2
  29. package/commands/pan/audit-deployment.md +11 -12
  30. package/commands/pan/cost.md +8 -4
  31. package/commands/pan/debug.md +10 -7
  32. package/commands/pan/design-phase.md +3 -3
  33. package/commands/pan/discuss-phase.md +2 -0
  34. package/commands/pan/exec-phase.md +21 -37
  35. package/commands/pan/experiment.md +9 -8
  36. package/commands/pan/focus-auto.md +22 -20
  37. package/commands/pan/focus-design.md +7 -6
  38. package/commands/pan/focus-doc-audit.md +4 -3
  39. package/commands/pan/focus-drift-walking.md +4 -3
  40. package/commands/pan/focus-exec.md +6 -6
  41. package/commands/pan/focus-plan.md +12 -11
  42. package/commands/pan/focus-scan.md +5 -3
  43. package/commands/pan/focus-sync.md +3 -2
  44. package/commands/pan/git.md +8 -8
  45. package/commands/pan/health.md +2 -2
  46. package/commands/pan/hud.md +3 -2
  47. package/commands/pan/hygiene.md +14 -7
  48. package/commands/pan/knowledge.md +9 -9
  49. package/commands/pan/learn.md +10 -7
  50. package/commands/pan/links.md +4 -1
  51. package/commands/pan/map-codebase.md +1 -1
  52. package/commands/pan/mcp-bridge.md +18 -18
  53. package/commands/pan/milestone-done.md +6 -3
  54. package/commands/pan/milestone-new.md +1 -1
  55. package/commands/pan/new-project.md +10 -10
  56. package/commands/pan/optimize.md +16 -14
  57. package/commands/pan/patches.md +2 -6
  58. package/commands/pan/pause.md +1 -1
  59. package/commands/pan/phase-tests.md +2 -1
  60. package/commands/pan/plan-phase.md +9 -19
  61. package/commands/pan/preview.md +1 -1
  62. package/commands/pan/profile.md +2 -2
  63. package/commands/pan/quick.md +1 -1
  64. package/commands/pan/remove-phase.md +1 -1
  65. package/commands/pan/report.md +2 -2
  66. package/commands/pan/research-phase.md +12 -11
  67. package/commands/pan/resume.md +9 -11
  68. package/commands/pan/retro.md +5 -3
  69. package/commands/pan/review-deep.md +7 -7
  70. package/commands/pan/settings.md +1 -1
  71. package/commands/pan/verify-phase.md +0 -11
  72. package/commands/pan/what-if.md +2 -2
  73. package/hooks/dist/pan-context-monitor.js +343 -44
  74. package/hooks/dist/pan-cost-logger.js +30 -0
  75. package/hooks/dist/pan-statusline.js +68 -22
  76. package/hooks/dist/pan-stop-guard.js +7 -2
  77. package/package.json +1 -1
  78. package/pan-wizard-core/bin/lib/agents-md.cjs +44 -6
  79. package/pan-wizard-core/bin/lib/bridge.cjs +6 -5
  80. package/pan-wizard-core/bin/lib/campaign.cjs +4 -2
  81. package/pan-wizard-core/bin/lib/commands-learnings.cjs +19 -2
  82. package/pan-wizard-core/bin/lib/commands.cjs +33 -4
  83. package/pan-wizard-core/bin/lib/config.cjs +2 -1
  84. package/pan-wizard-core/bin/lib/constants.cjs +18 -6
  85. package/pan-wizard-core/bin/lib/context-budget.cjs +12 -9
  86. package/pan-wizard-core/bin/lib/core.cjs +53 -19
  87. package/pan-wizard-core/bin/lib/cost-rebuild.cjs +13 -1
  88. package/pan-wizard-core/bin/lib/cost.cjs +142 -13
  89. package/pan-wizard-core/bin/lib/distill.cjs +6 -3
  90. package/pan-wizard-core/bin/lib/doc-lint.cjs +30 -11
  91. package/pan-wizard-core/bin/lib/findings.cjs +9 -2
  92. package/pan-wizard-core/bin/lib/focus.cjs +13 -4
  93. package/pan-wizard-core/bin/lib/frontmatter.cjs +105 -26
  94. package/pan-wizard-core/bin/lib/hygiene.cjs +178 -17
  95. package/pan-wizard-core/bin/lib/init.cjs +7 -4
  96. package/pan-wizard-core/bin/lib/knowledge.cjs +17 -1
  97. package/pan-wizard-core/bin/lib/learn-index.cjs +111 -10
  98. package/pan-wizard-core/bin/lib/learn-lint.cjs +30 -3
  99. package/pan-wizard-core/bin/lib/memory-optimize.cjs +8 -4
  100. package/pan-wizard-core/bin/lib/memory.cjs +508 -54
  101. package/pan-wizard-core/bin/lib/milestone.cjs +8 -3
  102. package/pan-wizard-core/bin/lib/optimize.cjs +84 -16
  103. package/pan-wizard-core/bin/lib/phase-remove.cjs +85 -21
  104. package/pan-wizard-core/bin/lib/phase-report.cjs +8 -2
  105. package/pan-wizard-core/bin/lib/phase.cjs +15 -13
  106. package/pan-wizard-core/bin/lib/preview.cjs +3 -1
  107. package/pan-wizard-core/bin/lib/roadmap-compact.cjs +267 -0
  108. package/pan-wizard-core/bin/lib/roadmap.cjs +243 -9
  109. package/pan-wizard-core/bin/lib/runner.cjs +2 -1
  110. package/pan-wizard-core/bin/lib/state-compact.cjs +11 -6
  111. package/pan-wizard-core/bin/lib/state.cjs +43 -28
  112. package/pan-wizard-core/bin/lib/template.cjs +11 -4
  113. package/pan-wizard-core/bin/lib/verify-preflight.cjs +4 -13
  114. package/pan-wizard-core/bin/lib/verify-retro.cjs +5 -3
  115. package/pan-wizard-core/bin/lib/verify-scope.cjs +5 -2
  116. package/pan-wizard-core/bin/lib/verify.cjs +30 -28
  117. package/pan-wizard-core/bin/lib/whatif.cjs +5 -3
  118. package/pan-wizard-core/bin/pan-tools.cjs +101 -15
  119. package/pan-wizard-core/learnings/index.json +5 -5
  120. package/pan-wizard-core/opencode/pan-wizard.js +111 -0
  121. package/pan-wizard-core/references/checkpoints.md +3 -3
  122. package/pan-wizard-core/references/continuation-format.md +3 -3
  123. package/pan-wizard-core/references/decimal-phase-calculation.md +2 -3
  124. package/pan-wizard-core/references/design-methodology.md +1 -1
  125. package/pan-wizard-core/references/git-integration.md +4 -6
  126. package/pan-wizard-core/references/git-planning-commit.md +2 -2
  127. package/pan-wizard-core/references/guardrails.md +2 -2
  128. package/pan-wizard-core/references/handoff-decisions.md +3 -3
  129. package/pan-wizard-core/references/model-profile-resolution.md +5 -5
  130. package/pan-wizard-core/references/model-profiles.md +14 -9
  131. package/pan-wizard-core/references/phase-argument-parsing.md +7 -7
  132. package/pan-wizard-core/references/planning-config.md +4 -4
  133. package/pan-wizard-core/references/tdd.md +10 -1
  134. package/pan-wizard-core/references/verification-patterns.md +5 -5
  135. package/pan-wizard-core/templates/codebase/architecture.md +2 -2
  136. package/pan-wizard-core/templates/codebase/best-practices.md +2 -2
  137. package/pan-wizard-core/templates/codebase/concerns.md +3 -3
  138. package/pan-wizard-core/templates/codebase/integrations.md +6 -6
  139. package/pan-wizard-core/templates/codebase/relationships.md +2 -2
  140. package/pan-wizard-core/templates/codebase/stack.md +2 -2
  141. package/pan-wizard-core/templates/codebase/structure.md +4 -4
  142. package/pan-wizard-core/templates/codebase/testing.md +4 -4
  143. package/pan-wizard-core/templates/continue-here.md +1 -1
  144. package/pan-wizard-core/templates/debug-subagent-prompt.md +3 -2
  145. package/pan-wizard-core/templates/debug.md +15 -1
  146. package/pan-wizard-core/templates/milestone-archive.md +6 -6
  147. package/pan-wizard-core/templates/milestone.md +1 -1
  148. package/pan-wizard-core/templates/phase-prompt.md +29 -17
  149. package/pan-wizard-core/templates/planner-subagent-prompt.md +3 -5
  150. package/pan-wizard-core/templates/research-project/architecture.md +3 -3
  151. package/pan-wizard-core/templates/research-project/features.md +1 -1
  152. package/pan-wizard-core/templates/research-project/pitfalls.md +1 -1
  153. package/pan-wizard-core/templates/research-project/stack.md +3 -3
  154. package/pan-wizard-core/templates/research.md +5 -5
  155. package/pan-wizard-core/templates/retrospective.md +1 -1
  156. package/pan-wizard-core/templates/roadmap.md +15 -15
  157. package/pan-wizard-core/templates/summary-complex.md +1 -0
  158. package/pan-wizard-core/templates/summary-minimal.md +1 -0
  159. package/pan-wizard-core/templates/summary-standard.md +2 -1
  160. package/pan-wizard-core/templates/summary.md +18 -2
  161. package/pan-wizard-core/templates/uat.md +3 -3
  162. package/pan-wizard-core/templates/user-setup.md +8 -8
  163. package/pan-wizard-core/templates/verification-report.md +53 -8
  164. package/pan-wizard-core/workflows/add-phase.md +1 -1
  165. package/pan-wizard-core/workflows/assumptions.md +1 -1
  166. package/pan-wizard-core/workflows/discuss-phase.md +9 -8
  167. package/pan-wizard-core/workflows/exec-phase.md +26 -57
  168. package/pan-wizard-core/workflows/execute-plan.md +8 -7
  169. package/pan-wizard-core/workflows/health.md +13 -12
  170. package/pan-wizard-core/workflows/help.md +8 -9
  171. package/pan-wizard-core/workflows/learn.md +13 -11
  172. package/pan-wizard-core/workflows/map-codebase.md +10 -10
  173. package/pan-wizard-core/workflows/milestone-audit.md +10 -10
  174. package/pan-wizard-core/workflows/milestone-gaps.md +17 -24
  175. package/pan-wizard-core/workflows/milestone-new.md +7 -6
  176. package/pan-wizard-core/workflows/new-project.md +9 -9
  177. package/pan-wizard-core/workflows/optimize.md +11 -9
  178. package/pan-wizard-core/workflows/pause.md +6 -1
  179. package/pan-wizard-core/workflows/phase-tests.md +4 -4
  180. package/pan-wizard-core/workflows/plan-phase.md +31 -34
  181. package/pan-wizard-core/workflows/profile.md +2 -2
  182. package/pan-wizard-core/workflows/progress.md +5 -7
  183. package/pan-wizard-core/workflows/quick.md +5 -3
  184. package/pan-wizard-core/workflows/remove-phase.md +1 -1
  185. package/pan-wizard-core/workflows/research-phase.md +9 -5
  186. package/pan-wizard-core/workflows/resume-project.md +4 -6
  187. package/pan-wizard-core/workflows/retro.md +3 -1
  188. package/pan-wizard-core/workflows/settings.md +16 -24
  189. package/pan-wizard-core/workflows/todo-check.md +1 -1
  190. package/pan-wizard-core/workflows/transition.md +12 -12
  191. package/pan-wizard-core/workflows/update.md +25 -17
  192. package/pan-wizard-core/workflows/verify-phase.md +17 -15
  193. package/pan-zcode/KNOWN-BETA-RISKS.md +2 -2
  194. package/pan-zcode/README.md +7 -7
  195. package/pan-zcode/bin/install-zcode.js +1 -1
  196. package/scripts/build-plugin.js +3 -1
  197. package/scripts/generate-skills-docs.py +13 -4
package/README.md CHANGED
@@ -45,7 +45,7 @@ PAN is the context engineering layer that makes Claude Code reliable. It breaks
45
45
  ```text
46
46
  ┌─────────────────────────────────────────────────────────────┐
47
47
  │ YOU │
48
- │ /pan:new-project → /pan:plan-phase → /pan:exec-phase │
48
+ │ /pan:new-project → /pan:plan-phase → /pan:exec-phase │
49
49
  └─────────────────────┬───────────────────────────────────────┘
50
50
  │ invokes
51
51
  ┌─────────────────────▼───────────────────────────────────────┐
@@ -91,7 +91,7 @@ PAN is the context engineering layer that makes Claude Code reliable. It breaks
91
91
  | **1 · Release** | `pan-release` | Ships behind a human gate | `always-ask` |
92
92
  | **2 · Workers** | the utility agents `pan-tools squad list` reports under `workers` | Narrow, high-volume jobs | scoped |
93
93
 
94
- **Mission Control runs on your session's model** — `pan-conductor` declares no `model:`, so it inherits whatever you launched with rather than pinning a model of its own.
94
+ **Mission Control runs on your session's model** — `pan-conductor` declares no `model:` and no spawn passes one, so it inherits whatever you launched with under every profile (`resolve-model` reports the `budget` profile's mid tier for it, but nothing applies that).
95
95
 
96
96
  **Reading the Access column.** The backticked values are the squad `access` labels `pan-tools squad list` reports; the tier-0 and tier-2 labels are PAN's own. Either way they describe the *role contract* PAN's prompts assign, not a sandbox — `squads.cjs` "modifies no agent and changes no execution path", so a label can differ from what an agent may actually do. The real tool grant is each agent's own `tools:` frontmatter (`grep '^tools:' agents/*.md`), and Mission Control's includes `Write` and `Bash`. The rail those grants do enforce is delegation depth: `grep -l '^tools:.*Task' agents/*.md` names every agent able to spawn another (today, the coordinator), so a squad agent cannot fan out further even if asked to. For the irreversible steps, back the convention with branch protection on your own repo.
97
97
 
@@ -130,7 +130,7 @@ People who want to describe what they want and have it built correctly — witho
130
130
  npx pan-wizard@latest
131
131
  ```
132
132
 
133
- The installer prompts you to choose the **runtime** — Claude Code, OpenCode, Gemini, Codex, Copilot CLI, or all. Location is not prompted: it defaults to the current project (`--local`); pass `--global` to install into your home config directory instead.
133
+ The installer prompts you to choose the **runtime** — Claude Code, OpenCode, Gemini, Codex, Copilot CLI, or all. Location is not prompted: it defaults to the current project (`--local`). To install into your home config directory instead, pass `--global` with a runtime flag, such as `--claude --global`. `--global` alone skips the runtime prompt and installs Claude Code.
134
134
 
135
135
  Verify with:
136
136
  - Claude Code / Gemini: `/pan:help`
@@ -142,7 +142,7 @@ Verify with:
142
142
 
143
143
  ### Staying Updated
144
144
 
145
- PAN evolves fast. On Claude Code, update periodically with `/pan:update`, which detects whether the install is local or global but passes no other flag, so it always updates Claude Code in its default location. For any other runtime, or an install made with `--config-dir` or `--unified-skills`, re-run the installer yourself with the flags you installed with (add `--global` for a global install, since the installer defaults to the current project):
145
+ PAN evolves fast. Update periodically with `/pan:update`, which reads from the install's own path whether it is local or global and which runtime it belongs to, and reinstalls that runtime. For an install made with `--config-dir` or `--unified-skills`, which it cannot tell from the path, re-run the installer yourself with the flags you installed with (add `--global` for a global install, since the installer defaults to the current project):
146
146
 
147
147
  ```bash
148
148
  npx pan-wizard@latest
@@ -175,7 +175,7 @@ npx pan-wizard --all --global # Install to all directories
175
175
  ```
176
176
 
177
177
  Use `--global` (`-g`) to install into your home config directory; `--local` (`-l`) is the default and may be omitted.
178
- Use `--claude`, `--opencode`, `--gemini`, `--codex`, `--copilot`, or `--all` to skip the runtime prompt. A local install also writes outside the runtime directory: a marker-fenced PAN section in the project's `AGENTS.md`; for Claude Code, an `@AGENTS.md` import in `CLAUDE.md` and a `pan` MCP server in `.mcp.json`; and for Codex or `--unified-skills`, the shared `.agents/` tree (skills, plus a shared core under `--unified-skills`). `--uninstall` removes them (the `AGENTS.md` and `CLAUDE.md` blocks and the `.agents/` tree stay while another PAN runtime in the project still uses them).
178
+ Use `--claude`, `--opencode`, `--gemini`, `--codex`, `--copilot`, or `--all` to skip the runtime prompt. A local install also writes outside the runtime directory: a marker-fenced PAN section in the project's `AGENTS.md`; for Claude Code, a marker-fenced block in `CLAUDE.md` (the `@AGENTS.md` import, and compact instructions that keep PAN's position through compaction) and a `pan` MCP server in `.mcp.json`; and for Codex or `--unified-skills`, the shared `.agents/` tree (skills, plus a shared core under `--unified-skills`). `--uninstall` removes them (the `AGENTS.md` and `CLAUDE.md` blocks and the `.agents/` tree stay while another PAN runtime in the project still uses them).
179
179
  Add `--unified-skills` to install commands as one shared `.agents/skills/` tree instead of per-runtime formats. Codex, Gemini CLI, OpenCode, Copilot CLI and Antigravity CLI read that tree; Claude Code does not, so for Claude the installer also copies each skill into `.claude/skills/` and the commands become `/pan-<name>`. Gemini CLI gives skills no slash command, so on a unified Gemini install you ask for the task and `/skills list` shows what loaded. See the User Guide for details.
180
180
 
181
181
  > **Gemini CLI note:** from June 18, 2026, Google's Gemini CLI serves Gemini Code Assist (Standard/Enterprise) customers; individual free / AI Pro / Ultra accounts are directed to Antigravity CLI instead. PAN's `--gemini` target installs for Gemini CLI. Antigravity CLI is not yet a PAN install target, but it reads the shared `.agents/skills/` tree natively — install with `--unified-skills` and PAN's commands are usable from Antigravity in the same project.
@@ -363,7 +363,7 @@ The system:
363
363
  1. **Runs plans in waves** — Parallel where possible, sequential when dependent
364
364
  2. **Fresh context per plan** — a whole context window purely for implementation, zero accumulated garbage (native sub-agent spawning on Claude Code; the other runtimes delegate through their own agent mechanism)
365
365
  3. **Commits per task** — Every task gets its own atomic commit (consecutive trivial chore or docs tasks may be coalesced into one)
366
- 4. **Verifies against goals** — Checks the codebase delivers what the phase promised
366
+ 4. **Verifies against goals** — Checks the codebase delivers what the phase promised (skipped, and said so, when `workflow.verifier` is off)
367
367
 
368
368
  Walk away, come back to completed work with clean git history.
369
369
 
@@ -399,7 +399,7 @@ Plans are grouped into "waves" based on dependencies. Within each wave, plans ru
399
399
 
400
400
  This is why "vertical slices" (Plan 01: User feature end-to-end) parallelize better than "horizontal layers" (Plan 01: All models, Plan 02: All APIs).
401
401
 
402
- **Creates:** `{phase_num}-{N}-summary.md`, `{phase_num}-review.md` (unless `--skip-review` or `--fast`), `{phase_num}-verification.md`
402
+ **Creates:** `{phase_num}-{N}-summary.md`, `{phase_num}-review.md` (unless `--skip-review` or `--fast`), `{phase_num}-verification.md` (unless `workflow.verifier` is off)
403
403
 
404
404
  ---
405
405
 
@@ -545,8 +545,8 @@ PAN runs autonomous experiments in isolated folders, harvests the resulting tele
545
545
 
546
546
  - `learnings/universal/<topic>.md` — patterns that ship to every install (atomic-state, concurrency, idempotency, secret-handling, test-patterns, …). Loaded by planner / executor / verifier agents during their work.
547
547
  - `learnings/internal/<topic>.md` — PAN-development patterns; source-only (stripped at install).
548
- - `learnings/index.json` — topic→agent-relevance map. Workflows call `pan-tools learn topics-for --agent <role> --token-budget N` to load only relevant patterns instead of skim-everything (avoids the distractor-density anti-pattern).
549
- - `pan-tools learn lint` — integrity check (duplicate IDs, dangling refs, scope leaks). Wired into `/check`.
548
+ - `learnings/index.json` — topic→agent-relevance map. Workflows call `pan-tools learn topics-for --agent <role> --cue "<the task>" --token-budget N` to load only the topics that match the task (falling back to the role's tagged topics when none does) instead of skim-everything (avoids the distractor-density anti-pattern).
549
+ - `pan-tools learn lint` — integrity check (duplicate IDs, dangling refs, scope leaks, citations whose code is gone). Contributors run it through the source repo's `/check` dev command.
550
550
 
551
551
  ### Atomic Git Commits
552
552
 
@@ -601,7 +601,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
601
601
  |---------|--------------|
602
602
  | `/pan:new-project [--auto]` | Full initialization: questions → research → requirements → roadmap |
603
603
  | `/pan:discuss-phase <N> [--auto]` | Capture implementation decisions before planning |
604
- | `/pan:design-phase [N]` | Design a phase — architecture, ADR, threat-lite — before planning |
604
+ | `/pan:design-phase <N>` | Design a phase — architecture, ADR, threat-lite — before planning |
605
605
  | `/pan:plan-phase [N] [--auto]` | Research + plan + verify for a phase |
606
606
  | `/pan:exec-phase <N>` | Execute all plans in parallel waves, verify when complete |
607
607
  | `/pan:verify-phase [N]` | Re-run goal-backward verification with a test-suite gate; lists gaps for `/pan:plan-phase N --gaps` ¹ |
@@ -639,7 +639,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
639
639
  | `/pan:add-phase <description>` | Append phase to roadmap |
640
640
  | `/pan:insert-phase <after> <description>` | Insert urgent work between phases |
641
641
  | `/pan:remove-phase <N>` | Remove future phase, renumber |
642
- | `/pan:assumptions [N]` | See Claude's intended approach before planning |
642
+ | `/pan:assumptions <N>` | See Claude's intended approach before planning |
643
643
  | `/pan:milestone-gaps` | Create phases to close gaps from audit |
644
644
 
645
645
  ### Session
@@ -660,13 +660,13 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
660
660
  | `/pan:debug [desc]` | Systematic debugging with persistent state |
661
661
  | `/pan:quick [--full]` | Execute ad-hoc task with PAN guarantees (`--full` adds plan-checking and verification) |
662
662
  | `/pan:health [--repair]` | Validate `.planning/` directory integrity; `--repair` fixes the issues it marks repairable |
663
- | `/pan:hygiene [--apply] [--trace-age-days N] [--all-tracks]` | Scan for PAN version drift and stale project artifacts (legacy filenames, .tmp orphans, memory bloat, poisoned cost ledgers, trace and report debris, cached-context bloat, fragment planning dirs); `--apply` executes the safe fixes — poisoned ledgers are quarantined by rename (only the newest quarantine copy is kept), and settled `state.md` history is archived rather than dropped |
664
- | `/pan:links [--strict]` | Validate the doc-code link graph: inline `[[<id>]]` refs, `// @pan:` source anchors, `require-code-mention` contracts (ADR-0027) |
663
+ | `/pan:hygiene [--apply] [--trace-age-days N] [--all-tracks]` | Scan for PAN version drift and stale project artifacts (legacy filenames, .tmp orphans, memory bloat and stale or expired memory entries, poisoned cost ledgers, trace and report debris, cached-context bloat, fragment planning dirs) and Claude Code's own memory index (reported, never edited); `--apply` executes the safe fixes — poisoned ledgers are quarantined by rename (only the newest quarantine copy is kept), and settled `state.md` history, shipped roadmap phases and stale memory entries are archived rather than dropped |
664
+ | `/pan:links [--strict] [--doc-root <dir>] [--source-root <dir>]` | Validate the doc-code link graph: inline `[[<id>]]` refs, `// @pan:` source anchors, `require-code-mention` contracts (ADR-0027). The default roots are PAN's own source layout, so pass your project's roots |
665
665
  | `/pan:phase-tests <N> [instructions]` | Generate tests for a completed phase based on UAT criteria |
666
666
  | `/pan:milestone-cleanup` | Archive accumulated phase directories from completed milestones |
667
667
  | `/pan:retro` | Milestone retrospective — estimation accuracy, verification patterns, gap analysis |
668
668
  | `/pan:patches` | Restore local modifications after a PAN update |
669
- | `/pan:research-phase [N]` | Standalone deep research for a phase (usually part of plan-phase) |
669
+ | `/pan:research-phase <N>` | Standalone deep research for a phase (usually part of plan-phase) |
670
670
  | `/pan:phase-budget` | Estimate context window utilization for current phase |
671
671
  | `/pan:experiment <subcommand>` | Manage external self-improvement experiments — scaffold, run, harvest, promote findings back to PAN (never inside the PAN source repo) |
672
672
 
@@ -677,8 +677,8 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
677
677
  | Command | What it does |
678
678
  |---------|--------------|
679
679
  | `pan-tools preflight [target]` | Pre-flight validation: state, blockers, git clean, config, error patterns |
680
- | `pan-tools dashboard` | Aggregated project overview as JSON: phase, progress, blockers, next action (for the visual HTML dashboard, see `/pan:hud`) |
681
- | `pan-tools learnings extract` | Auto-extract learnings from sessions, error patterns, and summaries |
680
+ | `pan-tools dashboard` | Aggregated project overview as JSON: phase, progress, blockers, next phase (for the visual HTML dashboard, see `/pan:hud`) |
681
+ | `pan-tools learnings extract` | Extract learnings from error patterns (`patterns.md`) and phase summaries |
682
682
  | `pan-tools learnings list` | List all extracted learnings with type breakdown |
683
683
  | `pan-tools learnings prune` | Remove old learnings by age (`--days N`) or ID (`--id LEARN-NNN`) |
684
684
  | `pan-tools deps validate` | Cross-reference roadmap vs disk phases, detect orphaned requirements |
@@ -705,14 +705,14 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
705
705
  | `/pan:review-deep <phase>` | Security audit (OWASP + STRIDE) + cross-check by meta-reviewer |
706
706
  | `/pan:knowledge {ask\|discuss\|playbook}` | Grounded Q&A, multi-turn discussion, or aggregate memory into playbook |
707
707
  | `/pan:what-if <phase> "scenario"` | Counterfactual phase replay in isolated git worktree |
708
- | `/pan:mcp-bridge {list\|recommend\|cache}` | Discover MCP tools and recommend per-phase relevance |
708
+ | `/pan:mcp-bridge {list\|recommend\|cache}` | List the MCP tools recorded in its cache (only `cache --servers` or an external script writes it) and recommend the ones relevant to a phase |
709
709
 
710
710
  ### Optimization & Git
711
711
 
712
712
  | Command | What it does |
713
713
  |---------|--------------|
714
- | `/pan:learn` | Analyze trace events, generate optimization report with auto-apply block |
715
- | `/pan:optimize {apply\|revert\|list\|stats\|trace}` | Apply optimizer recommendations, undo one apply (`revert <apply_id>` or `revert --last`), list reports, view stats, manage trace sessions |
714
+ | `/pan:learn` | Analyze trace events and write an optimization report. `/pan:optimize apply` records its suggestions; nothing is applied automatically |
715
+ | `/pan:optimize {apply\|revert\|list\|stats\|trace}` | Record a report's suggestions for a person to act on (`apply`: notes in `.planning/optimization/suggestions.md`, config notes in `config-suggestions.md`), undo one apply (`revert <apply_id>` or `revert --last`), list reports, view stats, manage trace sessions |
716
716
  | `/pan:git <subcommand>` | Phase-aware git workflow: commit/branch/push/status/log/stash/diff/rollback/tag/sync |
717
717
  | `/pan:audit-deployment <target-directory> [--enhancements] [--repair]` | Audit a PAN installation for integrity, project health, and draft enhancement specs |
718
718
 
@@ -830,12 +830,15 @@ This prevents Claude from reading these files entirely, regardless of what comma
830
830
  - For Claude Code, verify files exist in `~/.claude/commands/pan/` (global) or `./.claude/commands/pan/` (local) — or, after a `--unified-skills` install, in `.claude/skills/pan-*/SKILL.md`
831
831
  - For Codex, verify skills exist in `~/.agents/skills/pan-*/SKILL.md` (global) or `./.agents/skills/pan-*/SKILL.md` (local)
832
832
  - For Copilot CLI, verify skills exist in `~/.copilot/skills/pan-*/SKILL.md` (global) or `./.github/skills/pan-*/SKILL.md` (local)
833
+ - For OpenCode, verify files exist in `~/.config/opencode/commands/pan-*.md` (global) or `./.opencode/commands/pan-*.md` (local)
834
+ - For Gemini CLI, verify files exist in `~/.gemini/commands/pan/*.toml` (global) or `./.gemini/commands/pan/*.toml` (local)
835
+ - After a `--unified-skills` install, the runtimes other than Claude Code read `./.agents/skills/pan-*/SKILL.md` (`~/.agents/skills/` after `--global`)
833
836
 
834
837
  **Commands not working as expected?**
835
838
  - Run `/pan:help` (`/pan-help` on OpenCode, Copilot CLI and unified Claude installs; `$pan-help` on Codex) to verify installation
836
839
  - Re-run `npx pan-wizard` with the flags you installed with (the runtime, `--global`/`--local`, and any `--config-dir` or `--unified-skills`) to reinstall
837
840
 
838
- **Updating to the latest version?** On Claude Code, run `/pan:update`. For any other runtime, or an install made with `--config-dir` or `--unified-skills`, re-run the installer with the flags you installed with (`--global` for a global install):
841
+ **Updating to the latest version?** Run `/pan:update`; it reinstalls the runtime it runs in. For an install made with `--config-dir` or `--unified-skills`, re-run the installer with the flags you installed with (`--global` for a global install):
839
842
  ```bash
840
843
  npx pan-wizard@latest
841
844
  ```
@@ -12,7 +12,7 @@ You are the PAN conductor. You coordinate a hierarchical execution of a phase: d
12
12
  You are spawned by `/pan:exec-phase <N> --hierarchical`. Without that flag, the normal flat exec path runs instead — you are never invoked by default.
13
13
 
14
14
  **CRITICAL: Mandatory Initial Read**
15
- If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool to load every file listed there before performing any other actions. This includes the phase plan, the safety harness config, and any audit log from prior runs.
15
+ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool to load every file listed there before performing any other actions. This includes the phase plan and any audit log from prior runs.
16
16
  </role>
17
17
 
18
18
  <safety_harness>
@@ -25,7 +25,7 @@ This agent changes PAN's execution model — agents-spawn-agents is inherently r
25
25
  |-----|-------|-----------------------|
26
26
  | Nesting depth | 2 levels (you → sub-agent) | You may NOT spawn an agent that is instructed to spawn further agents |
27
27
  | Spawns per phase | 12 total | At spawn 12, continue without further spawning; document what was skipped |
28
- | Points budget | Phase budget from focus-auto config or default 40 | When remaining budget < next sub-agent's estimate, stop spawning |
28
+ | Points budget | `total_budget_points` from `pan-tools init execute-phase <N>` (config `budget.default_points`, default 50) | When remaining budget < next sub-agent's estimate, stop spawning |
29
29
  | Abort file | `.planning/orchestration/abort` | If this file exists at any point, abandon immediately (no graceful rollback, just stop and log state) |
30
30
 
31
31
  **Before each spawn, you MUST:**
@@ -45,12 +45,12 @@ This agent changes PAN's execution model — agents-spawn-agents is inherently r
45
45
 
46
46
  Given a phase plan, decompose into **sub-tasks** that correspond to sub-agents:
47
47
 
48
- 1. **Read the plan first.** Don't decompose from the phase title — read `plans/*-plan.md` files to understand what's actually required.
48
+ 1. **Read the plan first.** Don't decompose from the phase title — read the phase's plan files to understand what's actually required: `pan-tools phase-plan-index <N>` lists each plan with its `wave`, `autonomous` flag and `depends_on`, and `pan-tools init execute-phase <N>` gives `phase_dir`, where they are `{phase_dir}/*-plan.md`.
49
49
 
50
50
  2. **Natural sub-agent boundaries:**
51
- - **Executor sub-agents (up to 6):** one per `-plan.md` file that's marked `autonomous: true` in frontmatter. Non-autonomous plans require user checkpoints — flag them for flat-exec fallback.
52
- - **Reviewer (1):** always spawn a `pan-reviewer` after all executors complete.
53
- - **Verifier (1):** always spawn a `pan-verifier` after reviewer.
51
+ - **Executor sub-agents (up to 6):** one per `-plan.md` file that's marked `autonomous: true` in frontmatter. Non-autonomous plans need user checkpoints, which you cannot pause for: do not run them, and list them under "Skipped" in your summary with the instruction to run them with `/pan:exec-phase <N>` (no `--hierarchical`) — nothing runs them after you return.
52
+ - **Reviewer (1):** spawn a `pan-reviewer` after all executors complete, unless `--skip-review` or `--fast` was passed.
53
+ - **Verifier (1):** spawn a `pan-verifier` after the reviewer, unless `workflow.verifier` is false.
54
54
  - Optional hardener + meta-reviewer (2): only if `--deep-review` was also passed.
55
55
 
56
56
  3. **Wave grouping:** executors with no cross-plan dependencies can be grouped (within the 12-spawn cap). Sequential executors when `depends_on:` frontmatter indicates.
@@ -83,7 +83,7 @@ Append-only structured log. Entries:
83
83
 
84
84
  For each lifecycle event, also publish to the bus (see `bus.cjs`):
85
85
 
86
- ```
86
+ ```bash
87
87
  pan-tools bus publish orchestrator <payload-json> --source pan-conductor
88
88
  ```
89
89
 
@@ -95,7 +95,7 @@ The bus channel is append-only and diagnostic. The trace.json is authoritative f
95
95
 
96
96
  For each phase execution:
97
97
 
98
- ```
98
+ ```text
99
99
  1. Load phase plan + safety config
100
100
  2. Decompose into sub-tasks
101
101
  3. For each wave of executors (up to 6 per wave, 12 total):
@@ -106,10 +106,11 @@ For each phase execution:
106
106
  e. Publish to bus
107
107
  4. After all executors:
108
108
  a. Spawn pan-reviewer (always, unless --skip-review or --fast)
109
+ b. Save its returned report verbatim to {phase_dir}/{phase_number}-review.md (the reviewer is read-only; exec-phase's code_review step saves it the same way), then: pan-tools findings record --phase <N> --agent pan-reviewer --file {phase_dir}/{phase_number}-review.md
109
110
  5. After reviewer:
110
- a. If --deep-review: spawn pan-hardener + pan-meta-reviewer
111
- b. Merge via review-deep.cjs
112
- 6. Spawn pan-verifier (always)
111
+ a. If --deep-review: spawn pan-hardener (<output_path> .planning/reviews/<N>/hardener.md), then pan-meta-reviewer (<output_path> .planning/reviews/<N>/meta.md)
112
+ b. Merge: pan-tools review-deep merge <N> --reviewer-file {phase_dir}/{phase_number}-review.md --hardener-file .planning/reviews/<N>/hardener.md --meta-file .planning/reviews/<N>/meta.md
113
+ 6. Spawn pan-verifier — unless `workflow.verifier` is false: then report "verification skipped (workflow.verifier is off)", as exec-phase does
113
114
  7. Emit final orchestration summary
114
115
  ```
115
116
 
@@ -165,11 +166,11 @@ skipped: 2
165
166
 
166
167
  Other runtimes don't support agents-spawn-agents cleanly. The command's `--hierarchical` flag is a **no-op** on Codex / Gemini / OpenCode / Copilot — it falls back to the flat exec-phase path and prints a warning:
167
168
 
168
- ```
169
+ ```text
169
170
  --hierarchical is not supported on <runtime>. Falling back to flat exec.
170
171
  ```
171
172
 
172
- This agent file ships to all runtimes (keeps the installer uniform), but only gets invoked on a runtime that supports native sub-agent spawning. The constraint is the runtime, not the model — the conductor runs on whatever model the session was launched with. Installer + command layer are responsible for the gating; this agent assumes it has the capability when invoked.
173
+ This agent file ships to all runtimes (keeps the installer uniform), but only gets invoked on a runtime that supports native sub-agent spawning. The constraint is the runtime, not the model — the conductor runs on whatever model the session was launched with. The command layer does the gating (exec-phase falls back to flat exec off Claude Code); this agent assumes it has the capability when invoked.
173
174
 
174
175
  </runtime_gating>
175
176
 
@@ -191,10 +192,10 @@ This agent file ships to all runtimes (keeps the installer uniform), but only ge
191
192
 
192
193
  When invoked by `/pan:army` (ADR-0033), you are **Mission Control** for a whole-project campaign, not a single phase — same harness, wider scope. The differences:
193
194
 
194
- - **You delegate to squads, not bare agents.** Resolve the roster at runtime with `pan-tools squad list` / `squad show <name>` — never hardcode it. Route each mission to the squad that owns its lifecycle role: Architecture (design, read-only), Build (code, read/write), Quality (adversarial, read-only), Release (`pan-release`, always-ask). Workers (document_code, distiller) take narrow, high-volume jobs; they are the agents the `budget` profile drops to the `fast` tier, and run at the inherited reasoning tier otherwise.
195
- - **Build parallelizes by worktree — and you tear the worktrees down.** When the Build squad runs multiple tasks at once, each `pan-executor` gets its own `army/<task>` branch + isolated worktree (`pan-tools worktree create "<task>"`) so concurrent builders never share a tree or a file. The spawn cap and budget ceiling still bound the fan-out. Those worktrees are scaffolding: after each task's squash-merge lands, `pan-tools worktree remove <path> --branch army/<task>`; at campaign end or on any abort, `pan-tools worktree cleanup` sweeps the strays (`--force` to also discard dirty or unintegrated ones). Leaving `pan-army-*` sibling directories behind is a campaign defect, not residue (P-1815).
195
+ - **You delegate to squads, not bare agents.** Resolve the roster at runtime with `pan-tools squad list` / `squad show <name>` — never hardcode it. Route each mission to the squad that owns its lifecycle role: Architecture (design, read-only), Build (code, read/write), Quality (adversarial, read-only), Release (`pan-release`, always-ask). Workers (document_code, distiller and the rest that `squad list` reports under `workers`) take narrow, high-volume jobs. The army's spawns pass no `model`, so an agent runs on its own `model:` pin, else the session model, under every profile — the tiers `resolve-model` reports for `budget` are not what they run on here.
196
+ - **Build parallelizes by worktree — and you tear the worktrees down.** When the Build squad runs multiple tasks at once, each `pan-executor` gets its own `army/<task>` branch + isolated worktree (`pan-tools worktree create "<task>"`) so concurrent builders never share a tree or a file. The spawn cap and budget ceiling still bound the fan-out. Those worktrees are scaffolding: after each task's squash-merge lands, `pan-tools worktree remove <worktree_path> --branch <branch>` (as `worktree create` returned them: `army/<slug>`, the task name slugified); at campaign end or on any abort, `pan-tools worktree cleanup` sweeps the strays (`--force` to also discard dirty or unintegrated ones). Leaving `pan-army-*` sibling directories behind is a campaign defect, not residue (P-1815).
196
197
  - **Integration is human-gated.** You never merge to a protected branch. The Release squad prepares the merge and surfaces an `always-ask` approval request; a human approves. Recovery is `git revert` / previous tag — never force-push, never rewrite history.
197
- - **The loop carries learnings.** After each mission, squad summaries return to you; `/pan:retro --write-memory` persists recurring patterns to agent memory (the "Dreaming" step) so the next mission plans smarter.
198
+ - **The loop carries learnings.** After each mission, squad summaries return to you and `/pan:retro` reports the recurring patterns (the "Dreaming" step). You carry them into the next mission's plan. PAN does not load agent memory into agents, so a pattern you do not hand on is lost.
198
199
 
199
200
  Every Tier-0 cap from the safety harness still applies, unchanged: nesting depth 2, the spawn/budget ceiling per cycle, and the `.planning/orchestration/abort` kill-switch checked before every spawn. The campaign is a longer loop around the same bounded core — it does not relax a single cap.
200
201
 
@@ -9,7 +9,7 @@ effort: high
9
9
  <role>
10
10
  You are the PAN counterfactual agent. You explore alternative approaches to a phase in an isolated git worktree, then produce a comparison report for the main tree.
11
11
 
12
- You are spawned by `/pan:what-if <phase> <scenario>` after the command has already created an isolated worktree. Your working directory IS the worktree — modifications here do NOT affect the main project.
12
+ You are spawned by `/pan:what-if <phase> <scenario>` after the command has already created an isolated worktree at `<worktree_path>`. You start in the session's directory — the main project — not in the worktree: the spawn does not set your working directory. Work only inside `<worktree_path>`: use absolute paths under it and begin every shell command with `cd "<worktree_path>" &&`, because a relative path edits the main project.
13
13
 
14
14
  Your output has two parts:
15
15
  1. **Exploration** inside the worktree — you can edit files, try things, run tests. It's a safe sandbox.
@@ -21,7 +21,7 @@ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool t
21
21
 
22
22
  <boundaries>
23
23
 
24
- **You are in a worktree, not the main tree.** The main project's state is unchanged by anything you do here.
24
+ **Work in the worktree, not the main tree.** The main project's state is unchanged by what you do inside `<worktree_path>`; a relative path, or a shell command that does not start with `cd "<worktree_path>" &&`, changes the main project.
25
25
 
26
26
  **You may modify files in the worktree.** This is the safe sandbox for experimentation. Try the alternative approach.
27
27
 
@@ -312,7 +312,7 @@ function MinimalRepro() {
312
312
  5. Find divergence point (where expected vs actual first differ)
313
313
 
314
314
  **Example:** UI shows "User not found" when user exists
315
- ```
315
+ ```text
316
316
  Trace backwards:
317
317
  1. UI displays: user.error → Is this the right value to display? YES
318
318
  2. Component receives: user.error = "User not found" → Correct? NO, should be null
@@ -341,7 +341,7 @@ Trace backwards:
341
341
  **Process:** List differences, test each in isolation, find the difference that causes failure.
342
342
 
343
343
  **Example:** Works locally, fails in CI
344
- ```
344
+ ```text
345
345
  Differences:
346
346
  - Node version: Same ✓
347
347
  - Environment variables: Same ✓
@@ -696,7 +696,7 @@ The cost of insufficient verification: bug returns, user frustration, emergency
696
696
 
697
697
  ## Research vs Reasoning Decision Tree
698
698
 
699
- ```
699
+ ```text
700
700
  Is this an error message I don't recognize?
701
701
  ├─ YES → Web search the error message
702
702
  └─ NO ↓
@@ -744,7 +744,7 @@ Can I observe the behavior directly?
744
744
 
745
745
  ## File Location
746
746
 
747
- ```
747
+ ```bash
748
748
  DEBUG_DIR=.planning/debug
749
749
  DEBUG_RESOLVED_DIR=.planning/debug/resolved
750
750
  ```
@@ -753,7 +753,7 @@ DEBUG_RESOLVED_DIR=.planning/debug/resolved
753
753
 
754
754
  ```markdown
755
755
  ---
756
- status: gathering | investigating | fixing | verifying | awaiting_human_verify | resolved
756
+ status: gathering | investigating | diagnosed | fixing | verifying | awaiting_human_verify | resolved
757
757
  trigger: "[verbatim user input]"
758
758
  created: [ISO timestamp]
759
759
  updated: [ISO timestamp]
@@ -776,6 +776,14 @@ errors: [error messages]
776
776
  reproduction: [how to trigger]
777
777
  started: [when broke / always broken]
778
778
 
779
+ ## Reproduction
780
+ <!-- Written before the first hypothesis; OVERWRITE only to shrink it -->
781
+
782
+ command: [one command you have RUN that fails on the reported symptom, or "none"]
783
+ fails_with: [the output that shows the symptom, secrets redacted]
784
+ deterministic: [yes / rate N of M runs for a flaky bug]
785
+ tried: [only when command is "none": what you tried and why it cannot be built]
786
+
779
787
  ## Eliminated
780
788
  <!-- APPEND only - prevents re-investigating -->
781
789
 
@@ -808,6 +816,7 @@ files_changed: []
808
816
  | Frontmatter.updated | OVERWRITE | Every file update |
809
817
  | Current Focus | OVERWRITE | Before every action |
810
818
  | Symptoms | IMMUTABLE | After gathering complete |
819
+ | Reproduction | OVERWRITE to shrink | Before the first hypothesis; again only as it is minimised |
811
820
  | Eliminated | APPEND | When hypothesis disproved |
812
821
  | Evidence | APPEND | After each finding |
813
822
  | Resolution | OVERWRITE | As understanding evolves |
@@ -816,7 +825,7 @@ files_changed: []
816
825
 
817
826
  ## Status Transitions
818
827
 
819
- ```
828
+ ```text
820
829
  gathering -> investigating -> fixing -> verifying -> awaiting_human_verify -> resolved
821
830
  ^ | | |
822
831
  |____________|___________|_________________|
@@ -839,7 +848,7 @@ The file IS the debugging brain.
839
848
  <execution_flow>
840
849
 
841
850
  <step name="check_active_session">
842
- **First:** Check for active debug sessions.
851
+ **First:** Check for active debug sessions — only when your prompt names no issue. A spawned debugger is handed its issue (`<objective>`/`<symptoms>`, or the debug file to continue): `/pan:debug` lists active sessions before it spawns you, and you cannot wait for the user to pick one.
843
852
 
844
853
  ```bash
845
854
  ls .planning/debug/*.md 2>/dev/null | grep -v resolved
@@ -847,7 +856,7 @@ ls .planning/debug/*.md 2>/dev/null | grep -v resolved
847
856
 
848
857
  **If active sessions exist AND no $ARGUMENTS:**
849
858
  - Display sessions with status, hypothesis, next action
850
- - Wait for user to select (number) or describe new issue (text)
859
+ - Return them in a `decision` checkpoint (`## CHECKPOINT REACHED`) so the user can pick one or describe a new issue: you cannot wait for the answer
851
860
 
852
861
  **If active sessions exist AND $ARGUMENTS:**
853
862
  - Start new session (continue to create_debug_file)
@@ -896,6 +905,13 @@ Gather symptoms through questioning. Update file after EACH answer.
896
905
  - Run app/tests to observe behavior
897
906
  - APPEND to Evidence after each finding
898
907
 
908
+ **Phase 1b: Reproduce before you theorise** (no hypothesis until this is written)
909
+ - Build ONE command that drives the reported symptom: a failing test at the closest seam, a CLI call with a fixture, a script. It must assert the user's symptom, not merely run.
910
+ - RUN it and record it in Reproduction (`command`, `fails_with`, secrets redacted). Run it again: the same verdict, or for a flaky bug a recorded rate.
911
+ - Shrink it: cut inputs and steps one at a time, re-running after each, while it still fails. Keep the smallest command that fails.
912
+ - If no command can be built, write `command: none` and `tried:` (what you attempted, why it failed). With `goal: find_root_cause_only` and nothing at all to run against, return a `## CHECKPOINT REACHED` asking for the access, the captured artifact or the environment you need instead of guessing.
913
+ - Reading code to build a theory before this is written is the failure this step prevents: a fix aimed at a neighbouring bug.
914
+
899
915
  **Phase 2: Form hypothesis**
900
916
  - Based on evidence, form SPECIFIC, FALSIFIABLE hypothesis
901
917
  - Update Current Focus with hypothesis, test, expecting, next_action
@@ -940,6 +956,8 @@ Return structured diagnosis:
940
956
 
941
957
  **Root Cause:** {from Resolution.root_cause}
942
958
 
959
+ **Reproduction:** `{Reproduction.command}` — fails with {Reproduction.fails_with}; the fix is done when it passes (or "none: {Reproduction.tried}")
960
+
943
961
  **Evidence Summary:**
944
962
  - {key finding 1}
945
963
  - {key finding 2}
@@ -981,6 +999,7 @@ Update status to "fixing".
981
999
 
982
1000
  **2. Verify**
983
1001
  - Update status to "verifying"
1002
+ - Re-run Reproduction.command: it must now pass. A fix that leaves it failing is not a fix
984
1003
  - Test against original Symptoms
985
1004
  - If verification FAILS: status -> "investigating", return to investigation_loop
986
1005
  - If verification PASSES: Update Resolution.verification, proceed to request_human_verification
@@ -47,7 +47,7 @@ Before verifying, discover project context:
47
47
  |--------|----------------|
48
48
  | `roadmap.md` phase boundary (main flow) | The phase boundary is FIXED. Flag any design element that implements beyond it. |
49
49
  | Feature scope / spec (focus flow) | The feature boundary is FIXED. Flag scope creep past it. |
50
- | `context.md` `## Decisions` (if present) | LOCKED user decisions — the design MUST honor them. Flag contradictions. |
50
+ | `context.md` `## Implementation Decisions` (if present) | LOCKED user decisions — the design MUST honor them. Flag contradictions. |
51
51
  | `context.md` `## Deferred Ideas` (if present) | Out of scope — the design must NOT include these. Flag if designed in. |
52
52
  </upstream_input>
53
53
 
@@ -33,7 +33,7 @@ Before designing, discover project context:
33
33
 
34
34
  **Discovered conventions (MANDATORY):** Extract the project's ACTUAL conventions from the codebase before proposing architecture — module layout, error-handling style, filesystem boundaries, complexity limits, test conventions. Cite the files you learned them from. The design must conform to what the codebase actually does, not to assumptions.
35
35
 
36
- **Project skills:** If `.agents/skills/` exists, read each `SKILL.md` (lightweight index) and load specific `rules/*.md` as needed so the design honors project skill patterns.
36
+ **Project skills:** If `.agents/skills/` exists, read each `SKILL.md` (lightweight index) except PAN's own `pan-*` skills (a Codex or `--unified-skills` install puts one per PAN command there) and load specific `rules/*.md` as needed so the design honors project skill patterns.
37
37
  </project_context>
38
38
 
39
39
  <upstream_input>
@@ -41,7 +41,7 @@ Before designing, discover project context:
41
41
 
42
42
  | Section | How you use it |
43
43
  |---------|----------------|
44
- | `## Decisions` | LOCKED — the design MUST honor these exactly. |
44
+ | `## Implementation Decisions` (inside `<decisions>`) | LOCKED — the design MUST honor these exactly. |
45
45
  | `## Claude's Discretion` | Freedom areas — you choose the approach. |
46
46
  | `## Deferred Ideas` | Out of scope — the design must NOT include these. |
47
47
 
@@ -33,7 +33,7 @@ For each finding:
33
33
  1. **Validate the pattern**: Does the flagged span actually exhibit the bloat pattern? If the matcher had a false positive, mark `confidence: 0` and skip.
34
34
 
35
35
  2. **Classify safety tier** (refine the matcher's initial tier):
36
- - **safe** (auto-applicable): The rewrite cannot change observable behavior. Examples: removing an unused import, extracting a magic number that appears 3+ times to a constant, replacing `try { JSON.parse(literal) } catch` where the literal is constant.
36
+ - **safe** (auto-applicable): The rewrite cannot change observable behavior. Examples: removing an unused import, extracting a magic number that appears 3+ times to a constant, removing a `try`/`catch` around a call the matcher treats as non-throwing (`Number(x)`, `parseInt(x)`) only where `x` is always a string or number — both throw on a Symbol or an object whose `toString` throws, which is why the matcher emits these as `review_required` (it never flags `JSON.parse`, whose guard is load-bearing).
37
37
  - **review_required** (human-gate): The rewrite preserves behavior under all known invariants but the invariants must be checked by a human. Examples: function decomposition, removing a single-instance factory, deduplicating a 5-line block (parameters might differ in subtle ways).
38
38
  - **risky** (never auto-apply): The rewrite changes structure across files, affects public API, or might surface latent bugs. Examples: removing an unreferenced export that might be loaded dynamically, restructuring deeply nested control flow.
39
39
 
@@ -57,8 +57,8 @@ Return a JSON object:
57
57
  "validated": true,
58
58
  "tier": "safe" | "review_required" | "risky",
59
59
  "confidence": 0.95,
60
- "rewrite": "diff --git a/src/foo.js b/src/foo.js\n@@ -42,4 +42,1 @@\n-try {\n- return JSON.parse(literal);\n-} catch (e) { return null; }\n+return JSON.parse(literal);",
61
- "rationale": "JSON.parse on a constant literal does not throw; try/catch is dead code"
60
+ "rewrite": "diff --git a/src/foo.js b/src/foo.js\n@@ -42,4 +42,1 @@\n-try {\n- return parseInt(raw, 10);\n-} catch (e) { return null; }\n+return parseInt(raw, 10);",
61
+ "rationale": "raw is always a string at this call site and parseInt does not throw on a string; the try/catch around it is dead code"
62
62
  }
63
63
  ],
64
64
  "summary": {
@@ -40,9 +40,9 @@ You run in one of two modes depending on what the orchestrator determined in Sta
40
40
  - The orchestrator stitches outputs post-hoc
41
41
  - This is the historical default mode
42
42
 
43
- **How to detect your mode:** the orchestrator puts `mode: single-shot` or `mode: sharded` in the spawn prompt's `<context>` block along with your focus area (sharded) or the token count that justified single-shot. When `mode` is absent, assume `sharded`.
43
+ **How to detect your mode:** a sharded spawn names one focus area (`Focus: tech` and so on — the map-codebase workflow's prompts); a single-shot spawn names none and asks for every document. When unsure, assume `sharded`.
44
44
 
45
- **Do not change modes mid-execution.** If you hit context pressure in single-shot mode, finish writing whatever documents you've analyzed, emit a note in `overview.md` explaining the truncation, and exit cleanly. The orchestrator can re-spawn in sharded mode if needed.
45
+ **Do not change modes mid-execution.** A context note is not a reason to stop: keep the documents you have written on disk and carry on. Only if the repo plainly cannot fit your window, say so in `overview.md` and exit cleanly. The orchestrator can re-spawn in sharded mode if needed.
46
46
  </mode>
47
47
 
48
48
  <why_this_matters>
@@ -61,7 +61,7 @@ You run in one of two modes depending on what the orchestrator determined in Sta
61
61
  | dependency analysis | relationships.md, architecture.md |
62
62
  | code quality | best-practices.md, conventions.md, testing.md |
63
63
 
64
- **`/pan:exec-phase`** references codebase docs to:
64
+ **`/pan:exec-phase`** keeps them current (execute-plan's `update_codebase_map` step), and `pan-verifier` checks new code against `conventions.md` and `structure.md`. They exist to:
65
65
  - Follow existing conventions when writing code
66
66
  - Know where to place new files (structure.md)
67
67
  - Match testing patterns (testing.md)
@@ -103,7 +103,7 @@ Your documents guide future Claude instances writing code. "Use X pattern" is mo
103
103
  <process>
104
104
 
105
105
  <step name="parse_focus">
106
- Read the focus area from your prompt. It will be one of: `tech`, `arch`, `quality`, `concerns`, `relationships`, `practices`.
106
+ Read the focus area from your prompt. It will be one of: `tech`, `arch`, `quality`, `concerns`, `relationships`, `practices` — except from the `pan-map-codebase` workflow script, which names a repository area (a path) and asks for a structured result: document that area and return the fields it asks for; the script's synthesis step writes `.planning/codebase/`.
107
107
 
108
108
  Based on focus, determine which documents you'll write:
109
109
  - `tech` → stack.md, integrations.md
@@ -121,7 +121,7 @@ Explore the codebase thoroughly for your focus area.
121
121
 
122
122
  **CRITICAL: Project Scope Boundary**
123
123
  These directories are PAN Wizard infrastructure — NEVER explore, analyze, or include files from them in your documents:
124
- - `.claude/`, `.github/copilot-instructions.md`, `.opencode/`, `.gemini/`, `.codex/`, `.planning/`
124
+ - `.claude/`, `.codex/`, `.gemini/`, `.opencode/`, `.agents/`, `.planning/`, and the Copilot runtime paths PAN installs into under `.github/` (`agents/`, `skills/`, `hooks/`, `copilot/`, `pan-wizard-core/`, `pan-local-patches/`, `mcp.json`, `package.json`, `pan-file-manifest.json`)
125
125
  When using Glob or Grep, exclude these paths. They are NOT part of the project's source code.
126
126
 
127
127
  **For tech focus:**
@@ -183,7 +183,7 @@ Use the Write tool to create each document.
183
183
  Return a brief confirmation. DO NOT include document contents.
184
184
 
185
185
  Format:
186
- ```
186
+ ```text
187
187
  ## Mapping Complete
188
188
 
189
189
  **Focus:** {focus}
@@ -405,7 +405,7 @@ Ready for orchestrator summary.
405
405
 
406
406
  ## structure.md Template (arch focus)
407
407
 
408
- ```markdown
408
+ ````markdown
409
409
  # Codebase Structure
410
410
 
411
411
  **Analysis Date:** [YYYY-MM-DD]
@@ -470,7 +470,7 @@ Ready for orchestrator summary.
470
470
  ---
471
471
 
472
472
  *Structure analysis: [date]*
473
- ```
473
+ ````
474
474
 
475
475
  ## conventions.md Template (quality focus)
476
476
 
@@ -554,7 +554,7 @@ Ready for orchestrator summary.
554
554
 
555
555
  ## testing.md Template (quality focus)
556
556
 
557
- ```markdown
557
+ ````markdown
558
558
  # Testing Patterns
559
559
 
560
560
  **Analysis Date:** [YYYY-MM-DD]
@@ -660,7 +660,7 @@ Ready for orchestrator summary.
660
660
  ---
661
661
 
662
662
  *Testing analysis: [date]*
663
- ```
663
+ ````
664
664
 
665
665
  ## concerns.md Template (concerns focus)
666
666
 
@@ -744,7 +744,7 @@ Ready for orchestrator summary.
744
744
 
745
745
  ## relationships.md Template (relationships focus)
746
746
 
747
- ```markdown
747
+ ````markdown
748
748
  # Module Relationships
749
749
 
750
750
  **Analysis Date:** [YYYY-MM-DD]
@@ -823,11 +823,11 @@ Imports that cross architectural boundaries:
823
823
  ---
824
824
 
825
825
  *Relationship analysis: [date]*
826
- ```
826
+ ````
827
827
 
828
828
  ## best-practices.md Template (practices focus)
829
829
 
830
- ```markdown
830
+ ````markdown
831
831
  # Best Practices Assessment
832
832
 
833
833
  **Analysis Date:** [YYYY-MM-DD]
@@ -909,7 +909,7 @@ Top 3 improvements ranked by impact:
909
909
  ---
910
910
 
911
911
  *Best practices assessment: [date]*
912
- ```
912
+ ````
913
913
 
914
914
  </templates>
915
915