React State Management
involvex/youtube-music-cli
Master modern React state management with Redux Toolkit, Zustand, Jotai, and React Query.
Guide for Zustand state management patterns in Mobazha including store design, middleware usage, selectors, persistence, and integration with React Query.
$ npx skills add mobazha/mobazha-unified --skill state-management -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install mobazha/mobazha-unified state-management --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/mobazha/mobazha-unified.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.cursor/skills/state-management .claude/skills/state-management && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "state-management" agent skill from https://github.com/mobazha/mobazha-unified/tree/main/.cursor/skills/state-management into .claude/skills/state-management/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "state-management", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/mobazha/mobazha-unified/tree/main/.cursor/skills/state-managementType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add mobazha/mobazha-unified --skill state-management -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install mobazha/mobazha-unified state-management --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/mobazha/mobazha-unified.git skills-src && mkdir -p .agents/skills && cp -r skills-src/.cursor/skills/state-management .agents/skills/state-management && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "state-management" agent skill from https://github.com/mobazha/mobazha-unified/tree/main/.cursor/skills/state-management into .agents/skills/state-management/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "state-management", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add mobazha/mobazha-unified --skill state-management -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install mobazha/mobazha-unified state-management --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/mobazha/mobazha-unified.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/.cursor/skills/state-management .cursor/skills/state-management && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "state-management" agent skill from https://github.com/mobazha/mobazha-unified/tree/main/.cursor/skills/state-management into .cursor/skills/state-management/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "state-management", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/mobazha/mobazha-unified.git --path .cursor/skills/state-management--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add mobazha/mobazha-unified --skill state-management -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install mobazha/mobazha-unified state-management --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/mobazha/mobazha-unified.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/.cursor/skills/state-management .gemini/skills/state-management && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "state-management" agent skill from https://github.com/mobazha/mobazha-unified/tree/main/.cursor/skills/state-management into .gemini/skills/state-management/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "state-management", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install mobazha/mobazha-unified state-managementInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add mobazha/mobazha-unified --skill state-management -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/mobazha/mobazha-unified.git skills-src && mkdir -p .github/skills && cp -r skills-src/.cursor/skills/state-management .github/skills/state-management && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "state-management" agent skill from https://github.com/mobazha/mobazha-unified/tree/main/.cursor/skills/state-management into .github/skills/state-management/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "state-management", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add mobazha/mobazha-unified --skill state-management -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install mobazha/mobazha-unified state-management --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/mobazha/mobazha-unified.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/.cursor/skills/state-management .opencode/skills/state-management && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "state-management" agent skill from https://github.com/mobazha/mobazha-unified/tree/main/.cursor/skills/state-management into .opencode/skills/state-management/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "state-management", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
state-managementGuide for Zustand state management patterns in Mobazha including store design, middleware usage, selectors, persistence, and integration with React Query.
State Management is an agent skill from mobazha/mobazha-unified. Guide for Zustand state management patterns in Mobazha including store design, middleware usage, selectors, persistence, and integration with React Query. Use when creating or modifying stores, or working with state management, "状态管理", "Zustand", "Store", "全局状态", "持久化".
Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.
It sits in Frontend & Design, covering State management. It works with Zustand and TanStack. The repository describes itself as: Open-source commerce frontend for storefronts, marketplaces, checkout, and seller management. The licence is MPL-2.0.
2 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit 156c699. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
State Management loads about 1.7k tokens when it runs. Until then it costs about 72 tokens; SKILL.md has 134 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from mobazha/mobazha-unified at commit 156c699, republished under its MPL-2.0 licence (© mobazha). 134 words, ~1,685 tokens.
.claude/skills/state-management/SKILL.md (or your agent's skills folder).Mobazha 项目基于 Zustand 的状态管理模式和最佳实践。
| Store | 文件 | 持久化 | 用途 |
|---|---|---|---|
useUserStore | userStore.ts | ✅ 部分 | 用户认证、profile |
useCartStore | cartStore.ts | ✅ 全部 | 购物车 |
useWalletStore | walletStore.ts | ❌ | 钱包余额、交易 |
useCurrencyStore | currencyStore.ts | ✅ | 汇率、货币转换 |
useChatStore | chatStore.ts | ❌ | Matrix 聊天状态 |
useNotificationStore | notificationStore.ts | ❌ | 通知 |
useRoleStore | roleStore.ts | ❌ | 用户角色 |
每个 Store 对应一个业务领域,保持单一职责:
// ✅ 好:职责清晰
useCartStore; // 只管购物车
useWalletStore; // 只管钱包
// ❌ 差:职责混乱
useAppStore; // 什么都放| 类型 | 管理方式 | 示例 |
|---|---|---|
| Server State(后端数据) | React Query / API 请求 | 订单列表、商品详情 |
| Client State(本地状态) | Zustand Store | 购物车、UI 偏好、聊天状态 |
| Derived State(派生数据) | useMemo / Store 计算属性 | 购物车总价、筛选后的列表 |
// ✅ Server state 用 hook(内部可能用 React Query 或直接 API)
const { orders, isLoading } = useOrders();
// ✅ Client state 用 Store
const cartItems = useCartStore(state => state.items);import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
// 1. 定义接口
interface ExampleState {
// 状态
items: Item[];
selectedId: string | null;
isLoading: boolean;
error: string | null;
// 动作
fetchItems: () => Promise<void>;
addItem: (item: Item) => void;
removeItem: (id: string) => void;
selectItem: (id: string | null) => void;
clearError: () => void;
// 计算属性
getItemCount: () => number;
getItemById: (id: string) => Item | undefined;
}
// 2. 创建 Store
export const useExampleStore = create<ExampleState>()(
devtools(
persist(
(set, get) => ({
// 初始状态
items: [],
selectedId: null,
isLoading: false,
error: null,
// 异步动作
fetchItems: async () => {
try {
set({ isLoading: true, error: null });
const items = await exampleApi.getItems();
set({ items, isLoading: false });
} catch (err) {
set({
error: err instanceof Error ? err.message : '加载失败',
isLoading: false,
});
}
},
// 同步动作
addItem: item =>
set(state => ({
items: [...state.items, item],
})),
removeItem: id =>
set(state => ({
items: state.items.filter(i => i.id !== id),
})),
selectItem: id => set({ selectedId: id }),
clearError: () => set({ error: null }),
// 计算属性
getItemCount: () => get().items.length,
getItemById: id => get().items.find(i => i.id === id),
}),
{
name: 'mobazha-example-storage', // localStorage key
partialize: state => ({
items: state.items, // 只持久化必要的字段
// 不持久化 isLoading, error 等临时状态
}),
}
),
{ name: 'ExampleStore' } // DevTools 中显示的名称
)
);
// 3. 导出选择器
export const selectItems = (state: ExampleState) => state.items;
export const selectLoading = (state: ExampleState) => state.isLoading;
export const selectError = (state: ExampleState) => state.error;// 在 Redux DevTools 中可视化状态变化
devtools(storeCreator, { name: 'StoreName' });persist(storeCreator, {
name: 'mobazha-xxx-storage', // localStorage key,统一 mobazha- 前缀
partialize: state => ({
// 只持久化必要字段
items: state.items,
preferences: state.preferences,
// ❌ 不要持久化:isLoading, error, 临时 UI 状态
}),
});// 标准顺序:devtools 在最外层
create<State>()(
devtools( // 最外层
persist( // 内层(可选)
(set, get) => ({ ... })
)
)
);// ❌ 差:每次 store 任何变化都会重渲染
const { items, isLoading, error } = useCartStore();
// ✅ 好:只订阅需要的字段
const items = useCartStore(state => state.items);
const isLoading = useCartStore(state => state.isLoading);
// ✅ 更好:使用导出的选择器
const items = useCartStore(selectCartItems);
// ✅ 组合选择器(需要 shallow 比较)
import { useShallow } from 'zustand/react/shallow';
const { items, total } = useCartStore(
useShallow(state => ({
items: state.items,
total: state.getTotal(),
}))
);// 前缀 select + 描述
export const selectCartItems = (state: CartState) => state.items;
export const selectCartTotal = (state: CartState) => state.getTotal();
export const selectIsCartEmpty = (state: CartState) => state.items.length === 0;项目统一的异步动作错误处理:
fetchData: async () => {
try {
set({ isLoading: true, error: null });
const data = await apiCall();
set({ data, isLoading: false });
} catch (err) {
set({
error: err instanceof Error ? err.message : '未知错误',
isLoading: false,
});
}
},| 场景 | 建议 |
|---|---|
| 多个页面/组件共享的客户端状态 | ✅ 创建新 Store |
| 单个页面内的临时状态 | ❌ 用 useState |
| 从后端获取的数据 | ❌ 用 API hook(useOrders 等) |
| 全局 UI 状态(主题、语言) | ✅ Store + persist |
| 表单状态 | ❌ 用 useState 或表单库 |
import { act } from '@testing-library/react';
describe('useCartStore', () => {
beforeEach(() => {
// 重置 store 状态
useCartStore.setState({
items: [],
isLoading: false,
error: null,
});
});
it('应正确添加商品', () => {
act(() => {
useCartStore.getState().addItem(mockItem);
});
expect(useCartStore.getState().items).toHaveLength(1);
});
});devtools middleware?partialize 排除临时状态?mobazha- 前缀?© mobazha, MPL-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in .cursor/skills/state-management of mobazha/mobazha-unified.
Open the folder on GitHubat commit 156c699
State Management next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| State Management this skillmobazha/mobazha-unified | 165 | — | ~1.7k | Automated safety check: Pass | MPL-2.0 | |
| React State Managementinvolvex/youtube-music-cli | 456 | 13 repos | ~3k | Automated safety check: Pass | MIT | |
| Nextjs15 Initbear2u/my-skills | 933 | — | ~2.4k | Automated safety check: Pass | None | |
| Opik Frontend Patternscomet-ml/opik | 22k | — | ~1.1k | Automated safety check: Pass | Apache-2.0 | |
| State Managementemanueleielo/deepagents-open-lovable | 111 | — | ~1.7k | Automated safety check: Pass | None | |
| React ExpertJeffallan/claude-skills | 12k | — | ~1.4k | Automated safety check: Pass | MIT |
involvex/youtube-music-cli
Master modern React state management with Redux Toolkit, Zustand, Jotai, and React Query.
bear2u/my-skills
A skill your agent uses when user wants to create a new Next.js 15 project (Todo/Blog/Dashboard/E-commerce/Custom domain) with App Router, ShadCN, Zustand, Tanstack Query, and modern Next.js stack
comet-ml/opik
Sets the conventions for the Opik React frontend: TanStack Query for data, Zustand for shared state, one-way layer imports and a fix for Google Translate crashes.
emanueleielo/deepagents-open-lovable
State management patterns - Zustand, Jotai, Context. An agent skill from emanueleielo/deepagents-open-lovable.
Jeffallan/claude-skills
Builds React 19 components in TypeScript with Server Components, useActionState forms, custom hooks and state libraries, checked with tsc and React Testing Library.
mizchi/skills
A skill your agent uses when reviewing state management architecture — classifying state types (server/URL/form/UI), checking for over-globalization, Jotai/Zustand/Redux patterns, derived state, and…
mobazha/mobazha-unified
Accessibility guide for Mobazha following WCAG 2.1 AA standards including color contrast, reduced motion, ARIA patterns, keyboard navigation, focus management, and screen reader testing.
mobazha/mobazha-unified
Look up Mobazha backend API endpoints, request/response formats, and field mappings.
mobazha/mobazha-unified
Review code for quality, architecture consistency, and adherence to Mobazha project standards using confidence-based filtering.
mobazha/mobazha-unified
Simplify and refine recently written code for clarity, consistency, and maintainability while preserving all functionality.
mobazha/mobazha-unified
Generate commit messages and run pre-commit validation following Mobazha conventions.
mobazha/mobazha-unified
Create and modify UI components following Mobazha conventions including directory structure, spacing standards, accessibility, and testing.
Categories
Guide for Zustand state management patterns in Mobazha including store design, middleware usage, selectors, persistence, and integration with React Query. State Management is an agent skill from mobazha/mobazha-unified. Guide for Zustand state management patterns in Mobazha including store design, middleware usage, selectors, persistence, and integration with React Query.
State Management fits situations like: modifying stores; working with state management.
Run `npx skills add mobazha/mobazha-unified --skill state-management -a claude-code`. Or copy the skill folder (.cursor/skills/state-management in mobazha/mobazha-unified) into .claude/skills/state-management in your project. Claude Code loads it when a task matches its description.
Run `npx skills add mobazha/mobazha-unified --skill state-management -a codex`. Or copy the skill folder (.cursor/skills/state-management in mobazha/mobazha-unified) into .agents/skills/state-management in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mobazha/mobazha-unified --skill state-management -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/state-management, .gemini/skills/state-management, .github/skills/state-management and .opencode/skills/state-management in your project.
SKILL.md names no scripts, command-line tools or credentials: State Management is instructions for the agent only.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
State Management is published under the MPL-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.7k tokens (SKILL.md is roughly 6.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with State Management: React State Management (involvex/youtube-music-cli, 456 stars), Nextjs15 Init (bear2u/my-skills, 933 stars), Opik Frontend Patterns (comet-ml/opik, 22k stars) and State Management (emanueleielo/deepagents-open-lovable, 111 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
mobazha (a GitHub organization) maintains it in mobazha/mobazha-unified, which has 165 GitHub stars. The repository holds 29 skills in this directory. The repository was last updated on October 3, 2026.
Source: mobazha/mobazha-unified on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.