pan-wizard 2.9.0 → 3.4.1

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 (69) hide show
  1. package/README.md +8 -8
  2. package/agents/pan-conductor.md +189 -0
  3. package/agents/pan-counterfactual.md +112 -0
  4. package/agents/pan-debugger.md +15 -1
  5. package/agents/pan-document_code.md +21 -0
  6. package/agents/pan-executor.md +16 -0
  7. package/agents/pan-hardener.md +113 -0
  8. package/agents/pan-integration-checker.md +2 -0
  9. package/agents/pan-knowledge.md +81 -0
  10. package/agents/pan-meta-reviewer.md +91 -0
  11. package/agents/pan-plan-checker.md +2 -0
  12. package/agents/pan-previewer.md +98 -0
  13. package/agents/pan-project-researcher.md +4 -4
  14. package/agents/pan-reviewer.md +2 -0
  15. package/agents/pan-verifier.md +2 -0
  16. package/bin/install-lib.cjs +197 -0
  17. package/bin/install.js +1999 -1959
  18. package/commands/pan/assumptions.md +38 -3
  19. package/commands/pan/audit-deployment.md +6 -0
  20. package/commands/pan/cost.md +132 -0
  21. package/commands/pan/debug.md +71 -2
  22. package/commands/pan/exec-phase.md +105 -0
  23. package/commands/pan/focus-auto.md +199 -18
  24. package/commands/pan/focus-design.md +67 -2
  25. package/commands/pan/focus-exec.md +178 -47
  26. package/commands/pan/focus-scan.md +17 -5
  27. package/commands/pan/knowledge.md +129 -0
  28. package/commands/pan/map-codebase.md +47 -6
  29. package/commands/pan/mcp-bridge.md +145 -0
  30. package/commands/pan/milestone-audit.md +23 -0
  31. package/commands/pan/new-project.md +64 -0
  32. package/commands/pan/pause.md +42 -1
  33. package/commands/pan/plan-phase.md +95 -0
  34. package/commands/pan/preview.md +114 -0
  35. package/commands/pan/profile.md +37 -0
  36. package/commands/pan/quick.md +15 -0
  37. package/commands/pan/resume.md +62 -2
  38. package/commands/pan/review-deep.md +128 -0
  39. package/commands/pan/verify-phase.md +53 -0
  40. package/commands/pan/what-if.md +146 -0
  41. package/hooks/dist/pan-cost-logger.js +102 -0
  42. package/hooks/dist/pan-statusline.js +154 -108
  43. package/package.json +1 -1
  44. package/pan-wizard-core/bin/lib/bridge.cjs +269 -0
  45. package/pan-wizard-core/bin/lib/bus.cjs +251 -0
  46. package/pan-wizard-core/bin/lib/codebase.cjs +118 -0
  47. package/pan-wizard-core/bin/lib/constants.cjs +42 -1
  48. package/pan-wizard-core/bin/lib/context-budget.cjs +27 -0
  49. package/pan-wizard-core/bin/lib/core.cjs +91 -6
  50. package/pan-wizard-core/bin/lib/cost.cjs +359 -0
  51. package/pan-wizard-core/bin/lib/focus.cjs +105 -2
  52. package/pan-wizard-core/bin/lib/init.cjs +5 -5
  53. package/pan-wizard-core/bin/lib/knowledge.cjs +331 -0
  54. package/pan-wizard-core/bin/lib/memory.cjs +252 -0
  55. package/pan-wizard-core/bin/lib/phase.cjs +40 -13
  56. package/pan-wizard-core/bin/lib/preview.cjs +480 -0
  57. package/pan-wizard-core/bin/lib/review-deep.cjs +280 -0
  58. package/pan-wizard-core/bin/lib/roadmap.cjs +4 -4
  59. package/pan-wizard-core/bin/lib/state.cjs +2 -2
  60. package/pan-wizard-core/bin/lib/verify.cjs +34 -1
  61. package/pan-wizard-core/bin/lib/whatif.cjs +289 -0
  62. package/pan-wizard-core/bin/pan-tools.cjs +239 -4
  63. package/pan-wizard-core/templates/playbook.md +53 -0
  64. package/pan-wizard-core/templates/preview-report.md +93 -0
  65. package/pan-wizard-core/templates/roadmap.md +24 -24
  66. package/pan-wizard-core/templates/state.md +12 -9
  67. package/pan-wizard-core/workflows/plan-phase.md +1 -1
  68. package/scripts/build-hooks.js +2 -1
  69. package/scripts/generate-skills-docs.py +560 -0
@@ -18,11 +18,11 @@ Run purpose-driven improvement campaigns with a single command. The auto-runner
18
18
 
19
19
  **ADR:** ADR-0015 | **Heritage:** execplan budget + PanMonty categories + focus-exec pipeline
20
20
 
21
- ## CRITICAL: Project Scope Boundary
21
+ ## Project Scope Boundary
22
22
 
23
- This command runs improvement campaigns on the **host project's source code** — NOT on PAN Wizard's own infrastructure.
23
+ This command runs improvement campaigns on the **host project's source code** — not on PAN Wizard's own infrastructure.
24
24
 
25
- **ALWAYS EXCLUDE these directories from scanning and execution:**
25
+ **Exclude these directories from scanning and execution:**
26
26
  - `.claude/`, `.github/copilot-instructions.md`, `.opencode/`, `.gemini/`, `.codex/` — PAN runtime directories
27
27
  - Any `pan-wizard-core/`, `pan-tools`, agent `.md`, or command `.md` files within PAN runtime directories
28
28
 
@@ -30,6 +30,18 @@ This command runs improvement campaigns on the **host project's source code**
30
30
 
31
31
  ---
32
32
 
33
+ <completion_contract>
34
+ A campaign is complete when ANY stop condition is met:
35
+ 1. Max cycles reached (--max-cycles, default 10)
36
+ 2. Total budget exhausted (--total-budget, default 200)
37
+ 3. Scan returns zero items for the selected category
38
+ 4. Context window drops below 25% (CRITICAL threshold)
39
+ 5. User sends /pan:focus-auto --stop
40
+ 6. Category-specific completion (e.g., prompts_remaining === 0)
41
+
42
+ Each cycle is complete when: scan → plan → exec → commit succeeds, OR a safety harness triggers and the cycle is cleanly aborted with state preserved.
43
+ </completion_contract>
44
+
33
45
  ## FIRST ACTION — Category Selection (if no --category argument)
34
46
 
35
47
  If `$ARGUMENTS` does NOT contain `--category`, you MUST ask the user before doing anything else.
@@ -45,8 +57,9 @@ Which category should this auto campaign focus on?
45
57
  4. **features** — Roadmap items, new capabilities (P3-P5)
46
58
  5. **docs** — Stale documentation, missing command descriptions (P5-P6)
47
59
  6. **optimize** — Performance bottlenecks, redundant computation, robustness hardening (P1-P4)
60
+ 7. **prompts** — Execute micro-prompt documents sequentially, or generate them from specs (P0-P6)
48
61
 
49
- Reply with a number (1-6) or category name.
62
+ Reply with a number (1-7) or category name.
50
63
  ```
51
64
 
52
65
  **After the user replies, map their response to a category name:**
@@ -56,8 +69,9 @@ Reply with a number (1-6) or category name.
56
69
  - "4" or "features" → SELECTED_CATEGORY = features
57
70
  - "5" or "docs" → SELECTED_CATEGORY = docs
58
71
  - "6" or "optimize" → SELECTED_CATEGORY = optimize
72
+ - "7" or "prompts" → SELECTED_CATEGORY = prompts
59
73
 
60
- **Do NOT proceed past this point without a category. Do NOT guess. Do NOT pick a default. STOP and wait for the user's reply.**
74
+ Wait for the user's reply before proceeding. Do not guess or pick a default category.
61
75
 
62
76
  ## AUTONOMY RULES (apply AFTER category is selected)
63
77
 
@@ -75,7 +89,7 @@ Reply with a number (1-6) or category name.
75
89
 
76
90
  | Flag | Default | Description |
77
91
  |------|---------|-------------|
78
- | `--category` | null (all) | cleanup, tests, stability, features, docs |
92
+ | `--category` | null (all) | cleanup, tests, stability, features, docs, optimize, prompts |
79
93
  | `--mode` | category-dependent | bugfix, balanced, features, full |
80
94
  | `--budget` | category-dependent | Points per cycle (5-100) |
81
95
  | `--max-cycles` | 10 | Maximum iterations (1-50) |
@@ -95,6 +109,7 @@ Reply with a number (1-6) or category name.
95
109
  | features | P3-P5 | features | 50 |
96
110
  | docs | P5-P6 | balanced | 30 |
97
111
  | optimize | P1-P4 | balanced | 50 |
112
+ | prompts | P0-P6 | balanced | 100 |
98
113
 
99
114
  ## Pipeline
100
115
 
@@ -122,6 +137,20 @@ Reply with a number (1-6) or category name.
122
137
  4. Run `git status` to verify clean working tree (warn if dirty, don't block)
123
138
  5. Create safety tag: `git tag -f focus-auto-baseline`
124
139
 
140
+ <phase_dependencies>
141
+ Phase 0 → Phase 1: Init MUST succeed before baseline (state tracking requires valid run)
142
+ Phase 1 → Phase 2: Baseline MUST be captured before main loop (regression circuit breaker needs it)
143
+ Phase 2 (each cycle): Scan → Plan → Exec → Commit is strictly sequential within a cycle
144
+ - Scan MUST complete before plan (plan needs scan items)
145
+ - Plan MUST complete before exec (exec needs batch file)
146
+ - Exec MUST complete and tests pass before commit (never commit broken code)
147
+
148
+ HARD STOP conditions:
149
+ - Phase 1 fails (tests broken): Do not enter main loop — report and exit
150
+ - Any cycle: test count drops below baseline after revert → stop campaign, preserve state
151
+ - Context drops below 25%: stop campaign cleanly (safety harness 3)
152
+ </phase_dependencies>
153
+
125
154
  ### Phase 2: Main Loop
126
155
 
127
156
  **For each cycle (1 to max_cycles), execute Steps 2.1 through 2.5 without stopping:**
@@ -144,6 +173,9 @@ Perform a deep codebase scan to find actionable work items with evidence.
144
173
  - **features:** roadmap items not yet implemented, README promises without backing code
145
174
  - **docs:** stale documentation, missing command descriptions
146
175
  - **optimize:** N+1 operations (file I/O / network calls inside loops), redundant re-computation (`JSON.parse`/`stringify` of same data), synchronous blocking in async modules (`readFileSync`/`execSync` alongside async exports), algorithmic complexity (nested `.find()`/`.filter()` in loops creating O(n²)+), unnecessary allocations in hot paths (spread in loops, string concat vs `join()`), regex construction inside loops (should be hoisted), unbounded collection growth (`.push()` without size limits), swallowed errors (`catch {}` / `catch { /* */ }`), suboptimal data structures (array `.includes()` where Set is better), dead assignments, unguarded property access on nullable values (`.length`/`.split()`/`.match()[0]` without null check)
176
+ - **prompts:** Two operational modes — detect which applies:
177
+ - **Execute mode:** Find micro-prompt documents (`.md` files containing ordered prompt blocks, e.g., `## Prompt 1`, `## Prompt 2`, or numbered checklist items `- [ ] Prompt: ...`). Look in `.planning/`, project root, and `docs/` for files matching patterns: `*prompts*`, `*micro-prompt*`, `*prompt-plan*`, `*prompt-sequence*`. Each unchecked/incomplete prompt block is one work item.
178
+ - **Generate mode:** Find specification documents (files matching `*spec*`, `*prd*`, `*requirements*`, `*feature*` in `.planning/`, `docs/specs/`, project root) that do NOT already have a corresponding micro-prompt document. Each spec needing decomposition is one work item.
147
179
 
148
180
  **Optimize category: convergent re-scan.** On cycles 2+, cross-reference scan findings against previous cycle completions (`cycles[].items` in auto-run state). Only pick genuinely new items — skip IDs already completed or failed. If the count of new findings drops AND cycle efficiency drops below 30% of the prior cycle's, this signals convergence and the `diminishing_returns` stop condition fires.
149
181
  - Use the Agent tool with Explore subagent for thorough analysis if needed
@@ -226,6 +258,11 @@ Implement each item from the batch created in Step 2.2. Record `tests_before` by
226
258
  6. Run the project's test suite
227
259
  7. Pass = DONE | Fail = investigate (15 min max), then revert, mark FAILED
228
260
 
261
+ **Error Recovery Classification:**
262
+ - RECOVERABLE (retry up to 3 times): test failure after code change, build syntax error, file not found (search for moved path)
263
+ - UNRECOVERABLE (mark FAILED, move to next item): same failure after 3 retries, permission errors, state corruption, unrelated test regression
264
+ A failed item never blocks subsequent items.
265
+
229
266
  **After all items in the batch:**
230
267
  1. Run full test suite — ALL tests must pass
231
268
  2. Record `tests_after` from the summary line
@@ -244,12 +281,43 @@ Check the response for stop conditions:
244
281
  - `max_cycles`: Maximum iterations reached — go to Phase 3
245
282
  - `zero_completed`: No items completed in this cycle — go to Phase 3
246
283
  - `diminishing_returns`: Optimize only — cycle efficiency < 30% of previous cycle — go to Phase 3
284
+ - `prompts_complete`: Prompts only — all prompts in document executed — go to Phase 3
247
285
  - `null`: Continue to next cycle
248
286
 
249
- #### Step 2.5: Inter-Cycle Check
287
+ #### Step 2.5: Inter-Cycle Context Management
288
+
289
+ Between cycles, manage context to prevent quality degradation over long campaigns:
290
+ - **KEEP:** Current cycle goals, test baseline, error states, active file paths
291
+ - **SUMMARIZE:** Previous cycle results to a one-line summary each
292
+ - **DISCARD:** Raw tool output from previous cycles, superseded scan results
250
293
 
251
294
  Display one-line cycle summary: `Cycle N/M | X/Y pts | Z items done | Tests: A -> B`
252
295
 
296
+ #### Step 2.5a: Reflection Gate (Opus 4.7 thinking-capable models only)
297
+
298
+ Before committing to the next cycle, call the reflection helper:
299
+
300
+ ```
301
+ echo '{"run": <run-state>, "cycle": <just-completed-cycle>, "batch": <proposed-next-batch>, "tier": "reasoning"}' \
302
+ | pan-tools focus reflection
303
+ ```
304
+
305
+ The helper returns `{reflect: true, prompt: "..."}` when the current model tier supports extended thinking. If `reflect: true`, think through the prompt — which asks whether running another cycle is worthwhile given telemetry and remaining items — and respond with JSON: `{"continue": true|false, "rationale": "..."}`.
306
+
307
+ - If `continue: false`: stop the campaign and treat as a user-reason stop (preserve state, skip to Phase 3).
308
+ - If `continue: true`: proceed to the next cycle.
309
+
310
+ If the helper returns `reflect: false` (tier doesn't support thinking, or `reflection_enabled: false` in run state, or no next batch): skip this step silently and continue to the next cycle.
311
+
312
+ The reflection gate catches "zero progress" or "wrong category" drift earlier than the automatic stop rules.
313
+
314
+ **Attention anchor — emit after every cycle summary:**
315
+ ```
316
+ Remaining: {cycles_left} cycles | {budget_remaining}/{total_budget} pts | Safety: {active_harness_warnings}
317
+ Next: Cycle {N+1} — Scan → Plan → Exec → Commit
318
+ ```
319
+ This prevents lost-in-the-middle drift in 10+ cycle campaigns where the agent forgets budget limits or stop conditions.
320
+
253
321
  Then continue immediately to the next cycle (back to Step 2.1).
254
322
 
255
323
  ### Phase 3: Campaign End
@@ -294,20 +362,133 @@ Then continue immediately to the next cycle (back to Step 2.1).
294
362
  7. **Verify Understanding** — State understanding for M+ items before coding.
295
363
  8. **Preserve Tests** — Never change test expectations to match broken code.
296
364
  9. **Accurate Commits** — Only claim verified items in commit messages. Include actual test counts.
365
+ 10. **Vary Similar Fixes** — When 3+ items in a cycle share the same fix pattern (e.g., "add null check"), re-read each module's conventions before applying. The same pattern may need different implementations in different modules. Check after the 3rd fix whether a shared helper would be better than scattered copies.
366
+
367
+ ## Prompts Category — Execution Details
368
+
369
+ The prompts category operates in two distinct modes. Detect which mode applies during the scan phase based on what the scan finds.
370
+
371
+ ### Execute Mode (micro-prompt document found)
372
+
373
+ A micro-prompt document contains an ordered sequence of self-contained implementation prompts. Each prompt describes a single, testable change.
374
+
375
+ **Document format recognized:**
376
+
377
+ ```markdown
378
+ # Micro-Prompts: <Feature Name>
379
+
380
+ Source: <spec file or description>
381
+ Generated: <date>
382
+
383
+ ## Prompt 1: <title>
384
+ - [ ] Complete
385
+
386
+ <implementation instructions>
387
+
388
+ ### Expected outcome
389
+ <what should work after this prompt>
390
+
391
+ ### Test
392
+ <how to verify>
393
+
394
+ ---
395
+
396
+ ## Prompt 2: <title>
397
+ - [ ] Complete
398
+ ...
399
+ ```
400
+
401
+ Alternative format — checklist style:
402
+ ```markdown
403
+ - [ ] Prompt 1: <title> — <instructions>
404
+ - [ ] Prompt 2: <title> — <instructions>
405
+ ```
406
+
407
+ **Execution strategy:**
408
+
409
+ 1. Read the micro-prompt document, identify all prompt blocks
410
+ 2. Find the first uncompleted prompt (unchecked `- [ ]`)
411
+ 3. Execute that prompt's instructions — implement the code changes described
412
+ 4. Run the project's test suite (or the prompt-specific test if given)
413
+ 5. If tests pass: mark the prompt as complete (`- [x]`), commit, move to next prompt
414
+ 6. If tests fail: one fix attempt, then revert and mark prompt as FAILED, move to next prompt
415
+ 7. Each prompt = one batch item. Budget: 1 prompt per cycle unless prompt is trivial (XS)
416
+ 8. Record `prompts_remaining` count in cycle update — when 0, `prompts_complete` stop fires
417
+
418
+ **Key rules:**
419
+ - Execute prompts in document order — NEVER skip ahead or reorder
420
+ - Each prompt is atomic — commit after each successful prompt
421
+ - A failed prompt does NOT block subsequent prompts (mark failed, continue)
422
+ - The prompt document is the plan — do not re-plan or expand scope beyond what each prompt says
423
+
424
+ ### Generate Mode (spec found without corresponding prompt document)
425
+
426
+ When a specification document is found that doesn't have a matching micro-prompt document, decompose it into ordered prompts.
427
+
428
+ **Generation strategy:**
429
+
430
+ 1. Read the spec document thoroughly
431
+ 2. Identify all discrete implementation steps
432
+ 3. Order steps by dependency — foundation first, features that depend on earlier steps later
433
+ 4. For each step, write a prompt block containing:
434
+ - Clear title describing the change
435
+ - Implementation instructions (files to create/modify, logic to implement)
436
+ - Expected outcome (what should work after this prompt)
437
+ - Test instruction (how to verify the prompt succeeded)
438
+ 5. Write the micro-prompt document to `.planning/prompts/<spec-slug>-prompts.md`
439
+ 6. Each generated document = one batch item (typically M or L size)
440
+
441
+ **Decomposition heuristics:**
442
+ - One prompt per logical unit of work (one function, one API endpoint, one component)
443
+ - Each prompt should be independently testable
444
+ - Prompts should be 5-30 minutes of implementation work each
445
+ - Aim for 5-20 prompts per spec (split large specs, combine trivial items)
446
+ - Include a "Prompt 0: Project setup" if the spec requires new dependencies or scaffolding
447
+ - Include a final "Prompt N: Integration test" that verifies the full feature end-to-end
448
+
449
+ **After generation:** The document is written and committed. The next cycle will detect it in execute mode and begin executing prompts sequentially.
450
+
451
+ <failure_pattern_capture>
452
+ When the same failure pattern appears in 2+ items within a campaign, capture it for future runs.
453
+
454
+ **Detection:** After marking an item FAILED, check if the error classification matches any previous failure in this campaign:
455
+ - Same error type (e.g., "test regression in unrelated module")
456
+ - Same file or module involved
457
+ - Same root cause category (e.g., "missing null check pattern", "import path mismatch")
458
+
459
+ **Capture (when pattern repeats):**
460
+ Append to `.planning/focus/failure-patterns.md`:
461
+ ```markdown
462
+ ## Pattern: {short description}
463
+ - **First seen:** Cycle {N}, Item {ID}
464
+ - **Recurrence:** Cycle {M}, Item {ID2}
465
+ - **Error type:** {classification}
466
+ - **Root cause:** {what actually went wrong}
467
+ - **Avoidance rule:** {what to check before attempting similar items}
468
+ - **Files involved:** {paths}
469
+ ```
470
+
471
+ **Use (on subsequent cycles):**
472
+ Before executing an item, check if its target files or error category match a known failure pattern. If so:
473
+ - Apply the avoidance rule BEFORE implementing
474
+ - If the pattern suggests the item will fail (e.g., "all items touching module X regress"), skip with reason "matches known failure pattern — defer to manual investigation"
475
+
476
+ This prevents the campaign from burning budget on items that will predictably fail.
477
+ </failure_pattern_capture>
297
478
 
298
479
  ## NEVER DO
299
480
 
300
- - Invoke the Skill tool (no `/pan:focus-scan`, `/pan:focus-plan`, `/pan:focus-exec`)
301
- - Stop or pause between phases (unless a safety harness triggers)
302
- - Ask the user questions after category selection (Phases 1-3 are fully autonomous)
303
- - Skip the baseline test capture (Phase 1)
304
- - Continue after a test regression (circuit breaker is mandatory)
305
- - Expand scope beyond what the scan found
306
- - Run more cycles than --max-cycles
307
- - Spend more points than --total-budget
308
- - Skip recording cycle results via --update
309
- - Change test expectations to match broken code
310
- - Use `git add -A` or `git add .` — stage specific files only
481
+ - Invoke the Skill tool scan/plan/exec must run inline so state stays coherent across cycles
482
+ - Stop or pause between phases interruptions break the autonomous loop and lose cycle momentum
483
+ - Ask the user questions after category selection the whole point is autonomous execution; questions defeat that
484
+ - Skip the baseline test capture without a baseline, the regression circuit breaker has nothing to compare against
485
+ - Continue after a test regression a test count decrease means code was broken; continuing compounds the damage
486
+ - Expand scope beyond what the scan found — scope creep in an autonomous loop compounds unpredictably across cycles
487
+ - Run more cycles than --max-cycles — the limit exists to cap total cost and prevent runaway loops
488
+ - Spend more points than --total-budget — the budget cap is the user's cost control mechanism
489
+ - Skip recording cycle results via --update — unrecorded cycles break resume, status, and stop-condition checks
490
+ - Change test expectations to match broken code — this hides bugs instead of fixing them
491
+ - Use `git add -A` or `git add .` — bulk staging can accidentally commit secrets, build artifacts, or unrelated changes
311
492
 
312
493
  ## ALWAYS DO
313
494
 
@@ -41,9 +41,74 @@ If you find yourself analyzing PAN command files, agent definitions, or `pan-too
41
41
 
42
42
  ---
43
43
 
44
- ## MANDATORY: Complete All Phases For Selected Mode
44
+ ## Tool Selection Priority
45
45
 
46
- When `/pan:focus-design` is invoked, execute ALL phases for the selected mode automatically. Do NOT stop to ask questions between phases. Do NOT skip phases beyond what the mode specifies. Complete the FULL investigation and produce all output artifacts. The only permitted pause is the Strategy Gate in Phase 3 (if the user passed `--gate`).
46
+ Use the simplest sufficient tool for each research operation:
47
+ 1. **Grep/Glob** — for finding patterns and files in the local codebase
48
+ 2. **Read** — for examining specific files identified by Grep/Glob
49
+ 3. **Bash** — for git history, test runs, build commands
50
+ 4. **Agent (subagent)** — for broad exploration spanning many files (>5 reads)
51
+ 5. **WebSearch/WebFetch** — for external research after local sources are exhausted
52
+ 6. **mcp__context7__*** — for library documentation lookups
53
+
54
+ Prefer local evidence over web research. Start with the codebase, then broaden.
55
+
56
+ ## Context Management Across Phases
57
+
58
+ This pipeline spans 10+ phases. Manage context to maintain quality:
59
+ - **KEEP:** Problem statement, success criteria, key architectural decisions, file paths being designed for
60
+ - **SUMMARIZE:** Research findings (compress to key takeaways after each research phase), competitive analysis results
61
+ - **DISCARD:** Raw web fetch content after extracting relevant data, superseded design drafts
62
+ - After Phase 3 (Strategic Analysis), summarize all findings from Phases 0-3 into a compact brief before entering design phases
63
+
64
+ **Progressive context loading — load only what the current phase needs:**
65
+
66
+ | Phase | What to Load | What NOT to Load Yet |
67
+ |-------|-------------|---------------------|
68
+ | 0. Problem | User's feature description, project README | Implementation details, test files |
69
+ | 1. Landscape | Web search results, competitor docs | Project internals |
70
+ | 2. Codebase | Relevant source files (Glob→Grep→Read) | Unrelated modules, full test suite |
71
+ | 3. Strategic | Findings from 0-2 (summarized) | Raw web content (discard after summary) |
72
+ | 4-6. Design | Architecture files, key modules, API surface | Test implementation details |
73
+ | 7-8. Spec | Design decisions from 4-6, test patterns | Research raw data (long gone) |
74
+ | 9. Output | Spec template, ADR template | Everything else (already in spec) |
75
+
76
+ **Why:** A 10-phase pipeline that loads everything in Phase 0 exhausts context by Phase 5. Each phase loads only its inputs, summarizes its outputs, and discards its raw data.
77
+
78
+ ---
79
+
80
+ ## Reasoning Protocol
81
+
82
+ For research and analysis phases (0, 1, 2, 3), follow observe-think-act:
83
+ 1. **OBSERVE** — State what you found (code patterns, competitive data, user needs)
84
+ 2. **THINK** — Reason about what this means for the design
85
+ 3. **ACT** — Record the finding and move to the next investigation step
86
+ This keeps research structured and prevents rabbit holes.
87
+
88
+ ## Meta-Prompting: Self-Generated Investigation Strategy
89
+
90
+ Before starting Phase 0, generate your own investigation plan based on the feature description:
91
+
92
+ ```
93
+ Given: "{feature description}"
94
+ My investigation strategy:
95
+ 1. What is the core problem? → {how I'll validate it}
96
+ 2. Who are the competitors? → {what to search for}
97
+ 3. What codebase areas are affected? → {what to Glob/Grep for}
98
+ 4. What are the likely architectural constraints? → {what to read}
99
+ 5. What risks should I watch for? → {security, performance, compatibility}
100
+ 6. What is the ideal output format? → {spec structure for this feature type}
101
+ ```
102
+
103
+ This self-generated strategy adapts to the specific feature rather than following a generic checklist. A "add caching layer" feature needs different investigation than "add OAuth provider" — the meta-prompt captures that difference upfront.
104
+
105
+ **After Phase 3, regenerate:** The strategy may need revision based on what you've learned. Update it before entering design phases.
106
+
107
+ ---
108
+
109
+ ## Complete All Phases For Selected Mode
110
+
111
+ When `/pan:focus-design` is invoked, execute all phases for the selected mode automatically. Do not stop to ask questions between phases or skip phases beyond what the mode specifies. Complete the full investigation and produce all output artifacts. The only permitted pause is the Strategy Gate in Phase 3 (if the user passed `--gate`).
47
112
 
48
113
  **Modes (mutually exclusive — pick one, default `--full`):**
49
114