core/local-storage

Persists and loads preferences with error-safe localStorage helpers from redux-saga sagas.

6|6|Updated Jun 29, 2026
One-click install
npx skills add https://github.com/intent-hq/cloudlands-fe --skill core-local-storage-intent-hq
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: core/local-storage
Source: https://github.com/intent-hq/cloudlands-fe/tree/main/.agents/skills/themis/core/local-storage
Command: npx skills add https://github.com/intent-hq/cloudlands-fe --skill core-local-storage-intent-hq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Direct localStorage calls in sagas or components crash on quota errors, private-browsing SecurityErrors, and corrupt JSON payloads, leaving apps in broken states. This Skill provides error-safe saga helpers and patterns for loading startup defaults and persisting preference changes. ## Core Features & Use Cases - Error-Safe Saga Helpers: getLocalStorageItem, setLocalStorageItem, removeLocalStorageItem, prefix key enumeration, and typed JSON read/write helpers that swallow storage failures. - Init Saga Pattern: Load persisted settings on startup with a defaults merge so older payloads keep working when new fields are added. - Persistence Saga Pattern: Watch Redux actions with takeEvery and save state changes to localStorage automatically. - Use Case: A settings feature stores theme and font size. An init saga loads saved preferences at startup with fallback defaults, and a persistence saga writes updates whenever the user changes a setting. ## Quick Start Write a redux-saga init saga that loads my feature settings from localStorage with defaults and a persistence saga that saves them on every change.

Frequently Asked Questions about core/local-storage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use localStorage in redux-saga?▼

Call error-safe helper functions with yield* call(getLocalStorageItem, key) instead of touching window.localStorage directly. The helpers return null or undefined on failure and turn failed writes into no-ops, so sagas never crash on storage errors.

How to persist Redux state to localStorage with sagas?▼

Create a persistence saga that watches actions with takeEvery, selects the current value, and calls setLocalStorageItem with a JSON-serialized payload. Wrap the logic in try/catch so quota or security errors are ignored.

Why does localStorage throw errors in private browsing?▼

Browsers in private mode can throw SecurityError or quota errors on localStorage access. The safe saga helpers wrap every call in try/catch, returning null on failed reads and making failed writes no-ops.

Can I call localStorage directly from a Svelte component?▼

No, storage side effects belong in sagas, not components. Component writes cannot be replayed, logged, or tested like saga effects, so dispatch an action and let a watcher saga perform the storage write.

How do I handle corrupted JSON in localStorage?▼

Wrap JSON.parse in try/catch inside the init saga and fall through to default values on failure. Merging with { ...defaults, ...parsed } also keeps older payloads compatible when new fields are added.