--- name: design-html preamble-tier: 2 version: 1.0.0 description: | Design finalization: takes an approved AI mockup from /design-shotgun and generates production-quality Pretext-native HTML/CSS. Text actually reflows, heights are computed, layouts are dynamic. 30KB overhead, zero deps. Smart API routing: picks the right Pretext patterns for each design type. Use when: "finalize this design", "turn this mockup into HTML", "implement this design", or after /design-shotgun approves a direction. Proactively suggest when user has approved a design in /design-shotgun. (gstack) allowed-tools: - Bash - Read - Write - Edit - Glob - Grep - Agent - AskUserQuestion --- {{PREAMBLE}} # /design-html: Pretext-Native HTML Engine You generate production-quality HTML where text actually works correctly. Not CSS approximations. Computed layout via Pretext. Text reflows on resize, heights adjust to content, cards size themselves, chat bubbles shrinkwrap, editorial spreads flow around obstacles. {{DESIGN_SETUP}} {{BROWSE_SETUP}} --- ## Step 0: Input Detection ```bash eval "$(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null)" ``` 1. Find the most recent `approved.json`: ```bash setopt +o nomatch 2>/dev/null || true ls -t ~/.gstack/projects/$SLUG/designs/*/approved.json 2>/dev/null | head -1 ``` 2. If found, read it. Extract: approved variant PNG path, user feedback, screen name. 3. Read `DESIGN.md` if it exists in the repo root. These tokens take priority for system-level values (fonts, brand colors, spacing scale). 4. **Evolve mode:** Check for prior output: ```bash setopt +o nomatch 2>/dev/null || true ls -t ~/.gstack/projects/$SLUG/designs/*/finalized.html 2>/dev/null | head -1 ``` If a prior `finalized.html` exists, use AskUserQuestion: > Found a prior finalized HTML from a previous session. Want to evolve it > (apply new changes on top, preserving your custom edits) or start fresh? > A) Evolve — iterate on the existing HTML > B) Start fresh — regenerate from the approved mockup If evolve: read the existing HTML. Apply changes on top during Step 3. If fresh: proceed normally. 5. If no `approved.json` found, use AskUserQuestion: > No approved design found. You need a mockup first. > A) Run /design-shotgun — explore design variants and approve one > B) I have a PNG — let me provide the path If B: accept a PNG file path from the user and proceed with that as the reference. --- ## Step 1: Design Analysis 1. If `$D` is available (`DESIGN_READY`), extract a structured implementation spec: ```bash $D prompt --image --output json ``` This returns colors, typography, layout structure, and component inventory via GPT-4o vision. 2. If `$D` is not available, read the approved PNG inline using the Read tool. Describe the visual layout, colors, typography, and component structure yourself. 3. Read `DESIGN.md` tokens. These override any extracted values for system-level properties (brand colors, font family, spacing scale). 4. Output an "Implementation spec" summary: colors (hex), fonts (family + weights), spacing scale, component list, layout type. --- ## Step 2: Smart Pretext API Routing Analyze the approved design and classify it into a Pretext tier. Each tier uses different Pretext APIs for optimal results: | Design type | Pretext APIs | Use case | |-------------|-------------|----------| | Simple layout (landing, marketing) | `prepare()` + `layout()` | Resize-aware heights | | Card/grid (dashboard, listing) | `prepare()` + `layout()` | Self-sizing cards | | Chat/messaging UI | `prepareWithSegments()` + `walkLineRanges()` | Tight-fit bubbles, min-width | | Content-heavy (editorial, blog) | `prepareWithSegments()` + `layoutNextLine()` | Text around obstacles | | Complex editorial | Full engine + `layoutWithLines()` | Manual line rendering | State the chosen tier and why. Reference the specific Pretext APIs that will be used. --- ## Step 2.5: Framework Detection Check if the user's project uses a frontend framework: ```bash [ -f package.json ] && cat package.json | grep -o '"react"\|"svelte"\|"vue"\|"@angular/core"\|"solid-js"\|"preact"' | head -1 || echo "NONE" ``` If a framework is detected, use AskUserQuestion: > Detected [React/Svelte/Vue] in your project. What format should the output be? > A) Vanilla HTML — self-contained preview file (recommended for first pass) > B) [React/Svelte/Vue] component — framework-native with Pretext hooks If the user chooses framework output, ask one follow-up: > A) TypeScript > B) JavaScript For vanilla HTML: proceed to Step 3 with vanilla output. For framework output: proceed to Step 3 with framework-specific patterns. If no framework detected: default to vanilla HTML, no question needed. --- ## Step 3: Generate Pretext-Native HTML ### Pretext Source Embedding For **vanilla HTML output**, check for the vendored Pretext bundle: ```bash _PRETEXT_VENDOR="" _ROOT=$(git rev-parse --show-toplevel 2>/dev/null) [ -n "$_ROOT" ] && [ -f "$_ROOT/.claude/skills/gstack/design-html/vendor/pretext.js" ] && _PRETEXT_VENDOR="$_ROOT/.claude/skills/gstack/design-html/vendor/pretext.js" [ -z "$_PRETEXT_VENDOR" ] && [ -f ~/.claude/skills/gstack/design-html/vendor/pretext.js ] && _PRETEXT_VENDOR=~/.claude/skills/gstack/design-html/vendor/pretext.js [ -n "$_PRETEXT_VENDOR" ] && echo "VENDOR: $_PRETEXT_VENDOR" || echo "VENDOR_MISSING" ``` - If `VENDOR` found: read the file and inline it in a `` Add a comment: `` For **framework output**, add to the project's dependencies instead: ```bash # Detect package manager [ -f bun.lockb ] && echo "bun add @chenglou/pretext" || \ [ -f pnpm-lock.yaml ] && echo "pnpm add @chenglou/pretext" || \ [ -f yarn.lock ] && echo "yarn add @chenglou/pretext" || \ echo "npm install @chenglou/pretext" ``` Run the detected install command. Then use standard imports in the component. ### HTML Generation Write a single file using the Write tool. Save to: `~/.gstack/projects/$SLUG/designs/-YYYYMMDD/finalized.html` For framework output, save to: `~/.gstack/projects/$SLUG/designs/-YYYYMMDD/finalized.[tsx|svelte|vue]` **Always include in vanilla HTML:** - Pretext source (inlined or CDN, see above) - CSS custom properties for design tokens from DESIGN.md / Step 1 extraction - Google Fonts via `` tags + `document.fonts.ready` gate before first `prepare()` - Semantic HTML5 (`
`, `