core/state-serialization

Validates Redux state for structured-clone compatibility and replaces non-serializable values.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Redux state must survive JSON serialization and structured cloning, but values like Date, Map, Set, Error, and class instances silently break persistence, time-travel debugging, and state hydration. This Skill provides an operational checklist for keeping reducer state JSON-shaped. ## Core Features & Use Cases - Serialization Rules: Enforces primitives, arrays, and plain objects in Redux state, with timestamps stored as numbers or ISO strings and errors stored as plain data. - Collection Guidance: Replaces Map and Set with Record<string, T>, string[], or Collection<T, K> helpers for normalized entity storage. - Reducer Purity Checks: Prevents Date.now(), Math.random(), and ID generators inside reducer handlers by moving value generation into action creators or sagas. - Use Case: When adding a new reducer field that tracks sync timestamps, store syncedAtMs as a number generated in the action creator and add a JSON round-trip regression test instead of storing a Date object. ## Quick Start Ask the AI to review your reducer state and action payloads for non-serializable values like Date, Map, Set, or Error and rewrite them as JSON-safe plain data.

Frequently Asked Questions about core/state-serialization

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

FAQPage Schema
How do I make Redux state serializable in TypeScript?▼

Keep Redux state limited to primitives, arrays, and plain objects. Store timestamps as number milliseconds or ISO strings, entity sets as Record<string, T> or Collection<T, K>, and errors as plain objects like { message, stack }.

How to store dates in Redux state without Date objects?▼

Store dates as number milliseconds or ISO strings instead of Date instances. Generate the timestamp in an action creator or saga and pass it through the action payload rather than calling Date.now() inside the reducer.

Why should Map and Set not be used in Redux state?▼

Map and Set do not survive JSON.stringify or structured-clone round-trips used by persistence and debugging tools. Replace them with Record<string, T>, string arrays, or a serializable Collection<T, K> helper.

Can reducers call Date.now() or Math.random()?▼

No, reducers must stay pure and deterministic. Generate timestamps, random values, and IDs in action creators or sagas, then pass them into the reducer through the action payload.

How do I test Redux state serialization?▼

Write a regression test that runs JSON.parse(JSON.stringify(state)) and asserts the result equals the original state. Cover both the initial state and any changed paths introduced by new reducers.