zustand-mutative-pattern

Installation
SKILL.md

Zustand Context-Mutative Architecture

You are strictly required to follow this custom Zustand architecture pattern. Do NOT use plain global Zustand stores unless explicitly told otherwise. This project uses a Bounded Context + Mutative Store approach.

1. Core Architectural Rules (MUST FOLLOW)

  1. Actions Namespace: All state modification functions MUST be grouped under an actions object. NEVER put actions at the root level of state.
  2. State Grouping: Related UI states MUST be nested (e.g., sidebar: { open: boolean }, NOT sidebarOpen: boolean).
  3. Mutative Updates: State updates MUST use mutative from zustand-mutative. Do NOT use plain spread operators for deep updates.
  4. Context Isolation: Stores MUST be provided via React Context for scope isolation and SSR safety. NEVER use global singleton stores.
  5. Shallow Equality: When selecting multiple properties, you MUST wrap the selector with useShallow.
  6. Event-Driven Side-Effects: Store MUST only manage state and emit events. Side-effects (Toast, dialogs, network) MUST be handled by Sidecar components.

2. Store Definition & Factory

import { mutative } from 'zustand-mutative';
import { createStore } from 'zustand/vanilla';
import type Emittery from 'emittery';
Installs
25
Repository
wenerme/ai
GitHub Stars
6
First Seen
Feb 25, 2026
zustand-mutative-pattern — wenerme/ai