zustand-patterns — for Claude Code zustand-patterns, lylrv-reimagined, community, for Claude Code, ide skills, Zustand, Patterns, Modern, management, lightweight

v1.0.0

Sobre este Skill

Perfeito para Agentes Frontend que necessitam de gerenciamento de estado leve com TypeScript e aplicações React. Resumo localizado: Zustand 5.x state management with slices, middleware, Immer, useShallow, and persistence patterns for React applications. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

Recursos

Modern state management with Zustand 5.x - lightweight, TypeScript-first, no boilerplate.
Global state without Redux complexity
Shared state across components without prop drilling
Persisted state with localStorage/sessionStorage
Computed/derived state with selectors

# Core Topics

OmarHosamCodes OmarHosamCodes
[0]
[0]
Updated: 3/9/2026

Killer-Skills Review

Decision support comes first. Repository text comes second.

Reference-Only Page Review Score: 10/11

This page remains useful for teams, but Killer-Skills treats it as reference material instead of a primary organic landing page.

Original recommendation layer Concrete use-case guidance Explicit limitations and caution Quality floor passed for review
Review Score
10/11
Quality Score
52
Canonical Locale
en
Detected Body Locale
en

Perfeito para Agentes Frontend que necessitam de gerenciamento de estado leve com TypeScript e aplicações React. Resumo localizado: Zustand 5.x state management with slices, middleware, Immer, useShallow, and persistence patterns for React applications. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

Por que usar essa habilidade

Habilita os agentes a gerenciar o estado global sem a complexidade do Redux, utilizando a abordagem TypeScript-first do Zustand e recursos como estado persistido com localStorage/sessionStorage, estado computado/derivado com seletores e suporte a middleware para logging, devtools e persistência.

Melhor para

Perfeito para Agentes Frontend que necessitam de gerenciamento de estado leve com TypeScript e aplicações React.

Casos de Uso Práticos for zustand-patterns

Implementação de gerenciamento de estado global para aplicações React
Compartilhamento de estado entre componentes sem perfuração de propriedades
Manutenção de estado com localStorage ou sessionStorage para experiências de usuário sem interrupção

! Segurança e Limitações

  • Requer Zustand 5.x
  • Otimizado para aplicações TypeScript e React
  • Pode exigir configuração adicional para suporte a middleware

Why this page is reference-only

  • - Current locale does not satisfy the locale-governance contract.

Source Boundary

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

After The Review

Decide The Next Action Before You Keep Reading Repository Material

Killer-Skills should not stop at opening repository instructions. It should help you decide whether to install this skill, when to cross-check against trusted collections, and when to move into workflow rollout.

Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is zustand-patterns?

Perfeito para Agentes Frontend que necessitam de gerenciamento de estado leve com TypeScript e aplicações React. Resumo localizado: Zustand 5.x state management with slices, middleware, Immer, useShallow, and persistence patterns for React applications. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

How do I install zustand-patterns?

Run the command: npx killer-skills add OmarHosamCodes/lylrv-reimagined/zustand-patterns. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for zustand-patterns?

Key use cases include: Implementação de gerenciamento de estado global para aplicações React, Compartilhamento de estado entre componentes sem perfuração de propriedades, Manutenção de estado com localStorage ou sessionStorage para experiências de usuário sem interrupção.

Which IDEs are compatible with zustand-patterns?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for zustand-patterns?

Requer Zustand 5.x. Otimizado para aplicações TypeScript e React. Pode exigir configuração adicional para suporte a middleware.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add OmarHosamCodes/lylrv-reimagined/zustand-patterns. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use zustand-patterns immediately in the current project.

! Reference-Only Mode

This page remains useful for installation and reference, but Killer-Skills no longer treats it as a primary indexable landing page. Read the review above before relying on the upstream repository instructions.

Upstream Repository Material

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

Upstream Source

zustand-patterns

Install zustand-patterns, an AI agent skill for AI agent workflows and automation. Review the use cases, limitations, and setup path before rollout.

SKILL.md
Readonly
Upstream Repository Material
The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.
Supporting Evidence

Zustand Patterns

Modern state management with Zustand 5.x - lightweight, TypeScript-first, no boilerplate.

Overview

  • Global state without Redux complexity
  • Shared state across components without prop drilling
  • Persisted state with localStorage/sessionStorage
  • Computed/derived state with selectors
  • State that needs middleware (logging, devtools, persistence)

Core Patterns

1. Basic Store with TypeScript

typescript
1import { create } from 'zustand'; 2 3interface BearState { 4 bears: number; 5 increase: (by: number) => void; 6 reset: () => void; 7} 8 9const useBearStore = create<BearState>()((set) => ({ 10 bears: 0, 11 increase: (by) => set((state) => ({ bears: state.bears + by })), 12 reset: () => set({ bears: 0 }), 13}));

2. Slices Pattern (Modular Stores)

typescript
1import { create, StateCreator } from 'zustand'; 2 3// Auth slice 4interface AuthSlice { 5 user: User | null; 6 login: (user: User) => void; 7 logout: () => void; 8} 9 10const createAuthSlice: StateCreator<AuthSlice & CartSlice, [], [], AuthSlice> = (set) => ({ 11 user: null, 12 login: (user) => set({ user }), 13 logout: () => set({ user: null }), 14}); 15 16// Cart slice 17interface CartSlice { 18 items: CartItem[]; 19 addItem: (item: CartItem) => void; 20 clearCart: () => void; 21} 22 23const createCartSlice: StateCreator<AuthSlice & CartSlice, [], [], CartSlice> = (set) => ({ 24 items: [], 25 addItem: (item) => set((state) => ({ items: [...state.items, item] })), 26 clearCart: () => set({ items: [] }), 27}); 28 29// Combined store 30const useStore = create<AuthSlice & CartSlice>()((...a) => ({ 31 ...createAuthSlice(...a), 32 ...createCartSlice(...a), 33}));

3. Immer Middleware (Immutable Updates)

typescript
1import { create } from 'zustand'; 2import { immer } from 'zustand/middleware/immer'; 3 4interface TodoState { 5 todos: Todo[]; 6 addTodo: (text: string) => void; 7 toggleTodo: (id: string) => void; 8 updateNested: (id: string, subtaskId: string, done: boolean) => void; 9} 10 11const useTodoStore = create<TodoState>()( 12 immer((set) => ({ 13 todos: [], 14 addTodo: (text) => 15 set((state) => { 16 state.todos.push({ id: crypto.randomUUID(), text, done: false }); 17 }), 18 toggleTodo: (id) => 19 set((state) => { 20 const todo = state.todos.find((t) => t.id === id); 21 if (todo) todo.done = !todo.done; 22 }), 23 updateNested: (id, subtaskId, done) => 24 set((state) => { 25 const todo = state.todos.find((t) => t.id === id); 26 const subtask = todo?.subtasks?.find((s) => s.id === subtaskId); 27 if (subtask) subtask.done = done; 28 }), 29 })) 30);

4. Persist Middleware

typescript
1import { create } from 'zustand'; 2import { persist, createJSONStorage } from 'zustand/middleware'; 3 4interface SettingsState { 5 theme: 'light' | 'dark'; 6 language: string; 7 setTheme: (theme: 'light' | 'dark') => void; 8} 9 10const useSettingsStore = create<SettingsState>()( 11 persist( 12 (set) => ({ 13 theme: 'light', 14 language: 'en', 15 setTheme: (theme) => set({ theme }), 16 }), 17 { 18 name: 'settings-storage', 19 storage: createJSONStorage(() => localStorage), 20 partialize: (state) => ({ theme: state.theme }), // Only persist theme 21 version: 1, 22 migrate: (persisted, version) => { 23 if (version === 0) { 24 // Migration logic 25 } 26 return persisted as SettingsState; 27 }, 28 } 29 ) 30);

5. Selectors (Prevent Re-renders)

typescript
1// ❌ BAD: Re-renders on ANY state change 2const { bears, fish } = useBearStore(); 3 4// ✅ GOOD: Only re-renders when bears changes 5const bears = useBearStore((state) => state.bears); 6 7// ✅ GOOD: Shallow comparison for objects (Zustand 5.x) 8import { useShallow } from 'zustand/react/shallow'; 9 10const { bears, fish } = useBearStore( 11 useShallow((state) => ({ bears: state.bears, fish: state.fish })) 12); 13 14// ✅ GOOD: Computed/derived state via selector 15const totalAnimals = useBearStore((state) => state.bears + state.fish); 16 17// ❌ BAD: Storing computed state 18const useStore = create((set) => ({ 19 items: [], 20 total: 0, // Don't store derived values! 21 addItem: (item) => set((s) => ({ 22 items: [...s.items, item], 23 total: s.total + item.price, // Sync issues! 24 })), 25})); 26 27// ✅ GOOD: Compute in selector 28const total = useStore((s) => s.items.reduce((sum, i) => sum + i.price, 0));

6. Async Actions

typescript
1interface UserState { 2 user: User | null; 3 loading: boolean; 4 error: string | null; 5 fetchUser: (id: string) => Promise<void>; 6} 7 8const useUserStore = create<UserState>()((set) => ({ 9 user: null, 10 loading: false, 11 error: null, 12 fetchUser: async (id) => { 13 set({ loading: true, error: null }); 14 try { 15 const user = await api.getUser(id); 16 set({ user, loading: false }); 17 } catch (error) { 18 set({ error: error.message, loading: false }); 19 } 20 }, 21}));

7. DevTools Integration

typescript
1import { create } from 'zustand'; 2import { devtools } from 'zustand/middleware'; 3 4const useStore = create<State>()( 5 devtools( 6 (set) => ({ 7 // ... state and actions 8 }), 9 { name: 'MyStore', enabled: process.env.NODE_ENV === 'development' } 10 ) 11);

Quick Reference

typescript
1// ✅ Create typed store with double-call pattern 2const useStore = create<State>()((set, get) => ({ ... })); 3 4// ✅ Use selectors for all state access 5const count = useStore((s) => s.count); 6 7// ✅ Use useShallow for multiple values (Zustand 5.x) 8const { a, b } = useStore(useShallow((s) => ({ a: s.a, b: s.b }))); 9 10// ✅ Middleware order: immer → subscribeWithSelector → devtools → persist 11create(persist(devtools(immer((set) => ({ ... }))))) 12 13// ❌ Never destructure entire store 14const store = useStore(); // Re-renders on ANY change 15 16// ❌ Never store server state (use TanStack Query instead) 17const useStore = create((set) => ({ users: [], fetchUsers: async () => ... }));

Key Decisions

DecisionOption AOption BRecommendation
State structureSingle storeMultiple storesSlices in single store - easier cross-slice access
Nested updatesSpread operatorImmer middlewareImmer for deeply nested state (3+ levels)
PersistenceManual localStoragepersist middlewarepersist middleware with partialize
Multiple valuesMultiple selectorsuseShallowuseShallow for 2-5 related values
Server stateZustandTanStack QueryTanStack Query - Zustand for client-only state
DevToolsAlways onConditionalConditional - enabled: process.env.NODE_ENV === 'development'

Anti-Patterns (FORBIDDEN)

typescript
1// ❌ FORBIDDEN: Destructuring entire store 2const { count, increment } = useStore(); // Re-renders on ANY state change 3 4// ❌ FORBIDDEN: Storing derived/computed state 5const useStore = create((set) => ({ 6 items: [], 7 total: 0, // Will get out of sync! 8})); 9 10// ❌ FORBIDDEN: Storing server state 11const useStore = create((set) => ({ 12 users: [], // Use TanStack Query instead 13 fetchUsers: async () => { ... }, 14})); 15 16// ❌ FORBIDDEN: Mutating state without Immer 17set((state) => { 18 state.items.push(item); // Breaks reactivity! 19 return state; 20}); 21 22// ❌ FORBIDDEN: Using deprecated shallow import 23import { shallow } from 'zustand/shallow'; // Use useShallow from zustand/react/shallow

Integration with React Query

typescript
1// ✅ Zustand for CLIENT state (UI, preferences, local-only) 2const useUIStore = create<UIState>()((set) => ({ 3 sidebarOpen: false, 4 theme: 'light', 5 toggleSidebar: () => set((s) => ({ sidebarOpen: !s.sidebarOpen })), 6})); 7 8// ✅ TanStack Query for SERVER state (API data) 9function Dashboard() { 10 const sidebarOpen = useUIStore((s) => s.sidebarOpen); 11 const { data: users } = useQuery({ queryKey: ['users'], queryFn: fetchUsers }); 12 // Zustand: UI state | TanStack Query: server data 13}
  • tanstack-query-advanced - Server state management (use with Zustand for client state)
  • form-state-patterns - Form state (React Hook Form vs Zustand for forms)
  • react-server-components-framework - RSC hydration considerations with Zustand

Capability Details

store-creation

Keywords: zustand, create, store, typescript, state Solves: Setting up type-safe Zustand stores with proper TypeScript inference

slices-pattern

Keywords: slices, modular, split, combine, StateCreator Solves: Organizing large stores into maintainable, domain-specific slices

middleware-stack

Keywords: immer, persist, devtools, middleware, compose Solves: Combining middleware in correct order for immutability, persistence, and debugging

selector-optimization

Keywords: selector, useShallow, re-render, performance, memoization Solves: Preventing unnecessary re-renders with proper selector patterns

persistence-migration

Keywords: persist, localStorage, sessionStorage, migrate, version Solves: Persisting state with schema migrations between versions

References

  • references/middleware-composition.md - Combining multiple middleware
  • scripts/store-template.ts - Production-ready store template
  • checklists/zustand-checklist.md - Implementation checklist

Habilidades Relacionadas

Looking for an alternative to zustand-patterns or another community skill for your workflow? Explore these related open-source skills.

Ver tudo

openclaw-release-maintainer

Logo of openclaw
openclaw

Resumo localizado: 🦞 # OpenClaw Release Maintainer Use this skill for release and publish-time workflow. It covers ai, assistant, crustacean workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

widget-generator

Logo of f
f

Resumo localizado: Generate customizable widget plugins for the prompts.chat feed system # Widget Generator Skill This skill guides creation of widget plugins for prompts.chat . It covers ai, artificial-intelligence, awesome-list workflows. This AI agent skill supports Claude Code, Cursor, and

flags

Logo of vercel
vercel

Resumo localizado: The React Framework # Feature Flags Use this skill when adding or changing framework feature flags in Next.js internals. It covers blog, browser, compiler workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

138.4k
0
Navegador

pr-review

Logo of pytorch
pytorch

Resumo localizado: Usage Modes No Argument If the user invokes /pr-review with no arguments, do not perform a review . It covers autograd, deep-learning, gpu workflows. This AI agent skill supports Claude Code, Cursor, and Windsurf workflows.

98.6k
0
Desenvolvedor