3JS Games
Browse documentation

AI / Copy-ready prompt

Add Cloud Saves

A bounded implementation prompt for adding Storage SDK v1 to an existing game.

Integrate 3JSGames Cloud Storage into this game.

1. Inspect the existing save/load behavior before editing.
2. Preserve gameplay, UI, and existing save semantics.
3. Use the unchanged official Storage SDK v1 vendored at 3jsgames-sdk/v1/storage.js and load it with ./3jsgames-sdk/v1/storage.js.
4. Use only ThreeJSGames.storage.get(key), set(key, value), delete(key), and isAvailable().
5. Preserve standalone behavior and an existing localStorage fallback where practical.
6. Handle stable error codes, especially AUTH_REQUIRED; never parse error message strings.
7. Keep every JSON-compatible value within 32 KiB, no more than 64 keys, and total storage within 256 KiB per player per game.
8. Do not connect to Supabase, access window.parent, send raw postMessage messages, modify the SDK artifact, bypass upload scanning, or invent player/game IDs.
9. Avoid silently overwriting a newer local save; treat merge/conflict policy as game-owned behavior.
10. Add tests if the game already has test infrastructure.