skills/zustand-best-practices/SKILL.md
Zustand state management patterns for this project — store creation, selectors, Immer middleware, async actions with loading states, devtools, persist, and testing. Use when authoring or editing Zustand stores (use*Store files) or components that subscribe to stores. Do NOT use for React component structure or TypeScript-only utilities.
npx skillsauth add bkinsey808/songshare-effect zustand-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Requires: file-read, terminal (linting/testing). No network access needed.
Full reference: /docs/zustand-best-practices.md
docs/ai/rules.md for repo-wide constraints.Always use selectors — never subscribe to the whole store; select only the fields needed. → full detail
useShallow for derived arrays/objects — prevents unnecessary re-renders when a selector returns a new reference.
→ full detail
Named selector constants — define selectors outside components for reuse and stability. → full detail
One store per domain — split by concern; do not grow one monolithic store. → full detail
Track isLoading and error for every async action.
→ full detail
Use Immer for deeply nested state updates. → full detail
Wrap with devtools in all stores; use partialize when adding persist.
→ full detail
Never mock the store in tests — reset with useStore.setState(initialState) in beforeEach.
→ full detail
Write code changes directly. After edits, output a brief bullet list of which patterns were applied and which validation commands were run.
If npm run lint fails after changes, report verbatim and fix before declaring success.
npm run lint
react-best-practices.typescript-best-practices.testing
How to write, update, or split skill files in this repo. Use when creating a new SKILL.md, updating an existing one, or deciding whether to put content in a skill vs. docs/.
development
Complete guide for testing React hooks — renderHook, Documentation by Harness, installStore, fixtures, subscription patterns, lint/compiler traps, and pre-completion checklist. Read docs/testing/unit-test-hook-best-practices.md for the full reference.
development
Vitest unit test authoring for this repo — setup, mocking, API handler testing, and common pitfalls for non-hook code. Use when the user asks to add, update, fix, or review unit tests for utilities, components, API handlers, or scripts. Do NOT use for React hook tests — load unit-test-hook-best-practices instead.
development
TypeScript conventions for this repo (no `any`, explicit return types, JSDoc, exactOptionalPropertyTypes, ambient types, import style). Use when authoring or editing any `.ts` or `.tsx` file, resolving TypeScript strictness errors, or fixing type-related lint failures. Do NOT use for React-specific typing patterns (see react-best-practices skill) or JSDoc-only changes (see code-comment-best-practices skill).