core/domain-scoped-state

Manages Redux state keyed by workspace, project, or tenant id using immutable domain-scoped helpers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Redux slices that must be partitioned per workspace, project, or tenant are easy to get wrong: hand-rolled nested setters forget empty-state fallbacks, no-op clears trigger selector re-emissions, and renamed keys break type safety. This Skill provides the createDomainScopedHelpers pattern so per-domain state reads, writes, and clears stay immutable and consistent. ## Core Features & Use Cases - Immutable domain helpers: getDomainState falls back to emptyState for unknown ids, setDomainState produces new state only when the value changes, and clearDomainState returns the same reference on no-op clears. - Reducer integration: Shows how to wire the helpers into createReducer handlers with tuple payloads keyed by domain id, plus selector patterns that read the current workspace's slice. - Use Case: When a user switches workspaces or logs out, dispatch a clear action and clearDomainState removes that workspace's slice without re-emitting selectors for unrelated domains. ## Quick Start Ask the AI to create a Redux slice whose state is keyed by workspace id using createDomainScopedHelpers with get, set, and clear handlers.

Frequently Asked Questions about core/domain-scoped-state

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

FAQPage Schema
How do I key Redux state by workspace id?▼

Use createDomainScopedHelpers with a state shape of { byDomainId: Record<string, T> }. The returned getDomainState, setDomainState, and clearDomainState helpers handle immutable reads, writes, and removals keyed by the workspace id.

How to clear Redux state when a user leaves a workspace?▼

Dispatch an action carrying the domain id and handle it with clearDomainState(state, id) in the reducer. It returns the same state reference when the id was already absent, so selectors keyed on other domains do not re-emit.

Why does my domain-scoped reducer return undefined for new ids?▼

Hand-rolled nested setters skip the empty-state fallback, so reading an unknown domain id yields undefined and downstream property access crashes. getDomainState returns the provided emptyState for unknown ids, preventing this.

Can emptyState contain a Map or Date in domain-scoped Redux state?▼

No. emptyState is written into the state tree for every new domain id, so it must be serializable. Use plain values like a collection created by createCollection and numeric timestamps instead of Map, Set, Date, or class instances.

When should I not use domain-scoped state in Redux?▼

Avoid it when every consumer shares a single domain with no multi-workspace or multi-tenant concept. A plain slice is simpler in that case; reach for createDomainScopedHelpers only when the domain id is part of the state key.