state-management
Skill0 starsChanged 3 months agoMITView on GitHub
Design frontend state architecture. Covers state categorization (server vs client vs URL), library selection, cache invalidation, optimistic updates, and state machine patterns.
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 8 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
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
0xSeroSkillsecurity
Also in 4 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 repository44 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- a11y-auditSkill
- ai-engineerSkill
- api-clientSkill
- changelog-enforcerSkill
- code-cleanup-guardianSkill
- code-reviewerSkill
- contract-testSkill
- db-migrateSkill
- dep-auditSkill
- devops-automatorSkill
- env-configSkill
- error-observabilitySkill
- frontend-designSkill
- git-commit-helperSkill
- github-issues-managerSkill
- git-issue-syncSkill
- git-protocolSkill
- handoffSkill
- incident-responseSkill
- init-projectSkill
- karpathy-guidelinesSkill
- market-researcherSkill
- parallel-agent-git-isolationSkill
- product-strategistSkill
- pr-workflowSkill
- rapid-builderSkill
- release-managerSkill
- resumeSkill
- scrutinizeSkill
- shadcn-uiSkill
- skill-builderSkill
- sprint-plannerSkill
- state-machine-diagramsSkill
- surveySkill
- system-architectSkill
- tech-docsSkill
- unstuckSkill
- ux-design-systemSkill
- ux-researchSkill
- webapp-testingSkill
- web-dev-fundamentalsSkill
- workflow-optimizerSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 21 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Before choosing a library, classify every piece of state:
- Distinctive: line 99
Use discriminated unions to make invalid states unrepresentable.
“Common” is measured: kept by at least 6 in 10 of the 21 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
State Management Architect
State Categorization
Before choosing a library, classify every piece of state:
| Category | Source of Truth | Persistence | Examples |
| Server state | Database/API | Survives refresh | User profile, orders, products |
| Client state | Browser memory | Lost on refresh | Modal open/closed, selected tab, sidebar collapsed |
| URL state | URL bar | Shareable/bookmarkable | Current page, filters, search query, sort order |
| Form state | Input elements | Until submit | Field values, validation errors, dirty tracking |
Rule: Use the right tool for each category
| Category | Recommended Tool | Anti-Pattern |
| Server state | TanStack Query / SWR | Redux store with manual fetch |
| Client state | useState / Zustand / Jotai | Context for frequently changing values |
| URL state | URL search params / router | Redux or useState for page/filter state |
| Form state | React Hook Form / native | Global store for form values |
Server State (TanStack Query Pattern)
// Fetch with automatic caching, refetching, and loading states
const { data, isLoading, error } = useQuery({
queryKey: ['users', userId],
queryFn: () => api.getUser(userId),
staleTime: 5 * 60 * 1000, // Consider fresh for 5 minutes
});
// Mutation with optimistic update
const mutation = useMutation({
mutationFn: api.updateUser,
onMutate: async (newData) => {
await queryClient.cancelQueries({ queryKey: ['users', userId] });
const previous = queryClient.getQueryData(['users', userId]);
queryClient.setQueryData(['users', userId], newData);
return { previous };
},
onError: (err, vars, ctx) => queryClient.setQueryData(['users', userId], ctx.previous),
onSettled: () => queryClient.invalidateQueries({ queryKey: ['users', userId] }),
});Client State (Zustand Pattern)
const useUIStore = create<UIState>((set) => ({
sidebarOpen: false,
theme: 'light',
toggleSidebar: () => set((s) => ({ sidebarOpen: !s.sidebarOpen })),
setTheme: (theme) => set({ theme }),
}));
// Usage: subscribe to slices — const open = useUIStore((s) => s.sidebarOpen);URL State Pattern
// Filters and pagination belong in the URL, not in state
const [searchParams, setSearchParams] = useSearchParams();
const page = parseInt(searchParams.get('page') || '1', 10);
const sort = searchParams.get('sort') || 'newest';
const filter = searchParams.get('filter') || 'all';Cache Invalidation Strategy
| Event | Invalidate |
| Create item | List queries for that resource |
| Update item | Item query + list queries |
| Delete item | List queries (remove from cache directly) |
| Bulk operation | All queries for that resource type |
| Background (polling) | Stale queries on window focus |
State Machine Pattern (Complex Flows)
For multi-step workflows (checkout, onboarding, file upload):
type UploadState =
| { status: 'idle' }
| { status: 'selecting' }
| { status: 'uploading'; progress: number }
| { status: 'processing' }
| { status: 'complete'; url: string }
| { status: 'error'; message: string };Use discriminated unions to make invalid states unrepresentable.
Anti-Patterns
- Global state for everything (makes components impossible to test in isolation)
- Duplicating server data in client store (stale by definition)
- Prop drilling through 5+ levels (use composition or context for stable values)
- Context for frequently changing values (re-renders entire tree)
- Derived state stored separately (compute it from source, don't sync it)
useEffectto sync state between twouseStatecalls (combine into one state or use derived value)
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.

