/mindrally-skills:zustand-state-managementfrom Mindrally Skills Collection
Best practices for Zustand state management in React and TypeScript, covering store design, selectors, middleware, SSR, and testing. Use when creating or refactoring Zustand stores or deciding state ownership.
Ships in Mindrally Skills Collection. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill covers designing and using Zustand stores in React and TypeScript applications, including state ownership decisions, store slicing, selector performance, middleware, SSR, and testing.
useState or useReducer — don't reach for Zustand by default.isLoading, hasError.import { create } from 'zustand'
interface SidebarState {
isOpen: boolean
activePanelId: string | null
}
interface SidebarActions {
openPanel: (panelId: string) => void
close: () => void
toggle: () => void
}
type SidebarStore = SidebarState & SidebarActions
export const useSidebarStore = create<SidebarStore>()((set) => ({
isOpen: false,
activePanelId: null,
openPanel: (panelId) => set({ isOpen: true, activePanelId: panelId }),
close: () => set({ isOpen: false, activePanelId: null }),
toggle: () => set((state) => ({ isOpen: !state.isOpen })),
}))
useStore((state) => state.value). Avoid selecting the entire store.useShallow (from zustand/react/shallow) when a selector returns an object or tuple of multiple values, to avoid re-renders from a new object reference each call.import { useShallow } from 'zustand/react/shallow'
import { useSidebarStore } from '@/stores/sidebar-store'
export function SidebarToggle() {
const { isOpen, toggle } = useSidebarStore(
useShallow((state) => ({
isOpen: state.isOpen,
toggle: state.toggle,
})),
)
return (
<button type="button" aria-expanded={isOpen} onClick={toggle}>
Toggle sidebar
</button>
)
}
type Store = State & Actions) rather than one flat interface for non-trivial stores.any; use unknown plus narrowing for external data.set((state) => nextState) when the next value depends on current state.immer middleware only when it materially simplifies nested updates — don't mutate nested objects directly without it.import { persist } from 'zustand/middleware'
const useStore = create(
persist(
(set) => ({
// state and actions
}),
{ name: 'store-key' }
)
)
persist only for state that must survive reloads.partialize, version, and migrate when persisting anything beyond trivial preferences.import { devtools } from 'zustand/middleware'
const useStore = create(
devtools((set) => ({
// state and actions
}))
)
devtools in development for complex flows and give important actions clear names so they're identifiable in the trace.subscribeWithSelector for non-React subscriptions that need fine-grained updates outside of component rendering.idle, pending, success, and error rather than ad hoc booleans.window, document, and storage access outside middleware configuration.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub mindrally/skills --plugin mindrally-skills265 skills in this plugin
/accessibility-a11yImplement web accessibility (a11y) best practices following WCAG guidelines to create inclusive, accessible user interfaces./alpine-jsAlpine.js development guidelines for lightweight reactive interactions with Tailwind CSS and various backend frameworks./analytics-data-analysisBest practices for analytics, data analysis, and visualization using Python, pandas, matplotlib, seaborn, and Jupyter notebooks. Use when performing exploratory data analysis, building data pipelines, creating statistical visualizations, writing Jupyter notebooks, cleaning and transforming datasets, or implementing analytics dashboards./android-developmentAndroid development guidelines for Kotlin with clean architecture, MVI pattern, Material Design, and best practices for building robust mobile applications/angularExpert in Angular TypeScript development with scalable, high-performance patterns/angular-developmentExpert guidance for Angular and TypeScript development focused on scalable, high-performance web applicationsOther plugins' skills for the same job