---
name: "spectre-prototype"
description: "👻 | Generate a self-contained HTML prototype to validate a feature visually before planning - primary agent"
user-invocable: true
---
# prototype
## Input Handling
Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded `$ARGUMENTS` value.
# prototype: Make the Feature Visible Before You Plan It
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`.
## ARGUMENTS
$ARGUMENTS
## Invocation Modes
Detect mode from environment markers, ARGUMENTS, and existing docs. **Order matters** — check from most context to least:
- **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`.
- **`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.
- **`--explore` flag in ARGUMENTS** — pre-scope discovery. Concept is unvalidated. Default fidelity: **low-fi**. On completion, recommend `spectre-scope` as next step.
- **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.
- **Standalone, no context** — ask the user what they're prototyping. Default fidelity: **mid-fi**.
---
# STAGE 1: Intake & Fidelity Alignment
**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.
## Step 1 — Immediate Reply & Detect Context
- **Action** — ImmediateReply: Respond before any tools.
- **If** `FROM_UX=true` → acknowledge ux context, read approved flows from `{OUT_DIR}/ux.md`, **SKIP to Step 3**
- **Else If** ARGUMENTS empty → probe: "What are we prototyping? A quick description is enough — I'll figure out the fidelity from context."
- **Else** → proceed to Step 2
- **CRITICAL**: No tool calls in this step except reading ux output when `FROM_UX=true`.
## Step 2 — Read Available Context & Classify ux.md
- **Action** — DetectExistingDocs: Check for relevant inputs before asking the user anything.
- `branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)`
- Look for: `docs/tasks/{branch_name}/concepts/scope.md`, `docs/tasks/{branch_name}/specs/prd.md`, `docs/tasks/{branch_name}/ux.md`
- Read whichever exist FULLY (no offset/limit)
- **Action** — ClassifyUxDoc: If `ux.md` exists, classify its completeness — this drives fidelity AND how much intake to skip.
- **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**.
- **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**.
- **Absent** — fall back to scope.md / prd.md / standalone modes.
## Step 3 — Recommend Fidelity, Confirm Anchor
Pick fidelity from signals available:
| Signal present | Recommends |
|---|---|
| `--explore` flag, or no scope/prd | **Low-fi** — grayscale, layout-only, no typography polish |
| scope.md exists, no design system anchor | **Mid-fi** — real colors, basic type, simplified components (default) |
| scope.md + flows-only ux.md, or brand/design system anchor | **Mid-fi to High-fi** — depends on anchor strength |
| **Complete ux.md** (post-ux) | **High-fi** — full design tokens, realistic data, micro-interactions; render the spec faithfully |
### Intake by mode
**Post-ux mode** (complete ux.md) — present a tight confirmation, ask one question:
> **Prototype plan** — rendering complete UX spec
>
> Source: `{path to ux.md}` ({N} screens, {M} components, {K} states specified)
> Fidelity: **high-fi** (default — full spec is on disk; I'll render it faithfully, not invent)
>
> 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.
**All other modes** — present recommendation + request anchor + confirm framing:
> **Prototype plan**
>
> I'm reading this as: **{inferred feature/flow}**
> Recommended fidelity: **{low-fi | mid-fi | high-fi}** — {one-line reason}
> Primary flow: **{name}** (from {scope.md | ux.md flows | your description})
>
> Two things I need from you:
> 1. **Override fidelity?** Or "looks good."
> 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.
**Wait for response.** If user pushes back on fidelity or feature framing, adjust and re-confirm.
---
# STAGE 2: Parallel Research & Generation
**Gate**: Only proceed after Stage 1 confirmation (or `FROM_UX=true`).
## Step 4 — Dispatch Parallel Subagents
Spawn three subagents in parallel. Each has a focused job.
### `@web-research` — Visual Reference Discovery
Prompt template:
> Research visual design patterns and UI conventions for **{feature type}**. Specifically:
>
> 1. Find 2–3 living examples or screenshots of similar UI patterns in well-regarded products. Return URLs and visual descriptions.
> 2. Identify the established UX convention for this interaction type (wizard, dashboard, list+detail, modal flow, etc.) and any recent (2025–2026) refinements.
> 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.
> 4. Return concrete decisions — colors, fonts, layout patterns — not general advice.
>
> Length: under 400 words. Cite sources.
**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.
### `@analyst` — Flow & Content Extraction
Use one of two prompt templates based on mode detected in Step 2.
**Extraction mode** — post-ux (complete ux.md present):
> 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.
>
> Return a render brief organized by ux.md section:
>
> 1. **Screens** — verbatim from the Screens section: name, purpose, navigation relationships
> 2. **Layouts** — verbatim from Layouts: per-screen header/main/footer + responsive breakpoints
> 3. **Components** — verbatim from Components: each element's purpose, location, all documented states (default, hover, active, disabled, loading, error)
> 4. **Interactions** — verbatim from the Interactions table: Element | Action | Result
> 5. **States** — verbatim from the States table: State | Trigger | Appearance | Available Actions
> 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.
> 7. **Edge cases & a11y** — note any documented constraints (limits, null/long data, keyboard actions, focus management) the prototype should reflect
>
> 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.
**Synthesis mode** — flows-only ux, scope-only, or standalone:
> 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:
>
> 1. **Primary flow** — entry → action → outcome, with decision points
> 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
> 3. **Stated constraints** — any layout, behavior, or content constraints from the docs
> 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.
> 5. **Component inventory** — every recurring UI element that will need a named CSS class (button, card, input, badge, etc.)
>
> Return a structured flow brief: screen list, per-screen state list, realistic content for each, component inventory.
**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.
### `@patterns` — Existing Codebase Anchor (only if applicable)
Skip this agent if there is no existing app to anchor to. Otherwise:
> 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.
**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.
## Step 5 — Generate the HTML Artifact
Wait for ALL subagents to complete. Synthesize their outputs, then generate a single self-contained HTML file. Use `@dev` to produce the file (or inline if the synthesis is straightforward).
### Hard constraints on the generated HTML
**File structure** (every prototype includes these in order):
1. **`` + minimal `
`** with `` and an inline `