| Copy first |
“If the codebase you’re in already has working prototypes, open a similar one and copy its approach — verified working code beats anything you remember.” Especially model names and API details, “which both humans and models hallucinate” |
| The one hard constraint |
“One .html file = the whole app”: one <style>, one <script>, no build, no npm, no framework; vanilla JS and hand-written CSS with design tokens. Supporting files only as “optional plumbing” |
| Requirements triage |
Four tiers to settle before writing code, told to the user in plain language: 0, just a file; 1, static server (the default); 2, local proxy (~100-line Node script, for APIs without CORS); 3, cloud worker (public media URLs or away from localhost). “A surprise ‘blocked by CORS policy’ error at run time is how prototypes die” |
| Working with a non-technical user |
Open with a “what you’ll need” list; keys entered in a settings modal and kept in localStorage, never baked in; humanise every error; show plumbing status (a /health pill); make the exact request visible in a debug view; ship two sibling files for either/or interaction questions |
| House style |
A fixed file anatomy and banner-commented script order (STATE, ELEMENTS, UTILITIES, SETTINGS, features, INIT). One mutable state object exposed on window; :root design tokens with “its own palette and font personality”; a status trio (toast, status pill with elapsed timer, log panel); buttons that narrate; shared localStorage key names across sibling prototypes so keys are entered once |
| Dependencies: the loading ladder |
Zero dependencies by default, then pinned ESM from a CDN (“always pin the version”), import maps, classic scripts, and lazy import() for heavy libraries. “Prefer boring… hand-rolled beats clever when the file must survive being remixed” |
| Talking to AI APIs |
Async create-and-poll with a timeout that reports the job ID “so the user’s work (and money) isn’t lost”; schema-based structured output plus fence-stripping; media payload limits; “Every API has quirks.” “Cheap draft → expensive final” is “the strongest product pattern in this practice”; “prompt engineering lives in code” (template constants, composePrompt(), a live preview) |
| The proxy |
~65 lines of zero-dependency Node; “never holds keys” (forwards the browser’s own Authorization header); answers preflight itself; can be promoted to a Cloudflare worker with setup instructions in its header comment |
| Media techniques |
Canvas to video via MediaRecorder, downloads, drag-drop upload, crossOrigin for canvas reads, timeline and drag UIs with pointer capture, virtual trimming, webcam/mic input (“voice-input-as-prompt… is a reliably delightful feature”) |
| Shipping |
Descriptive hyphenated filenames with remixes beside originals; a hand-edited directory page with a “needs local plumbing” flag; a README per batch; “the browser is the test” |