Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
oakoss avatar

Zustand

  • 99 installs
  • 14 repo stars
  • Updated March 2, 2026
  • oakoss/agent-skills

Helps with ai & agent building tasks during AI-assisted development.

About

zustand is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.

  • zustand
  • AI & Agent Building
  • AI-coding skill

Zustand by the numbers

  • 99 all-time installs (skills.sh)
  • +3 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #4,419 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/oakoss/agent-skills --skill zustand

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs99
repo stars14
Last updatedMarch 2, 2026
Repositoryoakoss/agent-skills

What it does

Helps with ai & agent building tasks during AI-assisted development.

Files

SKILL.mdMarkdownGitHub ↗

Zustand State Management

Overview

Zustand v5 is a lightweight global state manager for React built on useSyncExternalStore. Requires React 18+ (uses useSyncExternalStore internally). When using createWithEqualityFn, install use-sync-external-store as a peer dependency. It provides type-safe stores, atomic selectors for minimal re-renders, composable middleware (persist, devtools, immer, subscribeWithSelector), and a slices pattern for large applications. Use Zustand for client-only global state; use TanStack Query for server-fetched data.

When to use: Client-side global state, persistent user preferences, complex multi-domain stores, cross-component state sharing, vanilla (non-React) state management.

When NOT to use: Server state with caching needs (use TanStack Query), single-component state (use useState), simple prop drilling scenarios.

Quick Reference

PatternAPIKey Points
Basic storecreate<T>()((set) => ({...}))Double parentheses required for TS
Atomic selectoruseStore(state => state.bears)Only re-renders when selected value changes
Multiple valuesuseShallow(state => ({a, b}))Import from zustand/react/shallow
Persistpersist(fn, { name })localStorage with SSR hydration handling
Devtoolsdevtools(fn, { name })Redux DevTools integration
SubscribeWithSelectorsubscribeWithSelector(fn)Subscribe to state slices outside React
Middleware orderdevtools(persist(fn))Outer to inner wrapping
Slices patternStateCreator<Combined, [], [], Slice>Split store by domain
SSR providercreateStore + React ContextPer-request stores prevent data leaks
Immerimmer(fn)Safe nested state mutations
Vanilla storecreateStore from zustand/vanillaUse outside React
Reset storeset(store.getInitialState())Use getInitialState() for reliable reset
Derived valuesuseStore(s => s.items.length)Compute in selector
Auto selectorscreateSelectors(store)Generate store.use.field() hooks automatically

Common Mistakes

MistakeCorrect Pattern
Using create<T>(...) with single parenthesesUse create<T>()(...) double parentheses for correct TypeScript middleware inference
Selecting full state object with useStore(state => state)Use atomic selectors like state.bears or useShallow to avoid unnecessary re-renders
Importing useShallow from zustand/shallowImport from zustand/react/shallow; zustand/shallow exports the plain shallow function only
Creating new object references in selectors causing infinite loopsUse separate primitive selectors or wrap with useShallow from zustand/react/shallow
Using a global singleton store with SSR or Next.jsUse the StoreContext provider pattern with createStore to prevent data leaks between requests
Tracking initial state manually for resetUse store.getInitialState() which Zustand provides automatically
Using Zustand for server-fetched data that needs caching and revalidationUse TanStack Query for server state; reserve Zustand for client-only global state

Delegation

  • Store architecture and slices design: Use Plan agent to define domain boundaries, slice interfaces, and middleware composition order
  • Hydration and SSR debugging: Use Task agent to diagnose persist middleware issues, hydration mismatches, and Next.js provider setup
  • Migration from v4 to v5: Use Explore agent to find deprecated import paths, single-parentheses patterns, and legacy middleware usage
  • Testing strategy: Use Task agent to set up store mocks and test isolation patterns

References

  • Store patterns, TypeScript, and core API
  • Middleware: persist, devtools, immer, subscribeWithSelector, and custom
  • Slices pattern and large store architecture
  • SSR, Next.js, and hydration handling
  • Testing stores with Vitest and Jest
  • Migration guide: Redux, Context, and v4 to v5

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.