State management

From rnavarych/alpha-engineer · View interactive version

State management is an AI agent skill from the GitHub repository rnavarych/alpha-engineer. State management expertise including local vs global state decisions, Redux Toolkit, Zustand, Jotai, MobX, Context API patterns, server state (React Query, SWR) vs client state, optimistic updates, and state machines with XState.

How to use this skill

Skill file

State Management

When to use

Core principles

  1. Server state belongs in TanStack Query or SWR — never duplicate API data in a client store
  2. URL is state too — pagination, filters, search: use nuqs or router search params
  3. Keep it local as long as possible — global state is a last resort, not a default
  4. Selectors prevent re-renders — subscribe to slices, not the whole store
  5. XState for impossible states — if "loading" and "error" can't coexist, the machine enforces it

Reference Files

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.