agent-browser
Browser automation CLI for AI agents. Use when the user needs to interact with websites,…
Expert guide for Zustand state management patterns, store organization, and best practices. Use when implementing client state management with Zustand, creating stores, or managing shared UI state across components.
$ npx -y skills add pedronauck/skills --skill zustand --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/zustandContext preview
The summary Claude sees to decide when to auto-load this skill.
Expert guide for Zustand state management patterns, store organization, and best practices. Use when implementing client state management with Zustand, creating stores, or managing shared UI state across components.
name: zustand description: Expert guide for Zustand state management patterns, store organization, and best practices. Use when implementing client state management with Zustand, creating stores, or managing shared UI state across components. allowed-tools: Read, Grep, Glob
This skill provides guidelines, patterns, and best practices for working with Zustand in this project.
For detailed store patterns, middleware usage, and comprehensive examples, please refer to `references/patterns.md`.
Use the following middleware combination for production stores:
import { create } from "zustand";
import { devtools, persist } from "zustand/middleware";
import { immer } from "zustand/middleware/immer";
export const useExampleStore = create<ExampleState>()(
devtools(
persist(
immer((set, get) => ({
// state and actions
})),
{ name: "example-storage" }
),
{ name: "example-store" }
)
);interface StoreState {
// State properties
data: DataType | null;
isLoading: boolean;
// Group actions together
actions: {
fetchData: () => Promise<void>;
updateData: (updates: Partial<DataType>) => void;
reset: () => void;
};
}Always create selector hooks for performance optimization:
// Bad - subscribes to entire store
const { user, isLoading } = useAuthStore();
// Good - subscribes only to specific slices
export const useUser = () => useAuthStore((state) => state.user);
export const useIsLoading = () => useAuthStore((state) => state.isLoading);
export const useAuthActions = () => useAuthStore((state) => state.actions);1. **Keep stores focused** on specific domains 2. **Use TypeScript** for full type safety 3. **Leverage middleware** for common patterns (devtools, persist, immer) 4. **Create selector hooks** for performance 5. **Use immer** for complex nested state updates 6. **Persist only necessary state** - use `partialize` option 7. **Test stores thoroughly** 8. **Handle async operations properly** with loading/error states 9. **Implement optimistic updates** when appropriate 10. **Document store structure** and actions
1. Define the state interface with typed actions 2. Create the store with appropriate middleware 3. Export selector hooks for each state slice 4. Add to the feature's barrel export
Use the `persist` middleware with `partialize` to persist only necessary data:
persist(
(set) => ({ /* ... */ }),
{
name: "store-key",
partialize: (state) => ({
// Only persist these fields
user: state.user,
preferences: state.preferences,
}),
}
);Immer allows mutable-style updates that produce immutable state:
immer((set) => ({
updateNested: (id, value) => {
set((state) => {
const item = state.items.find((i) => i.id === id);
if (item) {
item.value = value; // Mutable style, but produces immutable state
}
});
},
}));Before finishing a task involving Zustand:
For detailed rules, examples, and anti-patterns, please consult `references/patterns.md`.
A curated collection of 87 agent skills for Claude Code and compatible AI coding assistants — 40 original (⭐️), 34 hand-picked (💎), and 13 marketing & business (📣).
Repo: pedronauck/skills
Browser automation CLI for AI agents. Use when the user needs to interact with websites,…
Answer questions about the AI SDK and help build AI-powered features. Use when developers:…
Autonomously optimize any Claude Code skill by running it repeatedly, scoring outputs against…
Centrifugo real-time messaging server expert for WebSocket PUB/SUB, channel management, JWT…
Retrieves up-to-date documentation, API references, and code examples for any developer…
Diátaxis Documentation Expert. An expert technical writer specializing in creating…