Zustand Store TS
MicrosoftOfficialCreated by Microsoft
- Skill
- Tool integration
- Software development
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a standardized approach to building global state management in React applications using Zustand. It emphasizes TypeScript integration, the use of the subscribeWithSelector middleware, and the architectural separation of state and actions to ensure clean, maintainable, and performant code.
What it does
- Defines patterns for separating state and action interfaces in TypeScript.
- Demonstrates the implementation of the subscribeWithSelector middleware.
- Provides a template for consistent store creation.
- Encourages the use of individual selectors to prevent unnecessary component re-renders.
- Shows how to implement external subscriptions for non-React code.
When to use it
- When setting up global state management for a React application.
- When you need to ensure type safety for complex state objects.
- When you want to optimize performance by avoiding broad state subscriptions.
- When implementing reactive state patterns that require external subscriptions.
Advantages
- Promotes consistent store architecture across the project.
- Improves performance by minimizing unnecessary re-renders.
- Enhances code maintainability through clear separation of concerns.
- Ensures robust type checking for state and actions.
Usage examples
- “Create a new Zustand store for managing user authentication state.”
- The agent generates a TypeScript file using the defined interfaces for UserState and UserActions, wrapped in the subscribeWithSelector middleware.
- “How should I select data from my Zustand store to avoid re-rendering?”
- The agent provides a code snippet demonstrating the use of individual selectors, such as const data = useStore((state) => state.data), instead of destructuring the entire store.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/zustand-store-ts/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip zustand-store-ts.zip -d .agents/skills
Documentation by Microsoft
Zustand Store
Create Zustand stores following established patterns with proper TypeScript types and middleware.
Quick Start
Copy the template from assets/template.ts and replace placeholders:
{{StoreName}}→ PascalCase store name (e.g.,Project){{description}}→ Brief description for JSDoc
Always Use subscribeWithSelector
import { create } from 'zustand';
import { subscribeWithSelector } from 'zustand/middleware';
export const useMyStore = create<MyStore>()(
subscribeWithSelector((set, get) => ({
// state and actions
}))
);Separate State and Actions
export interface MyState {
items: Item[];
isLoading: boolean;
}
export interface MyActions {
addItem: (item: Item) => void;
loadItems: () => Promise<void>;
}
export type MyStore = MyState & MyActions;Use Individual Selectors
// Good - only re-renders when `items` changes
const items = useMyStore((state) => state.items);
// Avoid - re-renders on any state change
const { items, isLoading } = useMyStore();Subscribe Outside React
useMyStore.subscribe(
(state) => state.selectedId,
(selectedId) => console.log('Selected:', selectedId)
);Integration Steps
Create store in
src/frontend/src/store/Export from
src/frontend/src/store/index.tsAdd tests in
src/frontend/src/store/*.test.ts
Files
- ATTRIBUTION.mdAdded by AutoGineer967 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md1.7 KiB
- assets/template.tsScript3.3 KiB
LICENSE
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARERequirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills · .github/plugins/azure-sdk-typescript/skills/zustand-store-ts · commit 0696600
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download zustand-store-ts.zip