From zustand
Zustand state management for React applications. This skill should be used when creating Zustand stores, implementing TypeScript store patterns, using middleware (persist, devtools, immer, subscribeWithSelector), building slice patterns for large stores, optimizing React component re-renders with selectors, implementing async actions and data fetching, or testing Zustand stores.
How this skill is triggered — by the user, by Claude, or both
Slash command
/zustand:zustandThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Zustand is a small, fast, scalable state management solution for React. This skill covers store creation, TypeScript patterns, middleware, and performance optimization.
Zustand is a small, fast, scalable state management solution for React. This skill covers store creation, TypeScript patterns, middleware, and performance optimization.
import { create } from 'zustand'
interface BearStore {
bears: number
increase: () => void
reset: () => void
}
const useBearStore = create<BearStore>((set) => ({
bears: 0,
increase: () => set((state) => ({ bears: state.bears + 1 })),
reset: () => set({ bears: 0 }),
}))
// Select specific state (prevents unnecessary re-renders)
const bears = useBearStore((state) => state.bears)
const increase = useBearStore((state) => state.increase)
// Multiple selectors - use useShallow for object selections
import { useShallow } from 'zustand/react/shallow'
const { bears, increase } = useBearStore(
useShallow((state) => ({ bears: state.bears, increase: state.increase }))
)
For detailed patterns and advanced usage, load the appropriate reference:
| Topic | Reference | Use When |
|---|---|---|
| Store patterns | references/store-patterns.md | Creating stores, TypeScript setup, slice pattern, combining stores |
| Middleware | references/middleware.md | persist, devtools, immer, subscribeWithSelector, custom middleware |
| React integration | references/react-integration.md | Selectors, avoiding re-renders, subscriptions, context usage |
| Async & testing | references/async-testing.md | Async actions, data fetching, loading states, testing patterns |
// Get current state
const bears = useBearStore.getState().bears
// Subscribe to changes
const unsub = useBearStore.subscribe((state) => console.log(state.bears))
// Update state
useBearStore.setState({ bears: 10 })
import { create } from 'zustand'
import { devtools, persist } from 'zustand/middleware'
import { immer } from 'zustand/middleware/immer'
const useStore = create<Store>()(
devtools(
persist(
immer((set) => ({
// state and actions
})),
{ name: 'store-key' }
)
)
)
store-patterns.md for TypeScript setup and organizationmiddleware.md for middleware configurationreact-integration.md for selector optimizationasync-testing.md for async patterns and loading statesasync-testing.md for testing patternsGuides collaborative design exploration before implementation: explores context, asks clarifying questions, proposes approaches, and writes a design doc for user approval.
Creates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.
Resolves in-progress git merge or rebase conflicts by analyzing history, understanding intent, and preserving both changes where possible. Runs automated checks after resolution.
npx claudepluginhub kettleofketchup/kettleofskills --plugin zustand