This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A collection of standalone p5.js examples for teaching and learning, by Jon Froehlich and the Makeability Lab (UW). Categories span sound visualization, computer vision (ml5.js), games, generative art, Web Serial, animation, color, vectors, Perlin noise, and more.
Each example is a self-contained folder with its own index.html. There is no app-wide build step, bundler, or shared runtime — examples are independent and load p5.js (and other libs) from CDN.
- Most examples: open the folder's
index.htmldirectly in a browser, or use VS Code Live Server. - Web Serial examples (
WebSerial/): require a local web server (browsers block serial access fromfile://). Use Live Server. Requires Chrome/Edge/Opera. The Web Serial wrapper isSerialfrom the Makeability Lab JS library, loaded via CDN:https://cdn.jsdelivr.net/gh/makeabilitylab/js@main/dist/makelab.serial.iife.js. - Zero toolchain to run/develop examples: no npm, no build step, no
npm installrequired to run or develop an example — just a browser (and Live Server for serial). Keep it that way. (The repo-rootpackage.jsonand its Playwright/ffmpeg dev deps exist only for gallery preview generation — they are never on any example's load path. Seescripts/README.md.) - IntelliSense: p5 type definitions are vendored in
_p5types/and wired up by the single rootjsconfig.json, so VS Code autocomplete works offline with no install. Do not reintroduce@types/p5/node_modulesfor types, and do not add per-folderjsconfig.jsonfiles (a single root config covers the whole repo).
- Create a folder under the right category, e.g.
Sound/MyNewVis/. - Add
index.html(and optionalsketch.js,css/style.css). - Give the page a meaningful
<title>— the gallery scrapes it (generic titles like "p5.js"/"index" are skipped, seeextract_title_from_htmlinscripts/build_gallery.py). - Commit and push to
main; the gallery rebuilds automatically and a thumbnail preview is captured for the example. Optionally add apreview.json(skip/tune capture) or a hand-madescreenshot.*/thumbnail.*— seescripts/README.md.
Templates/ holds starter scaffolds (Simple, Multi, Autogenerated) — copy one when starting a new sketch.
- The repo-root
index.htmlis generated byscripts/build_gallery.py, which walks the tree, finds every folder with anindex.html, groups by category (top-level folder) and optional subcategory, and writes a self-contained page. Never edit rootindex.htmlby hand — it is overwritten on every build. - Thumbnails are auto-captured by
scripts/capture_previews.mjs(Playwright + ffmpeg) intopreviews/<rel_path>.webp(animated) +.poster.png, committed to the repo. It content-hashes each example viapreviews/manifest.jsonand skips unchanged ones.build_gallery.py --list-jsonis its single source of truth for the example set, so the two never disagree. Full pipeline:scripts/README.md. .github/workflows/build-gallery.ymlruns both scripts on every push tomainand commitsindex.html+previews/back with[skip ci](prevents an infinite loop). Published via GitHub Pages frommainat root.- To regenerate locally:
node scripts/capture_previews.mjsthenpython scripts/build_gallery.py(run from repo root). - Categories excluded from the gallery are configured in
EXCLUDED_DIRSin the build script:_libraries,_p5types,.vscode,.github,scripts,node_modules,Arduino,Node,Sandbox,Templates.
CDN library versions are pinned, not floating (no @latest). Current pins: p5.js & p5.sound 1.11.13, ml5.js 0.12.2. When adding or editing examples, match these pins. Maintenance scripts in scripts/:
audit_libraries.py— scan repo for library import issues and pinning status.fix_libraries.py— pin CDN versions, replace local lib refs with CDN, clean up local copies. Supports--dry-run.migrate_serial_imports.py— migrate old_libraries/serial.jsrefs to themakeabilitylab/jsCDN.
_libraries/ holds offline copies of libs (for local dev without internet); _p5types/ holds p5 type definitions. Neither is part of any example's normal load path — examples use CDN.
- HTML: 2-space indentation.
- Vanilla JS only (no frameworks). p5.js global mode (
setup()/draw()). - Web Serial examples follow the event-wiring pattern in
WebSerial/Basic/SliderOutSuperBasic/— instantiatenew Serial(), registerSerialEventshandlers, guardnavigator.serialand wrapserial.connectAndOpen()in try/catch.
- makeabilitylab/js — the Makeability Lab JS library (serial, math, graphics modules).
- makeabilitylab/arduino — Arduino sketches paired with the Web Serial examples.
- Physical Computing course — many examples accompany its Web Serial lessons.