Agent skill

Zustand State Management

by secondsky in secondsky/claude-skills

Zustand state management for React with TypeScript. An agent skill from secondsky/claude-skills.

MITAuto-check passedFrontend & Design

Install Zustand State Management

skills CLI
$ npx skills add secondsky/claude-skills --skill zustand-state-management -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install secondsky/claude-skills zustand-state-management --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/secondsky/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/zustand-state-management/skills/zustand-state-management .claude/skills/zustand-state-management && rm -rf skills-src

Use ~/.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/

Facts

Skill name
zustand-state-management
GitHub stars
227
Token cost
~2.5k tokens
SKILL.md length
660 words
Files
20 (incl. scripts, references, assets)
Skills in repo
168
Repo updated
First seen
Licence
MIT

At a glance

Zustand state management for React with TypeScript. An agent skill from secondsky/claude-skills.

  • Works in 3 steps: Install Zustand → Create Your First Store (TypeScript) → Use Store in Components
  • Redux/Context API migration
  • SKILL.md covers Quick Start (3 Minutes), The 3-Pattern Setup Process, Critical Rules and Known Issues Prevention (5…, plus 7 more sections
  • Runs TypeScript and Shell scripts from its folder; calls bun

What it does

Zustand State Management is an agent skill from secondsky/claude-skills. Zustand state management for React with TypeScript. Use for global state, Redux/Context API migration, localStorage persistence, slices pattern, devtools, Next.js SSR, or encountering hydration errors, TypeScript inference issues, persist middleware problems, infinite render loops.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 23 other files, including scripts, reference files and assets (for example `references/advanced-topics.md`, `references/common-patterns.md` and `references/example-reference.md`).

It sits in Frontend & Design, covering State management. It works with Zustand, TypeScript, Next.js and React. The repository describes itself as: Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations. The licence is MIT.

When your agent uses it

  • Redux/Context API migration
  • LocalStorage persistence
  • Encountering hydration errors
  • TypeScript inference issues

Example prompts

  • “/zustand-state-management”

Requirements

  • Node.js
  • A Bash shell

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Install Zustand
  2. Create Your First Store (TypeScript)
  3. Use Store in Components

What it can do on your machine

Read from SKILL.md and the folder at commit 8837836. It shows what the files ask for, not the result of running them.

  • Tool permissions

    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.

  • Runs code

    Ships 2 files in scripts/ (TypeScript and Shell, from the files we listed), which the agent can run.

    Shell commands in SKILL.md call:

    • bun

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • zustand.docs.pmnd.rs
    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Zustand State Management loads about 2.5k tokens when it runs, and up to ~13k if it reads all its reference files. Until then it costs about 77 tokens; SKILL.md has 660 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~77
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~13k

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.

Safety

Auto-check passed

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); the scripts in this folder are not scanned.

SKILL.md

The full file from secondsky/claude-skills at commit 8837836, republished under its MIT licence (© secondsky). 660 words, ~2,484 tokens.

Download SKILL.mdSave it as .claude/skills/zustand-state-management/SKILL.md (or your agent's skills folder). This skill also uses 19 other files; get the full folder from GitHub.
name
zustand-state-management
description
Zustand state management for React with TypeScript. Use for global state, Redux/Context API migration, localStorage persistence, slices pattern, devtools, Next.js SSR, or encountering hydration errors, TypeScript inference issues, persist middleware problems, infinite render loops.
metadata.keywords
zustand, state management, React state, TypeScript state, persist middleware, devtools, slices pattern, global state, React hooks, create store…
license
MIT

Zustand State Management

Status: Production Ready ✅ Last Updated: 2026-08-03 Latest Version: zustand@5.0.14 Dependencies: React 18+, TypeScript 5+


Quick Start (3 Minutes)

1. Install Zustand
bash
bun add zustand  # preferred
# or: npm install zustand
# or: yarn add zustand

Why Zustand?

  • Minimal API: Only 1 function to learn (create)
  • No boilerplate: No providers, reducers, or actions
  • TypeScript-first: Excellent type inference
  • Fast: Fine-grained subscriptions prevent unnecessary re-renders
  • Flexible: Middleware for persistence, devtools, and more
2. Create Your First Store (TypeScript)
typescript
import { create } from 'zustand'

interface BearStore {
  bears: number
  increase: (by: number) => void
  reset: () => void
}

const useBearStore = create<BearStore>()((set) => ({
  bears: 0,
  increase: (by) => set((state) => ({ bears: state.bears + by })),
  reset: () => set({ bears: 0 }),
}))

CRITICAL: Notice the double parentheses create<T>()() - this is required for TypeScript with middleware.

3. Use Store in Components
tsx
import { useBearStore } from './store'

function BearCounter() {
  const bears = useBearStore((state) => state.bears)
  return <h1>{bears} around here...</h1>
}

function Controls() {
  const increase = useBearStore((state) => state.increase)
  return <button onClick={() => increase(1)}>Add bear</button>
}

Why this works:

  • Components only re-render when their selected state changes
  • No Context providers needed
  • Selector function extracts specific state slice

The 3-Pattern Setup Process

Pattern 1: Basic Store (JavaScript)

For simple use cases without TypeScript:

javascript
import { create } from 'zustand'

const useStore = create((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
  decrement: () => set((state) => ({ count: state.count - 1 })),
}))

When to use:

  • Prototyping
  • Small apps
  • No TypeScript in project

For production apps with type safety:

typescript
import { create } from 'zustand'

// Define store interface
interface CounterStore {
  count: number
  increment: () => void
  decrement: () => void
}

// Create typed store
const useCounterStore = create<CounterStore>()((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
  decrement: () => set((state) => ({ count: state.count - 1 })),
}))

Key Points:

  • Separate interface for state + actions
  • Use create<T>()() syntax (currying for middleware)
  • Full IDE autocomplete and type checking
Pattern 3: Persistent Store

For state that survives page reloads:

typescript
import { create } from 'zustand'
import { persist, createJSONStorage } from 'zustand/middleware'

interface UserPreferences {
  theme: 'light' | 'dark' | 'system'
  language: string
  setTheme: (theme: UserPreferences['theme']) => void
  setLanguage: (language: string) => void
}

const usePreferencesStore = create<UserPreferences>()(
  persist(
    (set) => ({
      theme: 'system',
      language: 'en',
      setTheme: (theme) => set({ theme }),
      setLanguage: (language) => set({ language }),
    }),
    {
      name: 'user-preferences', // unique name in localStorage
      storage: createJSONStorage(() => localStorage), // optional: defaults to localStorage
    },
  ),
)

Why this matters:

  • State automatically saved to localStorage
  • Restored on page reload
  • Works with sessionStorage too
  • Handles serialization automatically

Critical Rules

Always Do

✅ Use create<T>()() (double parentheses) in TypeScript for middleware compatibility ✅ Define separate interfaces for state and actions ✅ Use selector functions to extract specific state slices ✅ Use set with updater functions for derived state: set((state) => ({ count: state.count + 1 })) ✅ Use unique names for persist middleware storage keys ✅ Handle Next.js hydration with hasHydrated flag pattern ✅ Use shallow for selecting multiple values ✅ Keep actions pure (no side effects except state updates)

Never Do

❌ Use create<T>(...) (single parentheses) in TypeScript - breaks middleware types ❌ Mutate state directly: set((state) => { state.count++; return state }) - use immutable updates ❌ Create new objects in selectors: useStore((state) => ({ a: state.a })) - causes infinite renders ❌ Use same storage name for multiple stores - causes data collisions ❌ Access localStorage during SSR without hydration check ❌ Use Zustand for server state - use TanStack Query instead ❌ Export store instance directly - always export the hook


Known Issues Prevention (5 Issues)

IssueErrorQuick Fix
#1 Hydration mismatch"Text content does not match"Use _hasHydrated flag + onRehydrateStorage
#2 TypeScript inferenceTypes break with middlewareUse create<T>()() double parentheses
#3 Import error"createJSONStorage not exported"Upgrade to zustand@5.0.14+
#4 Infinite loopBrowser freezesUse shallow or separate selectors
#5 Slices typesStateCreator types failExplicit StateCreator<Combined, [], [], Slice>

Most Critical - TypeScript double parentheses:

typescript
// ❌ WRONG: create<T>((set) => ...)
// ✅ CORRECT: create<T>()((set) => ...)

See: references/known-issues.md for complete solutions with code examples.


Show full SKILL.md (264 more words)Show less

Middleware Configuration

typescript
import { create } from 'zustand'
import { devtools, persist } from 'zustand/middleware'

const useStore = create<MyStore>()(
  devtools(
    persist(
      (set) => ({ /* store definition */ }),
      { name: 'my-storage' },
    ),
    { name: 'MyStore' },
  ),
)
MiddlewarePurposeImport
persistlocalStorage/sessionStoragezustand/middleware
devtoolsRedux DevTools integrationzustand/middleware
immerMutable update syntaxzustand/middleware/immer

Order matters: devtools(persist(...)) shows persist actions in DevTools.

See: references/middleware-guide.md for complete middleware documentation.


Common Patterns

PatternUse CaseKey Technique
Computed valuesDerived dataCompute in selector: state.items.length
Async actionsAPI callsset({ isLoading: true }) + try/catch
Reset storeLogout, form clearset(initialState)
Selector with paramsDynamic accessstate.todos.find(t => t.id === id)
Multiple storesSeparation of concernsCreate separate create() calls

See: references/common-patterns.md for complete implementations.


Advanced Topics

TopicUse CaseKey API
Vanilla storeNon-React, testingcreateStore() from zustand/vanilla
Custom middlewareLogging, timestampsWrap StateCreator
ImmerMutable update syntaximmer() middleware
SubscriptionsSide effectsstore.subscribe()

See: references/advanced-topics.md for complete implementations.


Bundled Resources

TypeFiles
Templatesbasic-store.ts, typescript-store.ts, persist-store.ts, slices-pattern.ts, devtools-store.ts, nextjs-store.ts, computed-store.ts, async-actions-store.ts
Referencesmiddleware-guide.md, typescript-patterns.md, nextjs-hydration.md, migration-guide.md, known-issues.md, common-patterns.md, advanced-topics.md

When to Load References

ReferenceLoad When...
known-issues.mdDebugging hydration, TypeScript, infinite loop, or slices errors
common-patterns.mdImplementing computed values, async actions, reset patterns
advanced-topics.mdVanilla stores, custom middleware, Immer, subscriptions
middleware-guide.mdConfiguring persist, devtools, or combining middlewares
typescript-patterns.mdComplex type inference issues, StateCreator problems
nextjs-hydration.mdNext.js SSR/hydration problems
migration-guide.mdMigrating from Redux, Context API, or Zustand v4

Quick Troubleshooting

ProblemSolution
Store updates don't trigger re-rendersUse selector: useStore(state => state.value) not destructuring
TypeScript errors with middlewareUse create<T>()() double parentheses
Hydration error with persistImplement _hasHydrated flag pattern
Actions not showing in DevToolsPass action name: set(newState, undefined, 'actionName')
Store resets unexpectedlyHMR causes reset in development

Dependencies

json
{ "dependencies": { "zustand": "^5.0.14", "react": "^18.0.0+" } }

Compatibility: React 18+, React 19, TypeScript 5+, Next.js 14+, Vite 5+


Official Docs: https://zustand.docs.pmnd.rs/ | GitHub: https://github.com/pmndrs/zustand

© secondsky, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 19 other files (scripts, references, assets) in plugins/zustand-state-management/skills/zustand-state-management of secondsky/claude-skills.

  • SKILL.md
  • assets/example-template.txt
  • references/advanced-topics.md
  • references/common-patterns.md
  • references/example-reference.md
  • references/known-issues.md
  • references/middleware-guide.md
  • references/migration-guide.md
  • references/nextjs-hydration.md
  • references/typescript-patterns.md
  • scripts/check-versions.sh
  • scripts/example-script.sh
  • templates/async-actions-store.ts
  • templates/basic-store.ts
  • templates/computed-store.ts
  • templates/devtools-store.ts
  • templates/nextjs-store.ts
  • … and 3 more

Open the folder on GitHubat commit 8837836

Compare with similar skills

Zustand 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.

Zustand State Management compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Zustand State Management this skillsecondsky/claude-skills227—~2.5kAutomated safety check: PassMIT
React ExpertJeffallan/claude-skills12k—~1.4kAutomated safety check: PassMIT
Nextjs15 Initbear2u/my-skills933—~2.4kAutomated safety check: PassNone
React Flow Node TSmicrosoft/skills3.1k6 repos~502Automated safety check: PassMIT
React Generate Skilljiushiwon/wg-skills114—~2.8kAutomated safety check: PassApache-2.0
React Idiomsirahardianto/awesome-agv157—~3.8kAutomated safety check: PassMIT

Similar skills

  • React Expert

    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.

    12k GitHub stars~1.4k tokensUpdated 6 days ago
    Frontend & DesignAuto-check passed
  • Nextjs15 Init

    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

    933 GitHub stars~2.4k tokensUpdated 3 mo ago
    Frontend & DesignAuto-check passed
  • React Flow Node TS

    microsoft/skills

    Official

    Create React Flow node components with TypeScript types, handles, and Zustand integration.

    3.1k GitHub starsUsed in 6 repos~502 tokens
    Frontend & DesignAuto-check passed
  • React Generate Skill

    jiushiwon/wg-skills

    This skill should be used when the user wants to create a standardized React 18 + TypeScript + Vite + Zustand project from scratch.

    114 GitHub stars~2.8k tokensUpdated 2 days ago
    Frontend & DesignAuto-check passed
  • React Idioms

    irahardianto/awesome-agv

    React 19+ patterns: custom hooks, Suspense boundaries, state management, component composition, and web performance.

    157 GitHub stars~3.8k tokensUpdated 4 days ago
    Frontend & DesignAuto-check passed
  • Frontend Development

    avibebuilder/claude-prime

    A skill your agent uses for ANY work involving React, Next.js, TypeScript, or Tailwind in the browser layer.

    120 GitHub stars~1.3k tokensUpdated 4 mo ago
    Frontend & DesignAuto-check passed

More from secondsky/claude-skills

All 168 skills in this repo
  • Auto Animate

    secondsky/claude-skills

    AutoAnimate (@formkit/auto-animate) zero-config animations for React.

    227 GitHub stars~2.9k tokensUpdated 11 days ago
    Auto-check passed
  • Base UI React

    secondsky/claude-skills

    MUI Base UI unstyled React components with Floating UI. An agent skill from secondsky/claude-skills.

    227 GitHub stars~1.9k tokensUpdated 11 days ago
    Auto-check passed
  • Cloudflare Images

    secondsky/claude-skills

    This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants"…

    227 GitHub stars~3.6k tokensUpdated 11 days ago
    Auto-check: notes
  • Cloudflare Nextjs

    secondsky/claude-skills

    Deploy Next.js to Cloudflare Workers via the OpenNext adapter (@opennextjs/cloudflare).

    227 GitHub stars~5.3k tokensUpdated 11 days ago
    Auto-check: notes
  • Cloudflare Sandbox

    secondsky/claude-skills

    Cloudflare Sandboxes SDK for secure code execution in Linux containers at edge.

    227 GitHub stars~4.5k tokensUpdated 11 days ago
    Auto-check passed
  • GitHub Project Automation

    secondsky/claude-skills

    GitHub repository automation (CI/CD, issue templates, Dependabot, CodeQL).

    227 GitHub stars~4k tokensUpdated 11 days ago
    Auto-check: notes

Questions about Zustand State Management

What does Zustand State Management do?

Zustand state management for React with TypeScript. An agent skill from secondsky/claude-skills. Zustand State Management is an agent skill from secondsky/claude-skills. Zustand state management for React with TypeScript.

When should I use Zustand State Management?

Zustand State Management fits situations like: redux/Context API migration; localStorage persistence; encountering hydration errors; typeScript inference issues.

How do I install Zustand State Management in Claude Code?

Run `npx skills add secondsky/claude-skills --skill zustand-state-management -a claude-code`. Or copy the skill folder (plugins/zustand-state-management/skills/zustand-state-management in secondsky/claude-skills) into .claude/skills/zustand-state-management in your project. Claude Code loads it when a task matches its description.

How do I install Zustand State Management in Codex?

Run `npx skills add secondsky/claude-skills --skill zustand-state-management -a codex`. Or copy the skill folder (plugins/zustand-state-management/skills/zustand-state-management in secondsky/claude-skills) into .agents/skills/zustand-state-management in your project. Codex loads it when a task matches its description.

Can I use Zustand State Management in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add secondsky/claude-skills --skill zustand-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/zustand-state-management, .gemini/skills/zustand-state-management, .github/skills/zustand-state-management and .opencode/skills/zustand-state-management in your project.

What does Zustand State Management need to run?

Going by SKILL.md and its folder, Zustand State Management needs TypeScript and a shell for the scripts in its folder and the command-line tools its instructions call (bun). Our summary lists: Node.js; A Bash shell.

Does Zustand State Management access the network?

SKILL.md names 2 domains. As links in the text: zustand.docs.pmnd.rs and github.com. This is read from the text; nothing was executed.

Is Zustand State Management safe to install?

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. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Zustand State Management use?

Zustand State Management is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Zustand State Management use?

About 2.5k tokens (SKILL.md is roughly 9.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 11k tokens, read only when the agent opens those files.

What are the alternatives to Zustand State Management?

Skills that share tags, products or a category with Zustand State Management: React Expert (Jeffallan/claude-skills, 12k stars), Nextjs15 Init (bear2u/my-skills, 933 stars), React Flow Node TS (microsoft/skills, 3.1k stars) and React Generate Skill (jiushiwon/wg-skills, 114 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Zustand State Management?

secondsky (a GitHub user) maintains it in secondsky/claude-skills, which has 227 GitHub stars. The repository holds 168 skills in this directory. The repository was last updated on September 28, 2026.

Source: secondsky/claude-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.