Zustand state management patterns for the Flux project. Slice pattern, strict selectors, and app-local store definitions. Use when creating new zustand stores, adding slices, writing selectors, integrating stores with React components, or refactoring client-side state management. Triggers on tasks involving zustand, store creation, state management, selectors, or client UI state.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
npx agent-skills-cli listSkill Instructions
name: zustand-store description: Zustand state management patterns for the Flux project. Slice pattern, strict selectors, and app-local store definitions. Use when creating new zustand stores, adding slices, writing selectors, integrating stores with React components, or refactoring client-side state management. Triggers on tasks involving zustand, store creation, state management, selectors, or client UI state.
Zustand Store
Zustand state management with Slice architecture for the Flux monorepo.
Architecture
- Factory:
apps/web/src/lib/create-store.tsβcreateStorewrapper withsubscribeWithSelector+devtools+shallow, and optionalpersistsupport - Store definitions:
apps/web/src/stores/β domain stores live in the consuming app - Store creation: All Zustand stores must be created through
createStore; for persistence use the third argumentoptions.persist - Middleware ownership:
createStoreowns middleware composition (devtools,subscribeWithSelector, optionalpersist) β do not compose these inline in feature store files - Organization: Multi-store by domain, each store uses Slice pattern
- Selectors: Strict mode β all state access through selector objects
- Types:
typeonly (nointerface) β Store = State & SliceAction1 & SliceAction2 & ... - Imports: Direct module paths only β no barrel files (
noBarrelFileBiome rule)
Quick Reference
| Pattern | Reference |
|---|---|
| Store creation & Slice pattern | store-patterns |
| Selector patterns | selector-patterns |
| React integration | react-integration |
Directory Structure
apps/web/src/stores/
βββ <domain>/
βββ store.ts # store creation + slice composition
βββ initial-state.ts # state types + initial values
βββ slices/
βββ <slice>/
βββ action.ts
βββ initial-state.ts
βββ selectors.ts
Rules
- Create stores only via
createStorefromapps/web/src/lib/create-store.ts; do not usecreate/createWithEqualityFndirectly in feature stores - Never compose
devtools,subscribeWithSelector, orpersistdirectly instores/**/store.ts; extendcreateStorefirst if new middleware behavior is required - Never access store state directly in components β always use selectors
- Every selector function must be exported via a
xxxSelectorsobject - Keep state flat β avoid deeply nested objects
- For localStorage persistence, pass
options.persistintocreateStoreand usepartializeto persist only needed fields - Use
typefor all state and action type definitions β neverinterface(prevents declaration merging) - Prefix internal-only actions with
internal_ - Access actions via
getXxxStoreState()in callbacks to avoid subscriptions (Vercel:rerender-defer-reads) - Subscribe to derived booleans, not raw values (Vercel:
rerender-derived-state) - Use functional
set((s) => ...)for state updates that depend on current state (Vercel:rerender-functional-setstate) - No facade hooks β components import selectors and actions directly; don't bundle unrelated state into a single hook
More by lyzno1
View allTurborepo monorepo build system guidance. Triggers on: turbo.json, task pipelines, dependsOn, caching, remote cache, the "turbo" CLI, --filter, --affected, CI optimization, environment variables, internal packages, monorepo structure/best practices, and boundaries. Use when user: configures tasks/workflows/pipelines, creates packages, sets up monorepo, shares code between apps, runs changed/affected packages, debugs cache, or has apps/packages directories.
Anthony Fu's opinionated tooling and conventions for JavaScript/TypeScript projects. Use when setting up new projects, configuring ESLint/Prettier alternatives, monorepos, library publishing, or when the user mentions Anthony Fu's preferences.
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 9 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples.
