state-management
Skill2 starsChanged 4 months agoMITView on GitHub
Choose and implement the right state management approach in React/Next.js — server state (React Query/SWR), global client state (Zustand/Context), URL state, and form state. Use whenever the user asks "where should this state live", introduces prop-drilling pain, asks about Redux/Zustand/Context/React Query, or is deciding how to share state across components.
27 other projects use a version of this.
Adopted by
Most recently taken up by
- komluk/scaffoldingtheir own version, first seen Nov 7, 2026
- compozy/compozytheir own version, first seen Nov 7, 2026
- omspradippatil/Claude-Skillstheir own version, first seen Nov 1, 2026
- github/replicatheir own version, first seen Nov 1, 2026
- darknecrocities/SkillBuildertheir own version, first seen Nov 1, 2026
- TheBeardedBearSAS/claude-crafttheir own version, first seen Oct 29, 2026
Used with
Projects with it also use css-architecture, error-handling and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Piyush8296Skillcss-architecture
CSS architecture, Tailwind patterns, responsive design, design tokens, and styling best practices. Use when implementing designs, setting up styling infrastructure, or debugging layout issues.
Also in 3 projects that use this
MicrosoftSkillerror-handling
统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。
Also in 6 projects that use this
lbednerSkilli18n
Use when a code or template change introduces a new translation message key, in either the framework CLI (aegis/i18n/locales/) or a generated project's CLI (the app/i18n/locales/ template tree). Covers adding the real English string, stubbing the same key into every other locale for parity, and the separate translation PR that later replaces placeholders with reviewed native text.
Also in 4 projects that use this
mijunriSkilldatabase
数据库脚本与操作规范。脚本放在 db_scripts 目录,遵循查询优化、事务、安全等实践。
Also in 3 projects that use this
genomewalkerSkillresume
Resume a thread by loading its ~800-token context capsule
Also in 3 projects that use this
NVIDIASkilltesting
Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.
Also in 6 projects that use this
Other versions27 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 27
- compozy/compozy★ 2.9ksame name
- github/replica★ 230same name
- conorluddy/xclaude-plugin★ 186same name
- cohen-liel/hivemind★ 108same name
- TheBeardedBearSAS/claude-craft★ 108same name
- EmeaAppGbb/spec2cloud★ 100same name
- statelyai/skills★ 48same name
- komluk/scaffolding★ 16same name
- darknecrocities/SkillBuilder★ 13same name
- PMDevSolutions/Aurelius★ 9same name
17 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository22 other files it gives its agents.
- accessibility-a11ySkill
- design-system-tailwindSkill
- motion-design-toolkitSkill
- nextjs-architectureSkill
- react-component-engineeringSkill
- react-three-fiber-3dSkill
- responsive-mobile-firstSkill
- auth-authorizationSkill
- database-schema-designSkill
- form-validation-error-handlingSkill
- mern-stack-architectureSkill
- rest-api-integrationSkill
- landing-page-conversionSkill
- payment-gateway-integrationSkill
- saas-dashboard-adminSkill
- startup-mvp-developmentSkill
- ux-research-flow-designSkill
- visual-design-languageSkill
- ai-assisted-frontend-workflowSkill
- deployment-vercel-productionSkill
- performance-seo-optimizationSkill
- project-architecture-clean-codeSkill
The file
Files
State Management Skill
Decision framework: classify the state before picking a tool
- Server state (data that lives in a database, fetched over the network — products, user profile, orders): use TanStack Query (React Query) or SWR, or in Next.js, Server Components + Server Actions with
revalidatePath/revalidateTag. Never mirror server data into a global client store (Redux/Zustand) — you'll fight cache invalidation forever. - URL state (filters, pagination, selected tab, search query — anything that should survive a refresh/be shareable/bookmarkable): keep it in the URL (
useSearchParams/nuqs), not component state. - Global client-only state (theme, sidebar open/closed, multi-step wizard progress not tied to a URL, cart contents before checkout): Zustand for anything beyond trivial — lighter and less boilerplate than Redux for most app sizes; React Context only for low-frequency-update, small-scope state (e.g. auth user object, theme) since Context re-renders all consumers on every change.
- Local component state: plain
useState/useReducer— the default, don't reach for global state until 2+ unrelated components genuinely need the same value.
When Redux Toolkit is still the right call
Large teams with complex, deeply interdependent client state, time-travel debugging needs, or an existing Redux codebase. For most new MERN/Next.js projects in 2026, Zustand + React Query covers the same ground with far less boilerplate — default to that combination unless there's a specific reason for Redux.
Zustand pattern
const useCartStore = create<CartState>((set) => ({
items: [],
addItem: (item) => set((state) => ({ items: [...state.items, item] })),
removeItem: (id) => set((state) => ({ items: state.items.filter(i => i.id !== id) })),
}));Select narrowly in components (useCartStore(s => s.items)) rather than destructuring the whole store, to avoid unnecessary re-renders.
React Query pattern (server state)
const { data, isLoading } = useQuery({ queryKey: ['products', filters], queryFn: () => fetchProducts(filters) });
const mutation = useMutation({ mutationFn: updateProduct, onSuccess: () => queryClient.invalidateQueries({ queryKey: ['products'] }) });In a Next.js App Router app with Server Components as the primary data source, reach for React Query mainly for client-side interactive data (search-as-you-type, optimistic updates, polling) rather than initial page data.
Anti-patterns to flag
- Server-fetched data duplicated into Redux/Zustand "just in case," creating two sources of truth
- Filter/pagination state kept in
useStateinstead of the URL, breaking back-button and shareable links - Context used for high-frequency-updating state (e.g. mouse position, form input on every keystroke) causing broad re-renders
- Prop-drilling 4+ levels instead of composition or a scoped store
Example prompt this skill should trigger on
"I'm prop-drilling the cart state through 5 components, what's the right way to manage this?"
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

