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
npx skills add existential-birds/beagle --skill zustand-state -a claude-codeWhat 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-code2Manually: put the files in place
~/.claude/skills/zustand-state/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/zustand-state/
1Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill zustand-state -a codex2Manually: put the files in place
.agents/skills/zustand-state/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill zustand-state -a cursor2Manually: put the files in place
.cursor/skills/zustand-state/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install existential-birds/beagle plugins/beagle-react/skills/zustand-state2Manually: put the files in place
.github/skills/zustand-state/SKILL.md1Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill zustand-state -a gemini-cli2Platform CLI
gemini skills install https://github.com/existential-birds/beagle --path plugins/beagle-react/skills/zustand-stateManually: put the files in place
.devin/skills/zustand-state/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add existential-birds/beagle --skill zustand-state -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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