core/reducers

Implements Themis createReducer handlers with immutable updates and no-op reference equality.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Redux-style reducers that stay pure, immutable, and deterministic is error-prone: accidental mutations, side effects like Date.now(), and unconditional object copies break reference-equality checks and time-travel debugging. This Skill provides operational rules and tested patterns for building reducers with the Themis createReducer builder. ## Core Features & Use Cases - Reducer construction guidance: Register action handlers via .with(actionCreator, handler) chains, including async request/success/failure branches from createAsyncAction. - Immutability and no-op rules: Return the incoming state reference on no-ops, preserve collection reference equality, and keep derived values in selectors instead of state. - Anti-pattern detection: Concrete bad examples covering mutation, nondeterministic values, and unconditional nested copies that lose no-op identity. - Use Case: When adding a new slice reducer for a todos feature, follow the patterns to chain handlers, guard parent state updates with reference checks, and wire reducer tests covering initial state, each action, and unknown-action identity. ## Quick Start Ask the AI to create a Themis slice reducer with createReducer that handles an async load action with success and failure branches while preserving no-op reference equality.

Frequently Asked Questions about core/reducers

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

FAQPage Schema
How do I create a reducer with createReducer in Themis?▼

Call createReducer<State>(initialState) and chain handlers with .with(actionCreator, handler). The builder returns the reducer function itself, so registrations chain, and reducer.initialState remains available for tests.

How to handle async actions in a Redux reducer?▼

Register separate handlers for the async action's request, success, and failure creators from createAsyncAction. Set loading and clear errors on request, store the response payload on success, and store the plain error message on failure.

Why should reducers return the same state reference on no-op?▼

Returning the incoming state reference preserves reference equality so subscribers and memoized selectors skip unnecessary re-renders. createReducer only shallow-compares the top-level state, so unconditional nested copies break no-op identity.

Can I call Date.now() or fetch inside a reducer?▼

No. Reducers must stay pure and deterministic, so side-effect APIs like Date.now(), Math.random(), fetch, and localStorage are forbidden. Move generated values, persistence, and external calls into actions or sagas.

Should derived values like counts or filtered lists live in reducer state?▼

No. Store only source facts such as collections, ids, relationships, request status, and plain errors. Derived fields like filtered*, sorted*, *Count, or has* belong in selectors that compute them from canonical state.