setup-zustand-store

setup-zustand-store is a command for Cursor from Farzannajipour/cursor-react-rules. It costs 0 tokens per session (1,276 once invoked), scanned A, original, MIT.

A procedure for creating a Zustand store, which is a shared place for application state, with TypeScript types, saved state, and developer tools.

In plain words
What is it for?
Use it to define state and actions, create a typed Zustand store, add persistence and development support, and connect selected state and actions to React components.
Why use it?
It gives shared data and the actions that change it a consistent structure. Saving state can preserve values between sessions, while developer tools help inspect changes.

Command for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/farzannajipour/cursor-react-rules/setup-zustand-store
Clone the repo
git clone --depth 1 https://github.com/Farzannajipour/cursor-react-rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for setup-zustand-store

README.md
[![agentmods](https://agentmods.dev/badge/commands/farzannajipour/cursor-react-rules/setup-zustand-store.svg)](https://agentmods.dev/commands/farzannajipour/cursor-react-rules/setup-zustand-store)
Your own site
<a href="https://agentmods.dev/commands/farzannajipour/cursor-react-rules/setup-zustand-store"><img src="https://agentmods.dev/badge/commands/farzannajipour/cursor-react-rules/setup-zustand-store.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,276 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01276
Opus 5 $0.00000 $0.00638
Sonnet 5 $0.00000 $0.00255
Haiku 4.5 $0.00000 $0.00128

Measured 5d ago against content hash 9dd18de616ef, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

setup-zustand-store scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/commands/setup-zustand-store.md · 210 lines

How it starts

The opening of the file, as written. The whole thing — 210 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Setup Zustand Store

Overview

Create a Zustand store for state management with TypeScript, persist middleware, and dev tools.

Steps

  1. Define store interface

    • Define state shape
    • Define actions (mutations)
    • Add proper TypeScript types
  2. Create store

    • Use Zustand create function
    • Add middleware (persist, devtools)
    • Implement actions
  3. Use in components

    • Import and use hooks
    • Select only needed state
    • Call actions to update state

Template

Basic Store

import { create } from 'zustand';

interface CounterStore {
  count: number;
  increment: () => void;
  decrement: () => void;
  reset: () => void;
}

export const useCounterStore = create<CounterStore>((set) => ({
  count: 0,
  increment: () => set((state) => ({ count: state.count + 1 })),
  decrement: () => set((state) => ({ count: state.count - 1 })),
  reset: () => set({ count: 0 }),
}));

Store with Persist

import { create } from 'zustand';
import { persist } from 'zustand/middleware';

interface AuthStore {
  user: User | null;
  token: string | null;
  login: (user: User, token: string) => void;
  logout: () => void;
  updateUser: (user: Partial<User>) => void;
}

export const useAuthStore = create<AuthStore>()(
  persist(
    (set) => ({
      user: null,
      token: null,
      login: (user, token) => set({ user, token }),
      logout: () => set({ user: null, token: null }),
      updateUser: (updates) =>
        set((state) => ({
          user: state.user ? { ...state.user, ...updates } : null,
        })),
    }),
    {
      name: 'auth-storage', // localStorage key
    }
  )
);

Store with DevTools

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

interface CartStore {
  items: CartItem[];
  addItem: (item: CartItem) => void;
  removeItem: (id: string) => void;
  updateQuantity: (id: string, quantity: number) => void;
  clearCart: () => void;
  total: () => number;
}

export const useCartStore = create<CartStore>()(
  devtools(
    persist(
      (set, get) => ({
        items: [],
        addItem: (item) =>
          set((state) => ({
            items: [...state.items, item],
          })),
        removeItem: (id) =>
          set((state) => ({
            items: state.items.filter((item) => item.id !== id),
          })),
        updateQuantity: (id, quantity) =>
          set((state) => ({
            items: state.items.map((item) =>
              item.id === id ? { ...item, quantity } : item
            ),
          })),
        clearCart: () => set({ items: [] }),
        total: () => {
          const { items } = get();
          return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
        },
      }),
      {
        name: 'cart-storage',
      }
    )
  )
);

Read the full file on GitHub · 210 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 210 lines · 0 tokens per session scan A 9dd18de616ef

Subscribe to this mod's changes

setup-zustand-store is a command published in the GitHub repository Farzannajipour/cursor-react-rules (3 stars, last pushed 7mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,276 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.