pan-wizard 3.31.0 → 3.33.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 (87) hide show
  1. package/README.md +28 -24
  2. package/agents/pan-conductor.md +2 -2
  3. package/agents/pan-design-checker.md +18 -0
  4. package/agents/pan-document_code.md +2 -2
  5. package/agents/pan-executor.md +3 -3
  6. package/agents/pan-experiment-runner.md +7 -10
  7. package/agents/pan-hardener.md +15 -15
  8. package/agents/pan-knowledge.md +1 -1
  9. package/agents/pan-meta-reviewer.md +2 -2
  10. package/agents/pan-optimizer.md +7 -3
  11. package/agents/pan-phase-researcher.md +2 -2
  12. package/agents/pan-plan-checker.md +29 -2
  13. package/agents/pan-planner.md +23 -10
  14. package/agents/pan-project-researcher.md +10 -67
  15. package/agents/pan-reviewer.md +19 -0
  16. package/agents/pan-roadmapper.md +5 -48
  17. package/agents/pan-verifier.md +49 -11
  18. package/bin/install-lib.cjs +170 -15
  19. package/bin/install.js +39 -14
  20. package/commands/pan/army.md +2 -2
  21. package/commands/pan/design-phase.md +8 -0
  22. package/commands/pan/exec-phase.md +1 -1
  23. package/commands/pan/experiment.md +2 -2
  24. package/commands/pan/focus-auto.md +12 -8
  25. package/commands/pan/focus-design.md +2 -0
  26. package/commands/pan/focus-exec.md +1 -1
  27. package/commands/pan/focus-scan.md +2 -7
  28. package/commands/pan/git.md +2 -2
  29. package/commands/pan/learn.md +2 -0
  30. package/commands/pan/map-codebase.md +4 -4
  31. package/commands/pan/mcp-bridge.md +1 -1
  32. package/commands/pan/milestone-done.md +1 -2
  33. package/commands/pan/optimize.md +14 -2
  34. package/commands/pan/phase-tests.md +2 -2
  35. package/commands/pan/profile.md +2 -2
  36. package/commands/pan/research-phase.md +2 -4
  37. package/commands/pan/review-deep.md +8 -8
  38. package/commands/pan/todo-add.md +2 -2
  39. package/commands/pan/todo-check.md +2 -2
  40. package/hooks/dist/pan-context-monitor.js +1 -1
  41. package/hooks/dist/pan-cost-logger.js +63 -11
  42. package/hooks/dist/pan-state-reinject.js +142 -17
  43. package/hooks/dist/pan-stop-guard.js +2 -2
  44. package/hooks/dist/pan-trace-logger.js +283 -18
  45. package/package.json +1 -1
  46. package/pan-wizard-core/bin/lib/agents-md.cjs +4 -1
  47. package/pan-wizard-core/bin/lib/commands.cjs +95 -2
  48. package/pan-wizard-core/bin/lib/config.cjs +110 -0
  49. package/pan-wizard-core/bin/lib/constants.cjs +39 -9
  50. package/pan-wizard-core/bin/lib/core.cjs +27 -7
  51. package/pan-wizard-core/bin/lib/cost.cjs +16 -6
  52. package/pan-wizard-core/bin/lib/findings.cjs +385 -0
  53. package/pan-wizard-core/bin/lib/focus.cjs +72 -19
  54. package/pan-wizard-core/bin/lib/foreign-planning.cjs +24 -6
  55. package/pan-wizard-core/bin/lib/hygiene.cjs +12 -2
  56. package/pan-wizard-core/bin/lib/init.cjs +9 -2
  57. package/pan-wizard-core/bin/lib/optimize.cjs +349 -21
  58. package/pan-wizard-core/bin/lib/phase.cjs +52 -2
  59. package/pan-wizard-core/bin/lib/review-deep.cjs +38 -2
  60. package/pan-wizard-core/bin/lib/state.cjs +10 -4
  61. package/pan-wizard-core/bin/lib/verdict.cjs +481 -0
  62. package/pan-wizard-core/bin/lib/verify-drift.cjs +14 -5
  63. package/pan-wizard-core/bin/lib/verify-preflight.cjs +4 -2
  64. package/pan-wizard-core/bin/lib/verify-scope.cjs +223 -0
  65. package/pan-wizard-core/bin/lib/verify.cjs +111 -8
  66. package/pan-wizard-core/bin/pan-tools.cjs +68 -6
  67. package/pan-wizard-core/learnings/README.md +10 -7
  68. package/pan-wizard-core/mcp/server.cjs +18 -9
  69. package/pan-wizard-core/mcp/tool-registry.cjs +2 -0
  70. package/pan-wizard-core/references/checkpoints.md +4 -2
  71. package/pan-wizard-core/references/verdict-contract.md +102 -0
  72. package/pan-wizard-core/templates/discovery.md +1 -1
  73. package/pan-wizard-core/templates/phase-prompt.md +2 -1
  74. package/pan-wizard-core/templates/verification-report.md +21 -0
  75. package/pan-wizard-core/workflows/exec-phase.md +73 -50
  76. package/pan-wizard-core/workflows/health.md +3 -0
  77. package/pan-wizard-core/workflows/learn.md +4 -2
  78. package/pan-wizard-core/workflows/milestone-audit.md +15 -3
  79. package/pan-wizard-core/workflows/new-project.md +1 -1
  80. package/pan-wizard-core/workflows/optimize.md +14 -1
  81. package/pan-wizard-core/workflows/plan-phase.md +20 -15
  82. package/pan-wizard-core/workflows/quick.md +6 -6
  83. package/pan-wizard-core/workflows/verify-phase.md +10 -15
  84. package/pan-zcode/README.md +3 -3
  85. package/scripts/build-agent-plugin.js +19 -5
  86. package/scripts/git-hooks/pre-commit +2 -1
  87. package/scripts/test-surface.cjs +4 -0
package/README.md CHANGED
@@ -105,16 +105,16 @@ PAN is the context engineering layer that makes Claude Code reliable. It breaks
105
105
 
106
106
  **Run it over days.** `--schedule` arms a resumable campaign with a per-day budget that burns the backlog down across sessions (the per-day budget is advisory unless the schedule is armed with `--enforce-budget`, which pauses the day's run once spent — `campaign status` shows the day's spend — and an external scheduler triggers each `--continue`) — and *still* waits for you at every merge. **Autonomy runs up to the irreversible step; a human is at the step.**
107
107
 
108
- **Watch it live.** `/pan:hud` renders a single self-contained HTML dashboard — Mission Control over the squads, in-flight worktrees, campaign budget, telemetry, and the safety harness — in one page.
108
+ **See it.** `/pan:hud` renders a single self-contained HTML snapshot — Mission Control over the squads, in-flight worktrees, campaign budget, telemetry, and the safety harness — in one page. The page does not refresh itself; re-run the command for a fresh one.
109
109
 
110
110
  ```bash
111
111
  /pan:army "ship the v1 reporting module" # plan → delegate → build → review → human-gated ship
112
112
  /pan:army "harden auth across the app" --schedule daily --daily-budget 200
113
113
  /pan:army --status # where the campaign stands
114
- /pan:hud --open # watch the army work, live
114
+ /pan:hud --open # snapshot of the army's current state
115
115
  ```
116
116
 
117
- Resolve the live squad roster any time with `pan-tools squad list`.
117
+ Resolve the live squad roster any time with `pan-tools squad list` (`pan-tools` is shorthand; see [Operations](#operations) for how to run it).
118
118
 
119
119
  ---
120
120
 
@@ -142,7 +142,7 @@ Verify with:
142
142
 
143
143
  ### Staying Updated
144
144
 
145
- PAN evolves fast. Update periodically:
145
+ PAN evolves fast. On Claude Code, update periodically with `/pan:update`, which detects whether the install is local or global but passes no other flag, so it always updates Claude Code in its default location. For any other runtime, or an install made with `--config-dir` or `--unified-skills`, re-run the installer yourself with the flags you installed with (add `--global` for a global install, since the installer defaults to the current project):
146
146
 
147
147
  ```bash
148
148
  npx pan-wizard@latest
@@ -163,8 +163,8 @@ npx pan-wizard --opencode --global # Install to ~/.config/opencode/
163
163
  npx pan-wizard --gemini --global # Install to ~/.gemini/
164
164
 
165
165
  # Codex (skills-first)
166
- npx pan-wizard --codex --global # Skills to ~/.agents/skills/, core and hooks to ~/.codex/
167
- npx pan-wizard --codex --local # Skills to ./.agents/skills/, core and hooks to ./.codex/
166
+ npx pan-wizard --codex --global # Skills to ~/.agents/skills/, core, agents and hooks to ~/.codex/
167
+ npx pan-wizard --codex --local # Skills to ./.agents/skills/, core, agents and hooks to ./.codex/
168
168
 
169
169
  # GitHub Copilot CLI (skills-first)
170
170
  npx pan-wizard --copilot --global # Install to ~/.copilot/
@@ -175,7 +175,7 @@ npx pan-wizard --all --global # Install to all directories
175
175
  ```
176
176
 
177
177
  Use `--global` (`-g`) to install into your home config directory; `--local` (`-l`) is the default and may be omitted.
178
- Use `--claude`, `--opencode`, `--gemini`, `--codex`, `--copilot`, or `--all` to skip the runtime prompt.
178
+ Use `--claude`, `--opencode`, `--gemini`, `--codex`, `--copilot`, or `--all` to skip the runtime prompt. A local install also writes outside the runtime directory: a marker-fenced PAN section in the project's `AGENTS.md`; for Claude Code, an `@AGENTS.md` import in `CLAUDE.md` and a `pan` MCP server in `.mcp.json`; and for Codex or `--unified-skills`, the shared `.agents/` tree (skills, plus a shared core under `--unified-skills`). `--uninstall` removes them (the `AGENTS.md` and `CLAUDE.md` blocks and the `.agents/` tree stay while another PAN runtime in the project still uses them).
179
179
  Add `--unified-skills` to install commands as one shared `.agents/skills/` tree instead of per-runtime formats. Codex, Gemini CLI, OpenCode, Copilot CLI and Antigravity CLI read that tree; Claude Code does not, so for Claude the installer also copies each skill into `.claude/skills/` and the commands become `/pan-<name>`. Gemini CLI gives skills no slash command, so on a unified Gemini install you ask for the task and `/skills list` shows what loaded. See the User Guide for details.
180
180
 
181
181
  > **Gemini CLI note:** from June 18, 2026, Google's Gemini CLI serves Gemini Code Assist (Standard/Enterprise) customers; individual free / AI Pro / Ultra accounts are directed to Antigravity CLI instead. PAN's `--gemini` target installs for Gemini CLI. Antigravity CLI is not yet a PAN install target, but it reads the shared `.agents/skills/` tree natively — install with `--unified-skills` and PAN's commands are usable from Antigravity in the same project.
@@ -190,8 +190,10 @@ directory. The installer hard-refuses to install into its own source repo (a
190
190
  `PAN_SOURCE_ROOT` guard exits with an error), so point it at a different target:
191
191
 
192
192
  ```bash
193
- # 1. Get the source
193
+ # 1. Get the source and build the hooks (hooks/dist/ is build output a clone lacks;
194
+ # the installer copies the hooks from there)
194
195
  git clone https://github.com/oharms/PanWizard.git
196
+ cd PanWizard && npm run build:hooks
195
197
 
196
198
  # 2. Install into a DIFFERENT project directory (never the PanWizard source dir)
197
199
  cd /path/to/some-test-project
@@ -346,7 +348,7 @@ The system:
346
348
 
347
349
  Each plan is small enough to execute in a fresh context window. No degradation, no "I'll be more concise now."
348
350
 
349
- **Creates:** `{phase_num}-research.md`, `{phase_num}-{N}-plan.md`
351
+ **Creates:** `{phase_num}-research.md`, `{phase_num}-{N}-plan.md`, `{phase_num}-plan-check.md` (the checker's report, when the checker runs)
350
352
 
351
353
  ---
352
354
 
@@ -397,7 +399,7 @@ Plans are grouped into "waves" based on dependencies. Within each wave, plans ru
397
399
 
398
400
  This is why "vertical slices" (Plan 01: User feature end-to-end) parallelize better than "horizontal layers" (Plan 01: All models, Plan 02: All APIs).
399
401
 
400
- **Creates:** `{phase_num}-{N}-summary.md`, `{phase_num}-verification.md`
402
+ **Creates:** `{phase_num}-{N}-summary.md`, `{phase_num}-review.md` (unless `--skip-review` or `--fast`), `{phase_num}-verification.md`
401
403
 
402
404
  ---
403
405
 
@@ -481,7 +483,7 @@ PAN handles it for you:
481
483
 
482
484
  | File | What it does |
483
485
  |------|--------------|
484
- | `project.md` | Project vision, always loaded |
486
+ | `project.md` | Project vision, read when PAN plans, researches or resumes work |
485
487
  | `research/` | Ecosystem knowledge (stack, features, architecture, pitfalls) |
486
488
  | `requirements.md` | Scoped v1/v2 requirements with phase traceability |
487
489
  | `roadmap.md` | Where you're going, what's done |
@@ -522,7 +524,7 @@ Every stage uses the same pattern: a thin orchestrator spawns specialized agents
522
524
  | Research | Coordinates, presents findings | Parallel researchers investigate stack, features, architecture and pitfalls |
523
525
  | Planning | Validates, manages iteration | Planner creates plans, checker verifies, up to three passes |
524
526
  | Execution | Groups into waves, tracks progress | Executors implement in parallel, each in a fresh context (native sub-agents on Claude Code, each runtime's own delegation elsewhere) |
525
- | Verification | Presents results, routes next | Verifier checks codebase against goals, debuggers diagnose failures |
527
+ | Verification | Presents results, routes next | Verifier checks codebase against goals; on Claude Code, `/pan-diagnose-issues` sends one debugger per failed UAT truth |
526
528
 
527
529
  The orchestrator never does heavy lifting. It spawns agents, waits, integrates results.
528
530
 
@@ -613,7 +615,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
613
615
  |---------|--------------|
614
616
  | `/pan:progress` | Where am I? What's next? |
615
617
  | `/pan:hud` (alias `/pan:dashboard`) | Render a self-contained HTML dashboard of project + bot-army state to `.planning/hud.html` (`--open`, `--out`, `--stdout`) |
616
- | `/pan:report phase <N> \| index \| all` | Self-contained HTML report for one phase, or a timeline index linking every phase report (`--out`, `--open`, `--stdout`; `--bundle` on `index` inlines every phase report into one file) |
618
+ | `/pan:report phase <N> \| index \| all` | Self-contained HTML report for one phase, or a timeline index linking every phase report (`--out`, `--open`, `--stdout` on `phase` and `index`; `--bundle` on `index` inlines every phase report into one file; `all` regenerates every phase report plus the index and takes only `--open`) |
617
619
  | `/pan:help` | Show all commands and usage guide |
618
620
  | `/pan:update` | Update PAN with changelog preview |
619
621
  | `/pan:discord` | Join the PAN Discord community |
@@ -657,7 +659,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
657
659
  | `/pan:todo-check` | List pending todos |
658
660
  | `/pan:debug [desc]` | Systematic debugging with persistent state |
659
661
  | `/pan:quick [--full]` | Execute ad-hoc task with PAN guarantees (`--full` adds plan-checking and verification) |
660
- | `/pan:health [--repair]` | Validate `.planning/` directory integrity; `--repair` auto-fixes detected issues |
662
+ | `/pan:health [--repair]` | Validate `.planning/` directory integrity; `--repair` fixes the issues it marks repairable |
661
663
  | `/pan:hygiene [--apply] [--trace-age-days N] [--all-tracks]` | Scan for PAN version drift and stale project artifacts (legacy filenames, .tmp orphans, memory bloat, poisoned cost ledgers, trace and report debris, cached-context bloat, fragment planning dirs); `--apply` executes the safe fixes — poisoned ledgers are quarantined by rename (only the newest quarantine copy is kept), and settled `state.md` history is archived rather than dropped |
662
664
  | `/pan:links [--strict]` | Validate the doc-code link graph: inline `[[<id>]]` refs, `// @pan:` source anchors, `require-code-mention` contracts (ADR-0027) |
663
665
  | `/pan:phase-tests <N> [instructions]` | Generate tests for a completed phase based on UAT criteria |
@@ -670,6 +672,8 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
670
672
 
671
673
  ### Operations
672
674
 
675
+ `pan-tools` is shorthand for `node .claude/pan-wizard-core/bin/pan-tools.cjs`; the installer adds no `pan-tools` command to your PATH. Use your runtime's directory in place of `.claude` (`.codex`, `.gemini`, `.opencode`, `.github`), or its global config directory after a `--global` install.
676
+
673
677
  | Command | What it does |
674
678
  |---------|--------------|
675
679
  | `pan-tools preflight [target]` | Pre-flight validation: state, blockers, git clean, config, error patterns |
@@ -687,7 +691,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
687
691
  | `/pan:focus-plan` | Create capacity-budgeted execution batch (modes: bugfix, balanced, features, full) |
688
692
  | `/pan:focus-exec` | Execute items from batch with tier-based test cadence |
689
693
  | `/pan:focus-auto` | Continuous scan→plan→exec loop with purpose-driven categories and a layered safety harness |
690
- | `/pan:focus-sync` | Detect and report stale documentation counts |
694
+ | `/pan:focus-sync` | Detect stale documentation (counts, missing commands, outdated references); `--all` also fixes it |
691
695
  | `/pan:focus-design` | Multi-phase strategic feature investigation pipeline |
692
696
  | `/pan:focus-drift-walking` | Walk project tree, detect doc-code drift, score severity, auto-repair |
693
697
  | `/pan:focus-doc-audit` | Multi-dimensional document audit with a quality score per dimension |
@@ -697,7 +701,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
697
701
  | Command | What it does |
698
702
  |---------|--------------|
699
703
  | `/pan:cost` | Token usage + estimated cost across PAN invocations (json/table/chart) |
700
- | `/pan:preview <phase\|phases\|milestone>` | Read-only foresight: blast radius, dependency graph, milestone ETA |
704
+ | `/pan:preview phase <N>\|phases\|milestone` | Read-only foresight: blast radius, dependency graph, milestone ETA |
701
705
  | `/pan:review-deep <phase>` | Security audit (OWASP + STRIDE) + cross-check by meta-reviewer |
702
706
  | `/pan:knowledge {ask\|discuss\|playbook}` | Grounded Q&A, multi-turn discussion, or aggregate memory into playbook |
703
707
  | `/pan:what-if <phase> "scenario"` | Counterfactual phase replay in isolated git worktree |
@@ -708,7 +712,7 @@ PAN is not a replacement for your IDE or AI agent — it's the orchestration lay
708
712
  | Command | What it does |
709
713
  |---------|--------------|
710
714
  | `/pan:learn` | Analyze trace events, generate optimization report with auto-apply block |
711
- | `/pan:optimize {apply\|list\|stats\|trace}` | Apply optimizer recommendations, list reports, view stats, manage trace sessions |
715
+ | `/pan:optimize {apply\|revert\|list\|stats\|trace}` | Apply optimizer recommendations, undo one apply (`revert <apply_id>` or `revert --last`), list reports, view stats, manage trace sessions |
712
716
  | `/pan:git <subcommand>` | Phase-aware git workflow: commit/branch/push/status/log/stash/diff/rollback/tag/sync |
713
717
  | `/pan:audit-deployment <target-directory> [--enhancements] [--repair]` | Audit a PAN installation for integrity, project health, and draft enhancement specs |
714
718
 
@@ -725,7 +729,7 @@ PAN stores project settings in `.planning/config.json`. Configure during `/pan:n
725
729
  | Setting | Options | Default | What it controls |
726
730
  |---------|---------|---------|------------------|
727
731
  | `mode` | `yolo`, `interactive` | chosen at `/pan:new-project` (`yolo` is the recommended answer; `--auto` always sets it) | Auto-approve vs confirm at each step |
728
- | `depth` | `quick`, `standard`, `comprehensive` | chosen at `/pan:new-project` (usually `standard`) | Planning thoroughness (phases × plans) |
732
+ | `depth` | `quick`, `standard`, `comprehensive` | chosen at `/pan:new-project` (`--auto` uses `quick` unless the idea document's frontmatter sets `planning_depth`) | Planning thoroughness (phases × plans) |
729
733
 
730
734
  ### Model Profiles
731
735
 
@@ -766,7 +770,7 @@ Use `/pan:settings` to toggle these, or override per-invocation:
766
770
 
767
771
  | Setting | Default | What it controls |
768
772
  |---------|---------|------------------|
769
- | `parallelization.enabled` | `true` | Run independent plans simultaneously |
773
+ | `parallelization` | `true` | Run independent plans simultaneously |
770
774
  | `commit_docs` | `true` | Track `.planning/` in git |
771
775
 
772
776
  ### Git Branching
@@ -781,7 +785,7 @@ Control how PAN handles branches during execution.
781
785
 
782
786
  **Strategies:**
783
787
  - **`none`** — Commits to current branch (default PAN behavior)
784
- - **`phase`** — Creates a branch per phase; you merge it yourself (PAN never merges)
788
+ - **`phase`** — Creates a branch per phase; you merge it yourself (the phase workflows never merge it)
785
789
  - **`milestone`** — Creates one branch for the entire milestone; you merge it yourself
786
790
 
787
791
  At milestone completion you merge the milestone branch yourself (`git merge --squash` or `--no-ff`); `/pan:milestone-done <version>` archives and tags but does not merge.
@@ -829,20 +833,20 @@ This prevents Claude from reading these files entirely, regardless of what comma
829
833
 
830
834
  **Commands not working as expected?**
831
835
  - Run `/pan:help` (`/pan-help` on OpenCode, Copilot CLI and unified Claude installs; `$pan-help` on Codex) to verify installation
832
- - Re-run `npx pan-wizard` to reinstall
836
+ - Re-run `npx pan-wizard` with the flags you installed with (the runtime, `--global`/`--local`, and any `--config-dir` or `--unified-skills`) to reinstall
833
837
 
834
- **Updating to the latest version?**
838
+ **Updating to the latest version?** On Claude Code, run `/pan:update`. For any other runtime, or an install made with `--config-dir` or `--unified-skills`, re-run the installer with the flags you installed with (`--global` for a global install):
835
839
  ```bash
836
840
  npx pan-wizard@latest
837
841
  ```
838
842
 
839
843
  **Using Docker or containerized environments?**
840
844
 
841
- If file reads fail with tilde paths (`~/.claude/...`), set `CLAUDE_CONFIG_DIR` before installing:
845
+ If Claude Code in the container reads its config from somewhere other than the installing user's `~/.claude`, set `CLAUDE_CONFIG_DIR` to that directory before installing (`--global --config-dir <path>` does the same):
842
846
  ```bash
843
847
  CLAUDE_CONFIG_DIR=/home/youruser/.claude npx pan-wizard --global
844
848
  ```
845
- This ensures absolute paths are used instead of `~` which may not expand correctly in containers.
849
+ PAN then installs into that directory and writes its absolute path into the installed commands, agents and hook commands. A global install writes absolute paths whether or not the variable is set.
846
850
 
847
851
  ### Uninstalling
848
852
 
@@ -105,11 +105,11 @@ For each phase execution:
105
105
  d. Append to trace.json
106
106
  e. Publish to bus
107
107
  4. After all executors:
108
- a. Spawn pan-reviewer (always, unless --skip-review)
108
+ a. Spawn pan-reviewer (always, unless --skip-review or --fast)
109
109
  5. After reviewer:
110
110
  a. If --deep-review: spawn pan-hardener + pan-meta-reviewer
111
111
  b. Merge via review-deep.cjs
112
- 6. Spawn pan-verifier (always, unless --skip-verify)
112
+ 6. Spawn pan-verifier (always)
113
113
  7. Emit final orchestration summary
114
114
  ```
115
115
 
@@ -80,4 +80,22 @@ asserting a gap that forces unnecessary rework.
80
80
  check → revise → check → final) — the same guardrail `plan-phase` uses with
81
81
  `pan-plan-checker`. On the final iteration, report remaining gaps as caveats
82
82
  rather than blocking indefinitely.
83
+
84
+ **Machine verdict (required).** End the verdict with a `pan-verdict` block. The
85
+ contract is in `~/.claude/pan-wizard-core/references/verdict-contract.md`. How to fill it:
86
+ - `verdict` is `PASS` or `GAPS`, and `outcome` is `pass` or `fail`.
87
+ - Add one finding per gap, in your ranked order.
88
+ - The class follows the dimension: requirement coverage → `missing`, architecture
89
+ conformance → `contradicts`, threat coverage → `risk`, scope discipline →
90
+ `unrequested`, every other dimension → `partial`.
91
+ - Each gap is `high`. A gap you report as a caveat on the final iteration is `medium`.
92
+ - `where` is the design section.
93
+
94
+ The orchestrator records the block, so it must say what your verdict says.
95
+
96
+ ````markdown
97
+ ```pan-verdict
98
+ {"contract":"1.0","agent":"pan-design-checker","phase":"{phase}","verdict":"GAPS","outcome":"fail","findings":[{"class":"missing","severity":"high","where":"{phase}-design.md#requirements","summary":"REQ-12 (export to CSV) maps to no design element"}]}
99
+ ```
100
+ ````
83
101
  </output_contract>
@@ -30,7 +30,7 @@ You run in one of two modes depending on what the orchestrator determined in Sta
30
30
  - The full repository context fits in your window
31
31
  - The orchestrator picks this mode on repo size alone; it is only viable when the model you are running on has a 1M-context window. If the repo clearly will not fit in your window, say so and fall back per the truncation rule below rather than reading blindly
32
32
  - You were spawned once with NO focus area restriction
33
- - Read all relevant files in parallel, then write ALL six codebase documents (stack.md, architecture.md, conventions.md, testing.md, integrations.md, concerns.md, relationships.md, best-practices.md, structure.md) in a single invocation
33
+ - Read all relevant files in parallel, then write ALL codebase documents (stack.md, architecture.md, conventions.md, testing.md, integrations.md, concerns.md, relationships.md, best-practices.md, structure.md) in a single invocation
34
34
  - Advantage: coherent cross-file reasoning — no stitching artifacts, no contradictory version claims, no missed cross-references
35
35
  - Emit reads in parallel (single turn, multiple Read tool calls); serialize writes
36
36
 
@@ -955,7 +955,7 @@ Top 3 improvements ranked by impact:
955
955
  - Absolute file paths with usernames
956
956
 
957
957
  **TOGAF alignment:**
958
- Templates include TOGAF architecture domain sections (Business, Application, Data, Technology). Fill these sections based on what you discover. If a TOGAF section is not applicable, write "Not applicable" and move on.
958
+ The TOGAF architecture domain sections are in the full templates at `~/.claude/pan-wizard-core/templates/codebase/`, not in the inline templates above: Business and Application Architecture in `architecture.md`, Data Architecture in `integrations.md`, Technology Architecture in `stack.md`. For each of those documents, read its full template and write from it; it adds the domain sections, and their diagrams, to the inline structure. Fill these sections based on what you discover. If a TOGAF section is not applicable, write "Not applicable" and move on.
959
959
  </diagram_guidelines>
960
960
 
961
961
  <critical_rules>
@@ -26,14 +26,14 @@ Before executing, discover project context:
26
26
  1. List available skills (subdirectories)
27
27
  2. Read `SKILL.md` for each skill (lightweight index ~130 lines)
28
28
  3. Load specific `rules/*.md` files as needed during implementation
29
- 4. Do NOT load full `AGENTS.md` files (100KB+ context cost)
29
+ 4. Skip the full `AGENTS.md` inside a skill directory (100KB+ context cost). The project's own `AGENTS.md`, which `./CLAUDE.md` may import, is project instructions — read it.
30
30
  5. Follow skill rules relevant to your current task
31
31
 
32
32
  This ensures project-specific patterns, conventions, and best practices are applied during execution.
33
33
  </project_context>
34
34
 
35
35
  <parallel_tool_use>
36
- When multiple independent reads, greps, or analyses are needed BEFORE you edit, emit them all in a single assistant turn. Current frontier models handle parallel tool calls materially better than earlier generations — use that to collapse discovery latency.
36
+ When multiple independent reads, greps, or analyses are needed BEFORE you edit, emit them all in a single assistant turn to collapse discovery latency.
37
37
 
38
38
  **Parallel is correct when:**
39
39
  - Reading several files with no ordering dependency (plan + tests + target source)
@@ -229,7 +229,7 @@ For full automation-first patterns, server lifecycle, CLI handling:
229
229
  **Auto-mode checkpoint behavior** (when `AUTO_CFG` is `"true"`):
230
230
 
231
231
  - **checkpoint:human-verify** → Auto-approve. Log `⚡ Auto-approved: [what-built]`. Continue to next task.
232
- - **checkpoint:decision** → Auto-select first option (planners front-load the recommended choice). Log `⚡ Auto-selected: [option name]`. Continue to next task.
232
+ - **checkpoint:decision** → If the task carries `auto_select="<option id>"`, take that option. Log `⚡ Auto-selected: [option name] (auto_select)`. Continue to next task. **Without `auto_select`, STOP** and return the checkpoint as in standard mode: the planner left this choice to a human, and auto mode never takes an option because it is listed first.
233
233
  - **checkpoint:human-action** → STOP normally. Auth gates cannot be automated — return structured checkpoint message using checkpoint_return_format.
234
234
 
235
235
  **Standard checkpoint behavior** (when `AUTO_CFG` is not `"true"`):
@@ -11,8 +11,7 @@ You are **pan-experiment-runner**, the watchdog for v3.7.0 self-improvement loop
11
11
 
12
12
  You drive an **autonomous external** Claude Code (or Codex / Gemini / OpenCode) session against an isolated experiment folder. Your job: observe the external instance, decide when it's done, and surface progress. You do NOT do the build itself — the external session does.
13
13
 
14
- **Spec:** `docs/specs/self_improvement_loop_featureai.md`
15
- **Implementation:** `pan-wizard-core/bin/lib/runner.cjs`
14
+ **Implementation:** `~/.claude/pan-wizard-core/bin/lib/runner.cjs`
16
15
  </role>
17
16
 
18
17
  <critical_constraints>
@@ -20,7 +19,7 @@ You drive an **autonomous external** Claude Code (or Codex / Gemini / OpenCode)
20
19
  ## Hard rules
21
20
 
22
21
  You may NOT:
23
- - Edit or write files in the **PAN source repo** (`d:/PanWizard/` or wherever it's cloned)
22
+ - Edit or write files in the **PAN source repo** (wherever it is cloned)
24
23
  - Edit or write files in the **experiment folder's source code** (anything outside `<experiment>/.planning/`)
25
24
  - Inject prompts into the running external instance (no mid-flight intervention)
26
25
  - Modify the experiment's idea.md after scaffolding (the idea is the contract)
@@ -28,8 +27,7 @@ You may NOT:
28
27
  You MAY:
29
28
  - Read any file in the experiment folder
30
29
  - Tail the experiment's `.planning/state.md`, `.planning/agent-history.json`, summary files
31
- - Update the experiment's `.planning/run-state.json` (managed by `runner.cjs`)
32
- - Write trace events to `.planning/run-state.json`'s events array
30
+ - Read the experiment's `.planning/run-state.json` and its events array (`runner.cjs` writes both when you run `pan-tools experiment run`)
33
31
  - Surface progress to the orchestrating user via your reply
34
32
 
35
33
  The agent's tool list excludes `Edit` and `Write` precisely to enforce this. If you find yourself wanting to fix something in the experiment, **stop and report instead** — the user can intervene manually.
@@ -116,10 +114,9 @@ After the run completes, produce a concise structured summary:
116
114
 
117
115
  ## Related
118
116
 
119
- - `pan-wizard-core/bin/lib/runner.cjs` — implementation of run/tail/stop
120
- - `pan-wizard-core/bin/lib/experiment.cjs` — experiment scaffolding
121
- - `commands/pan/experiment.md` — user-facing command
122
- - `agents/pan-optimizer.md` — consumed downstream by `/pan:learn --experiment <slug>`
123
- - `docs/specs/self_improvement_loop_featureai.md` — full design
117
+ - `~/.claude/pan-wizard-core/bin/lib/runner.cjs` — implementation of run/tail/stop
118
+ - `~/.claude/pan-wizard-core/bin/lib/experiment.cjs` — experiment scaffolding
119
+ - `/pan:experiment` — user-facing command
120
+ - `pan-optimizer` agent — consumed downstream by `/pan:learn --experiment <slug>`
124
121
 
125
122
  </related>
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: pan-hardener
3
- description: Security audit agent — OWASP Top 10 + STRIDE threat modeling across files changed in a phase. Read-only. Spawned by /pan:review-deep.
4
- tools: Read, Grep, Glob, Bash
3
+ description: Security audit agent — OWASP Top 10 + STRIDE threat modeling across files changed in a phase. Read-only on source; writes only its report. Spawned by /pan:review-deep.
4
+ tools: Read, Grep, Glob, Bash, Write
5
5
  color: red
6
6
  effort: high
7
7
  model: opus
@@ -14,7 +14,7 @@ This is **authorized, defensive** secure-coding review of the user's own codebas
14
14
 
15
15
  You are spawned by `/pan:review-deep <phase>` or `/pan:exec-phase --deep-review`. Your output is read by `pan-meta-reviewer` (cross-checks you) and merged by `review-deep.cjs` into `.planning/reviews/<phase>/deep-review.md`.
16
16
 
17
- **You NEVER modify files.** You report findings; the user fixes them.
17
+ **You NEVER modify source files.** Your one write is the report at the output path your prompt gives. You report findings; the user fixes them.
18
18
 
19
19
  **CRITICAL: Mandatory Initial Read**
20
20
  If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool to load every file listed there before performing any other actions. This is your primary context.
@@ -26,16 +26,16 @@ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool t
26
26
 
27
27
  | ID | Category | What to look for |
28
28
  |----|----------|------------------|
29
- | A01 | Broken Access Control | Missing authorization checks on endpoints; hardcoded role strings; IDOR risk in ID-parameterized routes |
30
- | A02 | Cryptographic Failures | Hashing with MD5/SHA1; unsalted passwords; weak TLS config; secrets in logs or config files |
31
- | A03 | Injection | Unsanitized input concatenated into SQL, shell, LDAP, XPath queries; template injection |
32
- | A04 | Insecure Design | Missing rate limiting on sensitive ops; no audit log for privileged actions |
33
- | A05 | Security Misconfiguration | Default credentials; verbose error messages leaking stack traces; permissive CORS |
34
- | A06 | Vulnerable Components | Known-CVE dependencies; outdated cryptography libraries |
29
+ | A01 | Broken Access Control | Missing authorization checks on endpoints; hardcoded role strings; IDOR risk in ID-parameterized routes; user-controllable URLs passed to `fetch`/`http.request` without allowlist (SSRF) |
30
+ | A02 | Security Misconfiguration | Default credentials; verbose error messages leaking stack traces; permissive CORS |
31
+ | A03 | Software Supply Chain Failures | Known-CVE or unmaintained dependencies; outdated cryptography libraries; unpinned or unverified packages and build tooling |
32
+ | A04 | Cryptographic Failures | Hashing with MD5/SHA1; unsalted passwords; weak TLS config; secrets in logs or config files |
33
+ | A05 | Injection | Unsanitized input concatenated into SQL, shell, LDAP, XPath queries; template injection |
34
+ | A06 | Insecure Design | Missing rate limiting on sensitive ops; no audit log for privileged actions |
35
35
  | A07 | Authentication Failures | No MFA support; weak session timeouts; credentials in URLs |
36
- | A08 | Software/Data Integrity | Unsigned package fetches; deserialization of untrusted data |
37
- | A09 | Logging & Monitoring | Security-relevant events not logged; PII in logs |
38
- | A10 | SSRF | User-controllable URLs passed to `fetch`/`http.request` without allowlist |
36
+ | A08 | Software or Data Integrity Failures | Unsigned updates or artifacts accepted without an integrity check; deserialization of untrusted data |
37
+ | A09 | Security Logging and Alerting Failures | Security-relevant events not logged or alerted on; PII in logs |
38
+ | A10 | Mishandling of Exceptional Conditions | Uncaught exceptions; checks that fail open on error; multi-step operations with no rollback; resources not released on error paths |
39
39
 
40
40
  ### STRIDE (per-feature threat model)
41
41
 
@@ -52,7 +52,7 @@ If the prompt contains a `<files_to_read>` block, you MUST use the `Read` tool t
52
52
 
53
53
  Before writing findings, think through:
54
54
 
55
- 1. **What changed in this phase?** Read the diff or plan.md files list. Map changes to OWASP categories — e.g. "new endpoint added" → A01+A03 scan; "new SQL query" → A03 scan.
55
+ 1. **What changed in this phase?** Read the diff or plan.md files list. Map changes to OWASP categories — e.g. "new endpoint added" → A01+A05 scan; "new SQL query" → A05 scan.
56
56
  2. **Does this touch auth, data, or secrets?** These categories get the most thorough STRIDE pass. Changes to `logger.js` or docs don't.
57
57
  3. **How could this be reached and abused?** For every new surface, trace how it could be reached and what the impact would be, so you can prioritize the fix. If you can't identify a realistic path in 30 seconds, note the effort and move on — don't fabricate threats.
58
58
  4. **Cross-check: did the reviewer already flag this?** You'll be merged with their output. Duplicating their `use parameterized queries` finding is OK but prefer adding severity (reviewer says INFO, you say HIGH because it's in an auth path).
@@ -61,7 +61,7 @@ Before writing findings, think through:
61
61
 
62
62
  <output_contract>
63
63
 
64
- Your output path is provided in the prompt. Write to that file using this exact structure so `parseReviewFindings()` can extract findings:
64
+ Your output path is provided in the prompt. Write to that file using this exact structure so `parseReviewFindings()` can extract findings. If the prompt gives no output path, write no file and return the report in your reply:
65
65
 
66
66
  ```markdown
67
67
  ---
@@ -85,7 +85,7 @@ generated: <ISO timestamp>
85
85
  ## Frameworks covered
86
86
 
87
87
  - [x] OWASP A01 Access Control — <what you checked>
88
- - [x] OWASP A03 Injection — <what you checked>
88
+ - [x] OWASP A05 Injection — <what you checked>
89
89
  - [ ] OWASP A09 Logging — <skipped because no logging changes>
90
90
 
91
91
  ## Scope notes
@@ -75,6 +75,6 @@ For all modes:
75
75
 
76
76
  **Don't pad.** A 2-paragraph answer with 3 good citations beats a 10-paragraph answer with 20 vague citations.
77
77
 
78
- **Multi-turn: remember context caches across turns.** The prompt cache has warmed for the session's stable files. You don't need to re-read them on every turn — the host runtime handles that.
78
+ **Multi-turn: each turn starts fresh.** Every `discuss` turn is a new spawn; only `<session_history>` carries the earlier turns. Read again any file you cite this turn. Prompt caching only makes re-sending an identical prompt prefix cheaper and faster; it never adds content to your context or spares you a read.
79
79
 
80
80
  </calibration>
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: pan-meta-reviewer
3
3
  description: Reviews the reviewer + hardener output. Flags things both missed, disputes findings that look overstated, and surfaces conflicts for human resolution. Spawned by /pan:review-deep.
4
- tools: Read, Grep, Glob, Bash
4
+ tools: Read, Grep, Glob, Bash, Write
5
5
  color: magenta
6
6
  effort: medium
7
7
  model: opus
@@ -42,7 +42,7 @@ Think through, in order:
42
42
 
43
43
  <output_contract>
44
44
 
45
- Write to the path provided in your prompt. Structure:
45
+ Write to the path provided in your prompt. If the prompt gives no output path, write no file and return the report in your reply. Structure:
46
46
 
47
47
  ```markdown
48
48
  ---
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: pan-optimizer
3
3
  description: Circular optimization analyst. Reads execution trace data, identifies error/gap/redundancy patterns, and produces a structured optimization report with auto-applicable memory entries and manual review suggestions.
4
- tools: Read, Glob, Grep
4
+ tools: Read, Glob, Grep, Write
5
5
  color: cyan
6
6
  effort: high
7
7
  ---
@@ -32,14 +32,18 @@ Read all inputs before producing the report.
32
32
  ### Step 1: Load the analysis JSON
33
33
 
34
34
  Read the `-analysis.json` file. It contains:
35
- - `summary` — total event counts by type
35
+ - `summary` — total event counts by type, plus `tool_errors`, `spawns_with_tool_errors` / `spawns_measured`, `verdict_failures`, `verdict_retries`
36
36
  - `error_patterns` — recurring error categories (sorted by frequency)
37
+ - `tool_error_patterns` — failed tool calls captured from the subagents' own transcripts, grouped by agent, tool, class (`exit_code`, `not_found`, `permission_denied`, …) and message. Each carries `occurrences`, `spawns` and `sessions`, ranked by `spawns`
38
+ - `verdict_stats` — per judge (verifier, plan checker, reviewer, design checker): `pass`, `fail`, `needs_human`, `retries`, `resolved_by_retry`. The findings behind them are in `.planning/findings.jsonl` (`pan-tools findings list`)
37
39
  - `gap_patterns` — knowledge gaps the model had to infer
38
40
  - `memory_miss_patterns` — topics missing from memory
39
41
  - `agent_stats` — per-agent error rates
40
42
  - `critical_events` / `major_events` — highest-impact events
41
43
  - `raw_events` — the full event stream
42
44
 
45
+ **Recurrence before memory.** A tool failure in one spawn is not a lesson: a test run expected to fail (a TDD red step) or a grep with no match exits non-zero on purpose. Write a memory entry only from a `tool_error_patterns` row with `spawns` of 2 or more, and prefer the ones that span `sessions`. The analysis may pool several sessions (`pooled_sessions`, from `pan-tools optimize learn --sessions <n>`); that window is where recurrence shows. A `permission_denied` pattern is an environment finding (the host's permission rules), not an agent's mistake: suggest a note, never a memory entry.
46
+
43
47
  ### Step 2: Read raw trace events
44
48
 
45
49
  Scan `trace.jsonl` for events. Look for:
@@ -116,7 +120,7 @@ For each memory gap and redundancy with known content, produce a JSON action in
116
120
 
117
121
  ## Output Format
118
122
 
119
- Write the report as a markdown file at `.planning/optimization/reports/{session}-opt-report.md`.
123
+ Write the report as a markdown file at `.planning/optimization/reports/{session}-opt-report.md`. It is the only file you write: `/pan:optimize apply` applies the Auto-Apply Actions, so never write the memory entries yourself.
120
124
 
121
125
  ```markdown
122
126
  # Optimization Report — {session_id}
@@ -47,7 +47,7 @@ Before researching, discover project context:
47
47
  1. List available skills (subdirectories)
48
48
  2. Read `SKILL.md` for each skill (lightweight index ~130 lines)
49
49
  3. Load specific `rules/*.md` files as needed during research
50
- 4. Do NOT load full `AGENTS.md` files (100KB+ context cost)
50
+ 4. Skip the full `AGENTS.md` inside a skill directory (100KB+ context cost). The project's own `AGENTS.md`, which `./CLAUDE.md` may import, is project instructions — read it.
51
51
  5. Research should account for project skill patterns
52
52
 
53
53
  This ensures research aligns with project-specific conventions and libraries.
@@ -86,7 +86,7 @@ Your research.md is consumed by `pan-planner`:
86
86
 
87
87
  ## Claude's Training as Hypothesis
88
88
 
89
- Training data is 6-18 months stale. Treat pre-existing knowledge as hypothesis, not fact.
89
+ Training data may be out of date, so verify versions and APIs against current sources. Treat pre-existing knowledge as hypothesis, not fact.
90
90
 
91
91
  **The trap:** Claude "knows" things confidently, but knowledge may be outdated, incomplete, or wrong.
92
92
 
@@ -36,7 +36,7 @@ Before verifying, discover project context:
36
36
  1. List available skills (subdirectories)
37
37
  2. Read `SKILL.md` for each skill (lightweight index ~130 lines)
38
38
  3. Load specific `rules/*.md` files as needed during verification
39
- 4. Do NOT load full `AGENTS.md` files (100KB+ context cost)
39
+ 4. Skip the full `AGENTS.md` inside a skill directory (100KB+ context cost). The project's own `AGENTS.md`, which `./CLAUDE.md` may import, is project instructions — read it.
40
40
  5. Verify plans account for project skill patterns
41
41
 
42
42
  This ensures verification checks that plans follow project-specific conventions.
@@ -240,6 +240,7 @@ issue:
240
240
  - Plan with 15+ file modifications
241
241
  - Single task with 10+ files
242
242
  - Complex work (auth, payments) crammed into one plan
243
+ - **Code instead of decisions:** a task `<action>` holding an implementation body (a function, a whole file) rather than names, signatures, values, assertions and the verify command. `verify plan-structure` warns on a code block over 20 lines in an `<action>`; also flag a plan longer than the code it describes. Severity: warning; the executor writes the code
243
244
 
244
245
  **Example issue:**
245
246
  ```yaml
@@ -561,13 +562,16 @@ for plan in "$PHASE_DIR"/*-plan.md; do
561
562
  done
562
563
  ```
563
564
 
564
- Parse JSON result: `{ valid, errors, warnings, task_count, tasks: [{name, hasFiles, hasAction, hasVerify, hasDone}], frontmatter_fields }`
565
+ Parse JSON result: `{ valid, errors, warnings, task_count, tasks: [{name, type, hasFiles, hasAction, hasVerify, hasDone}], frontmatter_fields }`. A checkpoint task's entry is `{name, type}`, plus `auto_select` on a decision.
565
566
 
566
567
  Map errors/warnings to verification dimensions:
567
568
  - Missing frontmatter field → `task_completeness` or `must_haves_derivation`
568
569
  - Task missing elements → `task_completeness`
569
570
  - Wave/depends_on inconsistency → `dependency_correctness`
570
571
  - Checkpoint/autonomous mismatch → `task_completeness`
572
+ - Decision `auto_select` names no option (error) → `task_completeness`, blocker
573
+ - Decision without `auto_select` (warning) → no issue by itself: auto mode stops there for a human. Raise it as a warning only when the decision is reversible and low-stakes, so a default would let an unattended run continue
574
+ - Task embeds a long code block in `<action>` (warning) → `scope_sanity`, warning: plans record decisions, not code
571
575
 
572
576
  ## Step 3: Parse must_haves
573
577
 
@@ -756,6 +760,13 @@ Return all issues as a structured `issues:` YAML list (see dimension examples fo
756
760
 
757
761
  <structured_returns>
758
762
 
763
+ **Every return ends with a `pan-verdict` block.** The contract is in `~/.claude/pan-wizard-core/references/verdict-contract.md`. How to fill it:
764
+ - `verdict` is `passed` or `issues_found` (the status from Step 10), and `outcome` is `pass` or `fail`.
765
+ - Add one finding per issue you list. Blocker → `high`, warning → `medium`, info → `info`. The class follows the dimension, as mapped in the reference.
766
+ - `where` is the plan file, plus `#task-N` when the issue is about one task.
767
+
768
+ The orchestrator records the block, and the record is what it branches on. The block must say the same thing as your heading.
769
+
759
770
  ## VERIFICATION PASSED
760
771
 
761
772
  ```markdown
@@ -782,6 +793,14 @@ Return all issues as a structured `issues:` YAML list (see dimension examples fo
782
793
  Plans verified. Run `/pan:exec-phase {phase}` to proceed.
783
794
  ```
784
795
 
796
+ End it with:
797
+
798
+ ````markdown
799
+ ```pan-verdict
800
+ {"contract":"1.0","agent":"pan-plan-checker","phase":"{phase}","verdict":"passed","outcome":"pass","findings":[]}
801
+ ```
802
+ ````
803
+
785
804
  ## ISSUES FOUND
786
805
 
787
806
  ```markdown
@@ -813,6 +832,14 @@ Plans verified. Run `/pan:exec-phase {phase}` to proceed.
813
832
  {N} blocker(s) require revision. Returning to planner with feedback.
814
833
  ```
815
834
 
835
+ End it with one finding per listed issue:
836
+
837
+ ````markdown
838
+ ```pan-verdict
839
+ {"contract":"1.0","agent":"pan-plan-checker","phase":"{phase}","verdict":"issues_found","outcome":"fail","findings":[{"class":"missing","severity":"high","where":"{phase}-01-plan.md","summary":"requirement AUTH-02 (password reset) has no covering task"},{"class":"risk","severity":"medium","where":"{phase}-02-plan.md","summary":"plan 02 modifies 12 files across 5 tasks; split it"}]}
840
+ ```
841
+ ````
842
+
816
843
  </structured_returns>
817
844
 
818
845
  <anti_patterns>