prizmkit 1.1.1 → 1.1.3

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 (99) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/claude/agent-adapter.js +18 -0
  3. package/bundled/adapters/claude/command-adapter.js +1 -27
  4. package/bundled/agents/prizm-dev-team-critic.md +2 -0
  5. package/bundled/agents/prizm-dev-team-dev.md +2 -0
  6. package/bundled/agents/prizm-dev-team-reviewer.md +2 -0
  7. package/bundled/dev-pipeline/README.md +63 -63
  8. package/bundled/dev-pipeline/assets/feature-list-example.json +1 -1
  9. package/bundled/dev-pipeline/assets/prizm-dev-team-integration.md +1 -1
  10. package/bundled/dev-pipeline/{launch-daemon.sh → launch-feature-daemon.sh} +33 -33
  11. package/bundled/dev-pipeline/launch-refactor-daemon.sh +454 -0
  12. package/bundled/dev-pipeline/lib/branch.sh +1 -1
  13. package/bundled/dev-pipeline/reset-feature.sh +3 -3
  14. package/bundled/dev-pipeline/reset-refactor.sh +312 -0
  15. package/bundled/dev-pipeline/{retry-bug.sh → retry-bugfix.sh} +47 -59
  16. package/bundled/dev-pipeline/retry-feature.sh +41 -54
  17. package/bundled/dev-pipeline/retry-refactor.sh +358 -0
  18. package/bundled/dev-pipeline/run-bugfix.sh +6 -0
  19. package/bundled/dev-pipeline/{run.sh → run-feature.sh} +31 -31
  20. package/bundled/dev-pipeline/run-refactor.sh +787 -0
  21. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +177 -10
  22. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +419 -0
  23. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +393 -0
  24. package/bundled/dev-pipeline/scripts/update-refactor-status.py +726 -0
  25. package/bundled/dev-pipeline/templates/agent-prompts/critic-code-challenge.md +13 -0
  26. package/bundled/dev-pipeline/templates/agent-prompts/critic-plan-challenge.md +7 -0
  27. package/bundled/dev-pipeline/templates/agent-prompts/dev-fix.md +7 -0
  28. package/bundled/dev-pipeline/templates/agent-prompts/dev-implement.md +26 -0
  29. package/bundled/dev-pipeline/templates/agent-prompts/dev-resume.md +5 -0
  30. package/bundled/dev-pipeline/templates/agent-prompts/reviewer-analyze.md +5 -0
  31. package/bundled/dev-pipeline/templates/agent-prompts/reviewer-review.md +12 -0
  32. package/bundled/dev-pipeline/templates/bootstrap-tier1.md +29 -2
  33. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +8 -7
  34. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +11 -10
  35. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +2 -3
  36. package/bundled/dev-pipeline/templates/feature-list-schema.json +1 -1
  37. package/bundled/dev-pipeline/templates/refactor-list-schema.json +159 -0
  38. package/bundled/dev-pipeline/templates/sections/ac-verification-checklist.md +13 -0
  39. package/bundled/dev-pipeline/templates/sections/feature-context.md +1 -1
  40. package/bundled/dev-pipeline/templates/sections/phase-analyze-agent.md +9 -8
  41. package/bundled/dev-pipeline/templates/sections/phase-analyze-full.md +9 -8
  42. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -1
  43. package/bundled/dev-pipeline/templates/sections/phase-critic-code.md +8 -10
  44. package/bundled/dev-pipeline/templates/sections/phase-critic-plan-full.md +9 -10
  45. package/bundled/dev-pipeline/templates/sections/phase-critic-plan.md +8 -9
  46. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +7 -10
  47. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +8 -15
  48. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +7 -12
  49. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +8 -19
  50. package/bundled/dev-pipeline/templates/sections/test-failure-recovery.md +75 -0
  51. package/bundled/skills/_metadata.json +33 -6
  52. package/bundled/skills/app-planner/SKILL.md +105 -320
  53. package/bundled/skills/app-planner/assets/app-design-guide.md +101 -0
  54. package/bundled/skills/app-planner/references/frontend-design-guide.md +1 -1
  55. package/bundled/skills/app-planner/references/project-brief-guide.md +49 -80
  56. package/bundled/skills/bug-fix-workflow/SKILL.md +2 -2
  57. package/bundled/skills/bug-planner/SKILL.md +68 -5
  58. package/bundled/skills/bug-planner/scripts/validate-bug-list.py +3 -2
  59. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +19 -5
  60. package/bundled/skills/{dev-pipeline-launcher → feature-pipeline-launcher}/SKILL.md +32 -32
  61. package/bundled/skills/feature-planner/SKILL.md +337 -0
  62. package/bundled/skills/{app-planner → feature-planner}/assets/evaluation-guide.md +4 -4
  63. package/bundled/skills/{app-planner → feature-planner}/assets/planning-guide.md +3 -171
  64. package/bundled/skills/{app-planner → feature-planner}/references/browser-interaction.md +6 -5
  65. package/bundled/skills/feature-planner/references/decomposition-patterns.md +75 -0
  66. package/bundled/skills/{app-planner → feature-planner}/references/error-recovery.md +8 -8
  67. package/bundled/skills/{app-planner → feature-planner}/references/incremental-feature-planning.md +1 -1
  68. package/bundled/skills/{app-planner/references/new-app-planning.md → feature-planner/references/new-project-planning.md} +1 -1
  69. package/bundled/skills/{app-planner → feature-planner}/scripts/validate-and-generate.py +4 -4
  70. package/bundled/skills/feature-workflow/SKILL.md +23 -23
  71. package/bundled/skills/prizm-kit/SKILL.md +1 -3
  72. package/bundled/skills/prizmkit-analyze/SKILL.md +2 -5
  73. package/bundled/skills/prizmkit-code-review/SKILL.md +2 -2
  74. package/bundled/skills/prizmkit-committer/SKILL.md +4 -8
  75. package/bundled/skills/prizmkit-deploy/SKILL.md +1 -5
  76. package/bundled/skills/prizmkit-implement/SKILL.md +3 -50
  77. package/bundled/skills/prizmkit-init/SKILL.md +5 -77
  78. package/bundled/skills/prizmkit-plan/SKILL.md +1 -12
  79. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +6 -24
  80. package/bundled/skills/prizmkit-prizm-docs/assets/PRIZM-SPEC.md +21 -0
  81. package/bundled/skills/prizmkit-retrospective/SKILL.md +12 -117
  82. package/bundled/skills/recovery-workflow/SKILL.md +166 -316
  83. package/bundled/skills/recovery-workflow/evals/evals.json +29 -13
  84. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +232 -274
  85. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +352 -0
  86. package/bundled/skills/refactor-planner/SKILL.md +436 -0
  87. package/bundled/skills/refactor-planner/assets/planning-guide.md +292 -0
  88. package/bundled/skills/refactor-planner/references/behavior-preservation.md +301 -0
  89. package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +221 -0
  90. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +786 -0
  91. package/bundled/skills/refactor-workflow/SKILL.md +299 -319
  92. package/package.json +1 -1
  93. package/src/clean.js +3 -3
  94. package/src/scaffold.js +6 -6
  95. package/bundled/skills/prizmkit-plan/assets/spec-template.md +0 -56
  96. package/bundled/skills/prizmkit-plan/references/clarify-guide.md +0 -67
  97. package/src/config.js +0 -504
  98. package/src/prompts.js +0 -210
  99. /package/bundled/skills/{dev-pipeline-launcher → feature-pipeline-launcher}/scripts/preflight-check.py +0 -0
@@ -0,0 +1,436 @@
1
+ ---
2
+ name: "refactor-planner"
3
+ description: "Interactive refactoring planner. Understands refactoring intent through dialogue, analyzes current code structure, produces validated refactor-list.json for dev-pipeline execution. Use whenever users discuss refactoring planning, code restructuring scope, or preparing refactor-list.json."
4
+ ---
5
+
6
+ # refactor planner
7
+
8
+ Plan executable refactoring items for dev-pipeline:
9
+ - **Scope Assessment**: analyze current code structure and identify refactoring targets
10
+ - **Item Decomposition**: break refactoring goals into well-ordered, behavior-preserving items
11
+
12
+ Always produce a validated `refactor-list.json` that conforms to `dev-pipeline-refactor-list-v1`.
13
+
14
+ ## Invocation Commitment (Hard Rule)
15
+
16
+ **When the user invokes `/refactor-planner`, you MUST execute the refactor-planner workflow.** You must NEVER:
17
+ - Decide on the user's behalf that the task "doesn't need refactor-planner"
18
+ - Skip refactor-planner to jump directly to refactor-workflow or any other skill
19
+ - Bypass the interactive phases because you judge the task to be "simple" or "obvious"
20
+
21
+ If you believe the task is better suited for a different workflow (e.g., single-file refactor via `/refactor-workflow`), you MUST:
22
+ 1. **Explain why** you think a different path is more appropriate
23
+ 2. **Ask the user explicitly** whether they want to switch or continue with refactor-planner
24
+ 3. **Only switch if the user confirms** — otherwise proceed with refactor-planner as invoked
25
+
26
+ The user chose this skill intentionally. Respect that choice.
27
+
28
+ ## Scope Boundary (Hard Rule)
29
+
30
+ **This skill is PLANNING ONLY.** You must NEVER:
31
+ - Create, modify, or delete source code files (*.js, *.ts, *.py, *.go, *.html, *.css, etc.)
32
+ - Execute refactoring operations (rename, move, extract, etc.)
33
+ - Run build/install/test commands
34
+ - Execute any implementation action beyond writing `refactor-list.json`
35
+
36
+ **Your ONLY writable outputs are:**
37
+ 1. `refactor-list.json` (project root)
38
+ 2. Draft backups in `.prizmkit/planning/`
39
+
40
+ **After planning is complete**, you MUST:
41
+ 1. Present the summary and recommended next step
42
+ 2. **Ask the user explicitly** whether they want to proceed to execution
43
+ 3. If the user agrees -> recommend invoking `refactor-pipeline-launcher` or running `run-refactor.sh` (do NOT execute it yourself)
44
+ 4. If the user wants to adjust -> continue refining `refactor-list.json`
45
+ 5. **NEVER auto-execute** the pipeline, launcher, or any implementation step
46
+
47
+ ## When to Use
48
+
49
+ Trigger this skill for requests like:
50
+ - "Plan refactoring", "Scope a restructuring"
51
+ - "Prepare refactor-list.json", "Prepare dev-pipeline input for refactoring"
52
+ - "Assess code for refactoring", "Identify refactoring targets"
53
+ - "Plan a code migration", "Decompose a large refactor"
54
+
55
+ Do NOT use this skill when the user wants to:
56
+ - Execute a single refactor directly (use `refactor-workflow`)
57
+ - Plan new features (use `feature-planner`)
58
+ - Fix bugs (use `bug-planner`)
59
+
60
+ ## Resource Loading Rules (Mandatory)
61
+
62
+ 1. **Read decomposition guide**:
63
+ - Read `${SKILL_DIR}/assets/planning-guide.md` for decomposition patterns and description guidelines
64
+
65
+ 2. **Read scope assessment reference**:
66
+ - Read `${SKILL_DIR}/references/refactor-scoping-guide.md` for scope classification and risk assessment
67
+
68
+ 3. **Read behavior preservation reference**:
69
+ - Read `${SKILL_DIR}/references/behavior-preservation.md` for preservation strategy selection
70
+
71
+ 4. **Load on-demand references when triggered**:
72
+ - Validation errors or interrupted session -> read error recovery patterns (similar to feature-planner)
73
+
74
+ 5. **Always validate output via script**:
75
+ - Run:
76
+ ```bash
77
+ python3 ${SKILL_DIR}/scripts/validate-and-generate-refactor.py validate --input <output-path>
78
+ ```
79
+
80
+ 6. **Use script output as source of truth**:
81
+ - If validation fails, **MUST** fix and re-run until pass
82
+
83
+ ## Prerequisites
84
+
85
+ Before questions, check optional context files (never block if absent):
86
+ - `.prizm-docs/root.prizm` (architecture/project context)
87
+ - `.prizmkit/config.json` (existing stack preferences and detected tech stack)
88
+ - Existing test suite (critical for behavior preservation assessment)
89
+ - Existing `refactor-list.json` (if appending additional items)
90
+ - If `.prizm-docs/root.prizm` is absent and the project has existing source code, scan the directory structure:
91
+ ```bash
92
+ find . -maxdepth 2 -type d -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/dist/*' -not -path '*/build/*' -not -path '*/__pycache__/*' -not -path '*/vendor/*' | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
93
+ ```
94
+
95
+ **Test suite detection:**
96
+ - Scan for test runner config files (`jest.config.*`, `vitest.config.*`, `pytest.ini`, `.mocharc.*`, `karma.conf.*`)
97
+ - If no test suite detected, WARN: "No test suite found. Behavior preservation will rely on manual verification. Consider writing tests before refactoring."
98
+ - Record test suite status in planning context for downstream use
99
+
100
+ ## Operation Modes
101
+
102
+ ### Mode A: Interactive (default)
103
+ Full Q&A -> code analysis -> item generation. Used when starting from scratch or exploring refactoring scope.
104
+
105
+ ### Mode B: From Analysis
106
+ When an existing analysis report (e.g., `refactor-analysis.md`) is available, skip the analysis phase and proceed directly to item decomposition.
107
+
108
+ ### Mode C: Validate
109
+ Validate an existing `refactor-list.json` without regenerating it:
110
+ ```bash
111
+ python3 ${SKILL_DIR}/scripts/validate-and-generate-refactor.py validate --input refactor-list.json
112
+ ```
113
+
114
+ ### Mode D: Summary
115
+ Display a human-readable summary of an existing `refactor-list.json`:
116
+ - Item count, dependency graph, complexity distribution, behavior preservation strategies
117
+
118
+ ## Interactive Mode — Core Workflow
119
+
120
+ Execute the planning workflow in conversation mode with mandatory checkpoints:
121
+
122
+ ### Phase 1: Project Context
123
+
124
+ **Goal**: Understand the current codebase structure and tech stack.
125
+
126
+ 1. Read `.prizm-docs/root.prizm` and relevant L1 docs
127
+ 2. Read `.prizmkit/config.json` for tech stack info
128
+ 3. Identify existing test suite and coverage
129
+ 4. Summarize project context to the user: "Here's what I found about your project..."
130
+
131
+ **CHECKPOINT CP-RP-0**: Project context loaded, tech stack and test suite status known.
132
+
133
+ ### Phase 2: Refactor Goal Collection
134
+
135
+ **Goal**: Through interactive dialogue, understand what the user wants to refactor and why.
136
+
137
+ Support 4 input formats (users may mix formats):
138
+
139
+ **Format A — Natural language**:
140
+ > "This module is too large and hard to maintain"
141
+ > "The auth logic is scattered across too many files"
142
+
143
+ **Format B — Code smell pointer**:
144
+ > "src/api/handler.js is 800 lines"
145
+ > "There are 5 files that all implement similar validation logic"
146
+
147
+ **Format C — Architecture migration**:
148
+ > "Convert callbacks to async/await"
149
+ > "Migrate from class components to hooks"
150
+ > "Move from monolith to modular architecture"
151
+
152
+ **Format D — Dependency decoupling**:
153
+ > "There's a circular dependency between auth and user modules"
154
+ > "The database layer is tightly coupled to the HTTP layer"
155
+
156
+ For each input, ask clarifying questions:
157
+ - What is the specific target (files, modules, patterns)?
158
+ - What is the desired end state?
159
+ - Are there constraints (must preserve API, must not touch certain files)?
160
+ - What is the motivation (maintainability, performance, testability)?
161
+
162
+ Continue collecting goals until the user says they're done. There is no limit on rounds.
163
+
164
+ **CHECKPOINT CP-RP-1**: All refactoring goals collected and understood.
165
+
166
+ ### Phase 3: Code Analysis
167
+
168
+ **Goal**: Analyze the target code to inform item decomposition.
169
+
170
+ Dispatch **parallel Agent reads** of target files:
171
+ - **Agent A (Structure)**: File inventory, dependency graph, module boundaries, public API surface
172
+ - **Agent B (Quality)**: Code smells, complexity hotspots, duplication, coupling metrics
173
+ - **Agent C (Tests)**: Test coverage of target areas, existing test patterns, behavior contracts
174
+
175
+ Present consolidated findings:
176
+ ```
177
+ ## Code Analysis Results
178
+
179
+ ### Structure
180
+ - [file inventory, dependency graph]
181
+
182
+ ### Quality Issues
183
+ - [code smells, complexity hotspots, duplication]
184
+
185
+ ### Test Coverage
186
+ - [test status for target areas]
187
+ - [behavior contracts that must be preserved]
188
+
189
+ ### Recommended Decomposition
190
+ - [suggested refactoring order based on findings]
191
+ ```
192
+
193
+ Ask: "Based on this analysis, here's how I'd recommend decomposing the refactoring. Does this align with your expectations?"
194
+
195
+ **CHECKPOINT CP-RP-2**: Code analysis complete, user agrees with recommended approach.
196
+
197
+ ### Phase 4: Item Decomposition
198
+
199
+ **Goal**: Split refactoring goals into executable, well-ordered items.
200
+
201
+ Read `${SKILL_DIR}/assets/planning-guide.md` for decomposition patterns and dependency ordering rules.
202
+
203
+ For each refactoring goal:
204
+ 1. Identify atomic refactoring operations
205
+ 2. Determine inter-item dependencies (safe renames first, structural changes later)
206
+ 3. Assess complexity per item (file count, cross-module scope, test coverage)
207
+ 4. Assign behavior preservation strategy per item (read `${SKILL_DIR}/references/behavior-preservation.md`)
208
+
209
+ **CHECKPOINT CP-RP-3**: All items decomposed with dependencies and preservation strategies.
210
+
211
+ ### Phase 5: Per-Item Confirmation
212
+
213
+ **Goal**: Present each item to the user for confirmation, modification, or rejection.
214
+
215
+ For each item, display:
216
+
217
+ ```
218
+ Refactor Item R-001:
219
+ Title: [title]
220
+ Type: [extract/rename/restructure/simplify/decouple/migrate]
221
+ Scope: [files list]
222
+ Priority: [critical/high/medium/low]
223
+ Complexity: [low/medium/high]
224
+ Behavior Preservation: [test-gate/snapshot/manual]
225
+ Acceptance Criteria:
226
+ - [criterion 1]
227
+ - [criterion 2]
228
+ Dependencies: [none / R-002, R-003]
229
+
230
+ Confirm? (Y/modify/skip)
231
+ ```
232
+
233
+ - **Y**: Accept item as-is
234
+ - **modify**: User provides changes, update item, re-display for confirmation
235
+ - **skip**: Remove item from the list
236
+
237
+ Continue until all items are confirmed or skipped.
238
+
239
+ **CHECKPOINT CP-RP-4**: All items confirmed by user.
240
+
241
+ ### Phase 6: Completeness Review
242
+
243
+ **Goal**: Check the full item set for consistency and gaps.
244
+
245
+ 1. **Dependency ordering check**: Verify items form a valid DAG (no cycles). Items should be ordered: safe renames -> extract/inline -> structural changes -> migrations
246
+ 2. **Behavior preservation check**: Every item must have a declared preservation strategy. Flag any item with `manual` strategy and no test coverage.
247
+ 3. **Gap detection**: Are there intermediate steps needed between items? Does item A's output match item B's input assumption?
248
+ 4. **Cross-module impact**: Do any items affect modules outside the declared scope?
249
+
250
+ Present review summary:
251
+ ```
252
+ Item | Deps Valid | Preservation | Gaps | Status
253
+ R-001 | OK | test-gate | - | Ready
254
+ R-002 | OK | test-gate | - | Ready
255
+ R-003 | OK | manual | No test coverage| Needs attention
256
+ R-004 | OK | snapshot | - | Ready
257
+ ```
258
+
259
+ If issues found, discuss with user and resolve before proceeding.
260
+
261
+ **CHECKPOINT CP-RP-5**: Completeness review passed, all issues resolved.
262
+
263
+ ### Phase 7: Generate & Validate
264
+
265
+ **Goal**: Produce `refactor-list.json` and validate it.
266
+
267
+ 1. Generate `refactor-list.json` at project root
268
+ 2. Run validation:
269
+ ```bash
270
+ python3 ${SKILL_DIR}/scripts/validate-and-generate-refactor.py validate --input refactor-list.json
271
+ ```
272
+ 3. If validation fails -> fix issues and re-validate (max 3 attempts)
273
+ 4. If validation passes -> present final summary
274
+
275
+ **CHECKPOINT CP-RP-6**: `refactor-list.json` generated and validated.
276
+
277
+ ## Checkpoints (Mandatory Gates)
278
+
279
+ | Checkpoint | Artifact/State | Criteria | Phase |
280
+ |-----------|----------------|----------|-------|
281
+ | **CP-RP-0** | Project Context | Tech stack, test suite status, .prizm-docs loaded | 1 |
282
+ | **CP-RP-1** | Goals Collected | All refactoring goals understood, no open ambiguities | 2 |
283
+ | **CP-RP-2** | Code Analyzed | Analysis complete, user agrees with approach | 3 |
284
+ | **CP-RP-3** | Items Decomposed | All items have deps, complexity, preservation strategy | 4 |
285
+ | **CP-RP-4** | Items Confirmed | User confirmed/modified/skipped each item | 5 |
286
+ | **CP-RP-5** | Completeness OK | DAG valid, preservation strategies declared, no gaps | 6 |
287
+ | **CP-RP-6** | Output Valid | `refactor-list.json` passes validation script | 7 |
288
+
289
+ **Resume Detection**: If existing artifacts found (partial `refactor-list.json`, draft in `.prizmkit/planning/`), offer to resume from the appropriate checkpoint.
290
+
291
+ ## Output Rules
292
+
293
+ `refactor-list.json` must satisfy:
294
+ - `$schema` = `dev-pipeline-refactor-list-v1`
295
+ - Non-empty `refactors` array
296
+ - Sequential IDs: `R-001`, `R-002`, ...
297
+ - Valid dependency DAG (no cycles)
298
+ - Each item has a declared `behavior_preservation` strategy: `test-gate`, `snapshot`, or `manual`
299
+ - `priority` must be a string: `"critical"`, `"high"`, `"medium"`, or `"low"`
300
+ - New items default `status: "pending"`
301
+ - English titles for stable slug generation
302
+ - `type` field must be one of: `extract`, `rename`, `restructure`, `simplify`, `decouple`, `migrate`
303
+ - Descriptions minimum 15 words (error). Recommended: 30/50/80 words for low/medium/high complexity (warning).
304
+ - `model` field is optional — omitting it means the pipeline uses $MODEL env or CLI default
305
+ - `scope` array lists target file/directory paths
306
+
307
+ ## Fast Path
308
+
309
+ For simple refactoring with minimal scope:
310
+
311
+ ### Eligibility Criteria (ALL must apply)
312
+ - 1-2 refactor items only
313
+ - Complexity: `low` or `medium` for all items
314
+ - No cross-module impact (all items within same module)
315
+ - Well-known refactoring pattern (rename, extract method/class, inline)
316
+ - Existing test coverage for target area
317
+
318
+ ### Fast Path Workflow
319
+ 1. Confirm refactoring scope with user
320
+ 2. **User confirmation (mandatory)** — Tell the user: "This qualifies for fast-path (simple refactoring). Skip detailed analysis and draft directly? Or use full workflow?" Only proceed if user confirms.
321
+ 3. Draft items (title + type + scope + description + acceptance_criteria + behavior_preservation + dependencies)
322
+ 4. Run validation script immediately
323
+ 5. If valid -> summarize and recommend next step
324
+ 6. If invalid -> apply fixes, re-validate (max 2 attempts, then escalate to full workflow)
325
+
326
+ ### When NOT to Use Fast Path
327
+ - More than 2 refactor items
328
+ - Any item with `high` complexity
329
+ - Cross-module impact
330
+ - Architecture migration patterns (Format C goals)
331
+ - No existing test coverage for target area
332
+
333
+ ### Example Fast Path Session
334
+ ```
335
+ User: "Rename the auth middleware function from checkAuth to requireAuth everywhere."
336
+ AI: [Detects simple rename, single module]
337
+ AI: [Qualifies for fast path: 1 item, low complexity, no cross-module impact]
338
+ AI: "This qualifies for fast-path. Skip detailed analysis and draft directly? Or use full workflow?"
339
+ User: "Fast path."
340
+ AI: "Drafting R-001..."
341
+ AI: [Validates immediately]
342
+ AI: "Ready to proceed to dev-pipeline."
343
+ ```
344
+
345
+ ## Refactoring-Specific Features
346
+
347
+ ### Behavior Preservation Check
348
+ Every item MUST declare a behavior preservation strategy. Read `${SKILL_DIR}/references/behavior-preservation.md` for strategy details.
349
+
350
+ | Strategy | When to Use |
351
+ |----------|-------------|
352
+ | `test-gate` | Target area has good test coverage. Run full test suite after each change. |
353
+ | `snapshot` | Compare output/state before and after. Used when tests are insufficient but behavior is observable. |
354
+ | `manual` | Human verification required. Last resort when neither tests nor snapshots are feasible. |
355
+
356
+ Flag items using `manual` strategy prominently — they carry the highest risk of behavior regression.
357
+
358
+ ### Dependency Ordering
359
+ Auto-detect inter-item dependencies and enforce safe ordering:
360
+ 1. **Safe renames** first (lowest risk, no structural change)
361
+ 2. **Extract/inline** operations (moderate risk, changes module boundaries)
362
+ 3. **Structural changes** (higher risk, reorganizes architecture)
363
+ 4. **Migrations** last (highest risk, changes patterns/paradigms)
364
+
365
+ ### Complexity Assessment
366
+ Assess each item's complexity based on:
367
+ - **File count**: 1-2 files = low, 3-5 files = medium, 6+ files = high
368
+ - **Cross-module scope**: same module = low, 2 modules = medium, 3+ modules = high
369
+ - **Test coverage**: high coverage = reduces complexity, low coverage = increases complexity
370
+ - **Pattern familiarity**: well-known pattern = low, novel restructuring = high
371
+
372
+ Take the highest of these individual assessments as the item's complexity.
373
+
374
+ ## Next-Step Execution Policy (after planning)
375
+
376
+ Recommend these three options in this strict order:
377
+
378
+ 1. **Preferred**: invoke `refactor-pipeline-launcher` skill (natural-language handoff)
379
+ 2. **Fallback A**: run daemon wrapper
380
+ ```bash
381
+ ./dev-pipeline/launch-refactor-daemon.sh start refactor-list.json
382
+ ./dev-pipeline/launch-refactor-daemon.sh status
383
+ ```
384
+ 3. **Fallback B**: run direct foreground script
385
+ ```bash
386
+ ./dev-pipeline/run-refactor.sh run
387
+ ./dev-pipeline/run-refactor.sh status
388
+ ```
389
+
390
+ When launcher is available, do not prioritize raw scripts.
391
+
392
+ ## Error Recovery & Resume
393
+
394
+ Key behaviors:
395
+ - Warnings only -> proceed with user approval
396
+ - Critical errors -> group by type, auto-fix where possible, max 3 total attempts
397
+ - Interrupted session -> detect checkpoint from existing artifacts, offer resume or restart
398
+ - `refactor-list.json` MUST be written to project root (same level as `package.json` / `.git`)
399
+
400
+ ### Resume Detection
401
+
402
+ | Artifact Found | Resume From |
403
+ |---------------|------------|
404
+ | Nothing | Phase 1: Project Context |
405
+ | Draft in `.prizmkit/planning/` | Phase matching draft state |
406
+ | Partial `refactor-list.json` | Phase 6: Completeness Review |
407
+ | Valid `refactor-list.json` | Mode D: Summary |
408
+
409
+ ## Session Exit Gate
410
+
411
+ Prevent accidental session exit without deliverable completion.
412
+
413
+ ### Trigger Conditions
414
+ Activate exit gate when ALL are true:
415
+ - User invoked `/refactor-planner` (not just mentioned refactoring)
416
+ - Current phase < Phase 7 (validation not yet passed)
417
+ - No valid `refactor-list.json` has been written in this session
418
+
419
+ ### Gate Behavior
420
+ When the session appears to be ending:
421
+ 1. **Remind**: "You set out to produce `refactor-list.json` but we haven't completed it yet."
422
+ 2. **Offer 3 options**:
423
+ - **(a) Continue to completion** — resume from current phase
424
+ - **(b) Save draft & exit** — write current progress as draft, exit session
425
+ - **(c) Abandon** — exit without saving
426
+ 3. **If (b)**: Write draft and remind: "This is a draft, not validated. Run `/refactor-planner` again to resume."
427
+ 4. **If (c)**: Accept without further prompting.
428
+
429
+ ## Handoff Message Template
430
+
431
+ After successful validation, report:
432
+ 1. Output file path
433
+ 2. Total refactor items
434
+ 3. Dependency ordering highlights (which items must run first)
435
+ 4. Behavior preservation strategy distribution (N items with test-gate, M with snapshot, etc.)
436
+ 5. Recommended next action: `refactor-pipeline-launcher`