Skip to main content
skill CX Codex

zustand-state — Claude Code skill: state without Redux overhead

zustand-state — a skill for Zustand, a lightweight state-management library for React and vanilla JavaScript.

Apache-2.0 261 installs ★ 89 updated 2026-09-15

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add existential-birds/beagle --skill zustand-state -a claude-code
Open on GitHub

What zustand-state does

Zustand cuts boilerplate: no providers, no wrapper components, state lives in a single create() call. Selectors let components subscribe to only the pieces they need, reducing renders. The skill covers flat updates, nested object mutations, and accessing state outside React via getState() and subscribe().

For performance, reach for useShallow when selecting multiple values—it prevents unnecessary rerenders on shallow changes. The vanilla store, createStore, works without React, useful for scripts and utilities.

Before merging code that uses persist, verify that stored keys are explicit and storage won't hold tokens or API keys. If devtools stays enabled in production, add a comment in the pull request explaining the tradeoff.

What it helps with

  • set up global state without provider overhead
  • reduce component rerenders by selecting only needed state
  • sync state to localStorage with persist middleware
  • debug state mutations using DevTools integration
  • manage state outside React components

Example prompts for the agent

  • Create a counter store with an increase method, subscribe the component to just the bears count
  • Update nested state without Redux boilerplate
  • Enable localStorage sync using the persist middleware

How to install zustand-state

1Skills CLI (Vercel)

npx skills add existential-birds/beagle --skill zustand-state -a claude-code

2Manually: put the files in place

~/.claude/skills/zustand-state/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/zustand-state/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about zustand-state

How do I install zustand-state in Claude Code?

Run npx skills add existential-birds/beagle --skill zustand-state -a claude-code, then open ~/.claude/skills/zustand-state/SKILL.md.

What does zustand-state do?

The skill provides examples and templates for Zustand, a state-management library. It shows how to create stores, write selectors, prevent unnecessary rerenders, and hook in middleware for persistence and debugging.

How is Zustand different from Redux?

Zustand skips providers and reducers—state initializes in a single function. Updates are more direct, boilerplate is lower, but very large apps with strict action separation may find Redux's structure clearer.

Source text

SKILL.md · Apache-2.0
---
name: zustand-state
description: Zustand state management for React and vanilla JavaScript. Use when creating stores, using selectors, persisting state to localStorage, integrating devtools, or managing global state without Redux complexity. Triggers on zustand, create(), createStore, useStore, persist, devtools, immer middleware.
---

# Zustand State Management

Minimal state management - no providers, minimal boilerplate.

## Quick Reference

```typescript
import { create } from 'zustand'

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

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

// In component - select only what you need
const bears = useBearStore((state) => state.bears)
const increase = useBearStore((state) => state.increase)
```

## State Updates

```typescript
// Flat updates (auto-merged at one level)
set({ bears: 5 })
set((state) => ({ bears: state.bears + 1 }))

// Nested objects (manual spread required)
set((state) => ({
  nested: { ...state.nested, count: state.nested.count + 1 }
}))

// Replace entire state (no merge)
set({ bears: 0 }, true)
```

## Selectors & Performance

```typescript
// Good - subscribes only to bears
const bears = useBearStore((state) => state.bears)

// Bad - rerenders on any change
const state = useBearStore()

// Multiple values with useShallow (prevents rerenders with shallow comparison)
import { useShallow } from 'zustand/react/shallow'

const { bears, fish } = useBearStore(
  useShallow((state) => ({ bears: state.bears, fish: state.fish }))
)

// Array destructuring also works
const [bears, fish] = useBearStore(
  useShallow((state) => [state.bears, state.fish])
)
```

## Access Outside Components

```typescript
// Get current state (non-reactive)
const state = useBearStore.getState()

// Update state
useBearStore.setState({ bears: 5 })

// Subscribe to changes
const unsub = useBearStore.subscribe((state) => console.log(state))
unsub() // unsubscribe
```

## Vanilla Store (No React)

```typescript
import { createStore } from 'zustand/vanilla'

const store = createStore((set) => ({
  bears: 0,
  increase: (by) => set((state) => ({ bears: state.bears + by })),
}))

store.getState().bears
store.setState({ bears: 10 })
store.subscribe((state) => console.log(state))
```

## Additional Documentation

- **Middleware**: See [references/middleware.md](references/middleware.md) for persist, devtools, immer
- **Patterns**: See [references/patterns.md](references/patterns.md) for slices, testing, best practices
- **TypeScript**: See [references/typescript.md](references/typescript.md) for advanced typing patterns

## Key Patterns

| Pattern | When to Use |
|---------|-------------|
| Single selector | One piece of state needed |
| `useShallow` | Multiple values, avoid rerenders |
| `getState()` | Outside React, event handlers |
| `subscribe()` | External systems, logging |
| Vanilla store | Non-React environments |

## Gates (persist and devtools)

Before merging code that uses these middlewares (see [references/middleware.md](references/middleware.md) for setup):

1. **`persist`** — **Pass when** persisted keys are explicit (`partialize` or a reviewed full-state snapshot) and the JSON written to storage cannot include auth tokens, API keys, or other secrets.
2. **`devtools` in shipped bundles** — **Pass when** DevTools runs only in development (env gate), or you leave a one-line note in the PR explaining why it stays enabled in production.

© existential-birds · Apache-2.0 · existential-birds/beagle

Similar skills

All skills for Frontend and UI →
zustand-state-management Mindrally zustand-state-management enforces Zustand store best practices in React and TypeScript apps, covering store slices, SSR, and testing. It helps eliminate selector re-renders and hydration bugs. CX Codex +1 1,000installs zustand-state-builder patricio0312rev zustand-state-builder — a skill for managing app state with Zustand: minimal API, full TypeScript support, persistence, and devtools. Runs on Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. CX Codex +1 264installs zustand vercel-labs This skill integrates Zustand into json-render to sync application state. Use it when your project already relies on Zustand and you need to connect it with components rendered by json-render. CX Codex +1 1,900installs zustand-patterns OrchestKit zustand-patterns — a skill for Claude Code enforces TypeScript-first patterns for Zustand 5.x state management. Triggers during store creation, slice composition, and middleware setup. CX Codex +1 1,500installs zustand-5 prowler-cloud Zustand 5 state management patterns for Claude Code: basic stores, selectors, persist middleware, and slice composition. Prevents unnecessary re-renders and keeps state logic clean. CX Codex +1 912installs zustand-store-ts Microsoft zustand-store-ts — a skill for Claude Code and GitHub Copilot that scaffolds Zustand stores with subscribeWithSelector and typed state/action separation. Drop it in when a React project needs global state with fine-grained subscriptions. CX Codex +1 3installs

From the same set68

The whole set →
langgraph-architecture langgraph-architecture helps you choose how to structure a LangGraph application, manage state, and handle persistence. Use it when comparing LangGraph with simpler options or planning a multi-agent system. CX Codex +1 283installs swiftui-code-review swiftui-code-review audits SwiftUI code for view composition quality, state management patterns, list performance, and accessibility. Use it when reviewing files with @State, @Binding, @Observable, or view layout code. CX Codex +1 277installs tutorial-docs tutorial-docs is a Claude Code skill that structures learning-oriented tutorials using the Diataxis framework. The model applies it when creating getting-started guides and onboarding docs. CX Codex +1 273installs bubbletea-code-review bubbletea-code-review reviews Go terminal UIs for Elm architecture, BubbleTea update flow, and Lipgloss styling. Use it when checking code built with charmbracelet/bubbletea. CX Codex +1 270installs dagre-react-flow dagre-react-flow configures automatic directed graph layouts in React Flow using dagre. It helps arrange hierarchical trees, process flows, and nodes across directional axes. CX Codex +1 257installs adr-writing adr-writing is a Claude Code skill that turns decisions into MADR-formatted ADRs and checks them against E.C.A.D.R. criteria. It also runs in Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. CX Codex +1 254installs swift-code-review swift-code-review is a Claude Code skill that checks Swift code for concurrency, error-handling, and memory issues. It activates for .swift reviews involving async/await, actors, or Sendable. CX Codex +1 253installs review-verification-protocol review-verification-protocol — a skill that enforces verification before any code review finding enters the report: read the source freshly, search for context, distinguish bugs from style. Cuts false positives. CX Codex +1 252installs

Project sponsors

Companies that keep this analytics open