React State Management skill for Claude

Master modern React state management with Redux Toolkit, Zustand, Jotai, and React Query.

When Claude uses it

Use when setting up global state, managing server state, or choosing between state management solutions.

React State Management SKILL.md

The full skill file from wshobson/agents (MIT).

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

TypeDescriptionSolutions
Local StateComponent-specific, UI stateuseState, useReducer
Global StateShared across componentsRedux Toolkit, Zustand, Jotai
Server StateRemote data, cachingReact Query, SWR, RTK Query
URL StateRoute parameters, searchReact Router, nuqs
Form StateInput values, validationReact 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)

// 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

// 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 });
    },
  },
});

How to install React State Management

Claude Code

Copy the skill into your personal skills folder (or into .claude/skills/ inside a project):

npx degit wshobson/agents/plugins/frontend-mobile-development/skills/react-state-management#main ~/.claude/skills/react-state-management

Codex

npx degit wshobson/agents/plugins/frontend-mobile-development/skills/react-state-management#main ~/.codex/skills/react-state-management

Claude.ai and Claude Desktop

Download the skill folder from GitHub, zip it, and upload it under Settings → Capabilities → Skills.

Frequently asked questions

+What does the React State Management skill do?

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.

+How do I install React State Management in Claude Code?

Copy the skill folder into ~/.claude/skills/react-state-management, for example with "npx degit wshobson/agents/plugins/frontend-mobile-development/skills/react-state-management#main ~/.claude/skills/react-state-management". Claude Code loads it automatically and uses it when a task matches.

+Does React State Management work with ChatGPT or Codex?

Yes. React State Management uses the open SKILL.md format. In Codex, put the folder in ~/.codex/skills/react-state-management. In Claude.ai, zip the folder and upload it under Settings → Capabilities → Skills.

+Is React State Management free?

React State Management is published on GitHub by wshobson under the MIT license, which allows free use.

Related design & frontend skills

  1. Design

    Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini, Atlas Cloud, MuAPI, or UberLLM…

    nextlevelbuilder/ui-ux-pro-max-skill★ 151k
  2. Frontend Design

    Official

    Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one.

    anthropics/skills★ 197k
  3. Ui Ux Pro Max

    UI/UX design intelligence for web, mobile, and desktop. This skill should be used when designing, building, reviewing, or fixing…

    nextlevelbuilder/ui-ux-pro-max-skill★ 151k
  4. Unity Ecs Patterns

    Master Unity ECS (Entity Component System) with DOTS, Jobs, and Burst for high-performance game development.

    wshobson/agents★ 43k
  5. Visual Design Foundations

    Apply typography, color theory, spacing systems, and iconography principles to create cohesive visual designs.

    wshobson/agents★ 43k
  6. Visual Edit Precision

    Use when making UI/frontend changes guided by visual context, when the user selects elements visually, draws annotations, or provides…

    wshobson/agents★ 43k
  7. Web Component Design

    Master React, Vue, and Svelte component patterns including CSS-in-JS, composition strategies, and reusable component architecture.

    wshobson/agents★ 43k
  8. Vercel React Native Skills

    Official

    React Native and Expo best practices for building performant mobile apps.

    vercel-labs/agent-skills★ 34k
  9. Vercel React View Transitions

    Official

    Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component,…

    vercel-labs/agent-skills★ 34k

See all design & frontend skills →

More skills from wshobson

  1. Recsys Pipeline Architect

    Design composable recommendation, ranking, and feed pipelines using the six-stage Source→Hydrator→Filter→Scorer→Selector→SideEffect…

    wshobson/agents★ 43k
  2. Review Agent Setup

    Configure human-in-the-loop gating for AI agent review actions in Claude Code.

    wshobson/agents★ 43k
  3. Risk Metrics Calculation

    Calculate portfolio risk metrics including VaR, CVaR, Sharpe, Sortino, and drawdown analysis.

    wshobson/agents★ 43k

All skills by wshobson →

Give your whole team an AI agent with skills

Cody runs managed AI agents your team can message in Slack, Teams, WhatsApp and the web, with 50+ business integrations, scheduled tasks and memory. No terminal required.