prizmkit 1.1.72 → 1.1.76

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 (62) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/agents/prizm-dev-team-dev.md +11 -1
  3. package/bundled/dev-pipeline/.env.example +1 -0
  4. package/bundled/dev-pipeline/lib/common.sh +53 -0
  5. package/bundled/dev-pipeline/lib/heartbeat.sh +94 -42
  6. package/bundled/dev-pipeline/run-bugfix.sh +5 -0
  7. package/bundled/dev-pipeline/run-feature.sh +5 -0
  8. package/bundled/dev-pipeline/run-recovery.sh +6 -0
  9. package/bundled/dev-pipeline/run-refactor.sh +5 -0
  10. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +265 -5
  11. package/bundled/dev-pipeline/templates/agent-prompts/dev-implement.md +21 -0
  12. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +1 -1
  13. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -9
  14. package/bundled/dev-pipeline/templates/sections/feature-context.md +3 -18
  15. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +1 -1
  16. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-base.md +6 -12
  17. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +10 -3
  18. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +1 -0
  19. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +4 -8
  20. package/bundled/dev-pipeline-windows/lib/common.ps1 +23 -0
  21. package/bundled/dev-pipeline-windows/lib/heartbeat.sh +439 -0
  22. package/bundled/dev-pipeline-windows/lib/pipeline.ps1 +33 -2
  23. package/bundled/dev-pipeline-windows/run-recovery.ps1 +11 -0
  24. package/bundled/dev-pipeline-windows/scripts/parse-stream-progress.py +265 -5
  25. package/bundled/dev-pipeline-windows/templates/agent-prompts/dev-implement.md +21 -0
  26. package/bundled/dev-pipeline-windows/templates/agent-prompts/reviewer-review.md +1 -1
  27. package/bundled/dev-pipeline-windows/templates/bootstrap-prompt.md +27 -0
  28. package/bundled/dev-pipeline-windows/templates/bootstrap-tier1.md +543 -14
  29. package/bundled/dev-pipeline-windows/templates/bootstrap-tier2.md +664 -14
  30. package/bundled/dev-pipeline-windows/templates/bootstrap-tier3.md +741 -14
  31. package/bundled/dev-pipeline-windows/templates/bugfix-bootstrap-prompt.md +2 -2
  32. package/bundled/dev-pipeline-windows/templates/feature-list-schema.json +1 -1
  33. package/bundled/dev-pipeline-windows/templates/refactor-bootstrap-prompt.md +1 -1
  34. package/bundled/dev-pipeline-windows/templates/refactor-list-schema.json +1 -1
  35. package/bundled/dev-pipeline-windows/templates/sections/context-budget-rules.md +3 -3
  36. package/bundled/dev-pipeline-windows/templates/sections/failure-capture.md +1 -1
  37. package/bundled/dev-pipeline-windows/templates/sections/feature-context.md +3 -18
  38. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-auto.md +239 -40
  39. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification-opencli.md +75 -26
  40. package/bundled/dev-pipeline-windows/templates/sections/phase-browser-verification.md +142 -36
  41. package/bundled/dev-pipeline-windows/templates/sections/phase-commit-full.md +2 -2
  42. package/bundled/dev-pipeline-windows/templates/sections/phase-commit.md +1 -1
  43. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-agent-suffix.md +1 -1
  44. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-base.md +7 -17
  45. package/bundled/dev-pipeline-windows/templates/sections/phase-context-snapshot-lite-suffix.md +10 -3
  46. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan-full.md +1 -1
  47. package/bundled/dev-pipeline-windows/templates/sections/phase-critic-plan.md +1 -1
  48. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-agent.md +3 -1
  49. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-full.md +7 -3
  50. package/bundled/dev-pipeline-windows/templates/sections/phase-implement-lite.md +1 -3
  51. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-agent.md +1 -1
  52. package/bundled/dev-pipeline-windows/templates/sections/phase-plan-lite.md +1 -1
  53. package/bundled/dev-pipeline-windows/templates/sections/phase-review-agent.md +1 -1
  54. package/bundled/dev-pipeline-windows/templates/sections/phase-review-full.md +2 -2
  55. package/bundled/dev-pipeline-windows/templates/sections/phase-specify-plan-full.md +13 -17
  56. package/bundled/dev-pipeline-windows/templates/sections/phase0-test-baseline.md +2 -4
  57. package/bundled/dev-pipeline-windows/templates/sections/subagent-timeout-recovery.md +1 -1
  58. package/bundled/skills/_metadata.json +1 -1
  59. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +1 -0
  60. package/bundled/skills/feature-pipeline-launcher/SKILL.md +1 -0
  61. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +1 -0
  62. package/package.json +1 -1
@@ -1,20 +1,91 @@
1
- # PrizmKit Windows Feature Pipeline Prompt (bootstrap-tier2)
1
+ # Dev-Pipeline Session Bootstrap Tier 2 (Dual Agent)
2
2
 
3
- You are running in headless non-interactive mode on Windows PowerShell. Use PowerShell-native commands only.
3
+ ## Session Context
4
4
 
5
- ## Feature
6
- {{FEATURE_ID}} {{FEATURE_TITLE}}
5
+ - **Feature ID**: {{FEATURE_ID}} | **Session**: {{SESSION_ID}} | **Run**: {{RUN_ID}}
6
+ - **Complexity**: {{COMPLEXITY}}
7
+ - **Init**: {{INIT_DONE}} | Artifacts: spec={{HAS_SPEC}} plan={{HAS_PLAN}}
8
+
9
+ ## Your Mission
10
+
11
+ You are the **session orchestrator**. Implement Feature {{FEATURE_ID}}: "{{FEATURE_TITLE}}".
12
+
13
+ **CRITICAL**: You MUST NOT exit until ALL work is complete and committed. When you spawn subagents, wait for each to finish (run_in_background=false).
14
+
15
+ **Tier 2 — Dual Agent**: You handle context + planning directly. Then spawn Dev and Reviewer subagents. Spawn Dev and Reviewer agents via the Agent tool.
16
+
17
+ **Agent spawn failure policy (all Agent tool calls)**:
18
+ - If spawning Dev, Reviewer, or Critic fails with team/config/lock errors, retry at most once.
19
+ - If the second attempt fails, do not keep spawning variants and do not enter artifact polling for Implementation Log, challenge report, or review report markers.
20
+ - Use the documented inline/recovery fallback for that phase: write the required report yourself where possible, complete remaining Dev work directly in the orchestrator when safe, or write `failure-log.md` with the spawn error and last observable state before stopping for recovery.
21
+ - Apply the same cap to any re-spawn for report repair or resume prompts; do not burn multiple minutes on identical team/config/lock failures.
22
+
23
+ ### Feature Description
7
24
 
8
25
  {{FEATURE_DESCRIPTION}}
9
26
 
10
- ## Required workflow
11
- 1. Read the relevant project context and existing PrizmKit docs.
12
- 2. Create or update the implementation plan in `.prizmkit/specs/{{FEATURE_SLUG}}/plan.md`.
13
- 3. Implement the feature, run targeted validation, and record results in `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md`.
14
- 4. Use browser verification when required by the feature metadata.
15
- 5. Commit the completed feature with the PrizmKit committer workflow.
27
+ {{USER_CONTEXT}}
28
+
29
+ ### Acceptance Criteria
30
+
31
+ {{ACCEPTANCE_CRITERIA}}
32
+
33
+ ### Project Brief
34
+
35
+ > Product ideas checklist from planning. Lines marked [x] are already implemented. When your feature touches any [ ] item, ensure alignment. After implementation, mark relevant items [x] and append the key file/directory paths.
36
+
37
+ {{PROJECT_BRIEF}}
38
+
39
+ ### Dependencies (Already Completed)
40
+
41
+ {{COMPLETED_DEPENDENCIES}}
42
+
43
+ ### App Global Context
44
+
45
+ {{GLOBAL_CONTEXT}}
46
+
47
+ ## ⚠️ Context Budget Rules (CRITICAL — read before any phase)
48
+
49
+ You are running in **headless non-interactive mode** with a FINITE context window. Exceeding it will crash the session and lose all work. Follow these rules strictly:
50
+
51
+ 0. **NON-INTERACTIVE MODE** — There is NO human on the other end. NEVER ask for user confirmation, NEVER wait for user input, NEVER use interactive prompts (e.g. "Would you like me to…"). If a skill has an interactive step (e.g. offer remediation, ask for approval), skip it and proceed autonomously. Make decisions based on the data available and move forward.
52
+
53
+ 1. **context-snapshot.md is your single source of truth** — After Phase 1 builds it, ALWAYS read context-snapshot.md instead of re-reading individual source files
54
+ 2. **Never re-read your own writes** — After you create/modify a file, do NOT read it back to verify. Trust your write was correct.
55
+ 3. **Stay focused** — Do NOT explore code unrelated to this feature. No curiosity-driven reads.
56
+ 4. **One task at a time** — In Phase 4 (implement), complete and test one task before starting the next.
57
+ 5. **Minimize tool output** — Never load full command output into context. First capture to a temp file (`& { <command> } 2>&1 | Tee-Object (Join-Path $env:TEMP "out.txt") | Select-Object -Last 20`), then scan the first/last lines to identify relevant fields, and use targeted filtering (`Select-String`, regex matching, PowerShell object filtering) to extract only the information needed for the current task. Only read the filtered result — never the raw full output.
58
+ 6. **No intermediate commits** — Do NOT run `git add`/`git commit` during Phase 1-5. All changes are committed once at the end in Phase 6 via `/prizmkit-committer`.
59
+ 7. **Capture test output once** — When running test suites, always use `& { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "test-out.txt") | Select-Object -Last 20`. Then Select-String `(Join-Path $env:TEMP "test-out.txt")` for details. Never re-run the suite just to apply a different filter.
60
+
61
+ ---
62
+
63
+ ## PrizmKit Directory Convention
64
+
65
+ ```
66
+ .prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md ← orchestrator writes Sections 1-4; Dev appends Implementation Log; Reviewer appends Review Notes
67
+ .prizmkit/specs/{{FEATURE_SLUG}}/plan.md ← includes Tasks section
68
+ ```
69
+
70
+ **`context-snapshot.md`** is the shared knowledge base. Orchestrator writes Sections 1-4; Dev appends Implementation Log; Reviewer appends Review Notes. Append-only after initial creation.
71
+
72
+ ---
73
+
74
+ ## Subagent Timeout Recovery
75
+
76
+ If any agent times out:
77
+ 1. `Get-ChildItem -LiteralPath ".prizmkit/specs/{{FEATURE_SLUG}}/" -ErrorAction SilentlyContinue` — check what exists
78
+ 2. If `context-snapshot.md` exists: open recovery prompt with `"Read .prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md for project context and any Implementation Log/Review Notes from previous agents. Run git diff HEAD to see actual code changes already made. Do NOT re-read individual source files unless the File Manifest directs you to."` + only remaining steps + `model: "lite"`
79
+ 3. Max 2 retries per phase. After 2 failures, orchestrator completes the work directly and appends a Recovery Note to context-snapshot.md.
80
+
81
+ ---
82
+
83
+ ## Execution
84
+
85
+ ### PowerShell Python Helper
86
+
87
+ Define this helper once in the active PowerShell session before running PrizmKit Python scripts:
16
88
 
17
- ## PowerShell checkpoint update
18
89
  ```powershell
19
90
  function Invoke-PrizmPython {
20
91
  param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
@@ -36,8 +107,587 @@ function Invoke-PrizmPython {
36
107
  }
37
108
  throw "Python 3 is required. Install Python and ensure python or py is in PATH."
38
109
  }
39
- Invoke-PrizmPython {{PIPELINE_DIR}}\scripts\update-checkpoint.py --checkpoint-path {{CHECKPOINT_PATH}} --step prizmkit-implement --status completed
40
110
  ```
41
111
 
42
- ## Failure capture
43
- If a phase fails, write the failed phase, reason, files touched, and next recommended action to `.prizmkit/specs/{{FEATURE_SLUG}}/failure-log.md`.
112
+
113
+ {{IF_INIT_NEEDED}}
114
+ ### Phase 0: Project Bootstrap
115
+ - Run `/prizmkit-init` (invoke the prizmkit-init skill)
116
+ - Run `Invoke-PrizmPython {{INIT_SCRIPT_PATH}} --project-root {{PROJECT_ROOT}} --feature-id {{FEATURE_ID}} --feature-slug {{FEATURE_SLUG}}`
117
+ - **CP-0**: Verify `.prizmkit/prizm-docs/root.prizm`, `.prizmkit/config.json` exist
118
+ {{END_IF_INIT_NEEDED}}
119
+ {{IF_INIT_DONE}}
120
+ ### Phase 0: SKIP (already initialized)
121
+ {{END_IF_INIT_DONE}}
122
+
123
+ ### Phase 0.5: Detect Test Commands
124
+
125
+ You know this project's tech stack. Identify ALL test commands that apply (e.g., `go test ./...`, `npm test`, `cargo test`, `pytest`, `make test`, etc.). Record them as `TEST_CMDS`. Then record baseline:
126
+ ```powershell
127
+ & { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "test-baseline.txt") | Select-Object -Last 20
128
+ ```
129
+ Save pre-existing failing tests as `BASELINE_FAILURES`.
130
+
131
+ > **⚠️ Test Output Rule**: Always capture test output to a temp file (`Tee-Object (Join-Path $env:TEMP "test-out.txt")`). Then use Select-String on the file instead of re-running the suite.
132
+
133
+ ### Phase 1: Build Context Snapshot (you, the orchestrator)
134
+
135
+ **Check for previous failure log:**
136
+ ```powershell
137
+ if (Test-Path -LiteralPath ".prizmkit/specs/{{FEATURE_SLUG}}/failure-log.md") {
138
+ Get-Content -LiteralPath ".prizmkit/specs/{{FEATURE_SLUG}}/failure-log.md"
139
+ } else {
140
+ "NO_PREVIOUS_FAILURE"
141
+ }
142
+ ```
143
+ If failure-log.md exists:
144
+ - Read ROOT_CAUSE and SUGGESTION — adjust your approach accordingly
145
+ - Read DISCOVERED_TRAPS — if any are genuine, inject into .prizmkit/prizm-docs/ during Phase 6 retrospective
146
+ - Do NOT delete failure-log.md until this session completes all phases and commits successfully
147
+
148
+ ```powershell
149
+ if (Test-Path -LiteralPath ".prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md") { "EXISTS" } else { "MISSING" }
150
+ ```
151
+
152
+ If MISSING — build it now:
153
+ 1. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 prizm docs
154
+ 2. Detect source code directories: read KEY_FILES and STRUCTURE sections from `root.prizm` to identify where source code lives (e.g. `src/`, `app/`, `lib/`, `cmd/`, `packages/`, or project root). If `root.prizm` is missing, scan the project tree:
155
+ ```powershell
156
+ Get-ChildItem -Path . -Recurse -File -Depth 2 -Include *.js,*.ts,*.py,*.go,*.java,*.rb,*.rs -ErrorAction SilentlyContinue |
157
+ Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|dist|build|vendor)\\' } |
158
+ Select-Object -First 30 -ExpandProperty FullName
159
+ ```
160
+ Identify the top-level source directories from the results.
161
+ 3. Scan the detected source directories for files related to this feature; read each one
162
+ 4. Write `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md`:
163
+ - **Section 1 — Feature Brief**: feature description + acceptance criteria (copy from above)
164
+ - **Section 2 — Project Structure**: run the following to get a visual directory tree, then paste output:
165
+ ```powershell
166
+ Get-ChildItem -Path . -Directory -Recurse -Depth 2 -ErrorAction SilentlyContinue |
167
+ Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|dist|build|__pycache__|vendor)\\' } |
168
+ Select-Object -ExpandProperty FullName
169
+ ```
170
+ - **Section 3 — Key TRAPS & RULES**: relevant TRAPS/RULES from prizm-docs (not full copies)
171
+ - **Section 4 — File Manifest**: For each file relevant to this feature, list: file path, why it's needed (modify/reference/test), key interface signatures (function names + params + return types). Do NOT include full file content — agents read files on-demand. Format:
172
+ ### Files to Modify
173
+ | File | Why Needed | Key Interfaces |
174
+ |------|-----------|----------------|
175
+ | `<source-dir>/config.js` | Add runtime config layer | `config` (Zod object), `configSchema` |
176
+
177
+ ### Files for Reference
178
+ | File | Why Needed | Key Interfaces |
179
+ |------|-----------|----------------|
180
+ | `<source-dir>/security/permission-guard.js` | Permission check integration | `checkCommandPermission(userId, cmd)` |
181
+
182
+ ### Known TRAPS (from .prizmkit/prizm-docs/)
183
+ - <trap entries extracted from L1/L2 docs>
184
+
185
+ ### Phase 2: Plan & Tasks (you, the orchestrator)
186
+
187
+ ```powershell
188
+ Test-Path -LiteralPath ".prizmkit/specs/{{FEATURE_SLUG}}/plan.md"
189
+ ```
190
+
191
+ If either missing, run `/prizmkit-plan` with `artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/` to generate missing files:
192
+ - `plan.md`: architecture — components, interfaces, data flow, files to create/modify, testing approach, and a Tasks section with `[ ]` checkboxes ordered by dependency
193
+ - Resolve any `[NEEDS CLARIFICATION]` markers using the feature description — do NOT pause for interactive input.
194
+
195
+ **Database Design Gate** (if feature involves data persistence — new tables, schema changes, new entities):
196
+ Before proceeding past CP-1, verify:
197
+ 1. Plan.md Data Model section references existing schema/model files (scan for `*.prisma`, `*.sql`, `migrations/`, `models/`, `*.entity.*` files; read them if not already in context-snapshot)
198
+ 2. All new tables/fields follow existing naming conventions, ID strategy, timestamp patterns, and constraint style
199
+ 3. No `[NEEDS CLARIFICATION]` remains in Data Model section — resolve by reading existing code and making a conservative choice that matches existing patterns. Document the resolution in plan.md.
200
+ 4. If a DB design decision genuinely cannot be resolved from existing code alone, document the assumption made and flag it in the Implementation Log for user review.
201
+
202
+ **CP-1**: plan.md exists with Tasks section.
203
+
204
+ ### Phase 3: Analyze — Reviewer Subagent
205
+
206
+ Spawn Reviewer agent (Agent tool, subagent_type="prizm-dev-team-reviewer", mode="plan", run_in_background=false).
207
+
208
+ Spawn failure cap: for team/config/lock errors, retry at most once for this Reviewer spawn. If the second attempt fails, do not poll for report artifacts; fix/check the plan inline or write `failure-log.md` before stopping for recovery.
209
+
210
+ Prompt:
211
+ > "Read {{REVIEWER_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
212
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has project context, Section 4 has file manifest.
213
+ > 2. Cross-check `plan.md` (including Tasks section) against feature description and acceptance criteria for consistency.
214
+ > 3. Before flagging CRITICAL or HIGH issues, read the relevant source files listed in the File Manifest to verify.
215
+ > Report: CRITICAL, HIGH, MEDIUM issues found (or 'No issues found')."
216
+
217
+ Wait for Reviewer to return.
218
+ - If CRITICAL issues found: fix them yourself — read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` for full project context. Fix ONLY the listed CRITICAL issues in plan.md. Then re-run analyze (max 1 round).
219
+
220
+ **CP-2**: No CRITICAL issues.
221
+
222
+ {{IF_CRITIC_ENABLED}}
223
+ ### Phase 3.5: Plan Challenge — Critic Agent
224
+
225
+ **Guard**: Verify critic agent file exists before spawning:
226
+ ```powershell
227
+ if (Test-Path -LiteralPath "{{CRITIC_SUBAGENT_PATH}}") { "CRITIC:READY" } else { "CRITIC:MISSING" }
228
+ ```
229
+ If CRITIC:MISSING — skip Phase 3.5 entirely and proceed to Phase 4. Log: "Critic agent not installed — skipping Plan Challenge."
230
+
231
+ Spawn Critic agent (Agent tool, subagent_type="prizm-dev-team-critic", mode="plan", run_in_background=false).
232
+
233
+ Spawn failure cap: for team/config/lock errors, retry at most once for this Critic spawn. If the second attempt fails, do not poll for `challenge-report.md`; perform the plan challenge inline and record the fallback.
234
+
235
+ Prompt:
236
+ > "Read {{CRITIC_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
237
+ > **MODE: Plan Challenge**
238
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has project context, Section 4 has file manifest.
239
+ > 2. Read `.prizmkit/prizm-docs/root.prizm` and relevant L1/L2 docs for affected modules.
240
+ > 3. Read existing source files in the modules this plan touches.
241
+ > 4. Challenge plan.md against the project's existing architecture, patterns, and style.
242
+ > Write `.prizmkit/specs/{{FEATURE_SLUG}}/challenge-report.md` with findings (or 'No significant challenges')."
243
+
244
+ Wait for Critic to return.
245
+ - Read challenge-report.md. For items marked CRITICAL/HIGH: decide whether to adjust plan.md or document why the plan stands.
246
+ - Max 1 plan revision round.
247
+
248
+ **CP-2.5**: Plan challenges reviewed and resolved.
249
+ {{END_IF_CRITIC_ENABLED}}
250
+
251
+ ### Phase 4: Implement — Dev Subagent
252
+
253
+ **Build artifacts rule** (passed to Dev): After any build/compile command (`go build`, `npm run build`, `tsc`, etc.), ensure the output binary or build directory is in `.gitignore`. Never commit compiled binaries, build output, or generated artifacts.
254
+
255
+ Spawn Dev subagent (Agent tool, subagent_type="prizm-dev-team-dev", run_in_background=false).
256
+
257
+ Spawn failure cap: for team/config/lock errors, retry at most once for this Dev spawn. If the second attempt fails, do not poll for `## Implementation Log`; write `failure-log.md` and either implement remaining tasks directly in the orchestrator or stop for recovery.
258
+
259
+ Prompt:
260
+ > "Read {{DEV_SUBAGENT_PATH}}. Implement feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}).
261
+ > **IMPORTANT**: Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` FIRST — Section 3 has Prizm Context (TRAPS/RULES), Section 4 has File Manifest with paths and interfaces.
262
+ > ⚠️ DO NOT re-read source files already listed in Section 4 File Manifest unless you need implementation detail beyond the interface summary.
263
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` for full context.
264
+ > 2. Run `/prizmkit-implement` to execute the tasks in plan.md. Run tests with: `{{TEST_CMD}}`. Known baseline failures (pre-existing, not your fault): `{{BASELINE_FAILURES}}`.
265
+ > 3. If plan.md has more than 5 tasks: run `/compact` after completing every 3 tasks to manage context budget. If `/compact` is unavailable, continue without it.
266
+ > 4. After implement completes, verify the '## Implementation Log' section was written to context-snapshot.md.
267
+ > 5. Do NOT execute any git commands (no git add/commit/reset/push).
268
+ > Do NOT exit until all tasks are [x] and the '## Implementation Log' section is written in context-snapshot.md."
269
+
270
+ Wait for Dev to return. All tasks must be `[x]`, tests pass.
271
+
272
+ **Gate Check — Implementation Log**:
273
+ After Dev agent returns, verify the Implementation Log was written:
274
+ ```powershell
275
+ if (Select-String -Path ".prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md" -Pattern "## Implementation Log" -Quiet -ErrorAction SilentlyContinue) { "GATE:PASS" } else { "GATE:MISSING" }
276
+ ```
277
+ If GATE:MISSING — send message to Dev (re-spawn if needed): "Write the '## Implementation Log' section to context-snapshot.md before I can proceed to review. Include: files changed/created, key decisions, deviations from plan, notable discoveries."
278
+
279
+ ### Phase 5: Review + Test — Reviewer Subagent
280
+
281
+ Spawn Reviewer subagent (Agent tool, subagent_type="prizm-dev-team-reviewer", run_in_background=false).
282
+
283
+ Spawn failure cap: for team/config/lock errors, retry at most once for this Reviewer spawn. If the second attempt fails, do not poll for `review-report.md`; write `failure-log.md` with the spawn error and last observable state before stopping or performing an inline fallback.
284
+
285
+ Prompt:
286
+ > "Read {{REVIEWER_SUBAGENT_PATH}}. For feature {{FEATURE_ID}} (slug: {{FEATURE_SLUG}}):
287
+ > 1. Read `.prizmkit/specs/{{FEATURE_SLUG}}/spec.md` for goals and acceptance criteria
288
+ > 2. Read `.prizmkit/specs/{{FEATURE_SLUG}}/plan.md` for architecture decisions and completed tasks
289
+ > 3. Run /prizmkit-code-review with artifact_dir=.prizmkit/specs/{{FEATURE_SLUG}}/. The skill runs an internal review-fix loop (Reviewer → filter → Dev fix, max 3 rounds) and writes review-report.md.
290
+ > 4. Run the full test suite using `{{TEST_CMD}}`. When running: `& { {{TEST_CMD}} } 2>&1 | Tee-Object (Join-Path $env:TEMP "review-test-out.txt") | Select-Object -Last 20`, then use Select-String on the file for details — do NOT re-run the suite multiple times.
291
+ > 5. review-report.md will be written to .prizmkit/specs/{{FEATURE_SLUG}}/ by prizmkit-code-review.
292
+ > Report: verdict (PASS/NEEDS_FIXES), number of rounds, findings fixed/rejected."
293
+
294
+ Wait for Reviewer to return.
295
+
296
+ **Gate Check — Review Report**:
297
+ After Reviewer agent returns, verify the review report was written:
298
+ ```powershell
299
+ if (Select-String -Path ".prizmkit/specs/{{FEATURE_SLUG}}/review-report.md" -Pattern "## Verdict" -Quiet -ErrorAction SilentlyContinue) { "GATE:PASS" } else { "GATE:MISSING" }
300
+ ```
301
+ If GATE:MISSING:
302
+ - Do not re-spawn Reviewer or re-run `/prizmkit-code-review` in an unbounded report-repair loop.
303
+ - Perform one bounded status check; retry at most once: inspect Reviewer output, code-review skill output, `review-report.md` path, and any Reviewer/Dev spawn messages.
304
+ - If the missing report is caused by team/config/lock errors from Reviewer or the internal code-review loop, write `failure-log.md` with the spawn/skill error and last observable state.
305
+ - If the report is still missing after that single check/retry, either perform a safe inline fallback review and write `review-report.md` with `## Verdict`, or stop with a clear recovery failure.
306
+
307
+ Read `review-report.md` and check the Verdict:
308
+ - `PASS` → proceed to next phase
309
+ - `NEEDS_FIXES` → the skill exhausted its max rounds; log the remaining findings and proceed
310
+
311
+ **CP-3**: Tests pass, review complete.
312
+
313
+ {{IF_BROWSER_INTERACTION}}
314
+ ### Phase 5.5: Browser Verification — MANDATORY
315
+
316
+ You MUST execute this phase. Do NOT skip it.
317
+
318
+ **Browser Tool**: {{BROWSER_TOOL}}
319
+
320
+ {{IF_BROWSER_TOOL_PLAYWRIGHT}}
321
+ **Using: playwright-cli**
322
+
323
+ **CRITICAL CONSTRAINT — playwright-cli ONLY, NO Playwright MCP**:
324
+ - You MUST use `playwright-cli` (the CLI tool) for ALL browser interactions in this phase
325
+ - **NEVER** use Playwright MCP server, Playwright MCP tools, or any MCP-based browser automation
326
+ - If you have Playwright MCP configured, IGNORE it entirely — use the CLI command `playwright-cli` exclusively
327
+ - All browser actions go through `playwright-cli <command>` in the PowerShell tool, not through any MCP tool call
328
+
329
+ **Step 0 — Playwright CLI Readiness Check (BLOCKING — must pass before any browser action)**:
330
+
331
+ 0a. Check if `playwright-cli` is installed:
332
+ ```powershell
333
+ $playwright = Get-Command playwright-cli -ErrorAction SilentlyContinue
334
+ if ($playwright) { playwright-cli --version } else { "NOT_INSTALLED" }
335
+ ```
336
+ If output is `NOT_INSTALLED`, install it:
337
+ ```powershell
338
+ npm install -g @playwright/cli@latest
339
+ ```
340
+ Then verify installation succeeded:
341
+ ```powershell
342
+ playwright-cli --version
343
+ ```
344
+ If installation fails, log the error in context-snapshot.md under `## Browser Verification: SKIPPED — playwright-cli installation failed` and proceed to the next phase. Do NOT attempt browser verification without playwright-cli.
345
+
346
+ 0b. Learn playwright-cli usage (run once per session to understand available commands):
347
+ ```powershell
348
+ playwright-cli --help
349
+ ```
350
+ Use this output to determine the correct commands for your verification steps. Do NOT guess command syntax — refer to the help output.
351
+
352
+ 0c. Check if playwright-cli skill is installed for the current AI platform:
353
+ ```powershell
354
+ $currentPlatform = "unknown"
355
+ $skillDir = $null
356
+ if (Get-Command claude -ErrorAction SilentlyContinue) {
357
+ $currentPlatform = "claude"
358
+ $skillDir = Join-Path $HOME ".claude\skills"
359
+ } elseif (Get-Command cbc -ErrorAction SilentlyContinue) {
360
+ $currentPlatform = "codebuddy"
361
+ $skillDir = Join-Path $HOME ".cbc\skills"
362
+ }
363
+
364
+ $skillExists = $false
365
+ if ($skillDir) {
366
+ $directSkill = Join-Path $skillDir "playwright-cli"
367
+ $matchingSkills = Get-ChildItem -Path $skillDir -Filter "playwright*" -ErrorAction SilentlyContinue
368
+ $skillExists = (Test-Path -LiteralPath $directSkill) -or [bool]$matchingSkills
369
+ }
370
+ if ($skillExists) { "SKILL_EXISTS" } else { "SKILL_MISSING" }
371
+ ```
372
+ If `SKILL_MISSING`:
373
+ ```powershell
374
+ playwright-cli install --skills
375
+ ```
376
+ If the current platform is NOT claude, move the installed skill files to the correct location:
377
+ ```powershell
378
+ $claudeSkillDir = Join-Path $HOME ".claude\skills"
379
+ $sourceSkill = Join-Path $claudeSkillDir "playwright-cli"
380
+ if ($currentPlatform -ne "claude" -and $currentPlatform -ne "unknown" -and $skillDir -and (Test-Path -LiteralPath $sourceSkill)) {
381
+ New-Item -ItemType Directory -Force -Path $skillDir | Out-Null
382
+ Copy-Item -Recurse -Force -Path $sourceSkill -Destination $skillDir
383
+ "Moved playwright-cli skill from claude to $currentPlatform"
384
+ }
385
+ ```
386
+
387
+ 0d. Read the installed playwright-cli skill for workflow guidance:
388
+ After skill installation, read the skill's SKILL.md to understand recommended workflows and patterns. Use these patterns to construct your verification flow — do NOT invent your own patterns if the skill provides them.
389
+
390
+ **Step 1 — Start Dev Server**:
391
+
392
+ You know this project's tech stack. Detect and start the dev server yourself:
393
+
394
+ 1. Identify the dev server start command from project config (`package.json` scripts, `Makefile`, `docker-compose.yml`, etc.)
395
+ 2. **Detect the dev server port** — use the pre-detected port from pipeline if available, otherwise extract from project config. Do NOT hardcode or guess the port:
396
+ ```powershell
397
+ $DEV_PORT = "{{DEV_PORT}}"
398
+ if ($DEV_PORT -eq "{{DEV_PORT}}" -or [string]::IsNullOrWhiteSpace($DEV_PORT)) {
399
+ $detectedPort = ""
400
+ if (Test-Path -LiteralPath "package.json") {
401
+ $detectedPort = node -e "const p=require('./package.json'); const s=(p.scripts?.dev) || ''; const m=s.match(/-p\s+(\d+)/); console.log(m?m[1]:'')"
402
+ }
403
+ if (-not $detectedPort -and $env:NEXT_PUBLIC_SITE_URL -match ':([0-9]+)') {
404
+ $detectedPort = $Matches[1]
405
+ }
406
+ if ($detectedPort) { $DEV_PORT = $detectedPort } else { $DEV_PORT = "3000" }
407
+ }
408
+ "Detected DEV_PORT=$DEV_PORT"
409
+ ```
410
+ 3. Verify the port is available and start the dev server in the background, capturing its process id:
411
+ ```powershell
412
+ $portBusy = Get-NetTCPConnection -LocalPort ([int]$DEV_PORT) -ErrorAction SilentlyContinue
413
+ if ($portBusy) { "PORT_IN_USE" } else { "PORT_FREE" }
414
+ $devServerCommand = "<start-command>"
415
+ $server = Start-Process -FilePath "powershell" -ArgumentList @("-NoProfile", "-Command", $devServerCommand) -PassThru
416
+ $DEV_SERVER_PID = $server.Id
417
+ ```
418
+
419
+ Wait for server to be ready: poll `http://localhost:$DEV_PORT` until it returns 200 or 302 (max 30 seconds, 2s interval):
420
+ ```powershell
421
+ $ready = $false
422
+ for ($i = 0; $i -lt 15; $i++) {
423
+ try {
424
+ $response = Invoke-WebRequest -Uri "http://localhost:$DEV_PORT" -UseBasicParsing -TimeoutSec 2
425
+ if ($response.StatusCode -in @(200, 302)) { $ready = $true; break }
426
+ } catch {
427
+ Start-Sleep -Seconds 2
428
+ }
429
+ }
430
+ if (-not $ready) { "DEV_SERVER_NOT_READY" }
431
+ ```
432
+ 4. Open the app in playwright-cli: `playwright-cli open "http://localhost:$DEV_PORT"`
433
+ 5. If the page requires authentication, use playwright-cli to register a test user and log in first
434
+
435
+ **Step 2 — Verification**:
436
+
437
+ Use `playwright-cli snapshot` on the running app to discover actual element refs, then verify these goals:
438
+ {{BROWSER_VERIFY_STEPS}}
439
+
440
+ Construct your verification workflow based on:
441
+ 1. The playwright-cli skill documentation (read in Step 0d)
442
+ 2. The `playwright-cli --help` output (captured in Step 0b)
443
+ 3. The current task's Verification Gates and implemented features
444
+
445
+ Decide the concrete playwright-cli actions (click, fill, snapshot, screenshot, etc.) yourself based on the snapshot output and your knowledge of the implemented code. The goals above describe WHAT to verify — you determine HOW using playwright-cli commands.
446
+
447
+ Take a final screenshot for evidence: `playwright-cli screenshot`
448
+
449
+ **Step 3 — Cleanup (REQUIRED — you started it, you stop it)**:
450
+
451
+ 1. Close the playwright-cli browser: `playwright-cli close`
452
+ 2. Stop the dev server process and any remaining process bound to the dev server port:
453
+ ```powershell
454
+ if ($DEV_SERVER_PID) { Stop-Process -Id $DEV_SERVER_PID -Force -ErrorAction SilentlyContinue }
455
+ Get-NetTCPConnection -LocalPort ([int]$DEV_PORT) -ErrorAction SilentlyContinue |
456
+ Select-Object -ExpandProperty OwningProcess -Unique |
457
+ ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }
458
+ ```
459
+
460
+ {{END_IF_BROWSER_TOOL_PLAYWRIGHT}}
461
+ {{IF_BROWSER_TOOL_OPENCLI}}
462
+ **Using: opencli** (reuses Chrome logged-in sessions)
463
+
464
+ **CRITICAL CONSTRAINT — opencli browser ONLY**:
465
+ - You MUST use `opencli browser` for ALL browser interactions in this phase
466
+ - All browser actions go through `opencli browser <command>` in the PowerShell tool
467
+
468
+ **Step 0 — OpenCLI Readiness Check (BLOCKING)**:
469
+
470
+ 0a. Check if `opencli` is installed:
471
+ ```powershell
472
+ $opencli = Get-Command opencli -ErrorAction SilentlyContinue
473
+ if ($opencli) { opencli --version } else { "NOT_INSTALLED" }
474
+ ```
475
+ If `NOT_INSTALLED`: `npm install -g @jackwener/opencli@latest`. If installation fails, log `## Browser Verification: SKIPPED — opencli installation failed` and proceed.
476
+
477
+ 0b. Verify Browser Bridge: `opencli doctor`. If fails, log skip and proceed.
478
+
479
+ 0c. Learn usage:
480
+ ```powershell
481
+ opencli browser --help 2>$null
482
+ if ($LASTEXITCODE -ne 0) { opencli --help }
483
+ ```
484
+
485
+ **Step 1 — Start Dev Server**: use the same port detection and server lifecycle pattern as the playwright-cli path:
486
+ ```powershell
487
+ $DEV_PORT = "{{DEV_PORT}}"
488
+ if ($DEV_PORT -eq "{{DEV_PORT}}" -or [string]::IsNullOrWhiteSpace($DEV_PORT)) {
489
+ $detectedPort = ""
490
+ if (Test-Path -LiteralPath "package.json") {
491
+ $detectedPort = node -e "const p=require('./package.json'); const s=(p.scripts?.dev) || ''; const m=s.match(/-p\s+(\d+)/); console.log(m?m[1]:'')"
492
+ }
493
+ if (-not $detectedPort -and $env:NEXT_PUBLIC_SITE_URL -match ':([0-9]+)') {
494
+ $detectedPort = $Matches[1]
495
+ }
496
+ if ($detectedPort) { $DEV_PORT = $detectedPort } else { $DEV_PORT = "3000" }
497
+ }
498
+ "Detected DEV_PORT=$DEV_PORT"
499
+ ```
500
+ ```powershell
501
+ $portBusy = Get-NetTCPConnection -LocalPort ([int]$DEV_PORT) -ErrorAction SilentlyContinue
502
+ if ($portBusy) { "PORT_IN_USE" } else { "PORT_FREE" }
503
+ $devServerCommand = "<start-command>"
504
+ $server = Start-Process -FilePath "powershell" -ArgumentList @("-NoProfile", "-Command", $devServerCommand) -PassThru
505
+ $DEV_SERVER_PID = $server.Id
506
+ ```
507
+
508
+ Wait for server to be ready: poll `http://localhost:$DEV_PORT` until it returns 200 or 302 (max 30 seconds, 2s interval):
509
+ ```powershell
510
+ $ready = $false
511
+ for ($i = 0; $i -lt 15; $i++) {
512
+ try {
513
+ $response = Invoke-WebRequest -Uri "http://localhost:$DEV_PORT" -UseBasicParsing -TimeoutSec 2
514
+ if ($response.StatusCode -in @(200, 302)) { $ready = $true; break }
515
+ } catch {
516
+ Start-Sleep -Seconds 2
517
+ }
518
+ }
519
+ if (-not $ready) { "DEV_SERVER_NOT_READY" }
520
+ ```
521
+
522
+ Start server, wait for ready, then:
523
+ ```powershell
524
+ opencli browser open "http://localhost:$DEV_PORT"
525
+ if ($LASTEXITCODE -eq 0) { opencli browser state }
526
+ ```
527
+
528
+ **Step 2 — Verification**:
529
+
530
+ Use `opencli browser state` to discover elements with `[N]` indices, then verify:
531
+ {{BROWSER_VERIFY_STEPS}}
532
+
533
+ Chain commands in PowerShell with semicolons and inspect each result, for example: `opencli browser click <N>; opencli browser wait time 1; opencli browser state`
534
+
535
+ **Step 3 — Cleanup**:
536
+ 1. `opencli browser close`
537
+ 2. Stop the dev server process and any remaining process bound to the dev server port:
538
+ ```powershell
539
+ if ($DEV_SERVER_PID) { Stop-Process -Id $DEV_SERVER_PID -Force -ErrorAction SilentlyContinue }
540
+ Get-NetTCPConnection -LocalPort ([int]$DEV_PORT) -ErrorAction SilentlyContinue |
541
+ Select-Object -ExpandProperty OwningProcess -Unique |
542
+ ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }
543
+ ```
544
+
545
+ {{END_IF_BROWSER_TOOL_OPENCLI}}
546
+ {{IF_BROWSER_TOOL_AUTO}}
547
+ **Tool Selection**: Choose the best browser tool at runtime.
548
+
549
+ **Step 0 — Detect available tools**:
550
+ ```powershell
551
+ "=== playwright-cli ==="
552
+ $playwright = Get-Command playwright-cli -ErrorAction SilentlyContinue
553
+ if ($playwright) { playwright-cli --version } else { "NOT_INSTALLED" }
554
+ "=== opencli ==="
555
+ $opencli = Get-Command opencli -ErrorAction SilentlyContinue
556
+ if ($opencli) { opencli --version } else { "NOT_INSTALLED" }
557
+ if ($opencli) {
558
+ opencli doctor 2>$null
559
+ if ($LASTEXITCODE -ne 0) { "OPENCLI_BRIDGE_FAILED" }
560
+ }
561
+ ```
562
+
563
+ **Decision table**:
564
+ | Condition | Tool |
565
+ |-----------|------|
566
+ | Only playwright-cli available | playwright-cli |
567
+ | Only opencli available (doctor passes) | opencli |
568
+ | Both — local dev server, forms, components | playwright-cli |
569
+ | Both — needs real login state (OAuth/SSO) | opencli |
570
+ | Both — third-party integration verification | opencli |
571
+ | Neither available | Install playwright-cli as default |
572
+
573
+ Then follow the corresponding tool's workflow above (Steps 1-3).
574
+
575
+ {{END_IF_BROWSER_TOOL_AUTO}}
576
+
577
+ **Step 4 — Reporting**:
578
+
579
+ Append results to `context-snapshot.md`:
580
+ ```
581
+ ## Browser Verification
582
+ Tool: <playwright-cli or opencli>
583
+ URL: http://localhost:$DEV_PORT
584
+ Dev Server Command: <actual command used>
585
+ Tool version: <version>
586
+ Steps executed: [list of commands used]
587
+ Screenshot: [path]
588
+ Result: PASS / FAIL (reason)
589
+ Server cleanup: confirmed
590
+ Browser cleanup: confirmed
591
+ ```
592
+
593
+ If verification fails, log the failure details but continue to commit. Failures do NOT block the commit, but you MUST attempt verification and MUST clean up the dev server.
594
+ {{END_IF_BROWSER_INTERACTION}}
595
+
596
+ ### Phase 6: Architecture Sync & Commit (SINGLE COMMIT)
597
+
598
+ **6a.** Run `/prizmkit-retrospective` — maintains `.prizmkit/prizm-docs/` (architecture index):
599
+ 1. **Structural sync**: Use `git diff --cached --name-status` to locate changed modules, update KEY_FILES/INTERFACES/DEPENDENCIES/file counts in affected `.prizmkit/prizm-docs/` files
600
+ 2. **Architecture knowledge** (feature sessions only): Extract TRAPS/RULES/DECISIONS from completed work into `.prizmkit/prizm-docs/`
601
+ 3. **L2 coverage check**: For any module/sub-module with source files created or significantly modified in this session but no L2 `.prizm` doc — evaluate whether L2 is warranted and create if so. The current session has the best context for accurate KEY_FILES, TRAPS, and DECISIONS.
602
+ 4. Stage doc changes: `git add .prizmkit/prizm-docs/`
603
+ ⚠️ Do NOT commit here. Only stage.
604
+
605
+ **6b.** Stage all feature code explicitly (NEVER use `git add -A` or `git add .`):
606
+ ```powershell
607
+ git add <specific-files-created-or-modified>
608
+ git add .prizmkit/prizm-docs/
609
+ ```
610
+
611
+ **6c.** Run `/prizmkit-committer` → THE ONLY commit for this feature:
612
+ `feat({{FEATURE_ID}}): {{FEATURE_TITLE}}`
613
+ This single commit includes: feature code + tests + .prizmkit/prizm-docs/ updates. Do NOT push.
614
+ - MANDATORY: commit must be done via `/prizmkit-committer` skill. Do NOT run manual `git add`/`git commit` as a substitute.
615
+ - Do NOT run `update-feature-status.py` here — the pipeline runner handles feature-list.json updates automatically after session exit.
616
+
617
+ **6d.** Final verification:
618
+ ```powershell
619
+ git status --short
620
+ ```
621
+ Working tree MUST be clean after this step. If any feature-related files remain, stage them into the SAME commit via `git add <file>; if ($LASTEXITCODE -eq 0) { git commit --amend --no-edit }`, do NOT create a separate commit.
622
+
623
+ **Exception**: `session-summary.md` in the artifact directory is a local cross-session artifact generated by `/prizmkit-committer` — it is NOT committed to git. Ignore it in the clean-tree check.
624
+
625
+ **6e.** Write completion summary for downstream dependency context:
626
+
627
+ Write `.prizmkit/specs/{{FEATURE_SLUG}}/completion-summary.json` with the key changes from this session. This file is NOT committed to git — the pipeline runner reads it to propagate context to dependent features.
628
+
629
+ ```json
630
+ {
631
+ "completion_notes": [
632
+ "<each item: one key change, API, model, or integration point that downstream features may need>",
633
+ "Example: Added User model (id, email, password_hash, display_name) in prisma/schema.prisma",
634
+ "Example: POST /api/auth/register and POST /api/auth/login endpoints in src/api/auth.ts",
635
+ "Example: Auth middleware in src/middleware/auth.ts — validates JWT on protected routes"
636
+ ]
637
+ }
638
+ ```
639
+
640
+ Rules for writing completion notes:
641
+ - Focus on **what downstream features need to know**: new APIs, models, exported functions, key file paths
642
+ - Each note should be self-contained and concise (one line, under 120 characters preferred)
643
+ - Include 3-8 notes covering the most important changes
644
+ - Do NOT include test files, config changes, or internal implementation details unless they affect other features
645
+ - If this feature has no downstream dependents, still write the summary (it serves as documentation)
646
+
647
+ ## Critical Paths
648
+
649
+ | Resource | Path |
650
+ |----------|------|
651
+ | Feature Artifacts Dir | `.prizmkit/specs/{{FEATURE_SLUG}}/` |
652
+ | Context Snapshot | `.prizmkit/specs/{{FEATURE_SLUG}}/context-snapshot.md` |
653
+ | Dev Agent Def | {{DEV_SUBAGENT_PATH}} |
654
+ | Reviewer Agent Def | {{REVIEWER_SUBAGENT_PATH}} |
655
+ {{IF_CRITIC_ENABLED}}
656
+ | Critic Agent Def | {{CRITIC_SUBAGENT_PATH}} |
657
+ {{END_IF_CRITIC_ENABLED}}
658
+ | Project Root | {{PROJECT_ROOT}} |
659
+
660
+ ## Failure Capture Protocol
661
+
662
+ If you encounter an unrecoverable error, context overflow, or are about to exit without completing all phases:
663
+
664
+ 1. Write `.prizmkit/specs/{{FEATURE_SLUG}}/failure-log.md` BEFORE exiting:
665
+ ```
666
+ FAILURE_TYPE: timeout | test_failure | review_rejected | context_overflow | unknown
667
+ PHASE: <Get-Command phase failed>
668
+ ROOT_CAUSE: <1-2 sentence explanation>
669
+ ATTEMPTED: <approaches already tried>
670
+ SUGGESTION: <what the next session should try differently>
671
+ DISCOVERED_TRAPS:
672
+ - [CRITICAL|HIGH|LOW] <gotcha discovered during this failed session> | FIX: <approach>
673
+ ```
674
+
675
+ 2. This file is intentionally lightweight — write it BEFORE context runs out.
676
+
677
+ **Lifecycle**: failure-log.md is a temporary cross-session artifact. Do NOT commit it to git. After a successful session (all phases complete + commit done), delete it:
678
+ ```powershell
679
+ Remove-Item -Force -ErrorAction SilentlyContinue .prizmkit/specs/{{FEATURE_SLUG}}/failure-log.md
680
+ ```
681
+
682
+ ## Reminders
683
+
684
+ - Tier 2: orchestrator builds context+plan, Analyzer checks consistency, Dev implements, Reviewer reviews+tests — use direct Agent spawn for agents
685
+ - Build context-snapshot.md FIRST; all subagents read it instead of re-reading source files
686
+ - context-snapshot.md is append-only: orchestrator writes Sections 1-4, Dev appends Implementation Log, Reviewer appends Review Notes
687
+ - Gate checks enforce Implementation Log and Review Notes are written before proceeding
688
+ - Do NOT use `run_in_background=true` when spawning subagents
689
+ - `/prizmkit-committer` is mandatory, and must not be replaced with manual git commit commands
690
+ - Do NOT run `git add`/`git commit` during Phase 1-5 — all changes are committed once in Phase 6
691
+ - If any files remain after the commit, amend the existing commit — do NOT create a follow-up commit
692
+ - When staging files, always use explicit file names — NEVER use `git add -A` or `git add .`
693
+ - On timeout: check snapshot + git diff HEAD → model:lite → remaining steps only → max 2 retries per phase → orchestrator fallback