A Twitch bot that queues Spotify tracks, plus an OBS overlay widget, a setup dashboard and a visual theme editor. Node, no build step, no framework.
npm start # the bot + widget (3001) + dashboard (3002)
npm test # node --test, ~220 tests, no network
npm run screenshot # capture the widget from a running instance
Tests must never touch real data. Every persisted path is overridable:
QUEUEIFY_THEMES_DIR, QUEUEIFY_WIDGET_CONFIG_FILE, QUEUEIFY_SETTINGS_FILE,
QUEUEIFY_DATA_DIR, QUEUEIFY_ENV_FILE, QUEUEIFY_SCENE_THEMES_FILE,
QUEUEIFY_HISTORY_FILE, QUEUEIFY_PRESETS_DIR, QUEUEIFY_VIEWER_EFFECTS_FILE, QUEUEIFY_WIDGET_URL. Set them before requiring the
module — themeStore, widgetLayout, core/state, services/history and
widget/server all read them at load time, so
a require above the assignment writes to the real project. Bust
require.cache for those modules between sandboxes. Point QUEUEIFY_WIDGET_URL
at a dead port so a test can never reach a Queueify the user is running.
A green test suite does not mean the widget looks right. Anything touching the overlay or the editor gets rendered in a real browser and looked at — Playwright is a devDependency for exactly this. Sample the first painted frame too, not just the settled one: a scene switch reloads the page, so the first frame is what people actually see.
OBS sizing is one uniform scale, never one per axis. services/obs.js sets
the browser source size and the scene item transform in a single pass, on
purpose: OBS applies a source resize asynchronously, so reading sourceWidth
back straight afterwards returns the old number and any scale derived from it
is wrong. Never split that into resize-then-reposition.
Saved !tr / !bc positions are rectangles, not scales. A scale only means
something against the source size it was measured at, and that size changes with
every theme. Nothing outside services/widgetPresets.js should compute one.
Who queued a song is decided in one place. updateActiveTrack in
core/state.js is the only code that decides which request is playing. !np
and the widget only read state.activeTrack. Requests are followed by their
place in Spotify's queue, not matched by song. When two copies of a song can't
be told apart, a viewer's song playing straight away is theirs (the
streamer's rule); with two viewers' copies in doubt it names nobody. tests/requester-tracking.test.js runs
thousands of made-up streams against a fake Spotify that knows the real
answer. Keep it green, and add a scenario there for any new way a name could
go wrong.
Themes are user data. Adding a field to the theme model means bumping
MODEL_VERSION in services/themeStore.js and giving normalizeModel a
fallback, so a theme somebody already saved does not change under them.
The dashboard is loopback-only. setup/server.js guards on that. It serves
tokens and settings; it must never bind anywhere else.
Nothing needs a restart. Credentials, settings, aliases, messages and themes are re-read while the bot runs. Keep it that way — no boot-time snapshots of things a user can edit.
Match the file you are in. No linter, no house style beyond that. Comments
explain why, especially where the obvious approach is wrong — most of the
comments in services/obs.js and services/widgetPresets.js exist because
somebody already made that mistake.
Bullet points do not end in a full stop.
The rules above are the short version. agents/skills/ has the detail, worth
reading before the kind of work it covers:
sandboxed-tests.md— the env-var overrides and the order they have to be set invisual-verification.md— how to actually look at a widget change, including the first painted framepersisted-state.md— theme versioning, and why a stored value must not be a derived one
See .github/claude-review.md for what to prioritize and how to write the
reply.