wcygan.net Demo Replication
Replicate one external demo at a time. The strategy is source-first: read
the real rendered demo in a testing browser before writing code, and let the
frame trace decide the representation — reimplement from scratch only when the
demo's own artifact cannot be vendored.
Load $wcygan-editorial-diagrams for the article shell, figure contract, and
verification bar. Load $agent-browser for the rendered work on both sides —
tracing the source and verifying the copy. Load $wcygan-demo-migrations when
replacing a first-pass demo that already exists in the repository.
Steps
- Fetch the source page.
read the URL for prose and structure. Note
which section carries the demo. Completion: the demo's hosting mechanism
(iframe, inline component) is named, or confirmed absent.
- Trace to the demo surface. If the prose references an iframe, fetch its
src from the raw HTML and load that iframe URL directly in the browser —
the parent page adds chrome and scroll. The iframe HTML is usually a thin
Vite loader pointing at one JS bundle. Completion: the demo runs on screen
in the testing browser.
- Frame trace. Capture a dense burst across a full run — one screenshot
every ~60ms for 20–30s — then step through frames at ~1s intervals. Read
each frame as an image. Extract the inventory: layout, columns, box colors
per state, typography, fill/flash animations, staircase or queue geometry,
the decisive transition, the end state, and the restart behavior.
Completion: every visual phase, including the decisive one, is observed —
none inferred.
- Inspect the running DOM. Evaluate
outerHTML on the demo root while it
runs. The rendered structure names the real technology (runtime-built SVG
with clipPaths, canvas, DOM). Grep the served bundle for the constants the
DOM cannot show: palette objects, query strings, state labels, timing
constants, and the state machine. Completion: exact colors, states,
timings, and content strings are extracted — not eyeballed.
- Choose the representation. Vendor when the demo ships as a
self-contained bundle and the user accepts the dependency; reimplement
under
$wcygan-editorial-diagrams when the lesson must be re-taught in the
editorial system or the bundle cannot be reused. State the choice and
reason before building. Completion: the decision is recorded.
- Build.
- Vendor: download the bundle, polyfill, and stylesheet into
public/<post-slug>/vendor/, write a local index.html shell mirroring
the source's (fonts, #app mount), and embed it through an iframe
wrapper component that carries the editorial figure shell, aspect-ratio
switching from measured stage width, and a Replay control that resets
iframe.src. Keep source attribution in the figcaption.
- Reimplement: deterministic model in
src/demos/<name>/, component,
CSS class family in src/styles/app.css, accessibility text, reduced
motion, per the editorial contract.
- Verify by diff against the trace. Render the copy, capture the same
phases traced in step 3, and compare frame by frame. Run model tests,
typecheck, and the repository gate when reimplementing; run the gate when
vendoring. Completion: copy frames show the source's phases, and the
checks pass.
Gotchas
- Spawn Chrome for Testing from the Playwright cache directly
(
--no-first-run); the relay may engage when a plain open fails.
- CDP
Page.startScreencast emits zero frames in this setup; a tight
page.screenshot loop is the working capture path (~60ms per frame).
- One browser
run call times out at 30s and kills the tab. Chunk long
traces: schedule captures at fixed offsets from a Replay click, several
calls per trace.
- Confirm viewport geometry from the screenshot's own dimensions; an
open
viewport may not stick, and re-apply it with page.setViewport.
- Demos that restart on their own make a missed phase a timing problem, not a
bug: re-run with captures centered on the phase's window.
- Dense capture can freeze the page's animation frames; if consecutive frames
are identical while the demo should be moving, re-run the trace with
spacing between captures.
Reference
- Lock-queue case study — the full
end-to-end trace of replicating the PlanetScale stuck-database demo: three
passes from prose-built to vendored, with the exact commands, extractions,
and frame evidence.
Once a demo is accepted, its bundle graduates into
$planet-scale-animation-design-system (assets/, sync script, token and
renderer inventory); embed new posts from that skill's published copies
rather than a post-local vendor directory.
1---2name: wcygan-demo-replication3description: Replicate an external interactive demo or visualization on wcygan.net. Use when the user asks to copy, replicate, or reimplement a demo from a blog post, product page, or documentation; when a page embeds its demo in an iframe; when a first-pass reimplementation does not match the source's styling or animations; or when a demo's runtime artifact (rendered SVG, JS bundle) could be vendored instead of rebuilt.4---56# wcygan.net Demo Replication78Replicate one external demo at a time. The strategy is **source-first**: read9the real rendered demo in a testing browser before writing code, and let the10frame trace decide the representation — reimplement from scratch only when the11demo's own artifact cannot be vendored.1213Load `$wcygan-editorial-diagrams` for the article shell, figure contract, and14verification bar. Load `$agent-browser` for the rendered work on both sides —15tracing the source and verifying the copy. Load `$wcygan-demo-migrations` when16replacing a first-pass demo that already exists in the repository.1718## Steps19201. **Fetch the source page.** `read` the URL for prose and structure. Note21 which section carries the demo. Completion: the demo's hosting mechanism22 (iframe, inline component) is named, or confirmed absent.232. **Trace to the demo surface.** If the prose references an iframe, fetch its24 `src` from the raw HTML and load that iframe URL directly in the browser —25 the parent page adds chrome and scroll. The iframe HTML is usually a thin26 Vite loader pointing at one JS bundle. Completion: the demo runs on screen27 in the testing browser.283. **Frame trace.** Capture a dense burst across a full run — one screenshot29 every ~60ms for 20–30s — then step through frames at ~1s intervals. Read30 each frame as an image. Extract the inventory: layout, columns, box colors31 per state, typography, fill/flash animations, staircase or queue geometry,32 the decisive transition, the end state, and the restart behavior.33 Completion: every visual phase, including the decisive one, is observed —34 none inferred.354. **Inspect the running DOM.** Evaluate `outerHTML` on the demo root while it36 runs. The rendered structure names the real technology (runtime-built SVG37 with clipPaths, canvas, DOM). Grep the served bundle for the constants the38 DOM cannot show: palette objects, query strings, state labels, timing39 constants, and the state machine. Completion: exact colors, states,40 timings, and content strings are extracted — not eyeballed.415. **Choose the representation.** Vendor when the demo ships as a42 self-contained bundle and the user accepts the dependency; reimplement43 under `$wcygan-editorial-diagrams` when the lesson must be re-taught in the44 editorial system or the bundle cannot be reused. State the choice and45 reason before building. Completion: the decision is recorded.466. **Build.**47 - _Vendor_: download the bundle, polyfill, and stylesheet into48 `public/<post-slug>/vendor/`, write a local `index.html` shell mirroring49 the source's (fonts, `#app` mount), and embed it through an iframe50 wrapper component that carries the editorial figure shell, aspect-ratio51 switching from measured stage width, and a Replay control that resets52 `iframe.src`. Keep source attribution in the figcaption.53 - _Reimplement_: deterministic model in `src/demos/<name>/`, component,54 CSS class family in `src/styles/app.css`, accessibility text, reduced55 motion, per the editorial contract.567. **Verify by diff against the trace.** Render the copy, capture the same57 phases traced in step 3, and compare frame by frame. Run model tests,58 typecheck, and the repository gate when reimplementing; run the gate when59 vendoring. Completion: copy frames show the source's phases, and the60 checks pass.6162## Gotchas6364- Spawn Chrome for Testing from the Playwright cache directly65 (`--no-first-run`); the relay may engage when a plain open fails.66- CDP `Page.startScreencast` emits zero frames in this setup; a tight67 `page.screenshot` loop is the working capture path (~60ms per frame).68- One browser `run` call times out at 30s and kills the tab. Chunk long69 traces: schedule captures at fixed offsets from a Replay click, several70 calls per trace.71- Confirm viewport geometry from the screenshot's own dimensions; an `open`72 viewport may not stick, and re-apply it with `page.setViewport`.73- Demos that restart on their own make a missed phase a timing problem, not a74 bug: re-run with captures centered on the phase's window.75- Dense capture can freeze the page's animation frames; if consecutive frames76 are identical while the demo should be moving, re-run the trace with77 spacing between captures.7879## Reference8081- [Lock-queue case study](references/lock-queue-case-study.md) — the full82 end-to-end trace of replicating the PlanetScale stuck-database demo: three83 passes from prose-built to vendored, with the exact commands, extractions,84 and frame evidence.8586Once a demo is accepted, its bundle graduates into87`$planet-scale-animation-design-system` (`assets/`, sync script, token and88renderer inventory); embed new posts from that skill's published copies89rather than a post-local vendor directory.