Packs / game-dev-web-public
versioned-save-games
Save and load game progress with a schema version, step-by-step migrations, a checksum against corruption and a pluggable store (localStorage, file, IndexedDB)
Install
logicpacks pack use game-dev-web-public/versioned-save-gamesget_pack game-dev-web-public/versioned-save-gamesThe second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.
Keys it needs (names only)
None.
Playbooks included
- Spec:
spec/SPEC.md(goal, steps, edge cases, don’ts) - Routes:
node-local - Checks: 1 in
outcome/checks.yaml - Code:
save.mjssave.test.mjs - Tools: node
Usage, last 8 weeks
New: no recorded use yet.
Purpose (from spec/SPEC.md)
Goal
Saves from any old version of the game load into the current one, corrupted saves are detected and backed up instead of crashing the game.
Steps
- Copy
code/save.mjs. DefineCURRENTandMIGRATIONS[n](n -> n+1). - Save:
saveGame(store, data)writes{v, data, sum}(FNV-1a checksum of the JSON). - Load:
loadGame(store, defaults)verifies the checksum, runs migrations up to CURRENT, returns{data, migratedFrom, recovered}. - Corrupt or newer-than-game saves are copied to
<key>.bakand defaults are returned. - Check:
node code/save.test.mjs.
Edge cases
- localStorage is ~5 MB and synchronous: big saves go to IndexedDB (same interface, async wrapper).
- Cloud saves: send the same envelope to your backend; resolve conflicts by
updatedAt.
Don'ts
- Don't delete a save you cannot read; back it up.
- Don't change the shape without bumping the version.