frontend-state
Skill0 starsChanged 12 days agoMITView on GitHub
Decide where frontend state belongs: local, lifted, URL search params, server cache, or global store. Use when components re-render or props drill excessively.
In this repository68 other files it gives its agents.
- skills/web-development/adapters/copilot-instructions.mdCopilot instructions
- accessibility-auditSkill
- agent-handoffSkill
- ai-tool-securitySkill
- api-designSkill
- audit-loggingSkill
- background-jobsSkill
- bulk-reporting-exportSkill
- changelog-generatorSkill
- ci-cdSkill
- codebase-onboardingSkill
- code-reviewSkill
- code-simplificationSkill
- context-engineeringSkill
- context-privacySkill
- data-import-exportSkill
- debuggingSkill
- dependency-auditSkill
- deprecation-and-migrationSkill
- design-tokensSkill
- documentation-and-adrsSkill
- doubt-driven-developmentSkill
- environmental-telemetrySkill
- erp-accountingSkill
- erp-domain-designSkill
- erp-inventorySkill
- erp-procurementSkill
- erp-salesSkill
- feature-flagsSkill
- forms-and-validationSkill
- frontend-ui-engineeringSkill
- git-workflowSkill
- identity-access-managementSkill
- incremental-implementationSkill
- java-code-standardsSkill
- java-deliverySkill
- kerangkaSkill
- mcp-builderSkill
- membership-managementSkill
- observabilitySkill
- performance-optimizationSkill
- planning-and-task-breakdownSkill
- product-analyticsSkill
- quarkus-observabilitySkill
- quarkus-persistenceSkill
- quarkus-securitySkill
- quarkus-serviceSkill
- quarkus-testingSkill
- responsive-layoutSkill
- rest-api-contractSkill
- saas-billingSkill
- saas-multitenancySkill
- saas-onboardingSkill
- security-hardeningSkill
- shipping-and-launchSkill
- skill-creatorSkill
- skill-evaluationSkill
- source-driven-developmentSkill
- spec-driven-developmentSkill
- test-driven-developmentSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
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 37
Ask whether it is state at all: If it can be computed from props, existing state, or the URL, compute it.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend State
Overview
Where state lives decides more about a frontend's future than any other choice. Put it too low and it gets lifted, drilled and duplicated; put it too high and every unrelated change re-renders the app. Most frontends described as spaghetti are not badly written — they are holding one fact in three places.
When to use
- Choosing between
useState, lifted state, context, a URL param, a query cache, a store - The same fact exists in more than one place and they disagree
- Props passed through components that do not use them
- A component re-renders on changes it does not care about
- Server data kept in a global store and manually refreshed
- A refresh, a shared link, or the back button loses the user's place
Hand off when
| Need | Skill |
| Splitting the component, file layout | frontend-ui-engineering |
| Field state, validation, submit lifecycle | forms-and-validation |
| The request and response contract | api-design |
| Measuring a render problem before fixing it | web-perf |
Process
- Ask whether it is state at all. If it can be computed from props, existing state, or the URL, compute it. Stored derived values are the most common source of two sources of truth disagreeing.
- Separate server data from client state. They have different lifecycles: server data is a cache of something you do not own, with staleness, refetching and invalidation. Client state is yours. Putting server data in a global store means reimplementing a cache by hand, badly.
- Climb the ladder only as far as needed. Local → lifted → URL → server cache → context → store. Each rung costs coupling; stop at the first that works.
- Put shareable state in the URL. Filters, tabs, pagination, the open item. If a user should be able to send the link, refresh, or press back, the URL is the store — and it is free.
- Use context for read-heavy, write-rare values — theme, locale, current user. Context is a dependency-injection mechanism, not a state manager: every consumer re-renders on every change.
- Reach for a global store last, and only for genuinely app-wide client state that several distant trees both read and write.
- Keep state minimal and normalised. Store ids, not copies of objects that also live in the cache. Two copies drift the moment one is updated.
- Co-locate. State used by one subtree lives in that subtree. Lifting to the root "so it is available" is how a root component acquires forty fields.
Red flags
useEffectthat copies a prop into state, then tries to keep them in sync- Server data in Redux/Zustand with hand-rolled loading and error flags
- Filters or the active tab in component state, so the URL is unshareable
- Context holding a value that changes on every keystroke
- A store slice one component reads and nothing else
- Props threaded through three components that only pass them along
- Derived values stored and recomputed in an effect instead of during render
useMemo/useCallbackadded before anything was measured- State lifted to the root because two leaves needed it
- The same entity held in a list and again in a "selected" object
Verification
- Every piece of state has one owner and one source of truth
- Derived values are computed, not stored
- Server data lives in a cache with invalidation, not in a client store
- Shareable UI state survives refresh, back, and copying the link
- No effect exists purely to synchronise two pieces of state
- Context values are stable, or split so a change wakes only its consumers
- Changing one feature's state does not re-render unrelated trees
- No prop passes through a component that does not read it
References
references/the-ladder.md— each rung, what it is for, and the cost of the next onereferences/server-vs-client.md— cache semantics, and why server data is not app statereferences/untangling.md— diagnosing duplicated state, sync effects, and drilling
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.

