pan-wizard 3.36.0 → 3.37.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 (314) hide show
  1. package/CHANGELOG.md +3645 -0
  2. package/README.md +36 -48
  3. package/agents/pan-conductor.md +2 -3
  4. package/agents/pan-counterfactual.md +1 -2
  5. package/agents/pan-debugger.md +14 -3
  6. package/agents/pan-design-checker.md +1 -2
  7. package/agents/pan-designer.md +1 -2
  8. package/agents/pan-document_code.md +1 -2
  9. package/agents/pan-hardener.md +2 -3
  10. package/agents/pan-integration-checker.md +1 -2
  11. package/agents/pan-knowledge.md +1 -2
  12. package/agents/pan-meta-reviewer.md +3 -3
  13. package/agents/pan-optimizer.md +4 -4
  14. package/agents/pan-phase-researcher.md +79 -488
  15. package/agents/pan-plan-checker.md +12 -2
  16. package/agents/pan-planner.md +10 -6
  17. package/agents/pan-previewer.md +1 -2
  18. package/agents/pan-project-researcher.md +70 -499
  19. package/agents/pan-release.md +1 -1
  20. package/agents/pan-reviewer.md +9 -3
  21. package/agents/pan-roadmapper.md +12 -7
  22. package/agents/pan-verifier.md +7 -2
  23. package/bin/install-lib.cjs +134 -14
  24. package/bin/install.js +59 -12
  25. package/commands/pan/army.md +1 -1
  26. package/commands/pan/autodev.md +76 -0
  27. package/commands/pan/exec-phase.md +3 -4
  28. package/commands/pan/focus-auto.md +14 -7
  29. package/commands/pan/focus-design.md +4 -5
  30. package/commands/pan/focus-docs.md +24 -0
  31. package/commands/pan/learn.md +13 -6
  32. package/commands/pan/milestone-audit.md +8 -1
  33. package/commands/pan/milestone-done.md +10 -5
  34. package/commands/pan/milestone-new.md +2 -2
  35. package/commands/pan/new-project.md +15 -12
  36. package/commands/pan/plan-phase.md +15 -9
  37. package/commands/pan/quick.md +1 -1
  38. package/commands/pan/review-deep.md +11 -5
  39. package/commands/pan/settings.md +6 -0
  40. package/commands/pan/verify-phase.md +6 -2
  41. package/docs/AGENTS.md +917 -0
  42. package/docs/ARCHITECTURE.md +1054 -0
  43. package/docs/CLI-REFERENCE.md +4582 -0
  44. package/docs/COMPARISON.md +116 -0
  45. package/docs/DEVELOPMENT.md +490 -0
  46. package/docs/ECOSYSTEM-REVIEW-2026-06.md +107 -0
  47. package/docs/ECOSYSTEM-REVIEW-2026-08.md +349 -0
  48. package/docs/EXAMPLES.md +584 -0
  49. package/docs/FAQ.md +254 -0
  50. package/docs/FIELD-HARVEST-2026-07.md +88 -0
  51. package/docs/FIELD-REPORT-army-2026-06.md +121 -0
  52. package/docs/HOOKS.md +638 -0
  53. package/docs/IMPROVEMENT-TODO.md +246 -0
  54. package/docs/INTERNALS.md +485 -0
  55. package/docs/MIGRATION-v2-to-v3.md +258 -0
  56. package/docs/SECURITY-HARDENING.md +230 -0
  57. package/docs/SKILLS-ENHANCEMENT-PLAN-V2.md +122 -0
  58. package/docs/SKILLS-FULL-TEXT.md +9685 -0
  59. package/docs/SKILLS-REFERENCE.md +1037 -0
  60. package/docs/TROUBLESHOOTING.md +1084 -0
  61. package/docs/USER-GUIDE.md +1437 -0
  62. package/docs/archive/SKILLS-ENHANCEMENT-PLAN.md +230 -0
  63. package/docs/audits/AUDIT-2026-08-e2e-ROADMAP.md +117 -0
  64. package/docs/audits/AUDIT-2026-08-e2e-VERIFICATION.md +693 -0
  65. package/docs/audits/AUDIT-2026-08-e2e.md +1546 -0
  66. package/docs/audits/OUTSTANDING-2026-08.md +275 -0
  67. package/docs/audits/STABILITY-TEST-2026-08.md +640 -0
  68. package/docs/branding/README-brand-draft.md +119 -0
  69. package/docs/branding/handoff/IMPLEMENTATION.md +205 -0
  70. package/docs/branding/handoff/README-brand-draft.md +119 -0
  71. package/docs/branding/handoff/image-prompts.md +46 -0
  72. package/docs/branding/image-prompts.md +46 -0
  73. package/docs/branding/nano-banana-prompts.txt +60 -0
  74. package/docs/context-monitor.md +13 -0
  75. package/docs/decisions/ADR-0001-strategic-feature-prioritization.md +83 -0
  76. package/docs/decisions/ADR-0002-copilot-cli-runtime.md +71 -0
  77. package/docs/decisions/ADR-0003-smart-execution.md +84 -0
  78. package/docs/decisions/ADR-0004-copilot-cli-interaction.md +89 -0
  79. package/docs/decisions/ADR-0005-command-naming.md +80 -0
  80. package/docs/decisions/ADR-0006-focus-commands.md +101 -0
  81. package/docs/decisions/ADR-0007-ship-v1.md +73 -0
  82. package/docs/decisions/ADR-0008-map-codebase-mermaid-togaf.md +80 -0
  83. package/docs/decisions/ADR-0009-production-deployment-checklist.md +68 -0
  84. package/docs/decisions/ADR-0010-standards-integration.md +79 -0
  85. package/docs/decisions/ADR-0011-help-commands-rewrite.md +64 -0
  86. package/docs/decisions/ADR-0012-contributors-attribution-index.md +42 -0
  87. package/docs/decisions/ADR-0013-strategic-feature-additions.md +53 -0
  88. package/docs/decisions/ADR-0014-internal-cleanup-code-quality.md +53 -0
  89. package/docs/decisions/ADR-0015-focus-auto-runner.md +296 -0
  90. package/docs/decisions/ADR-0016-enhanced-doc-sync.md +54 -0
  91. package/docs/decisions/ADR-0017-enhanced-focus-design.md +69 -0
  92. package/docs/decisions/ADR-0018-user-reality-testing.md +84 -0
  93. package/docs/decisions/ADR-0019-end-to-end-user-acceptance-testing.md +113 -0
  94. package/docs/decisions/ADR-0020-ai-drift-prevention.md +55 -0
  95. package/docs/decisions/ADR-0021-codebase-mapper-v2.md +76 -0
  96. package/docs/decisions/ADR-0022-lifecycle-completeness.md +63 -0
  97. package/docs/decisions/ADR-0023-opus-4-7-adoption.md +89 -0
  98. package/docs/decisions/ADR-0024-spec-b-v2-completion.md +137 -0
  99. package/docs/decisions/ADR-0025-behavioral-guardrails-layer.md +129 -0
  100. package/docs/decisions/ADR-0026-self-improvement-loop.md +171 -0
  101. package/docs/decisions/ADR-0027-doc-code-link-graph.md +164 -0
  102. package/docs/decisions/ADR-0028-unified-agents-skills-target.md +46 -0
  103. package/docs/decisions/ADR-0029-experiment-evaluator.md +76 -0
  104. package/docs/decisions/ADR-0030-planning-concurrency.md +37 -0
  105. package/docs/decisions/ADR-0031-focus-auto-backlog-source.md +47 -0
  106. package/docs/decisions/ADR-0032-squad-model.md +64 -0
  107. package/docs/decisions/ADR-0033-army-campaign.md +40 -0
  108. package/docs/decisions/ADR-0034-scheduled-campaigns.md +57 -0
  109. package/docs/decisions/ADR-0035-army-hud-dashboard.md +40 -0
  110. package/docs/decisions/ADR-0036-agentic-memory-architecture.md +106 -0
  111. package/docs/decisions/ADR-0037-pin-security-agents-to-opus.md +51 -0
  112. package/docs/decisions/ADR-0038-skill-aligned-decomposition.md +41 -0
  113. package/docs/decisions/ADR-0039-worktree-as-project-variant.md +37 -0
  114. package/docs/decisions/ADR-0040-memory-injection-defense.md +55 -0
  115. package/docs/decisions/ADR-0041-mcp-dual-era-bridge.md +47 -0
  116. package/docs/decisions/ADR-0042-design-parity-both-flows.md +45 -0
  117. package/docs/decisions/ADR-0043-addressable-planning-roots.md +56 -0
  118. package/docs/decisions/ADR-0044-bound-the-cached-context.md +104 -0
  119. package/docs/decisions/ADR-0045-agent-plugins-bundle.md +76 -0
  120. package/docs/decisions/ADR-0046-subagent-frontmatter-decisions.md +39 -0
  121. package/docs/decisions/ADR-0047-pan-harness.md +76 -0
  122. package/docs/decisions/ADR-0048-one-core-per-project.md +43 -0
  123. package/docs/decisions/ADR-0049-machine-verdicts-and-findings-ledger.md +116 -0
  124. package/docs/specs/ai_drift_prevention_featureai.md +286 -0
  125. package/docs/specs/codebase_mapper_v2_featureai.md +930 -0
  126. package/docs/specs/command_naming_optimization_featureai.md +930 -0
  127. package/docs/specs/comp_analysis_markdown_v1.md +149 -0
  128. package/docs/specs/continuous_autonomous_execution_featureai.md +304 -0
  129. package/docs/specs/contributors_attribution_index_featureai.md +476 -0
  130. package/docs/specs/copilot_cli_interaction_featureai.md +868 -0
  131. package/docs/specs/copilot_cli_runtime_featureai.md +647 -0
  132. package/docs/specs/custom-skills-assessment.md +461 -0
  133. package/docs/specs/deployment_audit_findings_featureai.md +243 -0
  134. package/docs/specs/doc_code_link_graph_featureai.md +253 -0
  135. package/docs/specs/documentation_alignment_cleanup_featureai.md +69 -0
  136. package/docs/specs/e2e_visual_testing_featureai.md +615 -0
  137. package/docs/specs/end_to_end_user_acceptance_testing_featureai.md +810 -0
  138. package/docs/specs/evidence-loop-plan.md +76 -0
  139. package/docs/specs/evidence_loop_featureai.md +497 -0
  140. package/docs/specs/focus-auto-optimize-category.md +449 -0
  141. package/docs/specs/focus-auto-optimize-superplan.md +188 -0
  142. package/docs/specs/focus_auto_runner_featureai.md +1102 -0
  143. package/docs/specs/focus_design_v2_featureai.md +197 -0
  144. package/docs/specs/focus_sync_v2_featureai.md +202 -0
  145. package/docs/specs/git_integration_overhaul_featureai.md +326 -0
  146. package/docs/specs/glm_zai_provider_featureai.md +200 -0
  147. package/docs/specs/googlecli_adoption_featureai.md +661 -0
  148. package/docs/specs/help_commands_rewrite_featureai.md +860 -0
  149. package/docs/specs/industry_analysis_strategic_additions_featureai.md +231 -0
  150. package/docs/specs/industry_comparison_and_feature_gaps_featureai.md +674 -0
  151. package/docs/specs/internal_cleanup_code_quality_featureai.md +486 -0
  152. package/docs/specs/investigations/README.md +31 -0
  153. package/docs/specs/investigations/digests/2026-09-28.md +47 -0
  154. package/docs/specs/investigations/digests/2026-10-08.md +62 -0
  155. package/docs/specs/investigations/digests/2026-10-10.md +61 -0
  156. package/docs/specs/investigations/features/debugger-red-loop-first.md +55 -0
  157. package/docs/specs/investigations/features/harness-cross-host-behaviour.md +93 -0
  158. package/docs/specs/investigations/features/optimize-apply-regression-gate.md +66 -0
  159. package/docs/specs/investigations/features/reviewer-smell-baseline.md +57 -0
  160. package/docs/specs/investigations/features/trace-failure-capture.md +69 -0
  161. package/docs/specs/lifecycle_completeness_featureai.md +754 -0
  162. package/docs/specs/local-first-ci.md +42 -0
  163. package/docs/specs/map_codebase_mermaid_togaf_featureai.md +805 -0
  164. package/docs/specs/market-delta-2026-09-superplan.md +310 -0
  165. package/docs/specs/market-ideas-2026-09.md +131 -0
  166. package/docs/specs/market-ideas-2026-10.md +428 -0
  167. package/docs/specs/market-ideas-ledger.md +177 -0
  168. package/docs/specs/memory-optimization-2026-10.md +285 -0
  169. package/docs/specs/multi-track-planning-roots.md +143 -0
  170. package/docs/specs/multi_model_routing_featureai.md +687 -0
  171. package/docs/specs/multi_model_routing_superplan.md +197 -0
  172. package/docs/specs/opus_47_existing_enhancements_featureai.md +247 -0
  173. package/docs/specs/opus_47_extended_features_featureai.md +363 -0
  174. package/docs/specs/opus_47_extended_features_v2_featureai.md +397 -0
  175. package/docs/specs/pan_focus_commands_featureai.md +2336 -0
  176. package/docs/specs/pan_zcode_mcp_bridge_featureai.md +120 -0
  177. package/docs/specs/product-excellence-superplan.md +315 -0
  178. package/docs/specs/product_excellence_program_2026_q4_featureai.md +365 -0
  179. package/docs/specs/production_deployment_readiness_featureai.md +433 -0
  180. package/docs/specs/production_readiness_ship_v1_featureai.md +698 -0
  181. package/docs/specs/real_test_enforcement_featureai.md +213 -0
  182. package/docs/specs/reality-check-2026-09-superplan.md +362 -0
  183. package/docs/specs/right-sized-ceremony.md +74 -0
  184. package/docs/specs/roadmap_and_competition_2026_q4_featureai.md +390 -0
  185. package/docs/specs/self_improvement_loop_featureai.md +875 -0
  186. package/docs/specs/skill-aligned-decomposition.md +155 -0
  187. package/docs/specs/standards_integration_featureai.md +833 -0
  188. package/docs/specs/testing-system-redesign-2026-09.md +267 -0
  189. package/docs/specs/user_reality_testing_system_featureai.md +788 -0
  190. package/docs/specs/watch-triggers.json +22 -0
  191. package/docs/specs/workflow-integration-redesign.md +742 -0
  192. package/docs/specs/workflow_state_consistency_featureai.md +183 -0
  193. package/hooks/dist/pan-context-monitor.js +9 -2
  194. package/hooks/dist/pan-cost-logger.js +5 -0
  195. package/hooks/dist/pan-guard.js +28 -5
  196. package/hooks/dist/pan-stop-guard.js +9 -9
  197. package/hooks/dist/pan-trace-logger.js +5 -0
  198. package/package.json +10 -2
  199. package/pan-wizard-core/bin/lib/agents-md.cjs +57 -8
  200. package/pan-wizard-core/bin/lib/autodev-report.cjs +180 -0
  201. package/pan-wizard-core/bin/lib/autodev.cjs +642 -0
  202. package/pan-wizard-core/bin/lib/ci.cjs +143 -0
  203. package/pan-wizard-core/bin/lib/commands.cjs +1 -1
  204. package/pan-wizard-core/bin/lib/config.cjs +31 -2
  205. package/pan-wizard-core/bin/lib/constants.cjs +27 -1
  206. package/pan-wizard-core/bin/lib/core.cjs +22 -10
  207. package/pan-wizard-core/bin/lib/cost.cjs +14 -4
  208. package/pan-wizard-core/bin/lib/cross-family.cjs +164 -0
  209. package/pan-wizard-core/bin/lib/debug-cases.cjs +104 -0
  210. package/pan-wizard-core/bin/lib/failure-class.cjs +81 -0
  211. package/pan-wizard-core/bin/lib/findings.cjs +34 -4
  212. package/pan-wizard-core/bin/lib/focus.cjs +1 -1
  213. package/pan-wizard-core/bin/lib/hosts.cjs +88 -0
  214. package/pan-wizard-core/bin/lib/init.cjs +7 -2
  215. package/pan-wizard-core/bin/lib/knowledge.cjs +2 -0
  216. package/pan-wizard-core/bin/lib/merge.cjs +50 -0
  217. package/pan-wizard-core/bin/lib/mutate.cjs +16 -5
  218. package/pan-wizard-core/bin/lib/next-action.cjs +112 -0
  219. package/pan-wizard-core/bin/lib/optimize.cjs +2 -2
  220. package/pan-wizard-core/bin/lib/phase.cjs +48 -4
  221. package/pan-wizard-core/bin/lib/plan-lint.cjs +150 -1
  222. package/pan-wizard-core/bin/lib/preview.cjs +23 -4
  223. package/pan-wizard-core/bin/lib/requirements-lint.cjs +130 -0
  224. package/pan-wizard-core/bin/lib/research-lint.cjs +150 -3
  225. package/pan-wizard-core/bin/lib/review-deep.cjs +14 -22
  226. package/pan-wizard-core/bin/lib/review-vote.cjs +105 -0
  227. package/pan-wizard-core/bin/lib/runner.cjs +2 -16
  228. package/pan-wizard-core/bin/lib/sizing.cjs +356 -0
  229. package/pan-wizard-core/bin/lib/squads.cjs +1 -1
  230. package/pan-wizard-core/bin/lib/state-write.cjs +247 -0
  231. package/pan-wizard-core/bin/lib/uat.cjs +149 -0
  232. package/pan-wizard-core/bin/lib/verdict.cjs +26 -3
  233. package/pan-wizard-core/bin/lib/verify-plan-set.cjs +30 -1
  234. package/pan-wizard-core/bin/lib/verify-preflight.cjs +2 -2
  235. package/pan-wizard-core/bin/lib/verify-red.cjs +37 -1
  236. package/pan-wizard-core/bin/lib/verify-retro.cjs +3 -2
  237. package/pan-wizard-core/bin/lib/verify.cjs +59 -4
  238. package/pan-wizard-core/bin/lib/worktree.cjs +70 -0
  239. package/pan-wizard-core/bin/pan-tools.cjs +168 -27
  240. package/pan-wizard-core/learnings/universal/autonomous-loop.md +2 -2
  241. package/pan-wizard-core/references/continuation-format.md +3 -3
  242. package/pan-wizard-core/references/guardrails.md +1 -1
  243. package/pan-wizard-core/references/model-profiles.md +2 -3
  244. package/pan-wizard-core/references/questioning.md +24 -0
  245. package/pan-wizard-core/references/ui-brand.md +4 -6
  246. package/pan-wizard-core/references/verdict-contract.md +2 -1
  247. package/pan-wizard-core/templates/config.json +5 -1
  248. package/pan-wizard-core/templates/debug.md +1 -0
  249. package/pan-wizard-core/templates/discovery.md +2 -2
  250. package/pan-wizard-core/templates/requirements.md +9 -0
  251. package/pan-wizard-core/workflows/add-phase.md +4 -6
  252. package/pan-wizard-core/workflows/assumptions.md +19 -1
  253. package/pan-wizard-core/workflows/diagnose-issues.md +2 -0
  254. package/pan-wizard-core/workflows/discuss-phase.md +4 -2
  255. package/pan-wizard-core/workflows/exec-lean.md +69 -0
  256. package/pan-wizard-core/workflows/exec-phase.md +36 -8
  257. package/{commands/pan → pan-wizard-core/workflows}/focus-doc-audit.md +13 -29
  258. package/{commands/pan → pan-wizard-core/workflows}/focus-drift-walking.md +3 -18
  259. package/{commands/pan → pan-wizard-core/workflows}/focus-exec.md +8 -23
  260. package/{commands/pan → pan-wizard-core/workflows}/focus-plan.md +6 -20
  261. package/{commands/pan → pan-wizard-core/workflows}/focus-scan.md +3 -16
  262. package/{commands/pan → pan-wizard-core/workflows}/focus-sync.md +7 -21
  263. package/pan-wizard-core/workflows/health.md +6 -0
  264. package/pan-wizard-core/workflows/help.md +31 -53
  265. package/pan-wizard-core/workflows/insert-phase.md +4 -6
  266. package/pan-wizard-core/workflows/learn.md +3 -3
  267. package/pan-wizard-core/workflows/milestone-audit.md +2 -2
  268. package/pan-wizard-core/workflows/milestone-new.md +38 -95
  269. package/pan-wizard-core/workflows/new-project.md +96 -258
  270. package/pan-wizard-core/workflows/optimize.md +107 -5
  271. package/pan-wizard-core/workflows/phase-tests.md +10 -0
  272. package/pan-wizard-core/workflows/plan-phase.md +86 -43
  273. package/pan-wizard-core/workflows/profile.md +50 -0
  274. package/pan-wizard-core/workflows/progress.md +10 -0
  275. package/pan-wizard-core/workflows/quick.md +34 -43
  276. package/pan-wizard-core/workflows/research-phase.md +118 -40
  277. package/pan-wizard-core/workflows/resume-project.md +18 -2
  278. package/pan-wizard-core/workflows/settings.md +21 -24
  279. package/pan-wizard-core/workflows/todo-check.md +6 -2
  280. package/pan-wizard-core/workflows/transition.md +22 -4
  281. package/pan-wizard-core/workflows/uat-walkthrough.md +90 -0
  282. package/pan-wizard-core/workflows/update.md +1 -1
  283. package/pan-wizard-core/workflows/verify-phase.md +2 -2
  284. package/scripts/build-agent-plugin.js +35 -15
  285. package/scripts/build-plugin.js +10 -1
  286. package/scripts/deprecate-old-versions.js +70 -3
  287. package/scripts/generate-skills-docs.py +1 -1
  288. package/scripts/git-hooks/pre-push +27 -0
  289. package/scripts/install-git-hooks.js +7 -5
  290. package/scripts/install-pre-push.cjs +38 -0
  291. package/scripts/land.cjs +151 -0
  292. package/scripts/local-ci.cjs +501 -0
  293. package/scripts/local-schedule.cjs +277 -0
  294. package/scripts/prompt-lint.cjs +32 -0
  295. package/scripts/prompt-rules.cjs +156 -0
  296. package/scripts/run-tests.cjs +7 -1
  297. package/scripts/test-quality-lint.cjs +3 -3
  298. package/scripts/test-surface.cjs +9 -2
  299. package/agents/pan-research-synthesizer.md +0 -246
  300. package/commands/pan/audit-deployment.md +0 -386
  301. package/commands/pan/dashboard.md +0 -22
  302. package/commands/pan/discord.md +0 -19
  303. package/commands/pan/mcp-bridge.md +0 -143
  304. package/commands/pan/milestone-cleanup.md +0 -19
  305. package/commands/pan/milestone-gaps.md +0 -35
  306. package/commands/pan/optimize.md +0 -115
  307. package/commands/pan/profile.md +0 -76
  308. package/commands/pan/research-phase.md +0 -189
  309. package/pan-wizard-core/bin/lib/bridge.cjs +0 -269
  310. package/pan-wizard-core/templates/research-project/architecture.md +0 -210
  311. package/pan-wizard-core/templates/research-project/features.md +0 -153
  312. package/pan-wizard-core/templates/research-project/pitfalls.md +0 -206
  313. package/pan-wizard-core/templates/research-project/stack.md +0 -126
  314. package/pan-wizard-core/templates/research-project/summary.md +0 -170
@@ -0,0 +1,1084 @@
1
+ # PAN Troubleshooting Guide
2
+
3
+ Deep-dive troubleshooting for PAN Wizard. For common issues, see the [Troubleshooting section in the User Guide](USER-GUIDE.md#troubleshooting).
4
+
5
+ This guide covers root causes, diagnostic steps, and recovery procedures for scenarios that go beyond basic troubleshooting. Use it as an escalation resource when the User Guide items are not enough.
6
+
7
+ **Other docs:** [User Guide](USER-GUIDE.md) | [FAQ](FAQ.md) | [CLI Reference](CLI-REFERENCE.md) | [Architecture](ARCHITECTURE.md) | [Development](DEVELOPMENT.md) | [Agents](AGENTS.md) | [Hooks](HOOKS.md)
8
+
9
+ ---
10
+
11
+ ## Table of Contents
12
+
13
+ - [Plan Structure and Validation](#plan-structure-and-validation)
14
+ - [Execution and Deviations](#execution-and-deviations)
15
+ - [State and File System](#state-and-file-system)
16
+ - [Checkpoints](#checkpoints)
17
+ - [Verification and Stubs](#verification-and-stubs)
18
+ - [Git Integration](#git-integration)
19
+ - [Models and Cost](#models-and-cost)
20
+ - [Context and Sessions](#context-and-sessions)
21
+ - [Cross-Platform Issues](#cross-platform-issues)
22
+ - [Diagnostic Commands](#diagnostic-commands)
23
+ - [Spec B v2 Troubleshooting](#spec-b-v2-troubleshooting)
24
+
25
+ ---
26
+
27
+ ## Plan Structure and Validation
28
+
29
+ ### Plan frontmatter validation fails
30
+
31
+ **Symptom:** Plan checker rejects your plan with "Missing required frontmatter field: <name>" errors.
32
+
33
+ **Required frontmatter fields:**
34
+
35
+ ```yaml
36
+ ---
37
+ phase: "01"
38
+ plan: "01"
39
+ type: execute|tdd
40
+ autonomous: true|false
41
+ wave: 1
42
+ depends_on: []
43
+ files_modified: []
44
+ must_haves: []
45
+ ---
46
+ ```
47
+
48
+ **Common causes:**
49
+
50
+ - Missing `wave` field
51
+ - `autonomous: true` but plan contains checkpoint tasks
52
+ - Note: `verify plan-structure` checks that each field is present, not its format, so an unpadded phase number or an unquoted plan number does not cause this error
53
+
54
+ **Diagnostic steps:**
55
+
56
+ 1. Open the plan.md and inspect the YAML frontmatter block between `---` markers
57
+ 2. Run `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs verify plan-structure <path-to-plan>` for detailed validation output
58
+ 3. Check that `autonomous` and the task types are consistent -- an autonomous plan must not contain any `type="checkpoint:*"` tasks
59
+
60
+ **Fix:** Correct the frontmatter to match the schema, then re-run `verify plan-structure` on the plan. `pan-tools validate consistency` checks every plan at once, but only for a missing `wave` and gaps in plan numbering; `/pan:health` does not check plan frontmatter.
61
+
62
+ ### Task XML structure errors
63
+
64
+ **Symptom:** Executor cannot parse tasks from plan.md. Execution fails early with no tasks found.
65
+
66
+ **Required task structure:**
67
+
68
+ ```xml
69
+ <task type="auto">
70
+ <name>Task name</name>
71
+ <action>What to do</action>
72
+ <verify>How to verify it worked</verify>
73
+ <done>Completion criteria</done>
74
+ <files>files/that/change.ts</files>
75
+ </task>
76
+ ```
77
+
78
+ **Common causes:**
79
+
80
+ - Missing `<name>` element (required)
81
+ - Missing `<action>` element (required)
82
+ - Missing `<verify>` -- not an error but the executor cannot validate task completion
83
+ - Unclosed XML tags (e.g., `<action>` without `</action>`)
84
+ - HTML entities or special characters in code snippets breaking XML parsing (e.g., `<`, `>`, `&` in code blocks)
85
+ - Nested XML-like content inside `<action>` that confuses the parser
86
+
87
+ **Diagnostic steps:**
88
+
89
+ 1. Open the plan.md and search for all `<task` occurrences
90
+ 2. Verify each task has matching open/close tags for `<name>`, `<action>`, and ideally `<verify>` and `<done>`
91
+ 3. Check that code snippets within tasks do not contain raw `<` or `>` characters outside of fenced code blocks
92
+ 4. Run `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs verify plan-structure <path>` for structural validation
93
+
94
+ **Fix:** Ensure all tasks have at minimum `<name>` and `<action>`. Wrap code snippets in CDATA sections or fenced markdown blocks if they contain XML-special characters. Use `<verify>` and `<done>` for better execution quality.
95
+
96
+ ### Wave dependency conflicts
97
+
98
+ **Symptom:** Plans in the same wave fail because one depends on another's output. For example, Plan 01-02 needs a type defined in Plan 01-01, but both are in wave 1.
99
+
100
+ **Root cause:** Plans assigned the same wave number but have implicit dependencies. Plans in the same wave may execute in parallel (when `parallelization: true`), so wave-mates must be independent.
101
+
102
+ **Diagnostic steps:**
103
+
104
+ 1. Review the `wave` field in the frontmatter of each plan in the affected phase — `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs phase-plan-index N` lists the phase's plans grouped by wave (roadmap.md lists the plans, not their waves)
105
+ 2. Check each plan's `depends_on` frontmatter field -- missing dependencies cause this issue
106
+ 3. Look for shared file references across plans in the same wave using the `<files>` elements
107
+
108
+ **Fix:** Increase the wave number of the dependent plan. Wave 1 runs first, wave 2 after wave 1 completes, and so on. If Plan B depends on Plan A, Plan B must be in a higher wave than Plan A.
109
+
110
+ ### Plan checker enters infinite rejection loop
111
+
112
+ **Symptom:** The planner generates a plan, the checker rejects it, the planner regenerates, the checker rejects again -- repeating up to the maximum number of checks (2 on the sized ceremony, one revision; 3 under `quality`, `workflow.ceremony: full` or `--quality`, two revisions).
113
+
114
+ **Root cause:** The planner and checker have conflicting expectations. Common triggers:
115
+
116
+ - Checker requires verification commands but the plan's domain has no obvious CLI verification
117
+ - Checker requires `must_haves` but the plan type (e.g., `docs`) does not naturally produce them
118
+ - Phase context.md specifies constraints that conflict with checker rules
119
+
120
+ **Diagnostic steps:**
121
+
122
+ 1. Read the checker's rejection message in the planner output -- it explains what failed
123
+ 2. Check `.planning/phases/XX-name/` for any draft plans that were rejected
124
+ 3. Review context.md for constraints that may conflict with plan structure requirements
125
+
126
+ **Fix:** Either adjust the context.md to align with the checker's expectations, or temporarily disable the checker: set `workflow.plan_check: false` in `/pan:settings`. You can also run `/pan:discuss-phase N` to surface assumptions before planning.
127
+
128
+ ### Plans sent back for Review Focus or design decisions
129
+
130
+ **Symptom:** plan-phase sends plans back to the planner without spawning the plan checker, citing one of these codes: `review_focus_missing`, `review_focus_empty`, `review_focus_too_many`, `review_focus_no_task`, `review_focus_unknown_task`, `review_focus_no_test`, `decision_unrecorded`, `decision_uncited` or `decision_duplicate`.
131
+
132
+ **Root cause:** plan-phase runs code checks that cost no model call, even with `--skip-verify` or `workflow.plan_check: false`:
133
+
134
+ - `verify review-focus <phase>` — each plan needs a `## Review Focus` section with at most five items, each naming its owning task (`Task N`, one of the plan's tasks) and a test, or one `None — <reason>` line.
135
+ - `verify decisions <phase>` — a plan cites a `DD-N` id the phase's design does not record, a recorded decision no plan cites, or the design records one id twice. A phase with no design passes; a design with no `DD-N` ids only warns (`decisions_without_ids`).
136
+
137
+ When the checker runs, `research lint <phase|path>` runs just before it but never blocks: claims in the research file's `## Claims` table with no source or checked date, and stale ones past their type's freshness window, go to the checker to weigh.
138
+
139
+ **Fix:** Run the command named in the code to see each failing plan, then fix the plan or the design and re-run `/pan:plan-phase N`. Each send-back counts as one of the checker loop's iterations.
140
+
141
+ ---
142
+
143
+ ## Execution and Deviations
144
+
145
+ ### Executor hits deviation Rule 4 (architectural change)
146
+
147
+ **Symptom:** Execution stops with a checkpoint asking about an architectural decision. The executor detected that completing the task requires structural changes beyond its auto-fix scope.
148
+
149
+ **What triggers Rule 4:**
150
+
151
+ - New database table or schema migration needed (not just a new column)
152
+ - Switching to a different library or framework than planned
153
+ - Adding a new service layer or API boundary
154
+ - Breaking changes to existing public APIs
155
+ - Changes that would affect other phases' assumptions or plans
156
+
157
+ **What to do:**
158
+
159
+ 1. Read the checkpoint description carefully -- it explains what was found, the proposed change, why it is needed, the impact, and alternatives
160
+ 2. Approve the change to let the executor continue with expanded scope
161
+ 3. Answer "defer" to leave the change out -- the executor tracks it as a `[Rule 4 - Architectural]` deviation in the plan's summary.md (`deferred-items.md` holds only the out-of-scope issues executors log there)
162
+ 4. If you need to discuss further, use `/pan:discuss-phase N` to explore alternatives
163
+
164
+ **Prevention:** Run `/pan:discuss-phase N` before planning to surface architectural decisions early. Write a context.md for the phase that captures your preferences.
165
+
166
+ ### Task fails after 3 auto-fix attempts
167
+
168
+ **Symptom:** The executor tried auto-fix rules (Rules 1-3) three times on a task but could not resolve the issue. The task appears in summary.md under "Deferred Issues."
169
+
170
+ **Deviation auto-fix rules and their limits:**
171
+
172
+ | Rule | Trigger | Auto-fixes | Example |
173
+ |------|---------|------------|---------|
174
+ | Rule 1 | Code does not work (wrong logic, null pointers, type errors) | Up to 3 attempts | Query returns wrong data |
175
+ | Rule 2 | Missing critical functionality (error handling, validation, security) | Up to 3 attempts | No input validation on API |
176
+ | Rule 3 | Blocking issues (missing deps, broken imports, build errors) | Up to 3 attempts | Missing npm package |
177
+
178
+ The limit is per task: three auto-fix attempts in all, whichever of Rules 1-3 they fall under.
179
+
180
+ **Diagnostic steps:**
181
+
182
+ 1. Open the summary.md for the plan and read the "Deferred Issues" section
183
+ 2. Check `deferred-items.md` in the phase directory for accumulated items
184
+ 3. Review the executor's commit history for the task to see what fixes were attempted: `git log --oneline -10`
185
+ 4. Look at the test output or build output that was failing
186
+
187
+ **Recovery:**
188
+
189
+ 1. Run `/pan:verify-phase N` to list the gaps, then `/pan:plan-phase N --gaps` to create gap-closure plans for them
190
+ 2. Execute fixes with `/pan:exec-phase N --gaps-only`
191
+ 3. For particularly stubborn issues, use `/pan:debug "description of the problem"` which spawns a dedicated debugging agent
192
+
193
+ ### Deferred items accumulating across plans
194
+
195
+ **Symptom:** Multiple summary.md files in a phase have deferred items. The phase technically "completed" but has quality gaps.
196
+
197
+ **Root cause:** Individual plan executors deferred issues they could not resolve within their 3-attempt limit. These accumulate because each plan executor starts fresh and does not see previous plans' deferred items.
198
+
199
+ **Diagnostic steps:**
200
+
201
+ 1. Check each summary.md in the phase directory for "Deferred Issues" sections
202
+ 2. Check `deferred-items.md` for the out-of-scope issues executors logged there; the issues they gave up on are only in each summary.md
203
+ 3. Run `/pan:verify-phase N` -- the verifier checks the phase goal against the codebase and produces a gap analysis (it does not read `deferred-items.md`, so check that separately)
204
+
205
+ **Recovery:**
206
+
207
+ 1. Run `/pan:verify-phase N` to get a verification.md with a consolidated gap analysis
208
+ 2. Review the verification results to prioritize which items to fix
209
+ 3. Run `/pan:plan-phase N --gaps` to create the gap-closure plans, then `/pan:exec-phase N --gaps-only` to execute only those
210
+ 4. Repeat the verify-then-fix cycle until verification.md shows all clear
211
+
212
+ ### Executor creates files in wrong locations
213
+
214
+ **Symptom:** The executor creates source files but they end up in unexpected directories, or the file structure does not match the plan's `<files>` section.
215
+
216
+ **Root cause:** The plan's `<files>` section listed relative paths that the executor interpreted differently, or the executor's working directory was not the project root.
217
+
218
+ **Diagnostic steps:**
219
+
220
+ 1. Compare the plan's `<files>` sections against the actual files created (check `git log --stat -5`)
221
+ 2. Check if the executor was running from the correct working directory
222
+
223
+ **Fix:** For future plans, use explicit paths relative to the project root in `<files>` sections. For the current issue, move files to the correct locations and commit, or use `/pan:quick` to fix the file layout.
224
+
225
+ ---
226
+
227
+ ## State and File System
228
+
229
+ ### state.md is corrupted or has wrong values
230
+
231
+ **Symptom:** `/pan:progress` shows wrong phase, plan count is incorrect, or fields have unexpected values. Commands behave as if you are at a different point in the project.
232
+
233
+ **Diagnostic:**
234
+
235
+ ```text
236
+ /pan:health
237
+ ```
238
+
239
+ **Common causes:**
240
+
241
+ - Manual editing of state.md broke the `**Field:** value` format (fields must follow this exact pattern)
242
+ - YAML frontmatter and markdown body fields are out of sync (the body is canonical: every state write re-derives the frontmatter from the `**Field:** value` lines, and a body value overwrites the frontmatter one)
243
+ - Interrupted execution left state partially updated (executor crashed between `state advance-plan` and `state update-progress`)
244
+ - A plan was manually deleted from the phase directory but state.md still references it
245
+ - state.md starts with two front-matter blocks: earlier releases stacked a new block on every state write to a CRLF checkout (`core.autocrlf=true`). State writes now refuse such a file with "state.md starts with more than one front-matter block" — keep the block with the right values, delete the other, and run the command again
246
+
247
+ **Fix options (from least to most destructive):**
248
+
249
+ 1. **Auto-repair:** Run `/pan:health --repair` to fix consistency issues automatically
250
+ 2. **Manual fix:** Edit `.planning/state.md` directly -- ensure fields use `**Field:** value` format and the YAML frontmatter matches
251
+ 3. **Reconstruct from disk:** Delete state.md and run `/pan:resume`, which offers to rebuild it from project.md, roadmap.md and the phase summaries (`/pan:health --repair` writes only a minimal scaffold whose current phase reads `(determining...)`) -- `/pan:progress` does not regenerate state.md; with it missing it points you at `/pan:new-project`
252
+ 4. **Full reset:** restore `.planning/roadmap.md` from git (or recreate it with `/pan:milestone-new`), delete `.planning/state.md`, then run `/pan:resume` to rebuild state.md from the roadmap (`/pan:health --repair` writes only a minimal scaffold: the roadmap's milestone, `Current phase: (determining...)`, `Status: Resuming`). `/pan:new-project` refuses to run while `project.md` exists — delete that too only for a true from-scratch reset
253
+
254
+ ### config.json will not parse
255
+
256
+ **Symptom:** Commands fail with "Failed to read config.json" or similar JSON parse errors.
257
+
258
+ **Common causes:**
259
+
260
+ - Trailing comma after the last property in an object (invalid JSON)
261
+ - Missing closing brace or bracket
262
+ - Single quotes instead of double quotes (JSON requires double quotes)
263
+ - Comments in the file (JSON does not support comments)
264
+ - BOM character at the start of the file (invisible but breaks parsers)
265
+
266
+ **Diagnostic steps:**
267
+
268
+ 1. Open `.planning/config.json` in your editor
269
+ 2. Use a JSON validator (e.g., `node -e "JSON.parse(require('fs').readFileSync('.planning/config.json','utf8'))"`) to find the syntax error
270
+ 3. Check the exact error message -- it usually includes a line/column number
271
+
272
+ **Fix:**
273
+
274
+ 1. Correct the JSON syntax error
275
+ 2. If the file is badly corrupted, delete it and run `/pan:health --repair` (or `pan-tools config-ensure-section`) to recreate it with defaults -- other commands fall back to in-memory defaults, and `config-set` writes a config.json holding only the key it sets
276
+ 3. Then use `/pan:settings` to reconfigure your preferences
277
+
278
+ ### .planning/ directory missing or inaccessible
279
+
280
+ **Symptom:** "Failed to create .planning directory", "EACCES: permission denied", or `/pan:health` reports `E001: .planning/ directory not found` despite previous initialization.
281
+
282
+ **Common causes:**
283
+
284
+ - Directory permissions prevent read/write access
285
+ - The `.planning/` directory was accidentally deleted or moved
286
+ - Running PAN from a different working directory than the project root
287
+ - On Windows, antivirus or file indexing may temporarily lock files
288
+
289
+ **Diagnostic steps:**
290
+
291
+ 1. Check if the directory exists: look for `.planning/` in the project root
292
+ 2. Check permissions on the directory and its contents
293
+ 3. Verify your working directory matches the project root
294
+
295
+ **Fix:**
296
+
297
+ - For permission issues: adjust permissions so your user has read/write access to `.planning/` and all subdirectories
298
+ - For missing directory: run `/pan:new-project` to reinitialize; `/pan:resume` routes there too when `.planning/` does not exist
299
+ - For wrong working directory: navigate to the project root before running PAN commands
300
+
301
+ ### PAN says the planning tree belongs to another tool
302
+
303
+ **Symptom:** `/pan:health` (or `pan-tools validate health`) reports `E006: planning tree belongs to gsd-core: …` with status `broken` and no other errors; `pan-tools hygiene scan` raises a single `foreign-planning-tree` warning, and `hygiene clean --apply` lists that warning as manual (`fixable: 0`) and renames nothing; `/pan:new-project` stops with `planning tree belongs to gsd-core`.
304
+
305
+ **Root cause:** the project's `.planning/` was written by another tool. gsd-core (the continuation of Get Shit Done) also uses `.planning/`, with `STATE.md`, `ROADMAP.md`, `PROJECT.md` and `REQUIREMENTS.md` in uppercase — exactly the filenames PAN used before v2.2 — so without this check PAN read the tree as a legacy PAN layout: hygiene would have renamed the other tool's state, health called it broken, and `new-project` would have scaffolded PAN files into it. PAN now recognises the tree from markers it never writes itself (`HANDOFF.json`, `.gsd-allow-shrink`, two or more gsd-only directories, or gsd-core's flat dotted `config.json` keys such as `"workflow.discuss_mode"`) and refuses to touch it. This is deliberate, not corruption.
306
+
307
+ **Fix:** give PAN a tree of its own. Run PAN with `--planning-dir <dir>` (or set `PAN_PLANNING_DIR`) so it works in a separate, project-relative planning directory — the planning-root flags are documented in `docs/CLI-REFERENCE.md` (ADR-0043). If the tree really is an old PAN project and the markers are a coincidence, remove the foreign markers and re-run `pan-tools hygiene scan`: a genuine legacy PAN tree still gets the `legacy-filenames` finding and its rename fix.
308
+
309
+ ### planning-with-files shares the planning tree (I004)
310
+
311
+ **Symptom:** `/pan:health` reports `I004: planning-with-files also writes into this planning tree: …` (info), and `pan-tools hygiene scan` raises a `shared-planning-tree` info finding.
312
+
313
+ **Root cause:** planning-with-files writes into `.planning/` beside PAN: `.active_plan`, `.attestation`, `sessions/`, `ledger-<agent>.jsonl`, and a dated `YYYY-MM-DD-slug/` directory per task holding `task_plan.md`. Unlike gsd-core (E006), it does not take the tree over, so the two tools can share it.
314
+
315
+ **Fix:** none is needed. PAN leaves those files alone and keeps checking its own, and `/pan:new-project` proceeds and reports the other tool in `shared_planning_tree`. If you prefer the tools apart, run PAN with `--planning-dir <dir>` (ADR-0043).
316
+
317
+ ### Planning commits commit nothing (I005)
318
+
319
+ **Symptom:** `pan-tools commit` exits 0 for planning docs but reports `committed: false` with `reason: "skipped_gitignored"`, `git status` never shows them, and `/pan:health` reports `I005: .planning/ is ignored by git while commit_docs is true`.
320
+
321
+ **Root cause:** `.planning/` is listed in `.gitignore`. planning-with-files adds that entry by default, so a project that uses both tools ends up with PAN committing into an ignored directory.
322
+
323
+ **Fix:** remove `.planning/` from `.gitignore` to keep PAN's docs in git. To keep them out on purpose, say so in the config: `pan-tools config-set commit_docs false`.
324
+
325
+ ### Phase directory numbering mismatch
326
+
327
+ **Symptom:** Phase directories use different numbering than roadmap.md, or `find-phase` returns the wrong directory.
328
+
329
+ **Root cause:** Phase directories are named `XX-phase-name/` where XX is the zero-padded phase number. If phases were inserted (e.g., phase 3.1), the directory name uses the full number. Renaming directories manually breaks the mapping.
330
+
331
+ **Diagnostic steps:**
332
+
333
+ 1. List phase directories: check `.planning/phases/` contents
334
+ 2. Compare against roadmap.md phase listing
335
+ 3. Run `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs find-phase N --raw` to see what PAN resolves
336
+
337
+ **Fix:** Do not rename phase directories manually. Use `/pan:insert-phase` and `/pan:remove-phase` to manage phase structure. If directories are already mismatched, `/pan:health --repair` never touches phase directories: what it rewrites is state.md as a minimal scaffold (after a timestamped `.bak-` backup), a missing or unparseable config.json, and requirement and roadmap plan checkboxes left unticked after state records every plan complete; fix the directory names by hand.
338
+
339
+ ---
340
+
341
+ ## Checkpoints
342
+
343
+ ### Dev server will not start at checkpoint
344
+
345
+ **Symptom:** A `checkpoint:human-verify` asks you to check the dev server, but the server fails to start.
346
+
347
+ **Common causes and fixes:**
348
+
349
+ | Cause | Diagnostic | Fix |
350
+ |-------|-----------|-----|
351
+ | Port already in use | `lsof -i :3000` (macOS/Linux) or `netstat -ano \| findstr :3000` (Windows) | Kill the stale process |
352
+ | Missing dependencies | Check for `node_modules/` or equivalent | Run `npm install` / `pip install` / etc. |
353
+ | Missing environment variables | Check error output for "undefined" env vars | Create `.env` file or set variables |
354
+ | Build errors from earlier tasks | Check the executor's task output above the checkpoint | Fix build errors, then retry the server start |
355
+ | Database not running | Check for connection refused errors | Start the database service |
356
+
357
+ **Important:** The executor is supposed to start the server before presenting the checkpoint. If it did not, this is a deviation Rule 3 issue (blocking problem). The checkpoint should include instructions for what the executor already tried.
358
+
359
+ ### Checkpoint appears during auto-advance mode
360
+
361
+ **Symptom:** You enabled `workflow.auto_advance: true` in config but still get a checkpoint that pauses execution.
362
+
363
+ **What auto-advance handles automatically:**
364
+
365
+ | Checkpoint type | Auto behavior |
366
+ |----------------|--------------|
367
+ | `checkpoint:human-verify` | Auto-approved (assumes verification passes) |
368
+ | `checkpoint:decision` | Takes the option named by the task's `auto_select`; **pauses when the task has none** |
369
+ | `checkpoint:human-action` | **Cannot be automated -- always pauses** |
370
+
371
+ **Root cause:** The checkpoint is a `checkpoint:human-action` type, which requires a real human action that cannot be simulated. Common examples: logging into a third-party service, entering a 2FA code, adding an API key, clicking a confirmation email link. Or it is a `checkpoint:decision` whose task has no `auto_select`: the planner left that choice to you, and auto mode never picks an option because it is listed first. To let a run continue unattended past a low-stakes decision, add `auto_select="<option id>"` to the task in the plan.
372
+
373
+ **Fix:** Perform the requested action and confirm completion. There is no way to auto-advance through human-action checkpoints because they require interaction with external systems.
374
+
375
+ ### Authentication gate during execution
376
+
377
+ **Symptom:** Executor hits an auth error and presents a dynamic checkpoint asking for credentials. This is not a code bug -- it is an authentication gate.
378
+
379
+ **How to distinguish auth gates from code bugs:**
380
+
381
+ | Indicator | Auth gate | Code bug |
382
+ |-----------|----------|----------|
383
+ | Error message | "Not authenticated", "401", "403", "Please run X login" | "TypeError", "Cannot read property", build errors |
384
+ | Executor behavior | Stops cleanly with a checkpoint | Enters auto-fix loop |
385
+ | Recovery | Provide credentials, executor retries | Fix code, re-execute |
386
+
387
+ **What to do:**
388
+
389
+ 1. Follow the checkpoint instructions exactly (login command, API key location, etc.)
390
+ 2. Confirm the action is complete
391
+ 3. The executor retries the failed command automatically after your confirmation
392
+ 4. If the auth gate recurs, check that credentials are being persisted (e.g., token stored in correct file, environment variable exported in the right shell profile)
393
+
394
+ ### Checkpoint continuation agent loses context
395
+
396
+ **Symptom:** After a checkpoint, the continuation agent does not seem to know what was already done. It may attempt to redo completed tasks.
397
+
398
+ **Root cause:** Each checkpoint spawns a fresh agent. The continuation agent relies on the `<completed_tasks>` section in its prompt and on git commits to know what was done.
399
+
400
+ **Diagnostic steps:**
401
+
402
+ 1. Check `git log --oneline -10` to verify previous task commits exist
403
+ 2. Look for the checkpoint return format in the orchestrator's output -- it should list completed tasks with commit hashes
404
+
405
+ **Fix:** If the continuation agent is redoing work, it likely means the previous tasks were not committed. Check git log. If commits are missing, the previous executor may have crashed before committing. In that case, review the working tree for uncommitted changes and commit them manually before resuming.
406
+
407
+ ---
408
+
409
+ ## Verification and Stubs
410
+
411
+ ### Verification finds stub components
412
+
413
+ **Symptom:** verification.md reports components that "render placeholder content", "have empty handlers", or "return hardcoded data."
414
+
415
+ **Common stub patterns the verifier detects:**
416
+
417
+ | Pattern | Example | Severity |
418
+ |---------|---------|----------|
419
+ | Placeholder rendering | `<div>ComponentName</div>` | High -- no real UI |
420
+ | Empty event handlers | `onClick={() => {}}` | High -- non-functional |
421
+ | Hardcoded API responses | `return { message: "Not implemented" }` | High -- no real logic |
422
+ | Skeleton schemas | Schema with only `id` field | Medium -- incomplete data model |
423
+ | TODO markers | `// TODO: implement this` | Medium -- acknowledged gap |
424
+ | Pass-through functions | `function validate(x) { return true; }` | Medium -- no real validation |
425
+
426
+ **Root cause:** The plan's tasks were too broadly scoped for the executor's context window, or the executor exhausted its auto-fix attempts and moved on.
427
+
428
+ **Recovery:**
429
+
430
+ 1. Read verification.md for the full list of stub components
431
+ 2. Run `/pan:plan-phase N --gaps` to generate targeted fix plans from verification.md
432
+ 3. Execute with `/pan:exec-phase N --gaps-only`
433
+ 4. Re-verify to confirm stubs are replaced with real implementations
434
+
435
+ ### Wiring verification fails
436
+
437
+ **Symptom:** verification.md reports "component does not call API", "API does not query database", or similar layer-connection failures.
438
+
439
+ **What wiring means in PAN's verification model:**
440
+
441
+ ```text
442
+ UI Component
443
+ --> calls API endpoint (fetch/axios/etc.)
444
+ --> API handler queries database (ORM/SQL/etc.)
445
+ --> Database returns real data
446
+ --> API returns response
447
+ --> Component renders response
448
+ ```
449
+
450
+ Each arrow is a "wire." The verifier checks that these connections exist in the code, not just that each layer exists independently.
451
+
452
+ **Common causes:**
453
+
454
+ - Executor completed individual layer tasks but did not connect them (e.g., built the API and the component but the component still uses mock data)
455
+ - Import paths are wrong so the connection code exists but does not resolve
456
+ - Environment variables for database connection are not set up
457
+
458
+ **Diagnostic steps:**
459
+
460
+ 1. Read the verification.md wiring section for specific disconnected layers
461
+ 2. Check the actual source files to see if the connection code exists but is broken, or does not exist at all
462
+ 3. Look at import statements and function call chains
463
+
464
+ **Fix:** Wiring issues usually require small, targeted changes (adding an import, changing a fetch URL, connecting a handler to the database). Run `/pan:plan-phase N --gaps` to create fix plans that specifically address the wiring gaps, then `/pan:exec-phase N --gaps-only` to run them.
465
+
466
+ ### summary.md self-check shows failure
467
+
468
+ **Symptom:** A summary.md file contains `## Self-Check: FAILED` at the bottom, or `/pan:exec-phase`'s end-of-wave spot-check reports the plan as failed and asks whether to retry it.
469
+
470
+ **What it means:** After completing all tasks, the executor ran its own self-check -- verifying that files it claimed to create actually exist and that commits it claimed to make are in the git log. One or more of these checks failed.
471
+
472
+ **Diagnostic steps:**
473
+
474
+ 1. Read the self-check section in the summary.md -- it lists exactly what is missing (files or commits)
475
+ 2. Check `git log --oneline -20` to see if commits are present but with different hashes
476
+ 3. Check the file system for the claimed files
477
+
478
+ **Common causes:**
479
+
480
+ - Executor reported a file path in the summary that differs from the actual path (e.g., case sensitivity on Linux)
481
+ - A commit was made but the hash was recorded incorrectly
482
+ - The executor crashed after writing the summary but before the final commit
483
+
484
+ **Fix:** If the actual work was done (files exist, commits present), the self-check failure is cosmetic. If files or commits are genuinely missing, use `/pan:verify-phase N` to identify the gaps and `/pan:plan-phase N --gaps` to plan their fixes.
485
+
486
+ ### Verification produces false positives
487
+
488
+ **Symptom:** verification.md reports issues that are not actually problems -- for example, flagging intentionally empty handlers or placeholder text that is correct for the current phase.
489
+
490
+ **Root cause:** The verifier applies generic quality heuristics that may not account for phase-specific context. An empty handler that will be wired in a later phase is correctly empty now.
491
+
492
+ **Fix:**
493
+
494
+ 1. Review each flagged item and determine if it is a true gap or a false positive
495
+ 2. A false positive the verifier lists only as a warning leaves its status alone, but one it counts as a gap (a STUB artifact, a NOT_WIRED link) sets `status: gaps_found`, and on `gaps_found` `/pan:exec-phase` does not mark the phase complete: it offers gap closure and skips auto-advance (a `human_needed` verdict completes the phase once you approve the listed items)
496
+ 3. Use `/pan:verify-phase N` which performs its own final check and distinguishes critical gaps from acceptable state
497
+ 4. If the verifier is consistently too aggressive, consider disabling it for prototyping phases: `workflow.verifier: false` in `/pan:settings`
498
+
499
+ ### Phase gate refuses to complete a phase
500
+
501
+ **Symptom:** `/pan:exec-phase` (or the transition to the next phase) stops without marking the phase complete, and `pan-tools phase complete <N>` exits 1 with `"error": "phase_gate_refused"` and a `reason` such as `missing_summary: 1 plan(s) have no summary: 01-01-plan.md | no_verification: the phase has no verification; run /pan:verify-phase`.
502
+
503
+ **Root cause:** `phase complete` runs the phase gate first, and `workflow.phase_gate` defaults to `enforce`. A config with no `phase_gate` key, including one written by an older PAN, reads as `enforce` too. The gate refuses on any of these codes: `no_plans`, `missing_summary`, `no_verification`, `verification_unreadable`, `verification_failed`, `verification_stale` (files changed since the verified commit), `test_failed`, `human_needed_unapproved`, `reconcile_contradiction`, `open_findings` (an open critical or high finding), `stubs_found` and `integrity_violation` (a weakened test). What it could not check (no git, verifier off) is listed under `not_checked` and never refused on.
504
+
505
+ **Diagnostic:** `pan-tools phase gate <N>` runs the gate alone and prints each reason with its `detail`; it exits 1 while the gate fails.
506
+
507
+ **Fix, in order of preference:**
508
+
509
+ 1. Fix each reason. The `detail` names the fix: run `/pan:verify-phase N` for a missing or stale verification, `/pan:plan-phase N --gaps` then `/pan:exec-phase N --gaps-only` for gaps, `pan-tools findings dispose <id> --as fixed|deferred|dismissed|decision --reason "..."` for an open finding, and `pan-tools findings dispose <id> --as decision --reason "<what was checked>"` for an unapproved human item (only a `decision` approves it). Then run `/pan:exec-phase N` (or `pan-tools phase complete N`) again.
510
+ 2. Complete past the gate once, with a recorded reason: `pan-tools phase complete <N> --force --reason "<why>"`. `--force` without `--reason` is refused (`reason_required`). The override is recorded as a decision.
511
+ 3. Make the gate advisory for the project: `pan-tools config-set workflow.phase_gate warn`. The phase is then marked complete and the reasons are shown as warnings; `/pan:exec-phase` does not auto-advance past a failed gate.
512
+
513
+ ---
514
+
515
+ ## Git Integration
516
+
517
+ ### Commits created but not on expected branch
518
+
519
+ **Symptom:** Commits exist in `git log` but on the wrong branch. The phase branch was supposed to be created but was not, or commits landed on `main` instead.
520
+
521
+ **Root cause:** The `branching_strategy` config controls branch creation. If set to `"phase"` or `"milestone"`, the exec-phase workflow should create a branch. If it did not, the commits go to whatever branch was checked out.
522
+
523
+ **Diagnostic steps:**
524
+
525
+ 1. Check current config: look at `.planning/config.json` for the `branching_strategy` and branch template keys
526
+ 2. Check all branches: `git branch -a`
527
+ 3. Check where the commits are: `git log --all --oneline --graph -20`
528
+
529
+ **Expected config for branching:**
530
+
531
+ ```json
532
+ {
533
+ "branching_strategy": "phase",
534
+ "phase_branch_template": "pan/phase-{phase}-{slug}",
535
+ "milestone_branch_template": "pan/{milestone}-{slug}"
536
+ }
537
+ ```
538
+
539
+ **Fix:**
540
+
541
+ - If commits are on the wrong branch, cherry-pick them to the correct one: `git cherry-pick <hash1> <hash2> ...`
542
+ - If the branch was never created, create it now and cherry-pick or rebase
543
+ - For future phases, verify the branching strategy config before executing
544
+
545
+ ### Planning docs committed when they should not be
546
+
547
+ **Symptom:** `.planning/` files appear in git history, but you wanted them excluded.
548
+
549
+ **Root cause:** `commit_docs` defaults to `true`, meaning PAN commits planning artifacts alongside code. If `.planning/` is not in `.gitignore`, these commits persist in history.
550
+
551
+ **Fix (prevent future commits):**
552
+
553
+ 1. Set `commit_docs: false` in `.planning/config.json` with `pan-tools config-set commit_docs false` (`/pan:settings` has no `commit_docs` question)
554
+ 2. Add `.planning/` to your `.gitignore`
555
+
556
+ **Fix (remove from history):**
557
+
558
+ 1. Remove from tracking (keeps files locally): `git rm -r --cached .planning/`
559
+ 2. Commit the removal: `git commit -m "chore: remove planning docs from tracking"`
560
+ 3. The files remain on disk but are no longer tracked
561
+
562
+ **Caution:** If planning docs have already been pushed to a shared remote, removing them from history requires a force push or BFG Repo-Cleaner. Coordinate with your team before rewriting shared history.
563
+
564
+ ### Commit message format does not match team standards
565
+
566
+ **Symptom:** PAN creates commits like `feat(03-02): add login endpoint` but your team uses a different conventional commit format or an entirely different commit style.
567
+
568
+ **Current format:** `{type}({phase}-{plan}): {description}`
569
+
570
+ **Available types (task commits, per `references/git-integration.md`):** `feat`, `fix`, `test`, `refactor`, `perf`, `chore`. Planning-doc commits go through `pan-tools commit`, whose `--type` accepts `feat`, `fix`, `docs`, `test`, `refactor`, `perf`, `chore`
571
+
572
+ **Workarounds:**
573
+
574
+ 1. **Squash at milestone:** Use `git merge --squash` when completing a milestone to combine all PAN commits into a single commit with your preferred message
575
+ 2. **Interactive rebase:** After phase completion, rebase to rewrite messages: `git rebase -i <base-commit>` (do this before pushing)
576
+ 3. **Post-push:** If already pushed, consider whether the PAN format is acceptable as-is for feature branches that will be squash-merged
577
+
578
+ **Note:** Commit message format is not configurable in the current version. This is a known limitation.
579
+
580
+ ### Git hooks conflict with PAN commits
581
+
582
+ **Symptom:** PAN's commits fail because a pre-commit hook (linter, formatter, test runner) rejects the changes.
583
+
584
+ **Root cause:** PAN executors use `git commit` normally and do not skip hooks. If the committed code does not pass your pre-commit hooks, the commit fails.
585
+
586
+ **Diagnostic steps:**
587
+
588
+ 1. Check which hooks are installed: look in `.git/hooks/` or `.husky/` (if using Husky)
589
+ 2. Run the hook manually on the staged files to see the exact failure
590
+ 3. Check if the failure is in PAN-generated code or in planning docs
591
+
592
+ **Fix:**
593
+
594
+ - If the hook fails on code quality: the PAN executor's auto-fix rules should handle this, but if the linter rules are unusual, the executor may not know how to satisfy them. Add linter configuration details to context.md for the phase.
595
+ - If the hook fails on planning docs: add `.planning/` to the hook's ignore list, or set `commit_docs: false` to avoid committing planning files entirely.
596
+ - Do not use `--no-verify` as a workaround -- fix the underlying issue instead.
597
+
598
+ ---
599
+
600
+ ## Models and Cost
601
+
602
+ ### Token usage higher than expected
603
+
604
+ **Symptom:** A phase consumed significantly more tokens than anticipated. API billing shows unexpectedly high usage.
605
+
606
+ **Token usage by stage (approximate):**
607
+
608
+ | Stage | `budget` | `balanced` | `quality` |
609
+ |-------|---------------|-----------------|-----------------|
610
+ | Research (opt-in) | 10-20K | 30-50K (on the mid tier) | 30-50K |
611
+ | Planning | 10-20K | 20-40K (checker on the mid tier) | 20-40K |
612
+ | Execution (per plan) | 10-40K | 20-80K | 20-80K |
613
+ | Verification | 5-10K | 10-20K | 10-20K |
614
+
615
+ `quality` and `balanced` are `inherit` for every agent except the researchers and the plan-checker, which `balanced` runs on the mid tier; `balanced` also sizes the ceremony (a precisely specified small phase skips the planner and the checker), where `quality` runs the full ceremony. `budget` is the only profile that down-tiers the rest. Derived from `MODEL_PROFILES` in `core.cjs` — that table is the source of truth.
616
+
617
+ **Common causes of higher-than-expected usage:**
618
+
619
+ - Plan checker rejection loop (the first plan and one revision on the sized ceremony, two under `quality` = up to 3x planning cost)
620
+ - Executor auto-fix loops (each Rule 1-3 attempt costs additional tokens)
621
+ - Plans with too many tasks (4+ tasks per plan increases per-plan cost)
622
+ - Staying on the default profile for high-volume work `budget` would have absorbed
623
+ - Research enabled for a domain you already know well
624
+
625
+ **Cost reduction strategies (ordered by impact):**
626
+
627
+ 1. **Switch profile:** `/pan:settings --profile budget` for prototyping or high-volume work — it lowers every agent's tier; `balanced` (the default) already runs the researchers and the plan-checker on the mid tier and sizes the ceremony, where `quality` spends the most
628
+ 2. **Leave research off:** it is off by default; `/pan:plan-phase N --research` turns it on for one phase, and `--skip-research` leaves it out when `workflow.research` is `true`
629
+ 3. **Disable plan checker:** `workflow.plan_check: false` in `/pan:settings` (saves 20-40K per phase)
630
+ 4. **Disable verifier:** `workflow.verifier: false` for early prototyping (saves 10-30K per phase)
631
+ 5. **Smaller plans:** Keep plans to 2-3 tasks each (reduces per-plan context usage)
632
+ 6. **Use --prd:** Provide a detailed PRD with `/pan:plan-phase N --prd spec.md` to skip discuss-phase
633
+
634
+ ### A wave report says the phase is near or over budget
635
+
636
+ **Symptom:** `/pan:exec-phase` adds "Spend: … of the … phase budget (…%)" to a wave report, or "over budget: the phase keeps running", and `/pan:plan-phase` ends with "Budget: … of … spent so far".
637
+
638
+ **What it means:** the phase's recorded spend has reached 80% (`near`) or 100% (`over`) of `cost.phase_budget_usd`, $20 by default. The dollars are API-equivalent: the cost ledger's tokens priced at the rate table, even on a subscription. It is a warning only: nothing pauses or stops on it.
639
+
640
+ **Fix:** `pan-tools cost budget --phase N` shows the figures. Raise or lower the budget with `/pan:settings` or `pan-tools config-set cost.phase_budget_usd 50`; `0` turns the warning off. To spend less, see the strategies above.
641
+
642
+ ### Wrong model being used for an agent
643
+
644
+ **Symptom:** An agent runs on a cheaper model than you expected, or execution quality does not match expectations for the configured profile.
645
+
646
+ **How model selection works:**
647
+
648
+ | Agent type | `budget` | `balanced` | `quality` |
649
+ |-----------|--------|----------|----------|
650
+ | Research | fast | mid | reasoning |
651
+ | Planning | mid | reasoning | reasoning |
652
+ | Execution | mid | reasoning | reasoning |
653
+ | Verification | fast | reasoning | reasoning |
654
+ | Plan checker | fast | mid | reasoning |
655
+
656
+ `quality` and `balanced` are `inherit` for every agent except the researchers and the plan-checker, which `balanced` runs on the mid tier. `budget` is the only profile that down-tiers the rest. `inherit` → the reasoning tier, i.e. the model the session was launched with; `mid` and `fast` map to the provider's mid/fast models (Sonnet and Haiku on Anthropic). Derived from `MODEL_PROFILES` in `core.cjs` — that table is the source of truth, and `pan-tools estimate-cost` prints the relative multiplier per profile.
657
+
658
+ So if the symptom is "an agent ran on a weaker model", the profile to look at is `budget`, or `balanced` when the agent was a researcher or the plan-checker; moving to `quality` puts those back on the reasoning tier.
659
+
660
+ **Override precedence:** Per-agent override (`model_overrides`) > per-phase roadmap model tier (read only by `resolve-model --metadata`, which no workflow passes) > profile default > hardcoded `mid`
661
+
662
+ **Diagnostic steps:**
663
+
664
+ 1. Check `.planning/config.json` for `model_profile` (the base profile)
665
+ 2. Check `model_overrides` in the same file for per-agent overrides
666
+ 3. Run `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs resolve-model <agent-type> --raw` to see what model PAN would actually use
667
+
668
+ **Fix:** Adjust `model_overrides` in config to pin a specific agent to a tier. The values are tiers, not model ids: `opus` or `reasoning` resolves to `inherit`, the session's own model; `sonnet` or `mid` and `haiku` or `fast` to the provider's mid and fast models; any other value, a full model id included, falls back to the mid tier. `resolve-model <agent> --raw` shows the result:
669
+
670
+ ```json
671
+ {
672
+ "model_profile": "balanced",
673
+ "model_overrides": {
674
+ "pan-executor": "opus",
675
+ "pan-phase-researcher": "haiku"
676
+ }
677
+ }
678
+ ```
679
+
680
+ ### Execution quality varies between plans in the same phase
681
+
682
+ **Symptom:** Some plans produce high-quality, complete implementations while others produce stubs or partial work, even though they are in the same phase.
683
+
684
+ **Root cause:** Each plan executor gets a fresh context window. Quality depends on:
685
+
686
+ - **Plan specificity:** Vague plans produce vague code. Detailed `<action>` sections produce better results.
687
+ - **Task count:** Plans with 4+ tasks may exhaust the context window.
688
+ - **Domain complexity:** Some tasks (e.g., complex state management) are inherently harder for a single context to handle.
689
+ - **Model selection:** The assigned model may be insufficient for the task complexity.
690
+
691
+ **Fix:**
692
+
693
+ 1. Review the lower-quality plans -- are their tasks specific enough?
694
+ 2. Consider re-planning with smaller, more detailed tasks
695
+ 3. If you are on `budget`, complex tasks are the case for leaving it — or pin just the executor back up with `model_overrides: { "pan-executor": "reasoning" }`
696
+ 4. Add more detail to the phase's context.md to provide implementation guidance
697
+
698
+ ### Per-agent `effort:` appears to have no effect
699
+
700
+ **Symptom:** PAN's agents carry an `effort:` level in their frontmatter (the shipped base level, which `AGENT_BASE_EFFORT` mirrors), but every agent runs at the session's effort regardless. `effort_overrides` and the `budget` profile's step-down change only the `effort` that `resolve-model` reports, never the frontmatter.
701
+
702
+ **Root cause:** Claude Code before `2.1.267` ignored `effort:` frontmatter on custom commands, skills and subagents whenever the model had a pinned default effort. PAN emitted the field correctly the whole time; the runtime did not read it.
703
+
704
+ **Fix:** Update Claude Code (`claude --version` to check) — nothing changes on PAN's side. On OpenCode, Gemini CLI and Copilot CLI PAN never relied on the field: their agent files carry an effort-scaled prose preamble instead, which is unaffected. Codex agents carry the level as Codex's own `model_reasoning_effort`.
705
+
706
+ **Also check `maxEffortLevel`.** Claude Code `2.1.267` added a `maxEffortLevel` setting (top-level, or per model under `modelSettings`). A managed or user value there clamps every `effort:` PAN emits, so an agent that seems to ignore its frontmatter on a current build may be capped rather than ignored. `claude config get maxEffortLevel` (or the settings file) shows whether one is set.
707
+
708
+ ### Cost report disagrees with Claude Code's `/usage` or with the invoice
709
+
710
+ **Symptom:** `pan-tools cost report` totals differ from what Claude Code shows or what the provider bills.
711
+
712
+ **Causes, in the order to check them:**
713
+
714
+ 1. **Stale rate table.** `pan-tools models check` prints when the built-in rates were last verified and flags the table once it is old. Provider prices move faster than PAN releases; if it says STALE, the fix is a rate refresh, not a config change.
715
+ 2. **Cache-read pricing on the newest Fable-tier model.** Its cache reads bill at a quarter of the standard Claude cache-read multiplier. PAN carries a dedicated rate row for it (see `DEFAULT_RATES` in `cost.cjs`); releases before that row existed priced its reads at the previous Fable model's rate, high by roughly four times on the line that dominates PAN's traffic.
716
+ 3. **The newest Opus-tier model, now the default everywhere.** Claude Code `2.1.280` made it the default model on every plan, and its cache reads bill at half the standard multiplier — a third cache-read rate in the current lineup. Releases before PAN carried its row priced it through the family-prefix fallback at the previous Opus row: cache reads high by two and a half times, input, output and cache writes by a quarter. Upgrade PAN; `pan-tools models check` (without `--raw`, which prints only the one-line verdict) lists the model ids the table prices under `models`.
717
+ 4. **Contracted rates.** If your organisation pins `modelPricing` in Claude Code's managed settings, PAN reads the same block and prices with it — its `overrides` rows, and its `multiplier` over every model, as Claude Code applies them; `pan-tools models check` (JSON output, not `--raw`) lists the model ids it found under `managed_model_pricing` and the multiplier under `managed_pricing_multiplier`. PAN 3.30.0 and earlier read a row shape the documentation does not describe, and so priced a real policy file at list price. Precedence is `.planning/config.json → cost.rates`, then managed `modelPricing`, then the built-in table. If the list is empty on a machine where the policy should apply, check that the file sits where Claude Code reads it (its managed-settings documentation gives the per-OS directory; the legacy Windows `ProgramData` path is read by neither tool), or point PAN at a relocated directory with `PAN_MANAGED_SETTINGS_DIR`.
718
+ 5. **Hook rows are priced at read time.** Records the SubagentStop hook writes carry `cost_usd: null` and are priced when the report runs, so a rate change re-prices history. That is deliberate: it is what lets a rate fix correct old totals.
719
+
720
+ ### Usage limits arrive sooner after a Claude Code update
721
+
722
+ **Symptom:** After updating Claude Code, a PAN phase uses noticeably more of the plan's allowance, or the cost report's model column moves from a Sonnet-tier id to an Opus-tier one.
723
+
724
+ **Root cause:** Claude Code `2.1.280` changed the default model on the Pro and Team Standard plans from Sonnet to the newest Opus-tier model, matching the other plans. PAN's `quality` and `balanced` profiles resolve the agents that plan, write and judge code to the session's own model (`inherit`; under `balanced` only the researchers and the plan-checker run on the mid tier), so a change of default moves those agents at once — nothing in PAN changed. The exception is an agent spawned with no model, as `/pan:army` spawns them: it runs on its own `model:` pin where its file has one (the reviewer-class agents pin `opus`).
725
+
726
+ **Fix:** Choose the session model yourself with `/model`, or switch PAN to the `budget` profile (planning and execution on the mid tier, verification and research on the fast tier), or pin individual agents with `model_overrides` in `.planning/config.json`.
727
+
728
+ ---
729
+
730
+ ## Context and Sessions
731
+
732
+ ### Context window exhausted mid-phase
733
+
734
+ **Symptom:** Claude becomes less coherent, loses track of the current task, or starts repeating itself. The context monitor (if installed) has given the agent PAN's context note: the host will compact the session soon.
735
+
736
+ **Why this happens:** The main session accumulates context from every command you run. PAN subagents (executors, verifiers) each get a fresh context window, but the orchestrating session does not reset until the host compacts it. After a compaction PAN re-injects the planning position, but a long session can still lose detail on the way there.
737
+
738
+ **Immediate recovery:**
739
+
740
+ 1. Run `/pan:pause` -- this saves progress to a `.continue-here.md` handoff document
741
+ 2. Start a new Claude Code session
742
+ 3. Run `/pan:resume` -- this restores context from state.md, project.md and `.continue-here.md`, and flags plans that have no summary.md yet
743
+
744
+ **Prevention strategies:**
745
+
746
+ - Run `/clear` between major commands (e.g., after plan-phase completes, before exec-phase)
747
+ - Avoid reading large files in the main session -- let subagents handle file reading
748
+ - Use the `budget` profile (its mid/fast agents produce shorter output, consuming less context); `balanced` and `quality` differ only in the researchers and the plan-checker, so switching between those two will not help much here
749
+ - Keep plans to 2-3 tasks each to reduce executor output size
750
+
751
+ ### resume restores incomplete context
752
+
753
+ **Symptom:** After resuming, PAN seems to have forgotten important details about the project or recent work.
754
+
755
+ **What `/pan:resume` restores:**
756
+
757
+ | Source | Content | Always loaded |
758
+ |--------|---------|--------------|
759
+ | state.md | Current phase, plan, status, decisions | Yes |
760
+ | roadmap.md | The next phase's goal; the phase list when it rebuilds a missing state.md | Only when routing to plan the next phase, or rebuilding state.md |
761
+ | .continue-here.md | Handoff notes from pause | If exists |
762
+ | summary.md files | Which plans have none yet (incomplete work); decisions and concerns when it rebuilds state.md | Checked for, not read, unless rebuilding state.md |
763
+ | project.md | Project brief | Yes |
764
+
765
+ **What is NOT restored:**
766
+
767
+ - Conversation history from the previous session
768
+ - In-progress work that was not committed
769
+ - Detailed context from subagent executions
770
+ - File contents that were read during the previous session
771
+
772
+ **Fix:** If critical context is missing after resume:
773
+
774
+ 1. Run `/pan:progress` for a comprehensive status analysis
775
+ 2. Manually read key files that provide needed context
776
+ 3. If you need details from a specific plan execution, read its summary.md directly
777
+ 4. For file-level details, read the relevant source files
778
+
779
+ ### OpenCode 2 says "Plugin must export a default definition with an id and an effect or setup function"
780
+
781
+ The installed `plugins/pan-wizard.js` predates OpenCode 2 support. OpenCode 2's loader requires `setup` (or `effect`), and older PAN plugins exported only `server`, so the compaction hand-off was lost. Re-run the installer with `--opencode` (or `/pan:update`) to get the plugin that exports both: OpenCode 1 keeps calling `server()`, OpenCode 2 calls `setup()`.
782
+
783
+ ### Multiple sessions interfere with each other
784
+
785
+ **Symptom:** Two Claude Code sessions running PAN on the same project produce conflicting commits, corrupted state.md, or duplicated work.
786
+
787
+ **Root cause:** `state.md` writes are serialized via advisory file locking plus atomic writes (ADR-0030), but PAN does not coordinate whole-session concurrency. Two sessions can still commit to the same branch, race on other artifacts, or duplicate work — keep to one session per project.
788
+
789
+ **Prevention:** Do not run multiple PAN sessions on the same project simultaneously. PAN is designed for single-session operation.
790
+
791
+ **Recovery:**
792
+
793
+ 1. Close all but one session
794
+ 2. Run `/pan:health --repair` to fix any state inconsistencies
795
+ 3. Check `git log` for duplicate or conflicting commits
796
+ 4. Manually resolve any git conflicts
797
+
798
+ ### Agents re-read the cached context at full price after a short pause
799
+
800
+ **Symptom:** `/usage` shows a low prompt-cache hit ratio for PAN's agents, or the ledger shows repeated cache *writes* of the same context block within an hour.
801
+
802
+ **Root cause:** Claude Code decides the prompt-cache lifetime per request bucket. The main conversation can get the one-hour lifetime on a subscription; **everything else — subagents, workflows, forks — gets five minutes** unless you say otherwise. Every PAN agent is a subagent, so a phase whose agents are spaced more than five minutes apart re-caches the same planning context each time. ADR-0044 measured that block as the bulk of PAN's token traffic.
803
+
804
+ **Fix:** Set `subagentPromptCacheTtl` to `"1h"` in a Claude Code settings file (Claude Code `2.1.242` or later). Weigh it first: one-hour cache writes bill at twice the base input rate against 1.25× for five-minute writes, so the longer lifetime pays off once a block is read at least twice inside the hour — true for a phase run, false for a single quick agent. To see which lifetime a session is using, `/usage` shows a `Prompt cache (main)` line with the hit ratio and, on recent builds, the likely cause of the last miss. On PAN's side, `pan-tools context-budget` reports the block's size under `cache.total_tokens` and its classification (`ok`, `warn`, `critical` or `absent`) under `cache.status` and, under `cache.ttl`, how many cache writes in the ledger followed an idle gap of five to sixty minutes (only the five-minute writes, on rows that record the cache-lifetime split; `cache.ttl.basis` says whether the count is `measured`, `mixed` or `inferred`) — the misses the one-hour lifetime would have avoided — recommending the setting only when that recurs; `pan-tools hygiene scan` raises the same recommendation as a `cache-context` finding — `info`, or `warn` once the re-written tokens reach `TTL_WARN_TOKENS` in `context-budget.cjs`.
805
+
806
+ ### A headless `claude -p` run sees no PAN commands, agents or hooks
807
+
808
+ **Symptom:** A scripted or CI run of Claude Code answers as if PAN were not installed: `/pan:*` commands are unknown, no PAN agent can be spawned, and the cost and context hooks never fire.
809
+
810
+ **Root cause:** The run is in bare mode. Claude Code's headless documentation recommends `--bare` for scripted and SDK calls and says it "will become the default for `-p` in a future release". Bare mode skips auto-discovery of hooks, skills, custom commands, subagents, plugins, MCP servers, auto memory and CLAUDE.md. With `--add-dir` it loads that directory's `.claude/skills/` but still skips `.claude/commands/` and `.claude/agents/`, and it never reads OAuth credentials (it needs an API key).
811
+
812
+ **Fix:** Leave `--bare` off for runs that need PAN. Where bare mode is imposed, load PAN's parts explicitly: `--settings` for a settings file carrying PAN's hooks, `--mcp-config .mcp.json` for the bridge, `--agents` for agent definitions, or `--plugin-dir` pointing at the built PAN plugin. A `--unified-skills` install places its skills under `.claude/skills/`, which is the one PAN surface `--add-dir` still loads.
813
+
814
+ ### The exec-phase orchestrator shows no todo checklist
815
+
816
+ **Symptom:** On the newest Claude models the `/pan:exec-phase` orchestrator never shows a todo list, although the command lists a todo tool among its allowed tools.
817
+
818
+ **Root cause:** Since Claude Code `2.1.233` its task-tracking tools (`TodoWrite` and the `TaskCreate` family) are offered by default only on older models; on newer ones they are absent unless `CLAUDE_CODE_ENABLE_TODO_TOOLS=1` is set. PAN never depends on them — the wave record is the attention anchor the orchestrator prints after each wave, the wave summaries, and `state.md`.
819
+
820
+ **Fix:** Nothing is required. Set `CLAUDE_CODE_ENABLE_TODO_TOOLS=1` if you want the checklist back.
821
+
822
+ ### PAN's project rules are not picked up
823
+
824
+ **Symptom:** Agents ignore the rules PAN adds to the project (for example they do not know where `.planning/` lives), in a project where the rules file exists.
825
+
826
+ **Root cause:** PAN writes its rules into a marker-fenced section of `AGENTS.md` and adds an `@AGENTS.md` import to `CLAUDE.md`, so Claude Code loads them either way. Since `2.1.277` Claude Code also reads `AGENTS.md` directly, but by default only when no `CLAUDE.md`, `.claude/CLAUDE.md` or `CLAUDE.local.md` exists in the working directory or above. Before `2.1.281`, some sessions (Amazon Bedrock, or telemetry disabled) read `CLAUDE.md` files only; from `2.1.281` that no longer depends on the provider. Disabling the built-in `agents-md` plugin turns direct reading off. So the rules go missing when the `@AGENTS.md` import has been removed from `CLAUDE.md` while a `CLAUDE.md` still exists, when the project instructions setting in `/config` is limited to `CLAUDE.md` files, or when the `agents-md` plugin is disabled.
827
+
828
+ **Fix:** Restore the import (re-running the installer does it). Or set the project instructions setting back to its default, `claude-md-or-agents-md`, or to `claude-md-and-agents-md`, which loads both and never reads an imported `AGENTS.md` twice. Re-enable the `agents-md` plugin in `/plugin` if it was disabled.
829
+
830
+ ### Copilot CLI loads PAN's rules twice in a project that also has Claude Code
831
+
832
+ **Symptom:** In a project with both the Claude Code and the Copilot CLI install, Copilot's system message carries PAN's rules section ("## PAN Wizard") twice. That is PAN's whole section repeated on every request, plus the compact instructions in `CLAUDE.md`, which only Claude Code uses.
833
+
834
+ **Root cause:** Copilot CLI reads `AGENTS.md` and `CLAUDE.md` as two separate repository instruction sources, both enabled by default (`copilot instruction list --json`, checked on `1.0.91`). Since `1.0.66` it also expands the `@AGENTS.md` import inside `CLAUDE.md`. So PAN's section arrives once from `AGENTS.md` and once through the import. Recorded sessions on `1.0.88` show both copies. Copilot removes duplicate instruction files only when their content is identical, and these two files differ. Its `already-loaded` skip applies only within one file's import tree.
835
+
836
+ **Why PAN does not change the files:** Claude Code needs the import. It reads `AGENTS.md` directly only when no `CLAUDE.md` exists, so dropping the import loses the rules there. Making the two files identical would hold only in a project where neither carries anything but PAN's block.
837
+
838
+ **Fix:** In Copilot, run `/instructions` and turn off the source you do not need:
839
+ - **`CLAUDE.md` holds only PAN's block:** turn it off. Copilot still reads PAN's section from `AGENTS.md`.
840
+ - **`CLAUDE.md` holds your own rules too:** turn off `AGENTS.md` instead. Copilot then gets PAN's section through the import.
841
+
842
+ ### `/skill-doctor` lists most PAN skills as unused
843
+
844
+ **Symptom:** Claude Code's `/skill-doctor` reports many `pan-*` skills loaded but never invoked, with a context cost beside each.
845
+
846
+ **Why this is expected:** A unified-skills install ships the whole command set as skills, and only a few are used in any one session. Until a skill is invoked it costs its `description` line and nothing else — PAN's descriptions are short by design, and the tool's per-skill figure is that line, not the body.
847
+
848
+ **Fix, if you want a shorter list:** use Claude Code's `skillOverrides` setting to mark individual skills `hidden` or `collapsed` rather than deleting their files — PAN's manifest tracks every installed file, and a deleted skill comes back on the next upgrade and fails verification until then.
849
+
850
+ ---
851
+
852
+ ## Cross-Platform Issues
853
+
854
+ ### Windows path backslashes cause failures
855
+
856
+ **Symptom:** File path comparisons or references fail on Windows. Plans reference files with forward slashes but verification checks use backslashes, or vice versa.
857
+
858
+ **Root cause:** Windows uses `\` backslashes natively but PAN normalizes to `/` forward slashes internally. Mismatches can occur when:
859
+
860
+ - plan.md `<files>` sections are written with backslashes
861
+ - External tools output paths with backslashes that PAN compares against forward-slash references
862
+ - `pan-tools.cjs` receives a backslash path as an argument
863
+
864
+ **Fix:**
865
+
866
+ - Always use forward slashes (`/`) in plan.md `<files>` sections and config paths
867
+ - PAN's internal `toPosix()` helper handles conversion for most operations
868
+ - If a specific command fails due to paths, check whether the path argument contains backslashes and convert them
869
+
870
+ ### Shell expansion breaks commands containing $ signs
871
+
872
+ **Symptom:** Commands containing `$` (such as JavaScript template literals or shell variable references) get expanded by the shell before PAN processes them.
873
+
874
+ **Root cause:** Bash interprets `$` as variable expansion. A command containing `${name}` may be expanded to an empty string or an unrelated variable's value.
875
+
876
+ **Where this matters:**
877
+
878
+ - Custom pre/post hooks that contain template literals
879
+ - context.md code examples that the executor copies verbatim
880
+ - Commands in plan `<action>` sections
881
+
882
+ **Fix:**
883
+
884
+ - Put content containing `$` in a file and pass the file rather than an inline argument -- this avoids shell expansion (`/pan:focus-auto --step exec` gives its agents the same advice)
885
+ - In context.md and plan code examples, use fenced code blocks (the executor reads them as literal text)
886
+ - In custom hooks or scripts, use single quotes to prevent expansion: `'${literal}'`
887
+ - Escape dollar signs with backslash when shell expansion is unavoidable: `\${escaped}`
888
+
889
+ ### File encoding issues
890
+
891
+ **Symptom:** plan.md, state.md, or other planning files contain garbled characters, or tools fail to parse files that look correct in an editor.
892
+
893
+ **Common causes:**
894
+
895
+ - Files saved with non-UTF-8 encoding (e.g., UTF-16, Windows-1252)
896
+ - BOM (Byte Order Mark) at the start of files confusing parsers
897
+ - Line endings mixed between CRLF (Windows) and LF (Unix) in files another tool parses (PAN's own frontmatter reader normalises CRLF and a leading BOM)
898
+
899
+ **Diagnostic steps:**
900
+
901
+ 1. Check file encoding in your editor (most show encoding in the status bar)
902
+ 2. Look for a BOM character: the file may start with invisible bytes `EF BB BF`
903
+ 3. Check line endings: look for `\r\n` versus `\n`
904
+
905
+ **Fix:**
906
+
907
+ - Convert files to UTF-8 without BOM
908
+ - Use consistent line endings (configure `.gitattributes` with `* text=auto`)
909
+ - If using VS Code, click the encoding indicator in the bottom bar to re-save with correct encoding
910
+
911
+ ### Long file paths on Windows
912
+
913
+ **Symptom:** File operations fail with "path too long" errors, especially in deeply nested phase directories or projects with long names.
914
+
915
+ **Root cause:** Windows has a default maximum path length of 260 characters. Phase directory paths like `.planning/phases/03-user-authentication/03-02-summary.md` add significant length.
916
+
917
+ **Fix:**
918
+
919
+ - Enable long paths in git: `git config --system core.longpaths true`
920
+ - Or enable via Group Policy: Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths
921
+ - Use shorter project directory names when possible
922
+
923
+ ---
924
+
925
+ ## Diagnostic Commands
926
+
927
+ Quick reference for diagnosing PAN issues at various levels. The `~/.claude/pan-wizard-core/...` paths below are a global Claude Code install's. A local install (the default) keeps the core in the project, so run `node .claude/pan-wizard-core/bin/pan-tools.cjs` from the project root, and use your runtime's directory (`.codex`, `.gemini`, `.opencode`, `.github`) in place of `.claude`.
928
+
929
+ ### Project health
930
+
931
+ | Command | What it checks |
932
+ |---------|---------------|
933
+ | `/pan:health` | Validates ROADMAP/disk consistency, phase directory naming, state integrity |
934
+ | `/pan:health --repair` | Same as above but auto-fixes what it can |
935
+ | `/pan:progress` | Shows current state, phase progress, identifies what to do next |
936
+ | `/pan:assumptions N` | Surfaces hidden assumptions about phase N |
937
+
938
+ ### CLI-level diagnostics
939
+
940
+ | Command | What it checks |
941
+ |---------|---------------|
942
+ | `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs validate consistency` | Direct consistency check between ROADMAP and disk |
943
+ | `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs verify plan-structure <file>` | Validate a single plan.md structure |
944
+ | `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs state load` | Config plus the raw state.md text, as JSON (`state json` parses the frontmatter) |
945
+ | `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs state json` | state.md frontmatter as JSON |
946
+ | `node ~/.claude/pan-wizard-core/bin/pan-tools.cjs find-phase N` | Resolve phase number to directory path |
947
+
948
+ ### Reading raw state
949
+
950
+ To inspect PAN's internal state directly:
951
+
952
+ ```bash
953
+ # Full state dump as JSON
954
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs state load
955
+
956
+ # Specific field value
957
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs state get "Current Phase" --raw
958
+
959
+ # Config value as written in config.json (a key the file leaves out
960
+ # reports "Key not found"; its built-in default still applies)
961
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs config-get workflow.research --raw
962
+
963
+ # Phase directory lookup
964
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs find-phase 3 --raw
965
+
966
+ # Resolve which model an agent would use
967
+ node ~/.claude/pan-wizard-core/bin/pan-tools.cjs resolve-model pan-executor --raw
968
+ ```
969
+
970
+ ### Git diagnostics
971
+
972
+ ```bash
973
+ # Recent PAN commits
974
+ git log --oneline -20
975
+
976
+ # Commits for a specific phase-plan
977
+ git log --oneline --grep="(03-02)"
978
+
979
+ # Files changed by PAN in this session
980
+ git diff --stat HEAD~10
981
+
982
+ # Check which branch you're on
983
+ git branch --show-current
984
+
985
+ # See all PAN branches
986
+ git branch -a | grep pan/
987
+ ```
988
+
989
+ ### When to escalate
990
+
991
+ If none of the above resolves your issue:
992
+
993
+ 1. **Check for known issues:** Review the [PAN Wizard repository](https://github.com/oharms/PanWizard) issues and discussions
994
+ 2. **Collect diagnostics:** Run `/pan:health`, copy the output, and note the exact error message and command that triggered it
995
+ 3. **Check versions:** Run `cat ~/.claude/pan-wizard-core/VERSION` for your installed PAN version, and note your Claude Code version
996
+ 4. **File an issue:** Include the health output, error message, PAN version, and steps to reproduce
997
+
998
+ ---
999
+
1000
+ ## Spec B v2 Troubleshooting
1001
+
1002
+ ### `/pan:what-if` worktree won't clean up
1003
+
1004
+ If `whatif cleanup` fails (e.g. process holding the directory open, permission issues), the worktree and branch remain. Clean up manually:
1005
+
1006
+ ```bash
1007
+ git worktree remove --force <worktree-path>
1008
+ git branch -D pan-whatif/<phase>-<slug>-<ts>
1009
+ ```
1010
+
1011
+ The worktree path and branch name are in the JSON `whatif prepare` prints (`worktree.worktree_path`, `worktree.branch`); the counterfactual report does not record them. Check `git worktree list` if you can't find the path.
1012
+
1013
+ Common causes:
1014
+ - Editor has files open in the worktree (close them first)
1015
+ - Uncommitted changes in the worktree (use `--force` to discard them)
1016
+ - Filesystem lock on Windows (close any terminal session with that cwd)
1017
+
1018
+ ### `/pan:army` left `pan-army-*` directories or `army/*` branches behind
1019
+
1020
+ Army worktrees are created as **siblings of the project directory** (`../pan-army-<slug>/`, the task name slugified), each on an `army/<slug>` branch. A completed or aborted campaign should leave none — Phase 5 removes each task's worktree and branch after its squash-merge lands. If any remain (a campaign aborted mid-flight, or predates the teardown), sweep them:
1021
+
1022
+ ```bash
1023
+ pan-tools worktree cleanup # safe sweep — see what it keeps and why
1024
+ pan-tools worktree cleanup --force # also discard dirty worktrees + unintegrated branches
1025
+ ```
1026
+
1027
+ The default sweep is deliberately cautious: it **keeps** any worktree with uncommitted changes and any branch whose commits are not reachable from your current branch — that branch may be the only copy of aborted work — and prints the exact command to remove each kept item. Read the `kept` list before reaching for `--force`. Two things to know:
1028
+
1029
+ - A **squash-merged** branch never looks merged to git, so it shows up as "not reachable" even though its work landed — if the merge is in, deleting it is correct (`git branch -D army/<slug>`, or `--force`).
1030
+ - The sweep only ever touches the `army/` namespace and `pan-army-*` worktrees; your own worktrees and branches are never candidates.
1031
+
1032
+ Manual recovery, if the sweep itself is blocked (same causes as the what-if section above):
1033
+
1034
+ ```bash
1035
+ git worktree remove --force ../pan-army-<slug>
1036
+ git branch -D army/<slug>
1037
+ git worktree prune
1038
+ ```
1039
+
1040
+ ### The `pan` MCP server is missing on Gemini CLI in a fresh checkout
1041
+
1042
+ **Symptom:** PAN installed for Gemini and wrote its `pan` server into `.gemini/settings.json`, but Gemini CLI lists no such server.
1043
+
1044
+ **Root cause:** Gemini CLI `0.59.0` (released `2026-09-08`) enforces workspace trust fail-closed. Its trusted-folders documentation states that in an untrusted folder the **whole project `.gemini/settings.json` is not loaded** — so PAN's hooks are absent too, not only the MCP server — and the release note names `mcpServers`, `tools`, `policyPaths` and telemetry among the keys filtered in restricted mode. The registration is present and correct; the runtime declines to load it until you trust the folder.
1045
+
1046
+ **Fix:** Accept Gemini CLI's trust prompt for the workspace (or mark it trusted through its workspace-trust setting), then restart the session. PAN's own install checks still pass in the meantime — they verify the file on disk, not the runtime's trust state — so a clean install check plus a missing server is the signature of this case.
1047
+
1048
+ ### A Codex plugin upgrade seems to need a restart
1049
+
1050
+ Since Codex CLI `0.154.0` (released `2026-09-09`), a live session picks up newly installed plugin tools and refreshes skills and hooks after an external plugin upgrade — no restart. If a PAN skill still reads stale after upgrading PAN, the cause is the install, not Codex caching (on Codex `pan-check-update` only records the newest version in `~/.codex/cache/pan-update-check.json`, since Codex runs no PAN statusline to show it): re-run the installer and compare the `version` in `pan-file-manifest.json` with the `VERSION` file the installer writes inside the installed core directory (beside its `bin/` folder).
1051
+
1052
+ ### PAN's hooks do not run under `copilot -p`
1053
+
1054
+ **Symptom:** Copilot CLI works in a PAN project, but no cost rows appear and the stop guard never fires when you run it headless with `copilot -p` — while an interactive session in the same folder behaves.
1055
+
1056
+ **Root cause:** in prompt mode Copilot loads a repository's hooks — `.github/hooks/*.json` and the project's `.claude/settings.json` alike — only when the folder is already trusted, `COPILOT_ALLOW_ALL=true` is set, or `GITHUB_COPILOT_PROMPT_MODE_REPO_HOOKS=true` is set (Copilot CLI reference, environment variables). A folder you have never opened interactively is not trusted, so a scripted `copilot -p` there runs none of PAN's hooks.
1057
+
1058
+ **Fix:** open the folder once in an interactive `copilot` session and trust it, or set `GITHUB_COPILOT_PROMPT_MODE_REPO_HOOKS=true` for the headless run.
1059
+
1060
+ ### PAN's hooks do not run on Codex, or stopped running after an upgrade
1061
+
1062
+ **Symptom:** `.codex/hooks.json` lists PAN's hooks, but no cost rows appear, the stop guard never fires, or they worked before a PAN upgrade and do not now. Codex may print a warning at startup telling you to open `/hooks`.
1063
+
1064
+ **Root cause:** Codex runs a non-managed hook only after you trust it, and records that trust against a hash of the hook's definition — its event, matcher and command. Its hooks documentation: "new or changed hooks are marked for review and skipped until trusted." A PAN install adds hooks, and an upgrade that registers a new one (the stop guard on `Stop`, or the state re-injection on `SessionStart`) or changes a command gives Codex hooks it has not reviewed; each is skipped until you trust it. Project-scoped `.codex/` hooks also load only once the project itself is trusted (the trust note the installer prints).
1065
+
1066
+ **Fix:** In Codex, run `/hooks`, review the `pan-*` hooks and trust them — the startup prompt's "Trust all and continue" does the same for every hook waiting on review. `--dangerously-bypass-hook-trust` runs enabled hooks without persisted trust for that one invocation, which is useful for a quick check but not a setting to keep. Repeat after any PAN upgrade that changes the hooks.
1067
+
1068
+ ### `/pan:exec-phase --hierarchical` printed a warning and ran flat
1069
+
1070
+ Expected when:
1071
+ - You're not on Claude Code — the flag needs native sub-agent spawning, which the other runtimes don't support cleanly
1072
+
1073
+ The flag degrades to flat exec in that case. There is **no model gate**: `pan-conductor` carries no `model:` frontmatter, so it runs on whatever model you launched the session with (the `budget` profile's advisory tiering is the only thing that would nominate a cheaper one, and it does not block the flag). So "wrong model" is never the reason. On Claude Code the command's `<process>` sends every `--hierarchical` run to `pan-conductor`, whatever the phase's plan count; that routing is prose the orchestrator follows, not a code guard, so a flat run there means the orchestrator did not follow `commands/pan/exec-phase.md`.
1074
+
1075
+ ### Cost log records have `input_tokens: 0` and `cost_usd: null`
1076
+
1077
+ The SubagentStop hook reads the subagent's own transcript when the payload carries an `agent_id` (`token_source: "agent-transcript"`); without one it sums the slice of the parent session transcript since the previous SubagentStop (`token_source: "transcript"`), and the payload's `usage` block is only a fallback. Zeros mean the payload named no transcript and carried no `usage` (`token_source: "usage-fallback"`), a parallel sibling already consumed the shared parent slice (`"transcript"`), the host named an agent whose transcript file was not there yet (`"agent-transcript-missing"`), or a plausibility guard dropped an implausible value (`clamped: true`) — the record's `token_source` and `clamped` fields say which. `cost_usd: null` on its own is normal: every hook row carries it, and the report prices the row when it runs. Since v3.29 a row with no tokens and no model is an unmeasured spawn: `cost report` excludes it from `calls` and counts it under `totals.empty_excluded` rather than as an unknown-cost call. Rows written by 3.28 and earlier from the parent slice can carry a whole session's usage; `cost report` quarantines those as `suspect_excluded` when they exceed 500M cache-read or 10M output tokens, span more than six hours, or (untimed rows only) show cache reads dwarfing input and output — a timed parent-slice row under those limits is counted, attributed to the subagent that happened to stop — and `hygiene scan` names the ledger poisoned when the quarantined rows dominate it.
1078
+
1079
+ Options:
1080
+ - **Upgrade Claude Code** if its SubagentStop payload carries no `agent_id` (the row's `agent_id` is `null`): the hook needs it to read the subagent's own transcript, and the payload's `usage` block is only the last resort.
1081
+ - **Append explicit records** for calls you care about: `pan-tools cost append --agent X --model <model-id> --input-tokens N --output-tokens N`. The aggregator merges hook-sourced and caller-sourced records.
1082
+ - **Reconcile from provider billing.** The hook is directional — use the provider's API (Anthropic console, etc.) for exact monthly totals.
1083
+
1084
+ Records with zero tokens still indicate that an agent ran — they're not useless, just incomplete. The exception is in older ledgers: a zero-token row with no agent name may be one of Claude Code's own helper agents, which PAN now records nothing for (see [Host-internal helper agents](HOOKS.md#host-internal-helper-agents)).