@codename_inc/spectre 4.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: plan_review
3
- description: 👻 | Find simplifications in a plan or tasks
3
+ description: 👻 | Independent multi-lens review of plan.md + tasks.md — finds overengineering, missing verification, hallucinated deps, weak references
4
4
  user-invocable: true
5
5
  ---
6
6
 
@@ -10,33 +10,174 @@ user-invocable: true
10
10
 
11
11
  Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded `$ARGUMENTS` value.
12
12
 
13
+ # plan_review: Multi-Lens Review of Plan & Tasks
13
14
 
14
- You are a senior staff engineer with deep expertise in system design, architecture, and pragmatic problem-solving. Your specialty is finding the simplest path to meet all requirements.
15
+ ## Description
15
16
 
16
- Review the following [plan/document/tasks/context] and identify opportunities to simplify while ensuring all requirements and functionality are delivered.
17
+ - **What** Independent review of `plan.md` + `tasks.md` from four specialized lenses, dispatched in parallel
18
+ - **Outcome** — Structured findings with concrete edit suggestions; optional write-back to update both artifacts
19
+ - **Role** — Senior staff engineer + reviewer panel; bias toward pragmatic problem-solving, YAGNI enforcement, and verifiability
17
20
 
18
- For each simplification opportunity, provide:
19
- 1. **What to simplify** - Specific component, process, or decision
20
- 2. **Why** - What complexity it removes (cognitive load, dependencies, maintenance burden, etc.)
21
- 3. **Impact** - Confirm that all original requirements remain satisfied
22
- 4. **Risk** - Any trade-offs or risks introduced by the simplification
21
+ ## ARGUMENTS Input
23
22
 
24
- Focus on:
25
- - Removing unnecessary abstractions or indirection
26
- - Consolidating duplicated logic or patterns
27
- - Questioning assumptions that add complexity
28
- - Identifying over-engineering
29
- - Suggesting proven, boring solutions over novel approaches
23
+ <ARGUMENTS>
24
+ $ARGUMENTS
25
+ </ARGUMENTS>
30
26
 
31
- ## Testing Review
32
- **Context**: We use fast TDD with 1 happy path test + 1 unhappy path test per feature. A separate task handles achieving 100% test coverage post-feature work.
27
+ ## Why Four Lenses
33
28
 
34
- Evaluate the testing approach and flag:
35
- - **Over-testing**: Tests beyond 1 happy + 1 unhappy path that should be deferred to the coverage task
36
- - **Wrong tests**: Testing implementation details instead of behavior, brittle tests that will break on refactors, or tests that don't actually validate requirements
37
- - **Missing critical paths**: Cases where the 1+1 approach genuinely misses a requirement-breaking scenario (rare, but call it out)
38
- - **Test complexity**: Overly elaborate test setup, mocking, or assertions that could be simpler
29
+ A single reviewer biases toward the issues it notices first. Published practice (Cognition, Anthropic, Osmani) converges on four high-yield review angles for AI-agent-authored plans. We dispatch each as a parallel subagent so coverage is structurally guaranteed, not dependent on a single reviewer remembering everything.
39
30
 
40
- Remember: The goal is fast feedback during development. More comprehensive testing comes later.
31
+ | Lens | Subagent | Finds |
32
+ |------|----------|-------|
33
+ | **YAGNI / familiar-shape bias** | `@reviewer` | Mature-system patterns that crept in unprompted (auth → rate-limit, CRUD → soft-delete, etc.). Forces ONE "delete this" recommendation. |
34
+ | **Verifiability** | `@analyst` | Acceptance criteria that aren't executable; verification gaps between plan and tasks. |
35
+ | **Existence / hallucination** | `@finder` | File paths, packages, APIs, or symbols referenced that don't actually exist. The slopsquatting fence. |
36
+ | **Canonical reference quality** | `@patterns` | "Follow existing pattern" claims without a real file:line anchor; missed reuse opportunities. |
41
37
 
42
- End with a prioritized list of recommendations (high/medium/low impact).
38
+ ## Step 1 Locate Artifacts
39
+
40
+ - **Action** — DetermineTaskDir:
41
+ - `branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)`
42
+ - **If** user specifies path in ARGUMENTS → `TASK_DIR={that value}`
43
+ - **Else** → `TASK_DIR=docs/tasks/{branch_name}`
44
+
45
+ - **Action** — ResolveArtifacts: Locate the three required inputs.
46
+ - `PLAN=${TASK_DIR}/specs/plan.md` (or scoped name)
47
+ - `TASKS=${TASK_DIR}/specs/tasks.md` (or scoped name)
48
+ - `CONTEXT=${TASK_DIR}/task_context.md`
49
+ - If any are missing, list what's missing and stop — do NOT review against a partial set. Suggest the user run `/spectre:plan` or `/spectre:create_tasks` first.
50
+
51
+ - **Action** — ReadAll: Read each file completely into context before dispatching reviewers. Reviewers receive curated excerpts, not raw paths.
52
+
53
+ ## Step 2 — Dispatch Four Parallel Reviewers
54
+
55
+ Spawn all four subagents in a single message (parallel). Each receives the same artifact excerpts but a different review brief.
56
+
57
+ ### Lens 1 — YAGNI / Familiar-Shape Bias (`@reviewer`)
58
+
59
+ > Review this plan and task list for unrequested complexity. Agents have a documented "familiar-shape bias": shown a feature, they reproduce the mature-system shape from their training data (auth → adds rate-limiting; CRUD → adds soft-delete; form → adds optimistic UI; service → adds telemetry; module → adds feature flags). Your job is to find that bias here.
60
+ >
61
+ > Find:
62
+ > 1. Anything in `plan.md` Technical Approach that isn't traceable to a requirement in `task_context.md` / scope / PRD.
63
+ > 2. Tasks in `tasks.md` that implement something the requirements don't ask for.
64
+ > 3. Abstractions, interfaces, or layers introduced for a single concrete caller.
65
+ > 4. Generality (config files, plugin points, factories) where the actual need is one specific behavior.
66
+ > 5. Overlap with the `Out-of-Bounds — DO NOT add` list (if anything violates that list, it's a hard fail).
67
+ >
68
+ > Required output: nominate the SINGLE highest-leverage thing to delete and justify it. You must pick one. Then list other simplifications ranked by impact. For each finding, cite the exact file:line or section header it lives in.
69
+
70
+ ### Lens 2 — Verifiability (`@analyst`)
71
+
72
+ > Review this plan and task list for verification quality. The single highest-correlate of successful AI-agent execution is the ability to self-verify. Find every place where verification is missing, prose-only, or disconnected.
73
+ >
74
+ > Find:
75
+ > 1. Items in `plan.md` "Verification — How We Know This Works" that are prose ("works correctly", "is consistent") rather than executable (test name / observable behavior / state condition).
76
+ > 2. Phases in `plan.md` that don't declare a verification signal.
77
+ > 3. Sub-tasks in `tasks.md` whose acceptance criteria aren't one of the three executable types (test passes / observable behavior / state condition).
78
+ > 4. Verification signals in `plan.md` with no matching acceptance criterion in `tasks.md`.
79
+ > 5. Behavior-changing sub-tasks in `tasks.md` that lack a preceding RED test sub-task.
80
+ >
81
+ > Required output: list every non-executable criterion with a proposed rewrite in one of the three types. Cite file:line for each.
82
+
83
+ ### Lens 3 — Existence / Hallucination (`@finder`)
84
+
85
+ > Review this plan and task list for references to things that may not exist. AI-generated plans hallucinate file paths, package names, function signatures, and API endpoints at measurable rates (~20% for packages per Snyk analysis). Your job is to verify every reference is real.
86
+ >
87
+ > Verify:
88
+ > 1. Every file path mentioned in `plan.md` "Critical Files for Implementation" and in `tasks.md` Context blocks — does the file exist in the repo today? Use Glob/Read to confirm.
89
+ > 2. Every package in `plan.md` "External Dependencies" — does it exist at the named version? (Note: actual install/registry check is the executor's Phase 0 job; your job is to flag suspicious names — typos, near-misses to well-known packages, lookalikes.)
90
+ > 3. Every function, class, or symbol named in plan/tasks — grep the repo, confirm it exists where claimed.
91
+ > 4. Every API endpoint, env var, or CLI flag referenced — confirm it's defined in the codebase.
92
+ >
93
+ > Required output: list every reference that fails verification, with `expected: <plan claim>` and `actual: <repo state>`. If everything checks out, say so explicitly — don't pad.
94
+
95
+ ### Lens 4 — Canonical Reference Quality (`@patterns`)
96
+
97
+ > Review this plan and task list for the quality of "follow existing pattern" references. Anthropic's own guidance is to anchor plans with concrete examples (e.g., "HotDogWidget.php is a good example"). Vague "follow existing patterns" without a file:line anchor is a documented failure mode.
98
+ >
99
+ > Find:
100
+ > 1. Places in `plan.md` Technical Approach that reference "existing patterns" or "similar features" without a specific file:line.
101
+ > 2. Sub-tasks in `tasks.md` whose Context block lacks a canonical reference pointer.
102
+ > 3. Better canonical references that the plan missed — actual files in the codebase that more closely match the intended shape.
103
+ > 4. Reuse opportunities the plan ignored: utilities, hooks, helpers, or types already in the repo that the plan re-implements.
104
+ >
105
+ > Required output: for each weak/missing reference, propose a specific file:line that should be the anchor. For each missed reuse, cite the existing utility and which task should use it.
106
+
107
+ ## Step 3 — Synthesize Findings
108
+
109
+ - **Action** — CollectFindings: Wait for all four reviewers to return. Read every finding.
110
+
111
+ - **Action** — DeduplicateAndPrioritize: Merge findings that overlap (e.g., a missing canonical reference may surface from both Lens 4 and Lens 2). Assign severity:
112
+ - **Blocker** — would cause execution to fail or produce wrong output (hallucinated file path, criterion the executor can't check, Out-of-Bounds violation)
113
+ - **High** — meaningfully reduces output quality (missing RED test, weak canonical reference, prose criterion)
114
+ - **Medium** — overengineering or reuse miss without functional blast radius
115
+ - **Low** — stylistic or nice-to-have
116
+
117
+ - **Action** — RenderFindingsTable: Output a single structured table. Schema is fixed.
118
+
119
+ ```markdown
120
+ ## Review Findings — {feature name}
121
+
122
+ ### Must-Delete (Lens 1 — YAGNI)
123
+ > {The single nominated highest-leverage cut, with rationale.}
124
+
125
+ ### Findings
126
+
127
+ | # | Severity | Lens | Location | Finding | Suggested Edit |
128
+ |---|----------|------|----------|---------|----------------|
129
+ | 1 | Blocker | Existence | plan.md `## External Dependencies` | `react-use-undocumented@2.4.0` doesn't exist on npm | Remove; the plan can use `useReducer` from React stdlib (see `src/hooks/useFormState.ts:18`) |
130
+ | 2 | High | Verifiability | tasks.md `1.2.1` | "Component renders correctly" is prose | Replace with: Test passes `<ProductCard /> renders product.title and product.price` |
131
+ | 3 | High | YAGNI | plan.md `## Technical Approach` | Adds retry-with-backoff for a sync internal call | Delete; not in requirements; Out-of-Bounds list already forbids retry logic |
132
+ | … | | | | | |
133
+
134
+ ### Summary
135
+ - Blockers: {N} — must resolve before /execute
136
+ - High: {N}
137
+ - Medium: {N}
138
+ - Low: {N}
139
+ ```
140
+
141
+ ## Step 4 — Surface Findings & Apply Edits
142
+
143
+ - **Action** — PresentFindings: Render the findings table inline.
144
+
145
+ - **Action** — OfferWriteBack: After the table, prompt:
146
+
147
+ > Reply with which findings to apply:
148
+ > - `all` — apply every suggested edit
149
+ > - `blockers` — apply Blocker + High severity only
150
+ > - `1,3,5` — apply specific finding numbers
151
+ > - `skip` — leave artifacts unchanged
152
+ >
153
+ > For findings I apply, I'll edit plan.md and/or tasks.md inline and re-run a fast self-check.
154
+
155
+ - **Wait** — User selects.
156
+
157
+ - **Action** — ApplyEdits: For each selected finding:
158
+ - Open the named artifact (plan.md or tasks.md)
159
+ - Apply the Suggested Edit verbatim where possible; if the edit needs adaptation, make the minimum change consistent with the finding's intent
160
+ - Track which findings were applied
161
+
162
+ - **Action** — SelfCheck: After edits, run a fast pass over the modified sections:
163
+ - Re-verify any file:line refs touched
164
+ - Re-verify acceptance criteria are still executable
165
+ - Confirm no edit introduced a new Out-of-Bounds violation
166
+ - If any check fails, surface it and ask the user before continuing
167
+
168
+ - **Action** — ReportApplied:
169
+
170
+ > Applied: {list of finding numbers}. Skipped: {list}.
171
+ > {Path to updated plan.md and tasks.md}.
172
+
173
+ ## Step 5 — Next Steps
174
+
175
+ - **Action** — RenderFooter: Use `@skill-spectre:spectre-guide` skill for Next Steps footer.
176
+
177
+ ---
178
+
179
+ ## Notes
180
+
181
+ - This skill does NOT generate plans or tasks. It reviews them. If `plan.md` or `tasks.md` doesn't exist, route the user to `/spectre:plan` first.
182
+ - The four lenses are intentionally non-overlapping by design but will surface overlap in practice — dedupe at synthesis, don't ask reviewers to coordinate.
183
+ - The "Must-Delete" nomination from Lens 1 is mandatory output — even on a tight plan, naming the single weakest element is a forcing function against under-review.
@@ -0,0 +1,314 @@
1
+ ---
2
+ name: prototype
3
+ description: 👻 | Generate a self-contained HTML prototype to validate a feature visually before planning - primary agent
4
+ user-invocable: true
5
+ ---
6
+
7
+ # prototype
8
+
9
+ ## Input Handling
10
+
11
+ Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded `$ARGUMENTS` value.
12
+
13
+ # prototype: Make the Feature Visible Before You Plan It
14
+
15
+ Produce a self-contained, clickable HTML artifact that makes a feature visible — resolving ambiguity before scope, validating flows before plan, or anchoring stakeholder review. Output: single portable HTML file the user can open locally or host anywhere, saved to `{OUT_DIR}/prototypes/{name}_{MMDDYY}.html`.
16
+
17
+ ## ARGUMENTS
18
+
19
+ <ARGUMENTS> $ARGUMENTS </ARGUMENTS>
20
+
21
+ ## Invocation Modes
22
+
23
+ Detect mode from environment markers, ARGUMENTS, and existing docs. **Order matters** — check from most context to least:
24
+
25
+ - **Complete ux.md exists** (post-ux) — full Stage 2 spec is on disk. The prototype's job is to **render the spec**, not synthesize it. Default fidelity: **high-fi**. Skip all intake except visual anchor. Treat ux.md as authoritative — don't invent screens, don't contradict documented states or copy. On completion, recommend `/spectre:plan` or `/spectre:create_tasks`.
26
+ - **`FROM_UX=true`** — invoked mid-flow from `ux` Stage 1 → Stage 2 gate. Only approved flows exist (no detailed spec yet). Skip flow-discovery intake. Default fidelity: **mid-fi**. On completion, point user back to `ux` Stage 2.
27
+ - **`--explore` flag in ARGUMENTS** — pre-scope discovery. Concept is unvalidated. Default fidelity: **low-fi**. On completion, recommend `/spectre:scope` as next step.
28
+ - **scope.md exists for this branch** (no ux.md) — post-scope validation. Default fidelity: **mid-fi**. On completion, recommend `/spectre:ux` or `/spectre:plan` based on feature complexity.
29
+ - **Standalone, no context** — ask the user what they're prototyping. Default fidelity: **mid-fi**.
30
+
31
+ ---
32
+
33
+ # STAGE 1: Intake & Fidelity Alignment
34
+
35
+ **Goal**: Confirm what we're prototyping, at what fidelity, and what visual anchor to use. Keep this tight — 2 to 4 questions, never a form.
36
+
37
+ ## Step 1 — Immediate Reply & Detect Context
38
+
39
+ - **Action** — ImmediateReply: Respond before any tools.
40
+ - **If** `FROM_UX=true` → acknowledge ux context, read approved flows from `{OUT_DIR}/ux.md`, **SKIP to Step 3**
41
+ - **Else If** ARGUMENTS empty → probe: "What are we prototyping? A quick description is enough — I'll figure out the fidelity from context."
42
+ - **Else** → proceed to Step 2
43
+ - **CRITICAL**: No tool calls in this step except reading ux output when `FROM_UX=true`.
44
+
45
+ ## Step 2 — Read Available Context & Classify ux.md
46
+
47
+ - **Action** — DetectExistingDocs: Check for relevant inputs before asking the user anything.
48
+ - `branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)`
49
+ - Look for: `docs/tasks/{branch_name}/concepts/scope.md`, `docs/tasks/{branch_name}/specs/prd.md`, `docs/tasks/{branch_name}/ux.md`
50
+ - Read whichever exist FULLY (no offset/limit)
51
+
52
+ - **Action** — ClassifyUxDoc: If `ux.md` exists, classify its completeness — this drives fidelity AND how much intake to skip.
53
+ - **Complete** — contains all of: Screens, Layouts, Components, Interactions, States, Content sections (the Stage 2 deliverables from `/spectre:ux`). Treat as authoritative. Skip flow-discovery questions. Set mode = **post-ux**.
54
+ - **Flows-only** — contains user flows / journeys but missing Stage 2 sections. Treat flows as approved input but expect to make UI decisions. Set mode = **flows-only ux**.
55
+ - **Absent** — fall back to scope.md / prd.md / standalone modes.
56
+
57
+ ## Step 3 — Recommend Fidelity, Confirm Anchor
58
+
59
+ Pick fidelity from signals available:
60
+
61
+ | Signal present | Recommends |
62
+ |---|---|
63
+ | `--explore` flag, or no scope/prd | **Low-fi** — grayscale, layout-only, no typography polish |
64
+ | scope.md exists, no design system anchor | **Mid-fi** — real colors, basic type, simplified components (default) |
65
+ | scope.md + flows-only ux.md, or brand/design system anchor | **Mid-fi to High-fi** — depends on anchor strength |
66
+ | **Complete ux.md** (post-ux) | **High-fi** — full design tokens, realistic data, micro-interactions; render the spec faithfully |
67
+
68
+ ### Intake by mode
69
+
70
+ **Post-ux mode** (complete ux.md) — present a tight confirmation, ask one question:
71
+
72
+ > **Prototype plan** — rendering complete UX spec
73
+ >
74
+ > Source: `{path to ux.md}` ({N} screens, {M} components, {K} states specified)
75
+ > Fidelity: **high-fi** (default — full spec is on disk; I'll render it faithfully, not invent)
76
+ >
77
+ > One thing I need: **visual anchor** — brand colors, font stack, an existing app/URL to match, or a named aesthetic (e.g. "Linear-style", "Notion-quiet", "Stripe-clean"). If the spec already specifies design tokens, reply "use the spec." If you skip this, I'll commit to a deliberate named aesthetic and call it out at the top of the file.
78
+
79
+ **All other modes** — present recommendation + request anchor + confirm framing:
80
+
81
+ > **Prototype plan**
82
+ >
83
+ > I'm reading this as: **{inferred feature/flow}**
84
+ > Recommended fidelity: **{low-fi | mid-fi | high-fi}** — {one-line reason}
85
+ > Primary flow: **{name}** (from {scope.md | ux.md flows | your description})
86
+ >
87
+ > Two things I need from you:
88
+ > 1. **Override fidelity?** Or "looks good."
89
+ > 2. **Visual anchor** — brand colors, font stack, an existing app/URL to match, or a named aesthetic (e.g. "Linear-style", "Notion-quiet", "Stripe-clean"). If you skip this, I'll commit to a deliberate named aesthetic and call it out at the top of the file so you can redirect.
90
+
91
+ **Wait for response.** If user pushes back on fidelity or feature framing, adjust and re-confirm.
92
+
93
+ ---
94
+
95
+ # STAGE 2: Parallel Research & Generation
96
+
97
+ **Gate**: Only proceed after Stage 1 confirmation (or `FROM_UX=true`).
98
+
99
+ ## Step 4 — Dispatch Parallel Subagents
100
+
101
+ Spawn three subagents in parallel. Each has a focused job.
102
+
103
+ ### `@spectre:web-research` — Visual Reference Discovery
104
+
105
+ Prompt template:
106
+
107
+ > Research visual design patterns and UI conventions for **{feature type}**. Specifically:
108
+ >
109
+ > 1. Find 2–3 living examples or screenshots of similar UI patterns in well-regarded products. Return URLs and visual descriptions.
110
+ > 2. Identify the established UX convention for this interaction type (wizard, dashboard, list+detail, modal flow, etc.) and any recent (2025–2026) refinements.
111
+ > 3. If the user specified an aesthetic anchor ({anchor_text}), find representative color palettes (hex), typography choices (font families with fallbacks), and one or two distinctive design moves that define the aesthetic.
112
+ > 4. Return concrete decisions — colors, fonts, layout patterns — not general advice.
113
+ >
114
+ > Length: under 400 words. Cite sources.
115
+
116
+ **Why**: Grounds generation in specific references. Without this step the model defaults to its own distribution (Inter + purple gradients). This is the anti-slop forcing function.
117
+
118
+ ### `@spectre:analyst` — Flow & Content Extraction
119
+
120
+ Use one of two prompt templates based on mode detected in Step 2.
121
+
122
+ **Extraction mode** — post-ux (complete ux.md present):
123
+
124
+ > Read **{path to ux.md}** fully. The Stage 2 spec is authoritative — your job is to **extract** structured data for HTML rendering, NOT to synthesize new screens, states, or content.
125
+ >
126
+ > Return a render brief organized by ux.md section:
127
+ >
128
+ > 1. **Screens** — verbatim from the Screens section: name, purpose, navigation relationships
129
+ > 2. **Layouts** — verbatim from Layouts: per-screen header/main/footer + responsive breakpoints
130
+ > 3. **Components** — verbatim from Components: each element's purpose, location, all documented states (default, hover, active, disabled, loading, error)
131
+ > 4. **Interactions** — verbatim from the Interactions table: Element | Action | Result
132
+ > 5. **States** — verbatim from the States table: State | Trigger | Appearance | Available Actions
133
+ > 6. **Content** — verbatim copy from the Content section: page titles, button labels, empty-state messages, error messages, confirmation dialogs. Use this copy EXACTLY in the prototype — do not paraphrase.
134
+ > 7. **Edge cases & a11y** — note any documented constraints (limits, null/long data, keyboard actions, focus management) the prototype should reflect
135
+ >
136
+ > If the spec specifies a state or content value, the prototype must match it. If the spec is silent on a detail, flag it as a "filled assumption" so it appears in the prototype's metadata header. Never invent screens that aren't in the spec.
137
+
138
+ **Synthesis mode** — flows-only ux, scope-only, or standalone:
139
+
140
+ > Read these documents fully: **{list of paths — scope.md, prd.md, ux.md flows section if present}**. Extract a content skeleton for an HTML prototype:
141
+ >
142
+ > 1. **Primary flow** — entry → action → outcome, with decision points
143
+ > 2. **Required UI states per screen** — every screen needs at minimum: happy path, empty state, error or edge state. Some screens also need: loading, success
144
+ > 3. **Stated constraints** — any layout, behavior, or content constraints from the docs
145
+ > 4. **Realistic content** — actual product names, plausible numbers, real-looking copy. NO Lorem ipsum. NO "Card Title." If domain-specific data is unclear, invent plausible values that match the feature's domain.
146
+ > 5. **Component inventory** — every recurring UI element that will need a named CSS class (button, card, input, badge, etc.)
147
+ >
148
+ > Return a structured flow brief: screen list, per-screen state list, realistic content for each, component inventory.
149
+
150
+ **Why**: This is the content skeleton. In post-ux mode, the spec already did this work — re-synthesizing risks contradicting documented decisions. In all other modes, skipping synthesis produces prototypes with Lorem ipsum and inconsistent component styling.
151
+
152
+ ### `@spectre:patterns` — Existing Codebase Anchor (only if applicable)
153
+
154
+ Skip this agent if there is no existing app to anchor to. Otherwise:
155
+
156
+ > Find existing UI patterns in this codebase that the prototype should match or extend: design tokens (colors, spacing, type), component conventions (button styles, card layouts), and any established interaction patterns. Return file references with the actual values (hex codes, class names, etc.) — not just paths.
157
+
158
+ **Why**: When prototyping inside an existing app, the prototype should look like a plausible new screen of that app, not a designer's blank canvas.
159
+
160
+ ## Step 5 — Generate the HTML Artifact
161
+
162
+ Wait for ALL subagents to complete. Synthesize their outputs, then generate a single self-contained HTML file. Use `@spectre:dev` to produce the file (or inline if the synthesis is straightforward).
163
+
164
+ ### Hard constraints on the generated HTML
165
+
166
+ **File structure** (every prototype includes these in order):
167
+
168
+ 1. **`<!DOCTYPE html>` + minimal `<head>`** with `<meta viewport>` and an inline `<style>` block
169
+ 2. **Metadata comment block** at the very top of `<head>`:
170
+ ```html
171
+ <!--
172
+ SPECTRE PROTOTYPE
173
+ Feature: {feature name}
174
+ Fidelity: {low-fi | mid-fi | high-fi}
175
+ Generated: {YYYY-MM-DD}
176
+ Branch: {branch_name}
177
+ Flow covered: {primary flow}
178
+ Screens/states: {comma-separated list}
179
+ Visual anchor: {named aesthetic or reference URL}
180
+ Source spec: {path to ux.md if post-ux mode, else "none — synthesized from {scope.md | description}"}
181
+ Key assumptions: {bullet list of design decisions and content assumptions}
182
+ Filled assumptions: {only in post-ux mode — items the spec was silent on that the prototype filled in; review these against the spec}
183
+ NOT included: {explicit list of what was deliberately left out}
184
+ Next step: /spectre:plan OR resume /spectre:ux Stage 2
185
+ -->
186
+ ```
187
+ 3. **Design tokens comment block** in `<head>`:
188
+ ```html
189
+ <!-- DESIGN TOKENS
190
+ Primary: #{hex}
191
+ Accent: #{hex}
192
+ Surface: #{hex}
193
+ Text: #{hex}
194
+ Font: {family}, served from {CDN or system}
195
+ Border-radius: {value}
196
+ Spacing unit: {value}
197
+ -->
198
+ ```
199
+ Also encode these as CSS custom properties on `:root` so they're reusable in the stylesheet.
200
+ 4. **Navigation bar** (only if multi-screen) — vanilla JS section toggling via `display:block/none`. No routing, no framework.
201
+ 5. **One `<section>` per screen.** Every screen must include the happy path AND at least one of: empty state, error state, loading state. Skipping these is the most common prototype failure mode.
202
+ 6. **Inline `<script>`** at end of body for interactions (tab switching, form submit interception, modal toggle, accordion). Vanilla JS only.
203
+
204
+ **Size budget**: under 300KB. No base64 photos. No Chart.js or other large libraries. Use inline SVG and CSS-drawn shapes for any illustrations. Tailwind via CDN is acceptable for mid/high-fi; skip for low-fi.
205
+
206
+ **Asset rules** (keep the file portable so users can open locally, email it, host on a gist, or push to any static host):
207
+ - No `<img src="https://...">` that can 404 — use inline SVG, data URIs, or CSS shapes
208
+ - No local relative paths (`./image.png`, `../style.css`) — they break the moment the file moves
209
+ - Fonts: Google Fonts CDN (single family, two weights max) or system fonts. No custom WOFF files.
210
+
211
+ ### Negative constraints (embed these explicitly in the @spectre:dev prompt)
212
+
213
+ When delegating to `@spectre:dev`, the prompt MUST include these as forbidden patterns:
214
+
215
+ - **No generic AI aesthetic.** Do not use Inter or Roboto by default. Do not use purple gradients on white. Commit to a named, deliberate aesthetic and call it out in the metadata.
216
+ - **No Lorem ipsum or placeholder filler.** All text must be realistic for the domain. "Card Title", "User Name", "Description goes here" are forbidden.
217
+ - **No happy-path-only screens.** Every screen must show at least one non-happy state (empty, error, or edge).
218
+ - **No broken interactivity.** Every `onclick`, `<form>`, or interactive element must respond visually. No `href="#"` that causes page jumps. No event handlers that throw console errors.
219
+ - **No external image dependencies that can break.** Inline SVG only.
220
+ - **No inconsistent component instances.** Define every recurring component as a named CSS class ONCE and reuse it. Do not re-style inline. If a card appears five times, it uses the same class five times.
221
+ - **No page-thinking when flow-thinking is required.** Screens appear in the order a user encounters them, not in the order they're easy to build.
222
+ - **No file-size bloat.** No base64 photos. No Chart.js, D3, or other heavyweight libraries. SVG and CSS only.
223
+
224
+ ### Output location
225
+
226
+ - **Action** — DetermineOutputDir:
227
+ - `branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)`
228
+ - **If** `FROM_UX=true` or `FROM_KICKOFF=true` → use the existing task directory
229
+ - **Else If** user specifies path → use that
230
+ - **Else** → `OUT_DIR=docs/tasks/{branch_name}`
231
+ - `mkdir -p "$OUT_DIR/prototypes"`
232
+
233
+ - **Action** — SaveArtifact: Write file to `{OUT_DIR}/prototypes/{feature_slug}_{MMDDYY}.html`
234
+
235
+ ## Step 6 — Self-Check Portability
236
+
237
+ Before reporting completion, sanity-check the artifact against the portability rules:
238
+
239
+ - File size under 300KB
240
+ - No `<img src="http...">` external images
241
+ - No local relative paths (`./`, `../`, `/local/`)
242
+ - All recurring components share a named CSS class (no inline-styled duplicates)
243
+ - Every screen includes at least one non-happy state
244
+
245
+ Surface any violations as caveats in the handoff. Don't silently ship a broken portable file.
246
+
247
+ ## Step 7 — Present & Handoff
248
+
249
+ - **Action** — PresentForReview:
250
+
251
+ > **Prototype complete**: `{path}` ({size} KB, {N} screens, {fidelity})
252
+ >
253
+ > **Visual anchor**: {named aesthetic}
254
+ > **Key assumptions made** (also embedded in file header):
255
+ > - {bullet 1}
256
+ > - {bullet 2}
257
+ > - {bullet 3}
258
+ > **NOT included**: {explicit list}
259
+ >
260
+ > Open the file in a browser to review (`open {path}` on macOS, or drag into any browser tab). The file is fully self-contained — share it however you like (email, gist, static host, etc.). Reply with feedback to iterate, or pick a next step below.
261
+
262
+ - **Action** — SurfaceFilledAssumptions (post-ux mode only): If `mode = post-ux` AND any filled assumptions exist (items the spec was silent on that the prototype filled in), append a closing-the-loop block:
263
+
264
+ > **Filled assumptions** — ux.md was silent on these; I made calls to render the spec. Review and tell me which to promote into the spec:
265
+ >
266
+ > 1. {assumption} → I chose **{decision}** ({why, one line})
267
+ > 2. {assumption} → I chose **{decision}** ({why, one line})
268
+ > 3. {assumption} → I chose **{decision}** ({why, one line})
269
+ >
270
+ > Reply with numbers to update ux.md (e.g. `1, 3`), `all` to add all, or `skip` to leave the spec as-is.
271
+
272
+ If user picks updates:
273
+ - Edit `ux.md` directly: place each chosen item in the appropriate section (Components / States / Content / Edge Cases / Interactions).
274
+ - Re-run the Step 6 portability check (no regen needed unless user also requested HTML changes).
275
+ - Re-present with a one-line diff per added item: `ux.md ← added: {item} (in {section})`.
276
+
277
+ - **Action** — RenderFooter: Render Next Steps using `@skill-spectre:spectre-guide` skill, with mode-specific recommendation:
278
+ - **If `FROM_UX=true`** → recommend: "Resume `/spectre:ux` Stage 2 with this prototype as input"
279
+ - **If `--explore`** → recommend: `/spectre:scope` with the prototype as anchor
280
+ - **If post-scope** → recommend: `/spectre:ux` (if flows still need detail) or `/spectre:plan` (if ready to build)
281
+ - **Else** → standard Next Steps options
282
+
283
+ ---
284
+
285
+ ## Iteration Loop
286
+
287
+ If the user replies with feedback after Step 7:
288
+ - Small visual tweaks (color, copy, layout) → edit the HTML directly
289
+ - Structural changes (add screen, change flow) → re-run Step 4 subagents with the deltas and regenerate
290
+ - **Spec contradicts prototype** (post-ux mode) → ask which is authoritative for each contradiction, then update ux.md AND the HTML together so they stay paired; re-run Step 6 portability check
291
+ - After any edit, re-run the Step 6 self-check before re-presenting
292
+
293
+ ---
294
+
295
+ ## Success Criteria
296
+
297
+ - [ ] Immediate reply sent; mode detected (FROM_UX, --explore, post-scope, or standalone)
298
+ - [ ] Existing context docs (scope.md, prd.md, ux.md) read FULLY before asking questions
299
+ - [ ] Fidelity recommended with rationale; user confirmed or overrode
300
+ - [ ] Visual anchor captured (named aesthetic or reference) — never left as generic default
301
+ - [ ] Three subagents dispatched in parallel: web-research (references), analyst (flow + content), patterns (existing codebase anchor, if applicable)
302
+ - [ ] ALL subagents completed before generation
303
+ - [ ] HTML artifact is single self-contained file under 300KB
304
+ - [ ] Metadata comment block at top of `<head>` includes feature, fidelity, assumptions, NOT-included list
305
+ - [ ] Design tokens block present and encoded as CSS custom properties on `:root`
306
+ - [ ] Every screen includes happy path + at least one non-happy state (empty, error, or edge)
307
+ - [ ] No Lorem ipsum, no placeholder filler — realistic domain content throughout
308
+ - [ ] No external image dependencies (inline SVG only)
309
+ - [ ] All recurring components use a single named CSS class (no inline re-styling)
310
+ - [ ] All interactive elements respond visually; no console errors; no `href="#"` jump links
311
+ - [ ] Saved to `{OUT_DIR}/prototypes/{slug}_{MMDDYY}.html`
312
+ - [ ] Portability self-check run (size, external images, relative paths, component reuse, state coverage); violations surfaced as caveats
313
+ - [ ] (post-ux mode only) Filled assumptions surfaced in chat with offer to update ux.md; selected items written to ux.md with diff summary
314
+ - [ ] Next Steps footer rendered with mode-appropriate recommendation