Agent skill · software engineering · aiskillstore

state-management

Implement state management patterns for frontend applications. Use when managing global state, handling complex data flows, or coordinating state across components. Handles React Context, Redux, Zustand, Recoil, and state management best practices.

Why this skill is useful

Provides specific patterns and examples for managing global state in React applications using various libraries, which the AI may not generate reliably on its own.

What it needs

Requires zustand installed locally. About 6k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.

What this skill does

State Management When to use this skill Global State Required: Multiple components share the same data Props Drilling Problem: Passing props through 5+ levels Complex State Logic: Authentication, shopping cart, themes, etc. State Synchronization: Sync server data with client state Instructions Step 1: Determine State Scope Distinguish between local and global state. Decision Criteria: Local State: Used only within a single component Form input values, toggle states, dropdown open/close Use useState, useReducer Global State: Shared across multiple components User authentication, shopping cart, theme, language settings Use Context API, Redux, Zustand Example: Step 2: React Context API (Simple Global State) Suitable for lightweight global state management. Example (Authentication Context): Usage: Step 3: Zustand (Modern and Concise State Management) Simpler than Redux with less boilerplate. Installation: Example (Shopping Cart): Usage: Step 4: Redux Toolkit (Large-Scale Apps) Use when complex state logic and middleware are required. Installation: Example (Todo): Usage: Step 5: Server State Management (React Query / TanStack Query) Specialized for API data fetching and caching. Output format State Management Tool Selection Guide Constraints Required Rules (MUST) 1. State Immutability: Never mutate state directly 2. Minimal State Principle: Do not store derivable values in state 3. Single Source of Truth: Do not duplicate the same data in multiple places Prohibited Rules (MUST NOT) 1. Excessive Props Drilling: Prohibited when passing props through 5+ levels Use Context or a state management library 2. Avoid Making Everything Global State: Prefer local state when sufficient Best practices 1. Selective Subscription: Subscribe only to the state you need 2. Clear Action Names: update → updateUserProfile 3. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills aiskillstore/state-management--dbe900

View the source on GitHub

Browse the @skills marketplace