zustand-patterns
Zustand 状态管理实战模式。涵盖 Store 设计规范、Slice 工厂复用、persist 持久化、可恢复任务持久化、Electron IPC 联动、Store 测试和常见陷阱。适用于 React + Zustand 项目。
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/bingfoon/zustand-patternsWhat This Skill Does
zustand-patterns is a professional-grade documentation and implementation framework for state management in React applications using Zustand. It provides a structured architectural blueprint for complex frontend projects, drawing from patterns used in large-scale modular applications. This skill encapsulates best practices for store design, action naming, multi-module state splitting, slice factory pattern for code reuse, persistence strategies, and testing methodologies. It acts as a standardizing agent for developers aiming to build maintainable, performant, and scalable React + Zustand architectures.
Installation
To integrate this skill into your environment, run the following command in your terminal:
clawhub install openclaw/skills/skills/bingfoon/zustand-patterns
Ensure you are in the root directory of your React project to allow the skill to analyze your existing directory structure if necessary.
Use Cases
- Large Scale Refactoring: Migrating messy global contexts or monolithic stores into modular, performant Zustand stores.
- Feature-Driven Development: Organizing code by modules where each feature possesses its own state, improving encapsulation and reducing re-renders.
- Cross-Component Logic Reuse: Implementing the Slice pattern to share complex logic like processing states (loading/progress) across multiple disparate stores.
- Desktop App State Persistence: Leveraging the
persistmiddleware to ensure Electron or web apps restore user state exactly as it was after a forced refresh or application restart. - Standardization: Implementing consistent action naming conventions (set, add, remove, reset) across a development team to decrease cognitive load.
Example Prompts
- "Analyze my current video processing module and show me how to refactor the state using the zustand-patterns slice factory."
- "Can you provide a boilerplate for a new Zustand store that includes persistence and a set of standard CRUD-like action naming conventions?"
- "How should I organize my folder structure for a multi-module project using the zustand-patterns approach?"
Tips & Limitations
- Store Granularity: Avoid the temptation of a single global store. Always follow the 'one module, one store' principle to optimize performance.
- Type Safety: Always define TypeScript interfaces for your store before implementing the logic. This ensures your actions remain predictable.
- Slice Complexity: While the Slice pattern is powerful, avoid over-nesting. Keep slices focused on specific state concerns like UI state, data synchronization, or processing logic.
- Debugging: Ensure your store names are unique to avoid collision errors in browser DevTools or during state hydration.
- Persistence Constraints: Be mindful of storage limits when using
persist; large state objects might trigger localStorage capacity warnings.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-bingfoon-zustand-patterns": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Related Skills
fluent-design
Microsoft Fluent Design System 实战参考。涵盖 Windows 11 设计语言、Mica/Acrylic 材质、WinUI 3 控件规格、排版层级、布局模式、Dark Mode、辅助功能和 Electron 适配。适用于开发 Windows 桌面应用或需要 Windows 原生感的跨平台应用。
apple-hig
Apple Human Interface Guidelines 实战参考。涵盖 macOS/iOS 设计规范、System Colors、排版层级、控件规格、布局间距、Dark Mode 适配、辅助功能和平台差异。适用于开发 macOS 桌面应用(Electron/SwiftUI/AppKit)和 iOS 应用时的 UI 设计决策。
material-design
Google Material Design 3 实战参考。涵盖 Material You 动态色彩、排版系统、组件规格、Shape 系统、Motion 规范、Dark Theme 适配和 Jetpack Compose/Flutter 对照。适用于 Android 应用、Web 应用和跨平台应用的 UI 设计决策。
batch-processing-patterns
批量处理与长时任务编排模式。涵盖队列管理、并发调度、中断恢复、熔断器、远程任务轮询、进度报告和反风控策略。适用于批量文件处理、AI API 调用、爬虫和后台任务场景。