/dm-game:settings-and-persistencefrom dm-game
Manages game settings persistence with versioned migration, per-bus audio, motion/flash/shake toggles for canvas effects, and accessibility options that survive updates.
Ships in dm-game. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Purpose: Every option the player sets takes effect everywhere at once and survives every update. The options screen is the visible half; a versioned, sanitised, single record is the half that decides whether players trust it.
Sources:
prefers-reduced-motion: reduce means remove or replace non-essential
motion. Large pans and scales trigger vestibular symptoms; fades usually don't.CONTROL_SETTINGS_VERSION)Typed sketch: references/settings.ts. It covers migrate, sanitise, load/save with
failing storage, the motion resolution and the bus gains.
| Failure | Seen in | Root cause |
|---|---|---|
| Reduced motion reaches CSS, not the canvas shake | timberwolf, gravelight; free-horses particles (read from code, not reproduced) | Setting read in one place; effects built once with the OS value |
| Settings wiped by an update | Hard Deck, logarithmic, gravelight (save) | Version mismatch resets instead of migrating |
| Many keys, versions only in key names | timberwolf (6 keys), abduction-run (4), volatile-state-redux | No single record; a "v1" in the key orphans data rather than migrating it |
| Two sources of truth for volume | redshifted | Audio modules write their own keys beside the panel's |
| OS reduced-motion preference frozen at first save | free-horses (read from code, not reproduced), logarithmic | OS default written into storage as if the player chose it |
| Only master volume, or no mute | gravelight (3 sliders, no mute), free-horses (no mute) | Bus model not exposed |
GainNode per bus (music, sfx, ui, voice, ambience: whichever the game
has), each feeding a master GainNode. With Howler, which has no buses, multiply
each sound's volume by its bus gain when it plays, and keep Howler.volume() as
master.gain = (v / 100) ** 2. Test: do
equal slider steps sound like equal loudness steps across the range? If the top
half seems to do nothing, steepen the curve, or switch to a dB mapping
(−40 dB to 0, also posture B, with the same test).The settings resolve into one runtime FX gate that every effect reads when it emits and when it renders:
interface FxGate { reduceMotion: boolean; reduceFlash: boolean; shakeScale: number }
Shake: the camera multiplies offset by shakeScale. At 0 it never offsets,
but trauma still decays: logarithmic decays while gated, so toggling mid-shake
leaves no stuck offset. The shake model is game-feel's; the scale is this
skill's.
Flash:
reduceFlash, full-screen flashes drop to a low-alpha tint or a border
pulseSee game-feel.
Motion: with reduceMotion:
Build effects to read the gate live, not to capture it at construction. Free-horses built its particle system with the OS value once, so the in-game toggle never reached it.
CSS joins the same gate. Set html[data-reduced-motion] from the gate, and
let one CSS rule collapse transitions. Don't rely on the @media query alone:
it ignores the in-game setting.
'system' | 'on' | 'off', defaulting to
'system'. Resolve at runtime:
matchMedia('(prefers-reduced-motion: reduce)').matches when set to system.change on that media query, so an OS toggle mid-session applies.'system', or shake: null) until the
player touches them; only then is the value their choice.<game>.settings, <game>.scores and
<game>.save are separate. A save-format bump must never wipe settings;
logarithmic's SAVE_VERSION check rejects the whole record.{ version: 3, audio: {…}, fx: {…}, input: {…}, display: {…} }.
The version lives in the payload, so old data can be migrated. A version in
the key name only orphans it.Parse inside try. Any failure means defaults, and a note in the console.
Migrate with a ladder: migrations[v](data) returns version v+1, applied
until current.
Sanitise field by field against the defaults, every time, after migrating:
The binding map goes through input-bindings' mergeSaved. Hard Deck and
volatile-state-redux both do this well.
A version from the future (the player downgraded, or another tab runs a newer build): sanitise what you can, use it in memory, and never write over it. Tell the player once: "Settings from a newer version: changes apply for this session only."
Legacy keys from a rename:
Hard Deck still reads bay-raid.* as a fallback after its rename.
Write when a setting changes. Skip it if the serialised record is unchanged:
Hard Deck de-duplicates writes. Debounce slider drags, or write on change
rather than input.
setItem can throw:
Catch it, keep running on the in-memory store, and tell the player once. Logarithmic and royal-inbox swallow it silently, which is half right.
Another tab can change the record. Optionally listen for the storage
event and reload, or at least don't overwrite a newer version (rule 5.4).
--ui-scale) that HUD and
menus use. Test at 200%: nothing overlaps or clips (XAG 101).Each line names what the check cannot see.
Migration fixtures: keep one stored JSON blob per past version in the tests. Each must migrate to the expected current record. Mutation-check: delete a migration step and its fixture must fail. Blind to: versions that shipped without a fixture, so add the fixture in the same commit as the bump.
Sanitiser: for garbage, null, wrong types, out-of-range numbers and
unknown keys, each field falls back on its own and the rest survives. Blind
to: semantically wrong but well-typed values.
Storage throws (stub setItem to throw): the game runs, and the one-line
notice appears once. Blind to: real quota behaviour on mobile Safari.
Reduced motion, end to end, in a real browser: - set Screen shake to 0 - take a hit - the camera offset stays 0 (read it from the render state, not a probe that recomputes it) - flip the OS setting with Motion on System; it applies without a reload
*Blind to: whether the remaining motion still causes discomfort. Ask a
motion-sensitive player.*
Every effect reads the gate: grep for effect constructors and shake writes; each references the FX gate. Blind to: effects that don't match the grep.
Update path: install the previous build, change every setting, update, reload. Every value survives. Blind to: the build before that, so that is what the fixtures are for.
Three tight links. Everything else routes through the map, so adding a skill
touches one file rather than twenty: references/routing-map.md (in
game-design).
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
game-settings, persistence, migration, accessibility, audio-buses
40 skills in this plugin
/accessibility-designUse when designing any player-facing feature, evaluating a game for accessibility, responding to accessibility feedback, designing difficulty or assist options, adding subtitle/caption systems, implementing input remapping, or when a player reports they can't play. Covers the four accessibility pillars (visual, auditory, motor, cognitive), implementation tiers, colorblind design, subtitle standards, input accessibility, and testing methodology. Accessibility is a design discipline, not a post-launch checklist./async-and-socialSocial and competitive design that does not require players to be online together: ghost/replay data, leaderboards, asynchronous PvP, offline vulnerability, and anti-snowball mechanics. Use when adding leaderboards or high-score tables, designing ghost races or replay challenges, letting players attack or compete against absent opponents, deciding what social signal a single-player game should carry, or when matches and runs feel decided in the first minutes. Anti-snowball applies to single-player roguelikes and simulations too, not just PvP. For real-time multiplayer architecture, matchmaking, guilds, and moderation, this skill deliberately does not cover them — those are large specialities and belong in dedicated references.npx claudepluginhub rbergman/dark-matter-marketplace --plugin dm-gameOther plugins' skills for the same job