react-state-management — Claude Code skill
Helps choose and structure React state management for local, global, server, URL, and form data.
/plugin marketplace add wshobson/agents
/plugin install frontend-mobile-development@claude-code-workflowsWhat react-state-management does
This skill maps React state to the right category and tool. It covers local state with useState and useReducer, shared state with Redux Toolkit, Zustand, and Jotai, plus remote data with React Query, SWR, and RTK Query. URL state and form state are included as well.
It gives selection guidance for small and large apps, shows a Zustand store using devtools and persist, and covers selectors, normalized data, and the split between client and server state. There are also sections on optimistic updates, state debugging, and moving from legacy Redux to Redux Toolkit.
Install it when you are choosing a React state architecture or planning a Redux migration. It is a poor fit for projects that do not use React.
What it helps with
- choose a global state library for a React app
- separate server data from client state
- set up a persisted Zustand store
- trace unnecessary React re-renders
- migrate legacy Redux to Redux Toolkit
Example prompts for the agent
- Compare Redux Toolkit, Zustand, and Jotai for this React app and recommend one.
- Separate this project’s local, global, and server state, then propose a React Query setup.
- Rewrite this legacy Redux reducer with Redux Toolkit.
How to install react-state-management
1Plugin marketplace
/plugin marketplace add wshobson/agents/plugin install frontend-mobile-development@claude-code-workflowsThis installs the whole frontend-mobile-development plugin with all its skills
2Skills CLI (Vercel)
npx skills add wshobson/agents --skill react-state-management -a claude-code3Manually: put the files in place
~/.claude/skills/react-state-management/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/react-state-management/
1Skills CLI (Vercel)
npx skills add wshobson/agents --skill react-state-management -a codex2Manually: put the files in place
.agents/skills/react-state-management/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add wshobson/agents --skill react-state-management -a cursor2Manually: put the files in place
.cursor/skills/react-state-management/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install wshobson/agents react-state-management2Manually: put the files in place
.github/skills/react-state-management/SKILL.mdPlatform CLI
gemini skills install https://github.com/wshobson/agents --path plugins/frontend-mobile-development/skills/react-state-managementManually: put the files in place
.devin/skills/react-state-management/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set213
The whole set →Similar
Questions about react-state-management
How do I install react-state-management in Claude Code?
Run npx skills add wshobson/agents --skill react-state-management -a claude-code. The skill file will be available at ~/.claude/skills/react-state-management/SKILL.md.
What does react-state-management do?
It helps design state in React apps and choose between Redux Toolkit, Zustand, Jotai, React Query, and related solutions.
Which platforms support react-state-management?
The skill targets Claude Code, Codex, and Cursor. Its instructions also include commands for GitHub Copilot and Gemini CLI.
Source text
SKILL.md · MIT
---
name: react-state-management
description: Master modern React state management with Redux Toolkit, Zustand, Jotai, and React Query. Use when setting up global state, managing server state, or choosing between state management solutions.
---
# React State Management
Comprehensive guide to modern React state management patterns, from local component state to global stores and server state synchronization.
## When to Use This Skill
- Setting up global state management in a React app
- Choosing between Redux Toolkit, Zustand, or Jotai
- Managing server state with React Query or SWR
- Implementing optimistic updates
- Debugging state-related issues
- Migrating from legacy Redux to modern patterns
## Core Concepts
### 1. State Categories
| Type | Description | Solutions |
| ---------------- | ---------------------------- | ----------------------------- |
| **Local State** | Component-specific, UI state | useState, useReducer |
| **Global State** | Shared across components | Redux Toolkit, Zustand, Jotai |
| **Server State** | Remote data, caching | React Query, SWR, RTK Query |
| **URL State** | Route parameters, search | React Router, nuqs |
| **Form State** | Input values, validation | React Hook Form, Formik |
### 2. Selection Criteria
```
Small app, simple state → Zustand or Jotai
Large app, complex state → Redux Toolkit
Heavy server interaction → React Query + light client state
Atomic/granular updates → Jotai
```
## Quick Start
### Zustand (Simplest)
```typescript
// store/useStore.ts
import { create } from 'zustand'
import { devtools, persist } from 'zustand/middleware'
interface AppState {
user: User | null
theme: 'light' | 'dark'
setUser: (user: User | null) => void
toggleTheme: () => void
}
export const useStore = create<AppState>()(
devtools(
persist(
(set) => ({
user: null,
theme: 'light',
setUser: (user) => set({ user }),
toggleTheme: () => set((state) => ({
theme: state.theme === 'light' ? 'dark' : 'light'
})),
}),
{ name: 'app-storage' }
)
)
)
// Usage in component
function Header() {
const { user, theme, toggleTheme } = useStore()
return (
<header className={theme}>
{user?.name}
<button onClick={toggleTheme}>Toggle Theme</button>
</header>
)
}
```
## Detailed patterns and worked examples
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
## Best Practices
### Do's
- **Colocate state** - Keep state as close to where it's used as possible
- **Use selectors** - Prevent unnecessary re-renders with selective subscriptions
- **Normalize data** - Flatten nested structures for easier updates
- **Type everything** - Full TypeScript coverage prevents runtime errors
- **Separate concerns** - Server state (React Query) vs client state (Zustand)
### Don'ts
- **Don't over-globalize** - Not everything needs to be in global state
- **Don't duplicate server state** - Let React Query manage it
- **Don't mutate directly** - Always use immutable updates
- **Don't store derived data** - Compute it instead
- **Don't mix paradigms** - Pick one primary solution per category
## Migration Guides
### From Legacy Redux to RTK
```typescript
// Before (legacy Redux)
const ADD_TODO = "ADD_TODO";
const addTodo = (text) => ({ type: ADD_TODO, payload: text });
function todosReducer(state = [], action) {
switch (action.type) {
case ADD_TODO:
return [...state, { text: action.payload, completed: false }];
default:
return state;
}
}
// After (Redux Toolkit)
const todosSlice = createSlice({
name: "todos",
initialState: [],
reducers: {
addTodo: (state, action: PayloadAction<string>) => {
// Immer allows "mutations"
state.push({ text: action.payload, completed: false });
},
},
});
```
© Seth Hobson · MIT · wshobson/agents