zustand-store-ts — Claude Code skill: typed Zustand stores
A skill that sets the pattern for Zustand stores in TypeScript: separate state and action types, subscribeWithSelector, individual selectors.
npx skills add microsoft/skills --skill zustand-store-ts -a claude-codeWhat zustand-store-ts does
The skill spells out how to write global Zustand stores in a React project. It ships a template at assets/template.ts with placeholders {{StoreName}} and {{description}} — a PascalCase store name and a short JSDoc line.
The rules are strict. Wrap the store in subscribeWithSelector from zustand/middleware every time. Describe state and actions as separate interfaces, then combine them into one store type. In components, pull values with individual selectors so a re-render happens only when that field changes, not on every store update. Outside React, subscribe through useMyStore.subscribe with a selector and a callback.
Integration is four steps: create the store under src/frontend/src/store/, export it from src/frontend/src/store/index.ts, add tests in src/frontend/src/store/*.test.ts. Those paths are fixed, so a project with a different folder layout needs them rewritten first — worth checking before you install.
What it helps with
- set up a global Zustand store with consistent types
- split state and actions into separate interfaces
- subscribe to a single field outside a React component
- cut extra re-renders with individual selectors
- place store files and tests where the project expects them
Example prompts for the agent
- create a Project store using the zustand-store-ts template
- add a loadItems action and a subscription on selectedId
- split the store state and actions into separate interfaces
How to install zustand-store-ts
1Skills CLI (Vercel)
npx skills add microsoft/skills --skill zustand-store-ts -a claude-code2Manually: put the files in place
~/.claude/skills/zustand-store-ts/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/zustand-store-ts/
Manually: put the files in place
.agents/skills/zustand-store-ts/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/zustand-store-ts/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install microsoft/skills zustand-store-ts2Manually: put the files in place
.github/skills/zustand-store-ts/SKILL.mdPlatform CLI
gemini skills install https://github.com/microsoft/skills --path .github/plugins/azure-sdk-typescript/skills/zustand-store-tsManually: put the files in place
.devin/skills/zustand-store-ts/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.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-store-ts
How do I install zustand-store-ts in Claude?
Run npx skills add microsoft/skills --skill zustand-store-ts -a claude-code. The skill file then lives at ~/.claude/skills/zustand-store-ts/SKILL.md.
What does zustand-store-ts do?
It gives you a template and rules for Zustand stores in TypeScript: the subscribeWithSelector middleware, separate state and action types, individual selectors, and subscriptions outside React.
Where does the skill put store files?
Following its steps, the store goes in src/frontend/src/store/, gets exported from src/frontend/src/store/index.ts, and tests land in src/frontend/src/store/*.test.ts.
Source text
SKILL.md · MIT
---
name: zustand-store-ts
description: Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.
license: MIT
metadata:
author: Microsoft
version: "1.0.0"
---
# Zustand Store
Create Zustand stores following established patterns with proper TypeScript types and middleware.
## Quick Start
Copy the template from [assets/template.ts](assets/template.ts) and replace placeholders:
- `{{StoreName}}` → PascalCase store name (e.g., `Project`)
- `{{description}}` → Brief description for JSDoc
## Always Use subscribeWithSelector
```typescript
import { create } from 'zustand';
import { subscribeWithSelector } from 'zustand/middleware';
export const useMyStore = create<MyStore>()(
subscribeWithSelector((set, get) => ({
// state and actions
}))
);
```
## Separate State and Actions
```typescript
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
```typescript
// 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
```typescript
useMyStore.subscribe(
(state) => state.selectedId,
(selectedId) => console.log('Selected:', selectedId)
);
```
## Integration Steps
1. Create store in `src/frontend/src/store/`
2. Export from `src/frontend/src/store/index.ts`
3. Add tests in `src/frontend/src/store/*.test.ts`
© Microsoft · MIT · microsoft/skills