agentleFS
belos-streetbelos-street/grimoire/skills/zustand/skill.md

zustand

Skill8 starsChanged 3 months agoMITView on GitHub

Modern, lightweight state management for React

  • Installs packages

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use app-renderer-systems, typescript-advanced and 7 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • pedronauckSkill

    app-renderer-systems

    Create, extend, or debug frontend domain modules organized under systems/. Covers adapters, Query hooks, local state, and public exports; excludes generic components and backend implementation.

    Also in 3 projects that use this

  • jander99Skill

    typescript-advanced

    Design, implement, refactor, and debug advanced TypeScript patterns including generics, utility types, mapped types, conditional types, type guards, discriminated unions, and strict mode configuration. Use when writing type-safe code, fixing type errors, or improving type inference.

    Also in 3 projects that use this

  • Layneformalized225Skill

    brand-storytelling

    Craft compelling company narrative, origin story, and pitch decks. Use for "what's our story" and investor/press narratives. For product positioning statement and taglines, use positioning-messaging instead.

    Also in 3 projects that use this

  • martinholovskySkill

    tailwindcss

    Tailwind CSS utility-first styling for JARVIS UI components

    Also in 3 projects that use this

  • pedronauckSkill

    tui-design

    Use this skill when designing terminal user interfaces, creating TUI layouts, choosing TUI color schemes, implementing keyboard navigation, building terminal dashboards, or working with any TUI framework. Activates on mentions of TUI design, terminal UI, Ratatui layout, Ink components, Textual widgets, Bubbletea views, terminal color palette, keybinding design, panel layout, split panes, terminal dashboard, box-drawing characters, sparklines, progress bars, modal dialogs, focus management, or terminal accessibility.

    Also in 3 projects that use this

  • Kastalien-ResearchSkill

    effect-ts

    Comprehensive guide for Effect-TS, the functional TypeScript library. Use when building Effect applications, especially MCP servers. Covers correct APIs, common misconceptions, and MCP-specific patterns.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No providers needed: Use anywhere in your app

    line 58
  2. Distinctive:

    Avoid prop drilling: Use stores for shared state

    line 129

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
skill.md

Zustand State Management

Zustand is a small, fast and scalable state-management solution using simplified flux principles. It has a comfy API based on hooks, isn't boilerplatey or opinionated.

Quick Start

npm install zustand
# or
yarn add zustand
# or
pnpm add zustand

Basic Usage

import { create } from 'zustand'

interface CounterState {
  count: number
  increment: () => void
  decrement: () => void
}

const useCounterStore = create<CounterState>((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
  decrement: () => set((state) => ({ count: state.count - 1 })),
}))
function Counter() {
  const { count, increment, decrement } = useCounterStore()
  
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={increment}>+</button>
      <button onClick={decrement}>-</button>
    </div>
  )
}

Key Features

  • Minimal API: Simple and intuitive
  • No providers needed: Use anywhere in your app
  • TypeScript support: Full type inference
  • Performance: Selective re-renders with selectors
  • DevTools: Built-in Redux DevTools integration
  • Persistence: Easy state persistence
  • Middleware: Composable middleware system

Common Patterns

Selective Subscriptions

function Count() {
  const count = useCounterStore((state) => state.count)
  return <div>{count}</div>
}

function Controls() {
  const { increment, decrement } = useCounterStore()
  return (
    <>
      <button onClick={increment}>+</button>
      <button onClick={decrement}>-</button>
    </>
  )
}

Async Actions

const useUserStore = create<UserState>((set) => ({
  user: null,
  isLoading: false,
  error: null,
  
  fetchUser: async (id: string) => {
    set({ isLoading: true, error: null })
    try {
      const response = await api.getUser(id)
      set({ user: response.data, isLoading: false })
    } catch (error) {
      set({ error: error as Error, isLoading: false })
    }
  },
}))

With Middleware

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

const useStore = create(
  devtools(
    persist(
      (set) => ({
        // store implementation
      }),
      { name: 'app-storage' }
    )
  )
)

Best Practices

  1. Use selectors: Subscribe only to what you need
  2. Keep stores focused: One store per domain
  3. Type everything: Leverage TypeScript
  4. Use middleware: For persistence and devtools
  5. Avoid prop drilling: Use stores for shared state

Resources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.