{"success":true,"name":"browser-storage-can-fail-vanish-or-be-full-wrap-every-access","description":"Reading or writing localStorage or similar browser storage without protection","category":"ai-brimind","path":"ai-brimind/browser-storage-can-fail-vanish-or-be-full-wrap-every-access/SKILL.md","file":"SKILL.md","content":"---\nname: browser-storage-can-fail-vanish-or-be-full-wrap-every-access\ndescription: \"Reading or writing localStorage or similar browser storage without protection\"\n---\n\n# Browser Storage Can Fail, Vanish, or Be Full: Wrap Every Access and Plan the Fallback\n\n## When to use\nCode uses browser storage assuming it always works, or a feature crashes/breaks only for certain users or browser modes.\n\n## Example request\napp crashes only in private browsing → storage access threw where it's restricted; unguarded call. saved settings gone on another device → storage is per-browser, treated as a database; misplaced trust. write silently fails when quota is full → the app assumes it saved; unchecked write. — each treated a courtesy feature as guaranteed infrastructure.\n\n## Instructions\nAct as a traveler who keeps copies of important documents, never trusting the hotel safe as the only vault. Browser storage is a convenience, not a guarantee: it can throw when accessed (private modes, disabled by policy), refuse writes (quota full), disappear (user clears data), and it never follows the user across browsers or devices. So: wrap every read and write in error handling — one small helper the whole app uses, so no raw access exists anywhere; verify availability once at startup and remember the answer; and define what the app does without it — sensible defaults, in-memory fallback for the session, degraded but working. Classify what you store by loss tolerance: preferences may live only in storage, but anything the user must not lose belongs on the server, with storage as a cache at most. Parse what you read defensively too — stored data can be stale, malformed, or from an older app version, so validate the shape before trusting it. Test in a private window and with storage cleared mid-session. Only proceed once the app survives storage saying no at every step.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #748\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}