data-fetching
Skill9 starsChanged 2 months agoMITView on GitHub
Async UI for remote data — loading, error, retry, empty, stale, cache boundaries. Use when building lists, detail pages, dashboards fed by API, React Query/SWR, fetch/loaders, or "ambil data", "loading state API", "retry".
In this repository36 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/design-system-enforcer.mdcCursor rule
- frontend-expertSkill
- accessibilitySkill
- anti-slop-codeSkill
- anti-slop-designSkill
- app-shellSkill
- architectureSkill
- componentsSkill
- content-designSkill
- design-colorSkill
- design-directionSkill
- design-foundationsSkill
- design-surfacesSkill
- design-typographySkill
- design-vocabularySkill
- devtoolsSkill
- engineering-vocabularySkill
- fidelitySkill
- formsSkill
- frontend-expertSkill
- marketingSkill
- monitoringSkill
- motion-inspectionSkill
- motionSkill
- performanceSkill
- polishSkill
- prototypeSkill
- quality-loopSkill
- responsiveSkill
- seoSkill
- skill-authoringSkill
- testingSkill
- tokensSkill
- webglSkill
The file
Files
Data Fetching
Overview
Separate server state from UI chrome. Every remote surface needs loading / error / empty / success — with retry where useful. Parity with Conventions States line.
When to use
- Lists, detail, search results, dashboards from API
- Introducing React Query, SWR, router loaders,
useEffectfetch - Fixing spinner-forever or silent failure UIs
When to skip
- Static content / mock-only prototypes with no async
- Pure presentational components receiving props only
- Generated catch/toast that ignores field cases / other modules → load
anti-slop-codefor taxonomy, then this skill for retry chrome
MUST (ship)
| State | Required UX |
| Loading | Skeleton/placeholder — not a blank hole (prefer local to the widget) |
| Error | User-safe message + Retry (or clear next step) |
| Empty | Real empty copy + optional action (not Lorem) |
| Success | Render data; don’t leave stale error UI |
Also: abort/cancel on unmount when using raw fetch; don’t block the whole app shell for one panel.
Workflow
- Choose ownership — server state in query/loader; local UI state stays in the component
- Required states — loading · error (message + retry) · empty · success
- UX — skeleton preferred; isolate loading to the widget when possible
- Errors — user-safe message; log details; retry for transient failures
- Cache — stale-while-revalidate when the stack supports it; invalidate on mutations
- Hand off — presentation via
components; tokens +responsivestill apply - Conventions — report
States: loading / empty / error covered? yes
Agent boundaries
- May decide: Query lib vs loader vs
useEffectmachine; skeleton vs spinner; toast vs inline error - Must not: Swallow errors to
console.logonly; ship success-only UI; invent off-token loading colors
Checklist
- Loading / error / empty / success covered
- Retry or clear next step on error
- Empty copy is real (not Lorem)
- Fetch logic not tangled inside giant presentational files
- Race/unmount handled for raw fetch
- Responsive + tokens still apply to async UI
- Conventions States line filled when shipping
Depth
Patterns: references/data-fetching.md.
State org: references/architecture.md.
Ship gate: references/compliance-gates.md (States).
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.

