AgentSkillsCN

zustand

React 应用程序 Zustand 状态管理的最佳实践。适用于编写、审查或重构 Zustand 存储时使用,以确保最佳性能与可维护性。适用于涉及状态管理、存储、选择器、重新渲染,以及 Zustand 模式等任务时使用。

SKILL.md
--- frontmatter
name: zustand
description: Zustand state management best practices for React applications. Use when writing, reviewing, or refactoring Zustand stores to ensure optimal performance and maintainability. Triggers on tasks involving state management, stores, selectors, re-renders, and Zustand patterns.

Community Zustand Best Practices

Comprehensive performance and architecture guide for Zustand state management in React applications. Contains 43 rules across 8 categories, prioritized by impact from critical (store architecture, selector optimization) to incremental (advanced patterns).

When to Apply

Reference these guidelines when:

  • Creating new Zustand stores
  • Optimizing re-render performance with selectors
  • Implementing persistence or middleware
  • Integrating Zustand with SSR/Next.js
  • Reviewing code for state management patterns

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Store ArchitectureCRITICALstore-
2Selector OptimizationCRITICALselect-
3Re-render PreventionHIGHrender-
4State UpdatesMEDIUM-HIGHupdate-
5Middleware ConfigurationMEDIUMmw-
6SSR and HydrationMEDIUMssr-
7TypeScript PatternsLOW-MEDIUMts-
8Advanced PatternsLOWadv-

Quick Reference

1. Store Architecture (CRITICAL)

2. Selector Optimization (CRITICAL)

3. Re-render Prevention (HIGH)

4. State Updates (MEDIUM-HIGH)

5. Middleware Configuration (MEDIUM)

6. SSR and Hydration (MEDIUM)

7. TypeScript Patterns (LOW-MEDIUM)

8. Advanced Patterns (LOW)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
metadata.jsonVersion and reference information