[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71GPHBKPC12T8Y1MWG2A7W6":3,"skill-same:01M71GPHBKPC12T8Y1MWG2A7W6":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":56,"repositoryHtmlUrl":57,"repositoryHomepageUrl":6,"ownerHtmlUrl":58,"ownerBlogUrl":59,"ownerDescription":60,"updatedAt":61,"install":62,"resources":75},"01M71GPHBKPC12T8Y1MWG2A7W6","design-html",null,"Turn an approved mockup, plan or description into production-quality, reflowing HTML\u002FCSS.","timurgaleev\u002Fvibestack","timurgaleev","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F32696429?v=4","01M71GMS53Z9B4JQTCQEFXAE9E","Timur Galeev","01M71GMS5S1Q7BEYB3Z7GY3E85",8,"MIT","https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack\u002Fblob\u002Fmain\u002Fskills\u002Fdesign-html\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"design","design html","html","css","code","Production","Bash","plan","quality","grep","read","write","edit","build","make","mockup","2026-11-10 10:12:30",false,"---\nname: design-html\ndescription: |\n  Turn an approved mockup, plan or description into production-quality, reflowing HTML\u002FCSS.\ntriggers:\n  - build the design\n  - code the mockup\n  - make design real\nallowed-tools:\n  - Bash\n  - Read\n  - Write\n  - Edit\n  - Glob\n  - Grep\n  - Agent\n  - AskUserQuestion\n---\n\nIf this session was compacted, the copy of this skill in context may be cut off.\nRead `${CLAUDE_SKILL_DIR}\u002FSKILL.md` from disk and resume at the step you are on.\n\n## When to invoke\n\nUse when: \"finalize this design\", \"turn this into HTML\", \"build me a page\", \"implement this design\", or after any planning skill.\n\nProactively suggest when user has approved a design or has a plan ready.\n\nFor a slide deck (\"deck\", \"slides\", or `--deck`), follow **Deck mode** below.\n\nVoice triggers (speech-to-text aliases): \"build the design\", \"code the mockup\", \"make it real\".\n\n## Preamble\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\" 2>\u002Fdev\u002Fnull || SLUG=\"unknown\"\n_LEARN_FILE=\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F${SLUG:-unknown}\u002Flearnings.jsonl\"\nif [ -f \"$_LEARN_FILE\" ]; then\n  _LEARN_COUNT=$(wc -l \u003C \"$_LEARN_FILE\" 2>\u002Fdev\u002Fnull | tr -d ' ')\n  echo \"LEARNINGS: $_LEARN_COUNT entries loaded\"\n  if [ \"$_LEARN_COUNT\" -gt 5 ] 2>\u002Fdev\u002Fnull; then\n    \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-learnings-search\" --limit 5 2>\u002Fdev\u002Fnull || true\n  fi\nelse\n  echo \"LEARNINGS: none yet\"\nfi\n```\n\n{{include lib\u002Fsnippets\u002Fsession-host.md}}\n\n{{include lib\u002Fsnippets\u002Fdecision-brief.md}}\n\n{{include lib\u002Fsnippets\u002Fworking-protocols.md}}\n\n{{include lib\u002Fsnippets\u002Fstate-protocols.md}}\n\n---\n\n# \u002Fdesign-html: Pretext-Native HTML Engine\n\nYou generate production-quality HTML where text actually works correctly. Not CSS\napproximations — computed layout via Pretext. Text reflows on resize, heights adjust\nto content, cards size themselves, chat bubbles shrinkwrap, editorial spreads flow\naround obstacles. If you find yourself faking a layout with fixed heights, magic\nnumbers, or `line-clamp`, you have left the engine behind and the output is no longer\nwhat this skill promises.\n\n## DESIGN SETUP\n\n```bash\n# Bind $D to vibe-design (OpenAI image backend) when a key is configured.\nD=${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-design\nif [ -x \"$D\" ] && [ \"$(\"$D\" status 2>\u002Fdev\u002Fnull)\" = \"DESIGN_AVAILABLE\" ]; then\n  echo \"DESIGN_AVAILABLE via $D\"\nelse\n  echo \"DESIGN_NOT_AVAILABLE\"\nfi\n```\n\nIf `DESIGN_NOT_AVAILABLE`: skip visual mockup generation and fall back to text-based design review.\n\n`$D` generates image variants — nothing else. There is no vision extractor here: when\nthis skill needs to read a mockup, you read it yourself with the Read tool. Never\ninvent a subcommand; anything other than `status` and `variants` either reports that\nit is unsupported or exits with a usage error.\n\n**CRITICAL PATH RULE:** All design artifacts (mockups,\n`approved.json`) MUST be saved under `${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F`, NEVER to\n`.context\u002F`, `docs\u002Fdesigns\u002F`, `\u002Ftmp\u002F`, or any project-local \u002F version-controlled\ndirectory. Design artifacts are USER data, not project files. The finalized HTML is\nthe exception — that is the deliverable, and it goes wherever the user asks for it.\n\n## UX Principles: How Users Actually Behave\n\nThese principles govern how real humans interact with interfaces. They are observed\nbehavior, not preferences. Apply them before, during, and after every design decision.\n\n### The Three Laws of Usability\n\n1. **Don't make me think.** Every page should be self-evident. If a user stops\n   to think \"What do I click?\" or \"What does this mean?\", the design has failed.\n   Self-evident > self-explanatory > requires explanation.\n\n2. **Clicks don't matter, thinking does.** Three mindless, unambiguous clicks\n   beat one click that requires thought. Each step should feel like an obvious\n   choice (animal, vegetable, or mineral), not a puzzle.\n\n3. **Omit, then omit again.** Get rid of half the words on each page, then get\n   rid of half of what's left. Happy talk (self-congratulatory text) must die.\n   Instructions must die. If they need reading, the design has failed.\n\n### How Users Actually Behave\n\n- **Users scan, they don't read.** Design for scanning: visual hierarchy\n  (prominence = importance), clearly defined areas, headings and bullet lists,\n  highlighted key terms. We're designing billboards going by at 60 mph, not\n  product brochures people will study.\n- **Users satisfice.** They pick the first reasonable option, not the best.\n  Make the right choice the most visible choice.\n- **Users muddle through.** They don't figure out how things work. They wing\n  it. If they accomplish their goal by accident, they won't seek the \"right\" way.\n  Once they find something that works, no matter how badly, they stick to it.\n- **Users don't read instructions.** They dive in. Guidance must be brief,\n  timely, and unavoidable, or it won't be seen.\n\n### Billboard Design for Interfaces\n\n- **Use conventions.** Logo top-left, nav top\u002Fleft, search = magnifying glass.\n  Don't innovate on navigation to be clever. Innovate when you KNOW you have a\n  better idea, otherwise use conventions. Even across languages and cultures,\n  web conventions let people identify the logo, nav, search, and main content.\n- **Visual hierarchy is everything.** Related things are visually grouped. Nested\n  things are visually contained. More important = more prominent. If everything\n  shouts, nothing is heard. Start with the assumption everything is visual noise,\n  guilty until proven innocent.\n- **Make clickable things obviously clickable.** No relying on hover states for\n  discoverability, especially on mobile where hover doesn't exist. Shape, location,\n  and formatting (color, underlining) must signal clickability without interaction.\n- **Eliminate noise.** Three sources: too many things shouting for attention\n  (shouting), things not organized logically (disorganization), and too much stuff\n  (clutter). Fix noise by removal, not addition.\n- **Clarity trumps consistency.** If making something significantly clearer\n  requires making it slightly inconsistent, choose clarity every time.\n\n### Navigation as Wayfinding\n\nUsers on the web have no sense of scale, direction, or location. Navigation\nmust always answer: What site is this? What page am I on? What are the major\nsections? What are my options at this level? Where am I? How can I search?\n\nPersistent navigation on every page. Breadcrumbs for deep hierarchies.\nCurrent section visually indicated. The \"trunk test\": cover everything except\nthe navigation. You should still know what site this is, what page you're on,\nand what the major sections are. If not, the navigation has failed.\n\n### The Goodwill Reservoir\n\nUsers start with a reservoir of goodwill. Every friction point depletes it.\n\n**Deplete faster:** Hiding info users want (pricing, contact, shipping). Punishing\nusers for not doing things your way (formatting requirements on phone numbers).\nAsking for unnecessary information. Putting sizzle in their way (splash screens,\nforced tours, interstitials). Unprofessional or sloppy appearance.\n\n**Replenish:** Know what users want to do and make it obvious. Tell them what they\nwant to know upfront. Save them steps wherever possible. Make it easy to recover\nfrom errors. When in doubt, apologize.\n\n### Mobile: Same Rules, Higher Stakes\n\nAll the above applies on mobile, just more so. Real estate is scarce, but never\nsacrifice usability for space savings. Affordances must be VISIBLE: no cursor\nmeans no hover-to-discover. Touch targets must be big enough (44px minimum).\nFlat design can strip away useful visual information that signals interactivity.\nPrioritize ruthlessly: things needed in a hurry go close at hand, everything\nelse a few taps away with an obvious path to get there.\n\n## SETUP\n\n{{include lib\u002Fsnippets\u002Fbrowse-detect.md}}\n\n## Step 0: Input Detection\n\nDetect what design context exists for this project. Run all four checks — each is a\nfresh shell, so each derives the project slug itself:\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\nsetopt +o nomatch 2>\u002Fdev\u002Fnull || true\n_CEO=$(ls -t \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fceo-plans\u002F\"*.md 2>\u002Fdev\u002Fnull | head -1)\n[ -n \"$_CEO\" ] && echo \"CEO_PLAN: $_CEO\" || echo \"NO_CEO_PLAN\"\n```\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\nsetopt +o nomatch 2>\u002Fdev\u002Fnull || true\n_APPROVED=$(ls -t \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F\"*\u002Fapproved.json 2>\u002Fdev\u002Fnull | head -1)\n[ -n \"$_APPROVED\" ] && echo \"APPROVED: $_APPROVED\" || echo \"NO_APPROVED\"\n```\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\nsetopt +o nomatch 2>\u002Fdev\u002Fnull || true\n_VARIANTS=$(ls -t \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F\"*\u002Fvariant-*.png 2>\u002Fdev\u002Fnull | head -1)\n[ -n \"$_VARIANTS\" ] && echo \"VARIANTS: $_VARIANTS\" || echo \"NO_VARIANTS\"\n```\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\nsetopt +o nomatch 2>\u002Fdev\u002Fnull || true\n_FINALIZED=$(ls -t \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F\"*\u002Ffinalized.html 2>\u002Fdev\u002Fnull | head -1)\n[ -n \"$_FINALIZED\" ] && echo \"FINALIZED: $_FINALIZED\" || echo \"NO_FINALIZED\"\n[ -f DESIGN.md ] && echo \"DESIGN_MD: exists\" || echo \"NO_DESIGN_MD\"\n```\n\nNow route based on what was found. Check these cases in order:\n\n### Case A: approved.json exists (design-shotgun ran)\n\nIf `APPROVED` was found, read it. Extract: the approved image, user feedback, screen\nname. The approved image is the file the record's `approved_path` names. An older\nrecord without `approved_path` points at `variant-\u003Capproved_variant>.png` in the\ndirectory that holds `approved.json`. If that file does not exist, stop and tell the\nuser the approved image is gone and they need to reselect with \u002Fdesign-shotgun; never\nsubstitute another variant. Also read the CEO plan if one exists (it adds strategic\ncontext).\n\nRead `DESIGN.md` if it exists in the repo root. These tokens take priority for\nsystem-level values (fonts, brand colors, spacing scale).\n\nThen check for prior finalized.html. If `FINALIZED` was also found, use AskUserQuestion:\n> Found a prior finalized HTML from a previous session. Want to evolve it\n> (apply new changes on top, preserving your custom edits) or start fresh?\n> A) Evolve — iterate on the existing HTML\n> B) Start fresh — regenerate from the approved mockup\n\nIf evolve: read the existing HTML. Apply changes on top during Step 3.\nIf fresh or no finalized.html: proceed to Step 1 with the approved PNG as the\nvisual reference.\n\n### Case B: CEO plan and\u002For design variants exist, but no approved.json\n\nIf `CEO_PLAN` or `VARIANTS` was found but no `APPROVED`:\n\nRead whichever context exists:\n- If CEO plan found: read it and summarize the product vision and design requirements.\n- If variant PNGs found: show them inline using the Read tool.\n- If DESIGN.md found: read it for design tokens and constraints.\n\nUse AskUserQuestion:\n> Found [CEO plan from \u002Fplan-ceo-review | design review variants from \u002Fplan-design-review | both]\n> but no approved design mockup.\n> A) Run \u002Fdesign-shotgun — explore design variants based on the existing plan context\n> B) Skip mockups — I'll design the HTML directly from the plan context\n> C) I have a PNG — let me provide the path\n\nIf A: tell the user to run \u002Fdesign-shotgun, then come back to \u002Fdesign-html.\nIf B: proceed to Step 1 in \"plan-driven mode.\" There is no approved PNG, the plan is\nthe source of truth. Ask the user for a screen name to use for the output directory\n(e.g., \"landing-page\", \"dashboard\", \"pricing\").\nIf C: accept a PNG file path from the user and proceed with that as the reference.\n\n### Case C: Nothing found (clean slate)\n\nIf none of the above produced any context:\n\nUse AskUserQuestion:\n> No design context found for this project. How do you want to start?\n> A) Run \u002Fplan-ceo-review first — think through the product strategy before designing\n> B) Run \u002Fplan-design-review first — design review with visual mockups\n> C) Run \u002Fdesign-shotgun — jump straight to visual design exploration\n> D) Just describe it — tell me what you want and I'll design the HTML live\n\nIf A, B, or C: tell the user to run that skill, then come back to \u002Fdesign-html.\nIf D: proceed to Step 1 in \"freeform mode.\" Ask the user for a screen name.\n\n### Context summary\n\nAfter routing, output a brief context summary:\n- **Mode:** approved-mockup | plan-driven | freeform | evolve\n- **Visual reference:** path to approved PNG, or \"none (plan-driven)\" or \"none (freeform)\"\n- **CEO plan:** path or \"none\"\n- **Design tokens:** \"DESIGN.md\" or \"none\"\n- **Screen name:** from approved.json, user-provided, or inferred from CEO plan\n\n---\n\n## Step 1: Design Analysis\n\n1. Read the approved PNG inline using the Read tool and build the implementation\n   spec from it yourself: colors as hex, typography (family, weights, scale), layout\n   structure, and a component inventory. Where the image is ambiguous — an exact hex,\n   a font family you cannot name — say so and take the value from DESIGN.md or the\n   plan rather than guessing a number that will look authoritative and be wrong.\n\n2. If in plan-driven or freeform mode (no approved PNG), design from context:\n   - **Plan-driven:** read the CEO plan and\u002For design review notes. Extract the described\n     UI requirements, user flows, target audience, visual feel (dark\u002Flight, dense\u002Fspacious),\n     content structure (hero, features, pricing, etc.), and design constraints. Build an\n     implementation spec from the plan's prose rather than a visual reference.\n   - **Freeform:** use AskUserQuestion to gather what the user wants to build. Ask about:\n     purpose\u002Faudience, visual feel (dark\u002Flight, playful\u002Fserious, dense\u002Fspacious),\n     content structure (hero, features, pricing, etc.), and any reference sites they like.\n   In both cases, describe the intended visual layout, colors, typography, and\n   component structure as your implementation spec. Write real copy from the plan or\n   the user's description (never lorem ipsum); proof comes only from the user, under\n   the craft floor below.\n\n3. Read `DESIGN.md` tokens. These override any extracted values for system-level\n   properties (brand colors, font family, spacing scale).\n\n4. When `approved.json` carries `archetype` and `sections`, the user already chose the\n   page's structure in \u002Fdesign-shotgun: build that archetype with those sections in\n   that order, and do not re-pick the archetype or ask about it under Persuade pages.\n\n5. Output an \"Implementation spec\" summary: colors (hex), fonts (family + weights),\n   spacing scale, component list, layout type.\n\n{{include lib\u002Fsnippets\u002Fdesign-craft-floor.md}}\n\n### Persuade pages\n\nWhen the page exists to make a visitor decide and act (landing, pricing, launch,\nwaitlist), settle these before writing markup:\n\n- **Surface line.** Open the spec with `Surface: PERSUADE — \u003Cwho visits> decides \u003Cwhat>`.\n- **Intake.** Ask at most three questions, in one AskUserQuestion, and only what the\n  plan or mockup leaves open: who the visitor is and what stops them, the one action\n  you want, and what proof the user can actually supply.\n- **Archetype.** Pick one archetype for the page's structure — `classic-hero` (show\n  the product working), `long-form-story` (problem then outcome), `comparison` (compare\n  and price) or `minimal-conversion` (a short launch\u002Fwaitlist page), the ids\n  \u002Fdesign-shotgun writes —\n  and say in one line why it fits this visitor — unless `approved.json` already\n  names one (Step 1, item 4). The hero still holds to one headline, one supporting\n  line, one action group.\n- **Primary action.** One named action with default, hover and focus states, and,\n  when the action submits data (a form, a signup, a purchase), also **invalid** (a message beside the field that names the fix), **pending**\n  (disabled, with a progress label), **failure** (what went wrong, the input kept,\n  a retry), and **success** (what happens next).\n- **Index decision.** `index` for a public page meant to be found, `noindex` for a\n  preview, campaign variant or unlaunched page, set with `\u003Cmeta name=\"robots\">` and\n  listed in the hand-off.\n\n---\n\n## Step 2: Smart Pretext API Routing\n\nAnalyze the approved design and classify it into a Pretext tier. Each tier uses\ndifferent Pretext APIs for optimal results:\n\n| Design type | Pretext APIs | Use case |\n|-------------|-------------|----------|\n| Simple layout (landing, marketing) | `prepare()` + `layout()` | Resize-aware heights |\n| Card\u002Fgrid (dashboard, listing) | `prepare()` + `layout()` | Self-sizing cards |\n| Chat\u002Fmessaging UI | `prepareWithSegments()` + `walkLineRanges()` | Tight-fit bubbles, min-width |\n| Content-heavy (editorial, blog) | `prepareWithSegments()` + `layoutNextLine()` | Text around obstacles |\n| Complex editorial | Full engine + `layoutWithLines()` | Manual line rendering |\n\nState the chosen tier and why. Reference the specific Pretext APIs that will be used.\n\n---\n\n## Step 2.5: Framework Detection\n\nCheck if the user's project uses a frontend framework:\n\n```bash\n[ -f package.json ] && cat package.json | grep -o '\"react\"\\|\"svelte\"\\|\"vue\"\\|\"@angular\u002Fcore\"\\|\"solid-js\"\\|\"preact\"' | head -1 || echo \"NONE\"\n```\n\nIf a framework is detected, use AskUserQuestion:\n> Detected [React\u002FSvelte\u002FVue] in your project. What format should the output be?\n> A) Vanilla HTML — self-contained preview file (recommended for first pass)\n> B) [React\u002FSvelte\u002FVue] component — framework-native with Pretext hooks\n\nIf the user chooses framework output, ask one follow-up:\n> A) TypeScript\n> B) JavaScript\n\nFor vanilla HTML: proceed to Step 3 with vanilla output.\nFor framework output: proceed to Step 3 with framework-specific patterns.\nIf no framework detected: default to vanilla HTML, no question needed.\n\n---\n\n## Step 3: Generate Pretext-Native HTML\n\n### Pretext Source Embedding\n\nFor **vanilla HTML output**: no Pretext bundle ships with this skill, so the page\nimports Pretext from the CDN as an ES module. Pretext is ESM-only and sets no global,\nso the import and all page code that calls it go in the same `\u003Cscript type=\"module\">`.\nThe import pins an exact version, so a later release cannot change a page that already\nworks:\n```html\n\u003Cscript type=\"module\">\n  import { prepare, layout, prepareWithSegments, walkLineRanges, layoutNextLine, layoutWithLines } from 'https:\u002F\u002Fesm.sh\u002F@chenglou\u002Fpretext@0.0.9'\n  \u002F\u002F page code (the wiring patterns below) goes here, after the import\n\u003C\u002Fscript>\n```\nTell the user the page needs the network to lay itself out: on an offline machine or\nbehind a CSP that blocks esm.sh it renders unlaid-out. If they need a fully\nself-contained file, they install `@chenglou\u002Fpretext` in their own project and use\nframework output (or their bundler) instead.\n\nFor **framework output**, add to the project's dependencies instead:\n```bash\n# Detect package manager\n[ -f bun.lockb ] && echo \"bun add @chenglou\u002Fpretext\" || \\\n[ -f pnpm-lock.yaml ] && echo \"pnpm add @chenglou\u002Fpretext\" || \\\n[ -f yarn.lock ] && echo \"yarn add @chenglou\u002Fpretext\" || \\\necho \"npm install @chenglou\u002Fpretext\"\n```\nRun the detected install command. Then use standard imports in the component.\n\n### HTML Generation\n\nResolve the output directory first (fill in `\u003Cscreen-name>`):\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\n_DESIGN_DIR=\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F\u003Cscreen-name>-$(date +%Y%m%d)\"\nmkdir -p \"$_DESIGN_DIR\"\necho \"DESIGN_DIR: $_DESIGN_DIR\"\n```\n\nWrite a single file using the Write tool. Save to `\u003CDESIGN_DIR>\u002Ffinalized.html`,\nwhere `\u003CDESIGN_DIR>` is the path the block printed on its `DESIGN_DIR:` line.\n\nFor framework output, save to `\u003CDESIGN_DIR>\u002Ffinalized.[tsx|svelte|vue]`.\n\n**Always include in vanilla HTML:**\n- Pretext imported from esm.sh in a `\u003Cscript type=\"module\">` (see above)\n- CSS custom properties for design tokens from DESIGN.md \u002F Step 1 extraction\n- Google Fonts via `\u003Clink>` tags + `document.fonts.ready` gate before first `prepare()`\n- Semantic HTML5 (`\u003Cheader>`, `\u003Cnav>`, `\u003Cmain>`, `\u003Csection>`, `\u003Cfooter>`)\n- Responsive behavior via Pretext relayout (not just media queries)\n- Breakpoint-specific adjustments at 375px, 768px, 1024px, 1440px\n- ARIA attributes, heading hierarchy, focus-visible states\n- `contenteditable` on text elements + MutationObserver to re-prepare + re-layout on edit\n- ResizeObserver on containers to re-layout on resize\n- `prefers-color-scheme` media query for dark mode\n- `prefers-reduced-motion` for animation respect\n- Real content extracted from the mockup (never lorem ipsum)\n\n**Never include by default** (AI slop blacklist):\nAn approved mockup that shows one, a DESIGN.md that chose it, or an explicit user request overrides the list: build it and state the tradeoff once.\n- Purple\u002Fblue gradients as default\n- Generic 3-column feature grids\n- Center-everything layouts with no visual hierarchy\n- Decorative blobs, waves, or geometric patterns not in the mockup\n- Stock photo placeholder divs\n- \"Get Started\" \u002F \"Learn More\" generic CTAs not from the mockup\n- Rounded-corner cards with drop shadows as the default component\n- Emoji as visual elements\n- Generic testimonial sections\n- Cookie-cutter hero sections with left-text right-image\n- Gradient buttons as the primary CTA pattern\n- A colored left border on cards; a card nested inside a card\n- Glowing edges, radial halos or spotlight glows on dark surfaces\n- Gradient text as emphasis; headings within a step of body size\n- A pill-shaped label or kicker floating above the hero headline\n- Frosted-glass panels as the default surface\n\n### Pretext Wiring Patterns\n\nUse these patterns based on the tier selected in Step 2. These are the correct\nPretext API usage patterns. Follow them exactly. The imports below are for framework\noutput; in vanilla HTML, import the same names from `'https:\u002F\u002Fesm.sh\u002F@chenglou\u002Fpretext@0.0.9'`\nonce, at the top of the page's `\u003Cscript type=\"module\">`.\n\n**Pattern 1: Basic height computation (Simple layout, Card\u002Fgrid)**\n```js\nimport { prepare, layout } from '@chenglou\u002Fpretext'\n\n\u002F\u002F 1. PREPARE — one-time, after fonts load\nawait document.fonts.ready\nconst elements = document.querySelectorAll('[data-pretext]')\nconst prepared = new Map()\n\nfor (const el of elements) {\n  const text = el.textContent\n  const font = getComputedStyle(el).font\n  prepared.set(el, prepare(text, font))\n}\n\n\u002F\u002F 2. LAYOUT — cheap, call on every resize\nfunction relayout() {\n  for (const [el, handle] of prepared) {\n    const { height } = layout(handle, el.clientWidth, parseFloat(getComputedStyle(el).lineHeight))\n    el.style.height = `${height}px`\n  }\n}\n\n\u002F\u002F 3. RESIZE-AWARE\nnew ResizeObserver(() => relayout()).observe(document.body)\nrelayout()\n\n\u002F\u002F 4. CONTENT-EDITABLE — re-prepare when text changes\nfor (const el of elements) {\n  if (el.contentEditable === 'true') {\n    new MutationObserver(() => {\n      const font = getComputedStyle(el).font\n      prepared.set(el, prepare(el.textContent, font))\n      relayout()\n    }).observe(el, { characterData: true, subtree: true, childList: true })\n  }\n}\n```\n\n**Pattern 2: Shrinkwrap \u002F tight-fit containers (Chat bubbles)**\n```js\nimport { prepareWithSegments, walkLineRanges } from '@chenglou\u002Fpretext'\n\n\u002F\u002F Tight-fit width: lay out at maxWidth, then shrink the bubble to its widest line\nfunction shrinkwrap(text, font, maxWidth) {\n  const segs = prepareWithSegments(text, font)\n  let widest = 0\n  const lineCount = walkLineRanges(segs, maxWidth, (line) => {\n    widest = Math.max(widest, line.width)\n  })\n  return { width: Math.ceil(widest), lineCount }\n}\n```\n\n**Pattern 3: Text around obstacles (Editorial layout)**\n```js\nimport { prepareWithSegments, layoutNextLine } from '@chenglou\u002Fpretext'\n\nfunction layoutAroundObstacles(text, font, containerWidth, lineHeight, obstacles) {\n  const segs = prepareWithSegments(text, font)\n  let cursor = { segmentIndex: 0, graphemeIndex: 0 }\n  let y = 0\n  const lines = []\n\n  while (true) {\n    \u002F\u002F Calculate available width at current y position, accounting for obstacles\n    let availWidth = containerWidth\n    for (const obs of obstacles) {\n      if (y >= obs.top && y \u003C obs.top + obs.height) {\n        availWidth -= obs.width\n      }\n    }\n\n    const result = layoutNextLine(segs, cursor, availWidth)\n    if (!result) break\n\n    lines.push({ text: result.text, width: result.width, x: 0, y })\n    cursor = result.end\n    y += lineHeight\n  }\n\n  return { lines, totalHeight: y }\n}\n```\n\n**Pattern 4: Full line-by-line rendering (Complex editorial)**\n```js\nimport { prepareWithSegments, layoutWithLines } from '@chenglou\u002Fpretext'\n\nconst segs = prepareWithSegments(text, font)\nconst { lines, height } = layoutWithLines(segs, containerWidth, lineHeight)\n\n\u002F\u002F lines = [{ text, width, start, end }, ...] (no x\u002Fy: line i sits at y = i * lineHeight)\n\u002F\u002F Use for Canvas\u002FSVG rendering or custom DOM positioning\nlines.forEach((line, i) => {\n  const span = document.createElement('span')\n  span.textContent = line.text\n  span.style.position = 'absolute'\n  span.style.left = '0px'\n  span.style.top = `${i * lineHeight}px`\n  container.appendChild(span)\n})\n```\n\n### Pretext API Reference\n\n```\nPRETEXT API CHEATSHEET:\n\nprepare(text, font) → handle\n  One-time text measurement. Call after document.fonts.ready.\n  Font: CSS shorthand like '16px Inter' or 'bold 24px Georgia'.\n\nlayout(prepared, maxWidth, lineHeight) → { height, lineCount }\n  Fast layout computation. Call on every resize. Sub-millisecond.\n\nprepareWithSegments(text, font) → handle\n  Like prepare() but enables line-level APIs below.\n\nlayoutWithLines(segs, maxWidth, lineHeight) → { lineCount, height, lines: [{text, width, start, end}...] }\n  Full line-by-line breakdown (no x\u002Fy: line i is at y = i * lineHeight). For Canvas\u002FSVG rendering.\n\nwalkLineRanges(segs, maxWidth, onLine) → lineCount\n  Calls onLine({ width, start, end }) once per line at maxWidth (no text built).\n  The widest line's width is the tight-fit container width. For chat bubbles.\n\nlayoutNextLine(segs, cursor, maxWidth) → { text, width, start, end } | null\n  Iterator. Different maxWidth per line = text around obstacles.\n  Start with cursor { segmentIndex: 0, graphemeIndex: 0 }; pass result.end next.\n  Returns null when text is exhausted. Takes no lineHeight: advance y yourself.\n\nclearCache() → void\n  Clears internal measurement caches. Use when cycling many fonts.\n\nsetLocale(locale?) → void\n  Retargets word segmenter for future prepare() calls.\n```\n\n---\n\n## Step 3.5: Live Reload Server\n\nAfter writing the HTML file, start a simple HTTP server for live preview:\n\n```bash\n# Start a simple HTTP server in the output directory\n_OUTPUT_DIR=$(dirname \u003Cpath-to-finalized.html>)\ncd \"$_OUTPUT_DIR\"\npython3 -I -m http.server 0 --bind 127.0.0.1 &\n_SERVER_PID=$!\n# The server needs a moment to bind; wait for its listening socket before reading the port.\n_PORT=\"\"\nfor _i in 1 2 3 4 5 6 7 8 9 10; do\n  _PORT=$(lsof -a -p \"$_SERVER_PID\" -iTCP -sTCP:LISTEN -P -n -Fn 2>\u002Fdev\u002Fnull | sed -n 's\u002F^n.*:\\([0-9][0-9]*\\)$\u002F\\1\u002Fp' | head -1)\n  [ -n \"$_PORT\" ] && break\n  sleep 0.2\ndone\n[ -n \"$_PORT\" ] || { echo \"SERVER_FAILED: no listening port after 2s\" >&2; kill \"$_SERVER_PID\" 2>\u002Fdev\u002Fnull; exit 1; }\necho \"SERVER: http:\u002F\u002F127.0.0.1:$_PORT\u002Ffinalized.html\"\necho \"PID: $_SERVER_PID\"\n```\n\nRemember the printed `SERVER:` URL and `PID:` value. Each bash block is a fresh\nshell, so `$_PORT` and `$_SERVER_PID` are empty in later blocks: restate the URL and\nPID literally wherever they are needed.\n\nIf python3 is not available, fall back to:\n```bash\nopen \u003Cpath-to-finalized.html>\n```\n\nTell the user: \"Live preview running at \u003CSERVER URL>.\nAfter each edit, just refresh the browser (Cmd+R) to see changes.\"\n\nWhen the refinement loop ends (Step 4 exits), kill the server:\n```bash\nkill \u003CPID> 2>\u002Fdev\u002Fnull || true\n```\n\n---\n\n## Step 4: Preview + Refinement Loop\n\n### Verification Screenshots\n\nIf SETUP printed `BROWSE_AVAILABLE`, take verification screenshots at 3 viewports.\n`screenshot` has no width flag, so set the viewport before each capture. Load the\npage through the live-reload server's `SERVER:` URL (not `file:\u002F\u002F`), so the module\nimport and relative assets resolve. This is a fresh shell, so replace `\u003CBROWSE_BIN>`\nwith the path SETUP printed on its `BROWSE_BIN:` line:\n\n```bash\nB='\u003CBROWSE_BIN>'\n$B goto \"\u003CSERVER URL>\"\n$B viewport 375x812\n$B screenshot \u002Ftmp\u002Fvibestack-verify-mobile.png\n$B viewport 768x1024\n$B screenshot \u002Ftmp\u002Fvibestack-verify-tablet.png\n$B viewport 1440x900\n$B screenshot \u002Ftmp\u002Fvibestack-verify-desktop.png\n```\n\nIf the live-reload server is not running (no python3), skip the screenshots rather\nthan pointing the browser at a `file:\u002F\u002F` path.\n\nShow all three screenshots inline using the Read tool. Check for:\n- Text overflow (text cut off or extending beyond containers)\n- Layout collapse (elements overlapping or missing)\n- Responsive breakage (content not adapting to viewport)\n\nIf issues are found, note them and fix before presenting to the user.\n\nIf SETUP printed `BROWSE_NOT_AVAILABLE`, skip verification and note:\n\"Browse binary not available. Skipping automated viewport verification.\"\n\n### Refinement Loop\n\n```\nLOOP:\n  1. If server is running, tell user to open the printed `SERVER:` URL\n     Otherwise: open \u003Cpath>\u002Ffinalized.html\n\n  2. If an approved mockup PNG exists, show it inline (Read tool) for visual comparison.\n     If in plan-driven or freeform mode, skip this step.\n\n  3. AskUserQuestion (adjust wording based on mode):\n     With mockup: \"The HTML is live in your browser. Here's the approved mockup for comparison.\n      Try: resize the window (text should reflow dynamically),\n      click any text (it's editable, layout recomputes instantly).\n      What needs to change? Say 'done' when satisfied.\"\n     Without mockup: \"The HTML is live in your browser. Try: resize the window\n      (text should reflow dynamically), click any text (it's editable, layout\n      recomputes instantly). What needs to change? Say 'done' when satisfied.\"\n\n  4. If \"done\" \u002F \"ship it\" \u002F \"looks good\" \u002F \"perfect\" → print the craft floor's\n     \"Before this can ship\" list, exit loop, go to Step 5\n\n  5. Apply feedback using targeted Edit tool changes on the HTML file\n     (do NOT regenerate the entire file — surgical edits only)\n\n  6. Brief summary of what changed (2-3 lines max)\n\n  7. If verification screenshots are available, re-take them to confirm the fix\n\n  8. Go to LOOP\n```\n\nMaximum 10 iterations. If the user hasn't said \"done\" after 10, use AskUserQuestion:\n\"We've done 10 rounds of refinement. Want to continue iterating or call it done?\"\n\n---\n\n## Deck mode\n\nDeck mode is explicit and never the default path. Enter it only when the input is a\nslide deck, the user says \"deck\" or \"slides\", or passes `--deck`. Otherwise build a\npage as above. In deck mode, Steps 0-3.5 still apply (input detection, design tokens,\noutput path, live-reload server); this section replaces the page structure and the\nStep 4 verification screenshots. Of the craft floor, a deck keeps the title and meta\ndescription, the favicon, alt text, real links, and the proof, honesty and scale rules;\nthe header\u002Fnav\u002Ffooter landmarks, the skip link, `aria-current` and inline form errors do\nnot apply to a deck (one `\u003Cmain>`, no navigation, no forms).\n\n**Structure:**\n- One `\u003Csection class=\"slide\">` per slide inside `\u003Cmain>`, each `height: 100dvh`\n  (with a `height: 100vh` line before it for older browsers).\n- Keyboard (ArrowLeft\u002FArrowRight, PageUp\u002FPageDown, Space, Home\u002FEnd), wheel and touch\n  navigation between slides, plus a visible slide index.\n- Under `prefers-reduced-motion: reduce`, slide changes jump instead of animating:\n  no smooth scrolling, no reveal transitions.\n- Type and spacing scale with `clamp()` (for example\n  `font-size: clamp(1rem, 0.6rem + 1.6vw, 2.5rem)`), never below a readable size.\n\n**Density heuristics** (a starting point for splitting content, not the gate):\n\n| Slide type | Heuristic |\n|------------|-----------|\n| Title | 1 heading + 1 line |\n| Content | 1 heading + 4-6 bullets |\n| Code | 8-10 lines |\n| Grid | at most 6 cells |\n\n**The viewport-fit gate.** At 1920×1080, 1280×720 and 375×667, every slide must pass\n`scrollHeight \u003C= clientHeight`, checked with `$B js`. A slide that fails is split into\ntwo slides, then the gate runs again; never clip it with `overflow: hidden` or shrink\nits type below the `clamp()` minimum, since that hides the failure instead of fixing it.\n\nIf SETUP printed `BROWSE_AVAILABLE`, run the gate. As with the verification\nscreenshots, set the viewport before each capture, load the live-reload server's\n`SERVER:` URL (not `file:\u002F\u002F`), and replace `\u003CBROWSE_BIN>` with the path SETUP printed\non its `BROWSE_BIN:` line, since this is a fresh shell:\n\n```bash\nB='\u003CBROWSE_BIN>'\n$B goto \"\u003CSERVER URL>\"\n$B viewport 1920x1080\n$B js \"[...document.querySelectorAll('section.slide')].map((s, i) => s.scrollHeight \u003C= s.clientHeight ? '' : 'OVERFLOW slide ' + (i + 1) + ': ' + s.scrollHeight + ' > ' + s.clientHeight).filter(Boolean).join('; ') || 'ALL_SLIDES_FIT'\"\n$B screenshot \u002Ftmp\u002Fvibestack-deck-1920.png\n$B viewport 1280x720\n$B js \"[...document.querySelectorAll('section.slide')].map((s, i) => s.scrollHeight \u003C= s.clientHeight ? '' : 'OVERFLOW slide ' + (i + 1) + ': ' + s.scrollHeight + ' > ' + s.clientHeight).filter(Boolean).join('; ') || 'ALL_SLIDES_FIT'\"\n$B screenshot \u002Ftmp\u002Fvibestack-deck-1280.png\n$B viewport 375x667\n$B js \"[...document.querySelectorAll('section.slide')].map((s, i) => s.scrollHeight \u003C= s.clientHeight ? '' : 'OVERFLOW slide ' + (i + 1) + ': ' + s.scrollHeight + ' > ' + s.clientHeight).filter(Boolean).join('; ') || 'ALL_SLIDES_FIT'\"\n$B screenshot \u002Ftmp\u002Fvibestack-deck-375.png\n```\n\nEach `js` line prints `ALL_SLIDES_FIT` or one `OVERFLOW slide N` entry per failing\nslide. Split every listed slide and rerun the block until all three viewports print\n`ALL_SLIDES_FIT`. An empty or error result is not a pass: report the gate as not run.\nShow the three screenshots inline with the Read tool.\n\nIf SETUP printed `BROWSE_NOT_AVAILABLE`, or the live-reload server is not running,\nreport the gate as not run, text-only: list each slide with its density against the\nheuristics above and flag the ones likely to overflow. Never report the deck as fitting\nwithout the gate.\n\n---\n\n## Step 5: Save & Next Steps\n\n### Design Token Extraction\n\nIf no `DESIGN.md` exists in the repo root, offer to create one from the generated HTML:\n\nExtract from the HTML:\n- CSS custom properties (colors, spacing, font sizes)\n- Font families and weights used\n- Color palette (primary, secondary, accent, neutral)\n- Spacing scale\n- Border radius values\n- Shadow values\n\nUse AskUserQuestion:\n> No DESIGN.md found. I can extract the design tokens from the HTML we just built\n> and create a DESIGN.md for your project. This means future \u002Fdesign-shotgun and\n> \u002Fdesign-html runs will be style-consistent automatically.\n> A) Create DESIGN.md from these tokens\n> B) Skip — I'll handle the design system later\n\nIf A: write `DESIGN.md` to the repo root with the extracted tokens, in the section\nlayout \u002Fdesign-consultation writes (Typography, Color, Spacing, Layout, Motion),\nplus a **Components** section listing each component this HTML built with its\nstates (default, hover, focus, active, disabled, loading, error — only the states\nit has) and a **Do's and Don'ts** section with the concrete rules the build followed.\n\n### Save Metadata\n\nWrite `finalized.json` alongside the HTML:\n```json\n{\n  \"source_mockup\": \"\u003Capproved variant PNG path or null>\",\n  \"source_plan\": \"\u003CCEO plan path or null>\",\n  \"mode\": \"\u003Capproved-mockup|plan-driven|freeform|evolve>\",\n  \"html_file\": \"\u003Cpath to finalized.html or component file>\",\n  \"pretext_tier\": \"\u003Cselected tier>\",\n  \"framework\": \"\u003Cvanilla|react|svelte|vue>\",\n  \"iterations\": \u003Cnumber of refinement iterations>,\n  \"date\": \"\u003CISO 8601>\",\n  \"screen\": \"\u003Cscreen name>\",\n  \"branch\": \"\u003Ccurrent branch>\"\n}\n```\n\n### Next Steps\n\nUse AskUserQuestion:\n> Design finalized with Pretext-native layout. What's next?\n> A) Copy to project — copy the HTML\u002Fcomponent into your codebase\n> B) Iterate more — keep refining\n> C) Done — I'll use this as a reference\n\nIf A: print the \"Before this can ship\" list again before copying. Copying never\nclears a `[Needs proof: …]` marker; it travels into the codebase with the page.\n\n---\n\n## Important Rules\n\n- **Source of truth fidelity over code elegance.** When an approved mockup exists,\n  pixel-match it. If that requires `width: 312px` instead of a CSS grid class, that's\n  correct. When in plan-driven or freeform mode, the user's feedback during the\n  refinement loop is the source of truth. Code cleanup happens later during\n  component extraction.\n\n- **Always use Pretext for text layout.** Even if the design looks simple, Pretext\n  ensures correct height computation on resize. The overhead is 30KB. Every page benefits.\n\n- **Surgical edits in the refinement loop.** Use the Edit tool to make targeted changes,\n  not the Write tool to regenerate the entire file. The user may have made manual edits\n  via contenteditable that should be preserved.\n\n- **Real content, never invented proof.** When a mockup exists, extract text from it. In\n  plan-driven mode, use content from the plan. In freeform mode, write copy from the\n  user's description. Never use \"Lorem ipsum\", \"Your text here\", or placeholder content,\n  and never invent proof: a missing quote, logo or number becomes a `[Needs proof: …]`\n  marker.\n\n- **One page per invocation.** For multi-page designs, run \u002Fdesign-html once per page.\n  Each run produces one HTML file.\n\n{{include lib\u002Fsnippets\u002Faskuserquestion-split.md}}\n","If this session was compacted, the copy of this skill in context may be cut off.\nRead `${CLAUDE_SKILL_DIR}\u002FSKILL.md` from disk and resume at the step you are on.\n\n## When to invoke\n\nUse when: \"finalize this design\", \"turn this into HTML\", \"build me a page\", \"implement this design\", or after any planning skill.\n\nProactively suggest when user has approved a design or has a plan ready.\n\nFor a slide deck (\"deck\", \"slides\", or `--deck`), follow **Deck mode** below.\n\nVoice triggers (speech-to-text aliases): \"build the design\", \"code the mockup\", \"make it real\".\n\n## Preamble\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\" 2>\u002Fdev\u002Fnull || SLUG=\"unknown\"\n_LEARN_FILE=\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F${SLUG:-unknown}\u002Flearnings.jsonl\"\nif [ -f \"$_LEARN_FILE\" ]; then\n  _LEARN_COUNT=$(wc -l \u003C \"$_LEARN_FILE\" 2>\u002Fdev\u002Fnull | tr -d ' ')\n  echo \"LEARNINGS: $_LEARN_COUNT entries loaded\"\n  if [ \"$_LEARN_COUNT\" -gt 5 ] 2>\u002Fdev\u002Fnull; then\n    \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-learnings-search\" --limit 5 2>\u002Fdev\u002Fnull || true\n  fi\nelse\n  echo \"LEARNINGS: none yet\"\nfi\n```\n\n{{include lib\u002Fsnippets\u002Fsession-host.md}}\n\n{{include lib\u002Fsnippets\u002Fdecision-brief.md}}\n\n{{include lib\u002Fsnippets\u002Fworking-protocols.md}}\n\n{{include lib\u002Fsnippets\u002Fstate-protocols.md}}\n\n---\n\n# \u002Fdesign-html: Pretext-Native HTML Engine\n\nYou generate production-quality HTML where text actually works correctly. Not CSS\napproximations — computed layout via Pretext. Text reflows on resize, heights adjust\nto content, cards size themselves, chat bubbles shrinkwrap, editorial spreads flow\naround obstacles. If you find yourself faking a layout with fixed heights, magic\nnumbers, or `line-clamp`, you have left the engine behind and the output is no longer\nwhat this skill promises.\n\n## DESIGN SETUP\n\n```bash\n# Bind $D to vibe-design (OpenAI image backend) when a key is configured.\nD=${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-design\nif [ -x \"$D\" ] && [ \"$(\"$D\" status 2>\u002Fdev\u002Fnull)\" = \"DESIGN_AVAILABLE\" ]; then\n  echo \"DESIGN_AVAILABLE via $D\"\nelse\n  echo \"DESIGN_NOT_AVAILABLE\"\nfi\n```\n\nIf `DESIGN_NOT_AVAILABLE`: skip visual mockup generation and fall back to text-based design review.\n\n`$D` generates image variants — nothing else. There is no vision extractor here: when\nthis skill needs to read a mockup, you read it yourself with the Read tool. Never\ninvent a subcommand; anything other than `status` and `variants` either reports that\nit is unsupported or exits with a usage error.\n\n**CRITICAL PATH RULE:** All design artifacts (mockups,\n`approved.json`) MUST be saved under `${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F`, NEVER to\n`.context\u002F`, `docs\u002Fdesigns\u002F`, `\u002Ftmp\u002F`, or any project-local \u002F version-controlled\ndirectory. Design artifacts are USER data, not project files. The finalized HTML is\nthe exception — that is the deliverable, and it goes wherever the user asks for it.\n\n## UX Principles: How Users Actually Behave\n\nThese principles govern how real humans interact with interfaces. They are observed\nbehavior, not preferences. Apply them before, during, and after every design decision.\n\n### The Three Laws of Usability\n\n1. **Don't make me think.** Every page should be self-evident. If a user stops\n   to think \"What do I click?\" or \"What does this mean?\", the design has failed.\n   Self-evident > self-explanatory > requires explanation.\n\n2. **Clicks don't matter, thinking does.** Three mindless, unambiguous clicks\n   beat one click that requires thought. Each step should feel like an obvious\n   choice (animal, vegetable, or mineral), not a puzzle.\n\n3. **Omit, then omit again.** Get rid of half the words on each page, then get\n   rid of half of what's left. Happy talk (self-congratulatory text) must die.\n   Instructions must die. If they need reading, the design has failed.\n\n### How Users Actually Behave\n\n- **Users scan, they don't read.** Design for scanning: visual hierarchy\n  (prominence = importance), clearly defined areas, headings and bullet lists,\n  highlighted key terms. We're designing billboards going by at 60 mph, not\n  product brochures people will study.\n- **Users satisfice.** They pick the first reasonable option, not the best.\n  Make the right choice the most visible choice.\n- **Users muddle through.** They don't figure out how things work. They wing\n  it. If they accomplish their goal by accident, they won't seek the \"right\" way.\n  Once they find something that works, no matter how badly, they stick to it.\n- **Users don't read instructions.** They dive in. Guidance must be brief,\n  timely, and unavoidable, or it won't be seen.\n\n### Billboard Design for Interfaces\n\n- **Use conventions.** Logo top-left, nav top\u002Fleft, search = magnifying glass.\n  Don't innovate on navigation to be clever. Innovate when you KNOW you have a\n  better idea, otherwise use conventions. Even across languages and cultures,\n  web conventions let people identify the logo, nav, search, and main content.\n- **Visual hierarchy is everything.** Related things are visually grouped. Nested\n  things are visually contained. More important = more prominent. If everything\n  shouts, nothing is heard. Start with the assumption everything is visual noise,\n  guilty until proven innocent.\n- **Make clickable things obviously clickable.** No relying on hover states for\n  discoverability, especially on mobile where hover doesn't exist. Shape, location,\n  and formatting (color, underlining) must signal clickability without interaction.\n- **Eliminate noise.** Three sources: too many things shouting for attention\n  (shouting), things not organized logically (disorganization), and too much stuff\n  (clutter). Fix noise by removal, not addition.\n- **Clarity trumps consistency.** If making something significantly clearer\n  requires making it slightly inconsistent, choose clarity every time.\n\n### Navigation as Wayfinding\n\nUsers on the web have no sense of scale, direction, or location. Navigation\nmust always answer: What site is this? What page am I on? What are the major\nsections? What are my options at this level? Where am I? How can I search?\n\nPersistent navigation on every page. Breadcrumbs for deep hierarchies.\nCurrent section visually indicated. The \"trunk test\": cover everything except\nthe navigation. You should still know what site this is, what page you're on,\nand what the major sections are. If not, the navigation has failed.\n\n### The Goodwill Reservoir\n\nUsers start with a reservoir of goodwill. Every friction point depletes it.\n\n**Deplete faster:** Hiding info users want (pricing, contact, shipping). Punishing\nusers for not doing things your way (formatting requirements on phone numbers).\nAsking for unnecessary information. Putting sizzle in their way (splash screens,\nforced tours, interstitials). Unprofessional or sloppy appearance.\n\n**Replenish:** Know what users want to do and make it obvious. Tell them what they\nwant to know upfront. Save them steps wherever possible. Make it easy to recover\nfrom errors. When in doubt, apologize.\n\n### Mobile: Same Rules, Higher Stakes\n\nAll the above applies on mobile, just more so. Real estate is scarce, but never\nsacrifice usability for space savings. Affordances must be VISIBLE: no cursor\nmeans no hover-to-discover. Touch targets must be big enough (44px minimum).\nFlat design can strip away useful visual information that signals interactivity.\nPrioritize ruthlessly: things needed in a hurry go close at hand, everything\nelse a few taps away with an obvious path to get there.\n\n## SETUP\n\n{{include lib\u002Fsnippets\u002Fbrowse-detect.md}}\n\n## Step 0: Input Detection\n\nDetect what design context exists for this project. Run all four checks — each is a\nfresh shell, so each derives the project slug itself:\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\nsetopt +o nomatch 2>\u002Fdev\u002Fnull || true\n_CEO=$(ls -t \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fceo-plans\u002F\"*.md 2>\u002Fdev\u002Fnull | head -1)\n[ -n \"$_CEO\" ] && echo \"CEO_PLAN: $_CEO\" || echo \"NO_CEO_PLAN\"\n```\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\nsetopt +o nomatch 2>\u002Fdev\u002Fnull || true\n_APPROVED=$(ls -t \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F\"*\u002Fapproved.json 2>\u002Fdev\u002Fnull | head -1)\n[ -n \"$_APPROVED\" ] && echo \"APPROVED: $_APPROVED\" || echo \"NO_APPROVED\"\n```\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\nsetopt +o nomatch 2>\u002Fdev\u002Fnull || true\n_VARIANTS=$(ls -t \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F\"*\u002Fvariant-*.png 2>\u002Fdev\u002Fnull | head -1)\n[ -n \"$_VARIANTS\" ] && echo \"VARIANTS: $_VARIANTS\" || echo \"NO_VARIANTS\"\n```\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\nsetopt +o nomatch 2>\u002Fdev\u002Fnull || true\n_FINALIZED=$(ls -t \"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F\"*\u002Ffinalized.html 2>\u002Fdev\u002Fnull | head -1)\n[ -n \"$_FINALIZED\" ] && echo \"FINALIZED: $_FINALIZED\" || echo \"NO_FINALIZED\"\n[ -f DESIGN.md ] && echo \"DESIGN_MD: exists\" || echo \"NO_DESIGN_MD\"\n```\n\nNow route based on what was found. Check these cases in order:\n\n### Case A: approved.json exists (design-shotgun ran)\n\nIf `APPROVED` was found, read it. Extract: the approved image, user feedback, screen\nname. The approved image is the file the record's `approved_path` names. An older\nrecord without `approved_path` points at `variant-\u003Capproved_variant>.png` in the\ndirectory that holds `approved.json`. If that file does not exist, stop and tell the\nuser the approved image is gone and they need to reselect with \u002Fdesign-shotgun; never\nsubstitute another variant. Also read the CEO plan if one exists (it adds strategic\ncontext).\n\nRead `DESIGN.md` if it exists in the repo root. These tokens take priority for\nsystem-level values (fonts, brand colors, spacing scale).\n\nThen check for prior finalized.html. If `FINALIZED` was also found, use AskUserQuestion:\n> Found a prior finalized HTML from a previous session. Want to evolve it\n> (apply new changes on top, preserving your custom edits) or start fresh?\n> A) Evolve — iterate on the existing HTML\n> B) Start fresh — regenerate from the approved mockup\n\nIf evolve: read the existing HTML. Apply changes on top during Step 3.\nIf fresh or no finalized.html: proceed to Step 1 with the approved PNG as the\nvisual reference.\n\n### Case B: CEO plan and\u002For design variants exist, but no approved.json\n\nIf `CEO_PLAN` or `VARIANTS` was found but no `APPROVED`:\n\nRead whichever context exists:\n- If CEO plan found: read it and summarize the product vision and design requirements.\n- If variant PNGs found: show them inline using the Read tool.\n- If DESIGN.md found: read it for design tokens and constraints.\n\nUse AskUserQuestion:\n> Found [CEO plan from \u002Fplan-ceo-review | design review variants from \u002Fplan-design-review | both]\n> but no approved design mockup.\n> A) Run \u002Fdesign-shotgun — explore design variants based on the existing plan context\n> B) Skip mockups — I'll design the HTML directly from the plan context\n> C) I have a PNG — let me provide the path\n\nIf A: tell the user to run \u002Fdesign-shotgun, then come back to \u002Fdesign-html.\nIf B: proceed to Step 1 in \"plan-driven mode.\" There is no approved PNG, the plan is\nthe source of truth. Ask the user for a screen name to use for the output directory\n(e.g., \"landing-page\", \"dashboard\", \"pricing\").\nIf C: accept a PNG file path from the user and proceed with that as the reference.\n\n### Case C: Nothing found (clean slate)\n\nIf none of the above produced any context:\n\nUse AskUserQuestion:\n> No design context found for this project. How do you want to start?\n> A) Run \u002Fplan-ceo-review first — think through the product strategy before designing\n> B) Run \u002Fplan-design-review first — design review with visual mockups\n> C) Run \u002Fdesign-shotgun — jump straight to visual design exploration\n> D) Just describe it — tell me what you want and I'll design the HTML live\n\nIf A, B, or C: tell the user to run that skill, then come back to \u002Fdesign-html.\nIf D: proceed to Step 1 in \"freeform mode.\" Ask the user for a screen name.\n\n### Context summary\n\nAfter routing, output a brief context summary:\n- **Mode:** approved-mockup | plan-driven | freeform | evolve\n- **Visual reference:** path to approved PNG, or \"none (plan-driven)\" or \"none (freeform)\"\n- **CEO plan:** path or \"none\"\n- **Design tokens:** \"DESIGN.md\" or \"none\"\n- **Screen name:** from approved.json, user-provided, or inferred from CEO plan\n\n---\n\n## Step 1: Design Analysis\n\n1. Read the approved PNG inline using the Read tool and build the implementation\n   spec from it yourself: colors as hex, typography (family, weights, scale), layout\n   structure, and a component inventory. Where the image is ambiguous — an exact hex,\n   a font family you cannot name — say so and take the value from DESIGN.md or the\n   plan rather than guessing a number that will look authoritative and be wrong.\n\n2. If in plan-driven or freeform mode (no approved PNG), design from context:\n   - **Plan-driven:** read the CEO plan and\u002For design review notes. Extract the described\n     UI requirements, user flows, target audience, visual feel (dark\u002Flight, dense\u002Fspacious),\n     content structure (hero, features, pricing, etc.), and design constraints. Build an\n     implementation spec from the plan's prose rather than a visual reference.\n   - **Freeform:** use AskUserQuestion to gather what the user wants to build. Ask about:\n     purpose\u002Faudience, visual feel (dark\u002Flight, playful\u002Fserious, dense\u002Fspacious),\n     content structure (hero, features, pricing, etc.), and any reference sites they like.\n   In both cases, describe the intended visual layout, colors, typography, and\n   component structure as your implementation spec. Write real copy from the plan or\n   the user's description (never lorem ipsum); proof comes only from the user, under\n   the craft floor below.\n\n3. Read `DESIGN.md` tokens. These override any extracted values for system-level\n   properties (brand colors, font family, spacing scale).\n\n4. When `approved.json` carries `archetype` and `sections`, the user already chose the\n   page's structure in \u002Fdesign-shotgun: build that archetype with those sections in\n   that order, and do not re-pick the archetype or ask about it under Persuade pages.\n\n5. Output an \"Implementation spec\" summary: colors (hex), fonts (family + weights),\n   spacing scale, component list, layout type.\n\n{{include lib\u002Fsnippets\u002Fdesign-craft-floor.md}}\n\n### Persuade pages\n\nWhen the page exists to make a visitor decide and act (landing, pricing, launch,\nwaitlist), settle these before writing markup:\n\n- **Surface line.** Open the spec with `Surface: PERSUADE — \u003Cwho visits> decides \u003Cwhat>`.\n- **Intake.** Ask at most three questions, in one AskUserQuestion, and only what the\n  plan or mockup leaves open: who the visitor is and what stops them, the one action\n  you want, and what proof the user can actually supply.\n- **Archetype.** Pick one archetype for the page's structure — `classic-hero` (show\n  the product working), `long-form-story` (problem then outcome), `comparison` (compare\n  and price) or `minimal-conversion` (a short launch\u002Fwaitlist page), the ids\n  \u002Fdesign-shotgun writes —\n  and say in one line why it fits this visitor — unless `approved.json` already\n  names one (Step 1, item 4). The hero still holds to one headline, one supporting\n  line, one action group.\n- **Primary action.** One named action with default, hover and focus states, and,\n  when the action submits data (a form, a signup, a purchase), also **invalid** (a message beside the field that names the fix), **pending**\n  (disabled, with a progress label), **failure** (what went wrong, the input kept,\n  a retry), and **success** (what happens next).\n- **Index decision.** `index` for a public page meant to be found, `noindex` for a\n  preview, campaign variant or unlaunched page, set with `\u003Cmeta name=\"robots\">` and\n  listed in the hand-off.\n\n---\n\n## Step 2: Smart Pretext API Routing\n\nAnalyze the approved design and classify it into a Pretext tier. Each tier uses\ndifferent Pretext APIs for optimal results:\n\n| Design type | Pretext APIs | Use case |\n|-------------|-------------|----------|\n| Simple layout (landing, marketing) | `prepare()` + `layout()` | Resize-aware heights |\n| Card\u002Fgrid (dashboard, listing) | `prepare()` + `layout()` | Self-sizing cards |\n| Chat\u002Fmessaging UI | `prepareWithSegments()` + `walkLineRanges()` | Tight-fit bubbles, min-width |\n| Content-heavy (editorial, blog) | `prepareWithSegments()` + `layoutNextLine()` | Text around obstacles |\n| Complex editorial | Full engine + `layoutWithLines()` | Manual line rendering |\n\nState the chosen tier and why. Reference the specific Pretext APIs that will be used.\n\n---\n\n## Step 2.5: Framework Detection\n\nCheck if the user's project uses a frontend framework:\n\n```bash\n[ -f package.json ] && cat package.json | grep -o '\"react\"\\|\"svelte\"\\|\"vue\"\\|\"@angular\u002Fcore\"\\|\"solid-js\"\\|\"preact\"' | head -1 || echo \"NONE\"\n```\n\nIf a framework is detected, use AskUserQuestion:\n> Detected [React\u002FSvelte\u002FVue] in your project. What format should the output be?\n> A) Vanilla HTML — self-contained preview file (recommended for first pass)\n> B) [React\u002FSvelte\u002FVue] component — framework-native with Pretext hooks\n\nIf the user chooses framework output, ask one follow-up:\n> A) TypeScript\n> B) JavaScript\n\nFor vanilla HTML: proceed to Step 3 with vanilla output.\nFor framework output: proceed to Step 3 with framework-specific patterns.\nIf no framework detected: default to vanilla HTML, no question needed.\n\n---\n\n## Step 3: Generate Pretext-Native HTML\n\n### Pretext Source Embedding\n\nFor **vanilla HTML output**: no Pretext bundle ships with this skill, so the page\nimports Pretext from the CDN as an ES module. Pretext is ESM-only and sets no global,\nso the import and all page code that calls it go in the same `\u003Cscript type=\"module\">`.\nThe import pins an exact version, so a later release cannot change a page that already\nworks:\n```html\n\u003Cscript type=\"module\">\n  import { prepare, layout, prepareWithSegments, walkLineRanges, layoutNextLine, layoutWithLines } from 'https:\u002F\u002Fesm.sh\u002F@chenglou\u002Fpretext@0.0.9'\n  \u002F\u002F page code (the wiring patterns below) goes here, after the import\n\u003C\u002Fscript>\n```\nTell the user the page needs the network to lay itself out: on an offline machine or\nbehind a CSP that blocks esm.sh it renders unlaid-out. If they need a fully\nself-contained file, they install `@chenglou\u002Fpretext` in their own project and use\nframework output (or their bundler) instead.\n\nFor **framework output**, add to the project's dependencies instead:\n```bash\n# Detect package manager\n[ -f bun.lockb ] && echo \"bun add @chenglou\u002Fpretext\" || \\\n[ -f pnpm-lock.yaml ] && echo \"pnpm add @chenglou\u002Fpretext\" || \\\n[ -f yarn.lock ] && echo \"yarn add @chenglou\u002Fpretext\" || \\\necho \"npm install @chenglou\u002Fpretext\"\n```\nRun the detected install command. Then use standard imports in the component.\n\n### HTML Generation\n\nResolve the output directory first (fill in `\u003Cscreen-name>`):\n\n```bash\neval \"$(\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fbin\u002Fvibe-slug\" 2>\u002Fdev\u002Fnull)\"\n_DESIGN_DIR=\"${VIBESTACK_HOME:-$HOME\u002F.vibestack}\u002Fprojects\u002F$SLUG\u002Fdesigns\u002F\u003Cscreen-name>-$(date +%Y%m%d)\"\nmkdir -p \"$_DESIGN_DIR\"\necho \"DESIGN_DIR: $_DESIGN_DIR\"\n```\n\nWrite a single file using the Write tool. Save to `\u003CDESIGN_DIR>\u002Ffinalized.html`,\nwhere `\u003CDESIGN_DIR>` is the path the block printed on its `DESIGN_DIR:` line.\n\nFor framework output, save to `\u003CDESIGN_DIR>\u002Ffinalized.[tsx|svelte|vue]`.\n\n**Always include in vanilla HTML:**\n- Pretext imported from esm.sh in a `\u003Cscript type=\"module\">` (see above)\n- CSS custom properties for design tokens from DESIGN.md \u002F Step 1 extraction\n- Google Fonts via `\u003Clink>` tags + `document.fonts.ready` gate before first `prepare()`\n- Semantic HTML5 (`\u003Cheader>`, `\u003Cnav>`, `\u003Cmain>`, `\u003Csection>`, `\u003Cfooter>`)\n- Responsive behavior via Pretext relayout (not just media queries)\n- Breakpoint-specific adjustments at 375px, 768px, 1024px, 1440px\n- ARIA attributes, heading hierarchy, focus-visible states\n- `contenteditable` on text elements + MutationObserver to re-prepare + re-layout on edit\n- ResizeObserver on containers to re-layout on resize\n- `prefers-color-scheme` media query for dark mode\n- `prefers-reduced-motion` for animation respect\n- Real content extracted from the mockup (never lorem ipsum)\n\n**Never include by default** (AI slop blacklist):\nAn approved mockup that shows one, a DESIGN.md that chose it, or an explicit user request overrides the list: build it and state the tradeoff once.\n- Purple\u002Fblue gradients as default\n- Generic 3-column feature grids\n- Center-everything layouts with no visual hierarchy\n- Decorative blobs, waves, or geometric patterns not in the mockup\n- Stock photo placeholder divs\n- \"Get Started\" \u002F \"Learn More\" generic CTAs not from the mockup\n- Rounded-corner cards with drop shadows as the default component\n- Emoji as visual elements\n- Generic testimonial sections\n- Cookie-cutter hero sections with left-text right-image\n- Gradient buttons as the primary CTA pattern\n- A colored left border on cards; a card nested inside a card\n- Glowing edges, radial halos or spotlight glows on dark surfaces\n- Gradient text as emphasis; headings within a step of body size\n- A pill-shaped label or kicker floating above the hero headline\n- Frosted-glass panels as the default surface\n\n### Pretext Wiring Patterns\n\nUse these patterns based on the tier selected in Step 2. These are the correct\nPretext API usage patterns. Follow them exactly. The imports below are for framework\noutput; in vanilla HTML, import the same names from `'https:\u002F\u002Fesm.sh\u002F@chenglou\u002Fpretext@0.0.9'`\nonce, at the top of the page's `\u003Cscript type=\"module\">`.\n\n**Pattern 1: Basic height computation (Simple layout, Card\u002Fgrid)**\n```js\nimport { prepare, layout } from '@chenglou\u002Fpretext'\n\n\u002F\u002F 1. PREPARE — one-time, after fonts load\nawait document.fonts.ready\nconst elements = document.querySelectorAll('[data-pretext]')\nconst prepared = new Map()\n\nfor (const el of elements) {\n  const text = el.textContent\n  const font = getComputedStyle(el).font\n  prepared.set(el, prepare(text, font))\n}\n\n\u002F\u002F 2. LAYOUT — cheap, call on every resize\nfunction relayout() {\n  for (const [el, handle] of prepared) {\n    const { height } = layout(handle, el.clientWidth, parseFloat(getComputedStyle(el).lineHeight))\n    el.style.height = `${height}px`\n  }\n}\n\n\u002F\u002F 3. RESIZE-AWARE\nnew ResizeObserver(() => relayout()).observe(document.body)\nrelayout()\n\n\u002F\u002F 4. CONTENT-EDITABLE — re-prepare when text changes\nfor (const el of elements) {\n  if (el.contentEditable === 'true') {\n    new MutationObserver(() => {\n      const font = getComputedStyle(el).font\n      prepared.set(el, prepare(el.textContent, font))\n      relayout()\n    }).observe(el, { characterData: true, subtree: true, childList: true })\n  }\n}\n```\n\n**Pattern 2: Shrinkwrap \u002F tight-fit containers (Chat bubbles)**\n```js\nimport { prepareWithSegments, walkLineRanges } from '@chenglou\u002Fpretext'\n\n\u002F\u002F Tight-fit width: lay out at maxWidth, then shrink the bubble to its widest line\nfunction shrinkwrap(text, font, maxWidth) {\n  const segs = prepareWithSegments(text, font)\n  let widest = 0\n  const lineCount = walkLineRanges(segs, maxWidth, (line) => {\n    widest = Math.max(widest, line.width)\n  })\n  return { width: Math.ceil(widest), lineCount }\n}\n```\n\n**Pattern 3: Text around obstacles (Editorial layout)**\n```js\nimport { prepareWithSegments, layoutNextLine } from '@chenglou\u002Fpretext'\n\nfunction layoutAroundObstacles(text, font, containerWidth, lineHeight, obstacles) {\n  const segs = prepareWithSegments(text, font)\n  let cursor = { segmentIndex: 0, graphemeIndex: 0 }\n  let y = 0\n  const lines = []\n\n  while (true) {\n    \u002F\u002F Calculate available width at current y position, accounting for obstacles\n    let availWidth = containerWidth\n    for (const obs of obstacles) {\n      if (y >= obs.top && y \u003C obs.top + obs.height) {\n        availWidth -= obs.width\n      }\n    }\n\n    const result = layoutNextLine(segs, cursor, availWidth)\n    if (!result) break\n\n    lines.push({ text: result.text, width: result.width, x: 0, y })\n    cursor = result.end\n    y += lineHeight\n  }\n\n  return { lines, totalHeight: y }\n}\n```\n\n**Pattern 4: Full line-by-line rendering (Complex editorial)**\n```js\nimport { prepareWithSegments, layoutWithLines } from '@chenglou\u002Fpretext'\n\nconst segs = prepareWithSegments(text, font)\nconst { lines, height } = layoutWithLines(segs, containerWidth, lineHeight)\n\n\u002F\u002F lines = [{ text, width, start, end }, ...] (no x\u002Fy: line i sits at y = i * lineHeight)\n\u002F\u002F Use for Canvas\u002FSVG rendering or custom DOM positioning\nlines.forEach((line, i) => {\n  const span = document.createElement('span')\n  span.textContent = line.text\n  span.style.position = 'absolute'\n  span.style.left = '0px'\n  span.style.top = `${i * lineHeight}px`\n  container.appendChild(span)\n})\n```\n\n### Pretext API Reference\n\n```\nPRETEXT API CHEATSHEET:\n\nprepare(text, font) → handle\n  One-time text measurement. Call after document.fonts.ready.\n  Font: CSS shorthand like '16px Inter' or 'bold 24px Georgia'.\n\nlayout(prepared, maxWidth, lineHeight) → { height, lineCount }\n  Fast layout computation. Call on every resize. Sub-millisecond.\n\nprepareWithSegments(text, font) → handle\n  Like prepare() but enables line-level APIs below.\n\nlayoutWithLines(segs, maxWidth, lineHeight) → { lineCount, height, lines: [{text, width, start, end}...] }\n  Full line-by-line breakdown (no x\u002Fy: line i is at y = i * lineHeight). For Canvas\u002FSVG rendering.\n\nwalkLineRanges(segs, maxWidth, onLine) → lineCount\n  Calls onLine({ width, start, end }) once per line at maxWidth (no text built).\n  The widest line's width is the tight-fit container width. For chat bubbles.\n\nlayoutNextLine(segs, cursor, maxWidth) → { text, width, start, end } | null\n  Iterator. Different maxWidth per line = text around obstacles.\n  Start with cursor { segmentIndex: 0, graphemeIndex: 0 }; pass result.end next.\n  Returns null when text is exhausted. Takes no lineHeight: advance y yourself.\n\nclearCache() → void\n  Clears internal measurement caches. Use when cycling many fonts.\n\nsetLocale(locale?) → void\n  Retargets word segmenter for future prepare() calls.\n```\n\n---\n\n## Step 3.5: Live Reload Server\n\nAfter writing the HTML file, start a simple HTTP server for live preview:\n\n```bash\n# Start a simple HTTP server in the output directory\n_OUTPUT_DIR=$(dirname \u003Cpath-to-finalized.html>)\ncd \"$_OUTPUT_DIR\"\npython3 -I -m http.server 0 --bind 127.0.0.1 &\n_SERVER_PID=$!\n# The server needs a moment to bind; wait for its listening socket before reading the port.\n_PORT=\"\"\nfor _i in 1 2 3 4 5 6 7 8 9 10; do\n  _PORT=$(lsof -a -p \"$_SERVER_PID\" -iTCP -sTCP:LISTEN -P -n -Fn 2>\u002Fdev\u002Fnull | sed -n 's\u002F^n.*:\\([0-9][0-9]*\\)$\u002F\\1\u002Fp' | head -1)\n  [ -n \"$_PORT\" ] && break\n  sleep 0.2\ndone\n[ -n \"$_PORT\" ] || { echo \"SERVER_FAILED: no listening port after 2s\" >&2; kill \"$_SERVER_PID\" 2>\u002Fdev\u002Fnull; exit 1; }\necho \"SERVER: http:\u002F\u002F127.0.0.1:$_PORT\u002Ffinalized.html\"\necho \"PID: $_SERVER_PID\"\n```\n\nRemember the printed `SERVER:` URL and `PID:` value. Each bash block is a fresh\nshell, so `$_PORT` and `$_SERVER_PID` are empty in later blocks: restate the URL and\nPID literally wherever they are needed.\n\nIf python3 is not available, fall back to:\n```bash\nopen \u003Cpath-to-finalized.html>\n```\n\nTell the user: \"Live preview running at \u003CSERVER URL>.\nAfter each edit, just refresh the browser (Cmd+R) to see changes.\"\n\nWhen the refinement loop ends (Step 4 exits), kill the server:\n```bash\nkill \u003CPID> 2>\u002Fdev\u002Fnull || true\n```\n\n---\n\n## Step 4: Preview + Refinement Loop\n\n### Verification Screenshots\n\nIf SETUP printed `BROWSE_AVAILABLE`, take verification screenshots at 3 viewports.\n`screenshot` has no width flag, so set the viewport before each capture. Load the\npage through the live-reload server's `SERVER:` URL (not `file:\u002F\u002F`), so the module\nimport and relative assets resolve. This is a fresh shell, so replace `\u003CBROWSE_BIN>`\nwith the path SETUP printed on its `BROWSE_BIN:` line:\n\n```bash\nB='\u003CBROWSE_BIN>'\n$B goto \"\u003CSERVER URL>\"\n$B viewport 375x812\n$B screenshot \u002Ftmp\u002Fvibestack-verify-mobile.png\n$B viewport 768x1024\n$B screenshot \u002Ftmp\u002Fvibestack-verify-tablet.png\n$B viewport 1440x900\n$B screenshot \u002Ftmp\u002Fvibestack-verify-desktop.png\n```\n\nIf the live-reload server is not running (no python3), skip the screenshots rather\nthan pointing the browser at a `file:\u002F\u002F` path.\n\nShow all three screenshots inline using the Read tool. Check for:\n- Text overflow (text cut off or extending beyond containers)\n- Layout collapse (elements overlapping or missing)\n- Responsive breakage (content not adapting to viewport)\n\nIf issues are found, note them and fix before presenting to the user.\n\nIf SETUP printed `BROWSE_NOT_AVAILABLE`, skip verification and note:\n\"Browse binary not available. Skipping automated viewport verification.\"\n\n### Refinement Loop\n\n```\nLOOP:\n  1. If server is running, tell user to open the printed `SERVER:` URL\n     Otherwise: open \u003Cpath>\u002Ffinalized.html\n\n  2. If an approved mockup PNG exists, show it inline (Read tool) for visual comparison.\n     If in plan-driven or freeform mode, skip this step.\n\n  3. AskUserQuestion (adjust wording based on mode):\n     With mockup: \"The HTML is live in your browser. Here's the approved mockup for comparison.\n      Try: resize the window (text should reflow dynamically),\n      click any text (it's editable, layout recomputes instantly).\n      What needs to change? Say 'done' when satisfied.\"\n     Without mockup: \"The HTML is live in your browser. Try: resize the window\n      (text should reflow dynamically), click any text (it's editable, layout\n      recomputes instantly). What needs to change? Say 'done' when satisfied.\"\n\n  4. If \"done\" \u002F \"ship it\" \u002F \"looks good\" \u002F \"perfect\" → print the craft floor's\n     \"Before this can ship\" list, exit loop, go to Step 5\n\n  5. Apply feedback using targeted Edit tool changes on the HTML file\n     (do NOT regenerate the entire file — surgical edits only)\n\n  6. Brief summary of what changed (2-3 lines max)\n\n  7. If verification screenshots are available, re-take them to confirm the fix\n\n  8. Go to LOOP\n```\n\nMaximum 10 iterations. If the user hasn't said \"done\" after 10, use AskUserQuestion:\n\"We've done 10 rounds of refinement. Want to continue iterating or call it done?\"\n\n---\n\n## Deck mode\n\nDeck mode is explicit and never the default path. Enter it only when the input is a\nslide deck, the user says \"deck\" or \"slides\", or passes `--deck`. Otherwise build a\npage as above. In deck mode, Steps 0-3.5 still apply (input detection, design tokens,\noutput path, live-reload server); this section replaces the page structure and the\nStep 4 verification screenshots. Of the craft floor, a deck keeps the title and meta\ndescription, the favicon, alt text, real links, and the proof, honesty and scale rules;\nthe header\u002Fnav\u002Ffooter landmarks, the skip link, `aria-current` and inline form errors do\nnot apply to a deck (one `\u003Cmain>`, no navigation, no forms).\n\n**Structure:**\n- One `\u003Csection class=\"slide\">` per slide inside `\u003Cmain>`, each `height: 100dvh`\n  (with a `height: 100vh` line before it for older browsers).\n- Keyboard (ArrowLeft\u002FArrowRight, PageUp\u002FPageDown, Space, Home\u002FEnd), wheel and touch\n  navigation between slides, plus a visible slide index.\n- Under `prefers-reduced-motion: reduce`, slide changes jump instead of animating:\n  no smooth scrolling, no reveal transitions.\n- Type and spacing scale with `clamp()` (for example\n  `font-size: clamp(1rem, 0.6rem + 1.6vw, 2.5rem)`), never below a readable size.\n\n**Density heuristics** (a starting point for splitting content, not the gate):\n\n| Slide type | Heuristic |\n|------------|-----------|\n| Title | 1 heading + 1 line |\n| Content | 1 heading + 4-6 bullets |\n| Code | 8-10 lines |\n| Grid | at most 6 cells |\n\n**The viewport-fit gate.** At 1920×1080, 1280×720 and 375×667, every slide must pass\n`scrollHeight \u003C= clientHeight`, checked with `$B js`. A slide that fails is split into\ntwo slides, then the gate runs again; never clip it with `overflow: hidden` or shrink\nits type below the `clamp()` minimum, since that hides the failure instead of fixing it.\n\nIf SETUP printed `BROWSE_AVAILABLE`, run the gate. As with the verification\nscreenshots, set the viewport before each capture, load the live-reload server's\n`SERVER:` URL (not `file:\u002F\u002F`), and replace `\u003CBROWSE_BIN>` with the path SETUP printed\non its `BROWSE_BIN:` line, since this is a fresh shell:\n\n```bash\nB='\u003CBROWSE_BIN>'\n$B goto \"\u003CSERVER URL>\"\n$B viewport 1920x1080\n$B js \"[...document.querySelectorAll('section.slide')].map((s, i) => s.scrollHeight \u003C= s.clientHeight ? '' : 'OVERFLOW slide ' + (i + 1) + ': ' + s.scrollHeight + ' > ' + s.clientHeight).filter(Boolean).join('; ') || 'ALL_SLIDES_FIT'\"\n$B screenshot \u002Ftmp\u002Fvibestack-deck-1920.png\n$B viewport 1280x720\n$B js \"[...document.querySelectorAll('section.slide')].map((s, i) => s.scrollHeight \u003C= s.clientHeight ? '' : 'OVERFLOW slide ' + (i + 1) + ': ' + s.scrollHeight + ' > ' + s.clientHeight).filter(Boolean).join('; ') || 'ALL_SLIDES_FIT'\"\n$B screenshot \u002Ftmp\u002Fvibestack-deck-1280.png\n$B viewport 375x667\n$B js \"[...document.querySelectorAll('section.slide')].map((s, i) => s.scrollHeight \u003C= s.clientHeight ? '' : 'OVERFLOW slide ' + (i + 1) + ': ' + s.scrollHeight + ' > ' + s.clientHeight).filter(Boolean).join('; ') || 'ALL_SLIDES_FIT'\"\n$B screenshot \u002Ftmp\u002Fvibestack-deck-375.png\n```\n\nEach `js` line prints `ALL_SLIDES_FIT` or one `OVERFLOW slide N` entry per failing\nslide. Split every listed slide and rerun the block until all three viewports print\n`ALL_SLIDES_FIT`. An empty or error result is not a pass: report the gate as not run.\nShow the three screenshots inline with the Read tool.\n\nIf SETUP printed `BROWSE_NOT_AVAILABLE`, or the live-reload server is not running,\nreport the gate as not run, text-only: list each slide with its density against the\nheuristics above and flag the ones likely to overflow. Never report the deck as fitting\nwithout the gate.\n\n---\n\n## Step 5: Save & Next Steps\n\n### Design Token Extraction\n\nIf no `DESIGN.md` exists in the repo root, offer to create one from the generated HTML:\n\nExtract from the HTML:\n- CSS custom properties (colors, spacing, font sizes)\n- Font families and weights used\n- Color palette (primary, secondary, accent, neutral)\n- Spacing scale\n- Border radius values\n- Shadow values\n\nUse AskUserQuestion:\n> No DESIGN.md found. I can extract the design tokens from the HTML we just built\n> and create a DESIGN.md for your project. This means future \u002Fdesign-shotgun and\n> \u002Fdesign-html runs will be style-consistent automatically.\n> A) Create DESIGN.md from these tokens\n> B) Skip — I'll handle the design system later\n\nIf A: write `DESIGN.md` to the repo root with the extracted tokens, in the section\nlayout \u002Fdesign-consultation writes (Typography, Color, Spacing, Layout, Motion),\nplus a **Components** section listing each component this HTML built with its\nstates (default, hover, focus, active, disabled, loading, error — only the states\nit has) and a **Do's and Don'ts** section with the concrete rules the build followed.\n\n### Save Metadata\n\nWrite `finalized.json` alongside the HTML:\n```json\n{\n  \"source_mockup\": \"\u003Capproved variant PNG path or null>\",\n  \"source_plan\": \"\u003CCEO plan path or null>\",\n  \"mode\": \"\u003Capproved-mockup|plan-driven|freeform|evolve>\",\n  \"html_file\": \"\u003Cpath to finalized.html or component file>\",\n  \"pretext_tier\": \"\u003Cselected tier>\",\n  \"framework\": \"\u003Cvanilla|react|svelte|vue>\",\n  \"iterations\": \u003Cnumber of refinement iterations>,\n  \"date\": \"\u003CISO 8601>\",\n  \"screen\": \"\u003Cscreen name>\",\n  \"branch\": \"\u003Ccurrent branch>\"\n}\n```\n\n### Next Steps\n\nUse AskUserQuestion:\n> Design finalized with Pretext-native layout. What's next?\n> A) Copy to project — copy the HTML\u002Fcomponent into your codebase\n> B) Iterate more — keep refining\n> C) Done — I'll use this as a reference\n\nIf A: print the \"Before this can ship\" list again before copying. Copying never\nclears a `[Needs proof: …]` marker; it travels into the codebase with the page.\n\n---\n\n## Important Rules\n\n- **Source of truth fidelity over code elegance.** When an approved mockup exists,\n  pixel-match it. If that requires `width: 312px` instead of a CSS grid class, that's\n  correct. When in plan-driven or freeform mode, the user's feedback during the\n  refinement loop is the source of truth. Code cleanup happens later during\n  component extraction.\n\n- **Always use Pretext for text layout.** Even if the design looks simple, Pretext\n  ensures correct height computation on resize. The overhead is 30KB. Every page benefits.\n\n- **Surgical edits in the refinement loop.** Use the Edit tool to make targeted changes,\n  not the Write tool to regenerate the entire file. The user may have made manual edits\n  via contenteditable that should be preserved.\n\n- **Real content, never invented proof.** When a mockup exists, extract text from it. In\n  plan-driven mode, use content from the plan. In freeform mode, write copy from the\n  user's description. Never use \"Lorem ipsum\", \"Your text here\", or placeholder content,\n  and never invent proof: a missing quote, logo or number becomes a `[Needs proof: …]`\n  marker.\n\n- **One page per invocation.** For multi-page designs, run \u002Fdesign-html once per page.\n  Each run produces one HTML file.\n\n{{include lib\u002Fsnippets\u002Faskuserquestion-split.md}}\n",{"name":5,"triggers":40,"description":44,"allowed-tools":45},[41,42,43],"build the design","code the mockup","make design real","Turn an approved mockup, plan or description into production-quality, reflowing HTML\u002FCSS.\n",[25,46,47,48,49,50,51,52],"Read","Write","Edit","Glob","Grep","Agent","AskUserQuestion","main","777ec643a83c17a0955856b2eb7f596601709fda","skills\u002Fdesign-html",0,"https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack","https:\u002F\u002Fgithub.com\u002Ftimurgaleev","https:\u002F\u002Ftgaleev.com\u002F","Forward Deployed Engineer \u002F\r\nAWS Community Builder \u002F Cloud Architect ","2026-11-11 15:42:25",{"source":8,"skillName":5,"commands":63,"prompt":73,"zipAvailable":74},[64,67,70],{"tool":65,"command":66},"npx","npx skills add timurgaleev\u002Fvibestack --skill design-html",{"tool":68,"command":69},"bunx","bunx skills add timurgaleev\u002Fvibestack --skill design-html",{"tool":71,"command":72},"pnpm","pnpm dlx skills add timurgaleev\u002Fvibestack --skill design-html","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack\u002Fblob\u002Fmain\u002Fskills\u002Fdesign-html\u002FSKILL.md",true,[],[77,83,89,95,101,107],{"skillNo":78,"name":79,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":35},"01M71GVHCCSQCCPVM8XPSPTA73","docs","https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Frender\u002F15-backtick-info-string\u002Fskills\u002Fdocs\u002FSKILL.md",[],[79],{"skillNo":84,"name":85,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":35},"01M71GVFT1S5MRNM0AYRT2E6VQ","fences","https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Frender\u002F14-indented-tilde-fence\u002Fskills\u002Ffences\u002FSKILL.md",[],[85],{"skillNo":90,"name":91,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":35},"01M71GVEYB54K1S83FGRNKN8CF","dirty","https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Frender\u002F10-check-with-drift\u002Fskills\u002Fdirty\u002FSKILL.md",[],[91],{"skillNo":96,"name":97,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":35},"01M71GVDX9PMND1337C4388DK4","clean","https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Frender\u002F09-check-no-drift\u002Fskills\u002Fclean\u002FSKILL.md",[],[97],{"skillNo":102,"name":103,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":35},"01M71GVC3VM66F1ZQT2G8JXDR0","bare","https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Frender\u002F08-no-frontmatter\u002Fskills\u002Fbare\u002FSKILL.md",[],[103],{"skillNo":108,"name":109,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":35},"01M71GV9T8DAYZT0PX52QX0TE1","idem","https:\u002F\u002Fgithub.com\u002Ftimurgaleev\u002Fvibestack\u002Fblob\u002Fmain\u002Ftest\u002Ffixtures\u002Frender\u002F07-idempotent-rerender\u002Fskills\u002Fidem\u002FSKILL.md",[],[109]]