react-boundaries
Skill1 starsChanged 3 months agoMITView on GitHub
Enforces React component ownership boundaries—colocate state, queries, and mutations with consuming leaves; avoid prop drilling and parent data hubs; structure trees for render isolation and composability. Includes TanStack Query, Router, Start, Form, and Store patterns. Use when designing or reviewing component architecture, refactoring prop-heavy trees, fixing unnecessary re-renders from lifted state, deciding where API or query logic should live, or when the user says react-boundaries, ownership boundaries, push state down, or stop prop drilling.
In this repository81 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agents-mdSkill
- base-uiSkill
- better-authSkill
- brainstormSkill
- bullmqSkill
- bunSkill
- clickhouseSkill
- clone-to-tempSkill
- compound-uiSkill
- copywritingSkill
- create-durable-planSkill
- d3Skill
- date-fnsSkill
- decimal-jsSkill
- deduplicateSkill
- design-engineerSkill
- designSkill
- drizzle-ormSkill
- effectSkill
- elysia-architectureSkill
- elysiaSkill
- evlogSkill
- feedsmithSkill
- grokSkill
- handoffSkill
- heyapiSkill
- impitSkill
- intlayerSkill
- jsdocSkill
- kafkaSkill
- kill-legacySkill
- legend-stateSkill
- loopSkill
- mantine-hooksSkill
- mobbinSkill
- motionSkill
- oxfmtSkill
- oxlintSkill
- permixSkill
- plain-languageSkill
- playwrightSkill
- react-emailSkill
- reactSkill
- reorganizeSkill
- researchSkill
- schema-dtsSkill
- sentrySkill
- seoSkill
- setup-competitors-mdSkill
- setup-copywriting-mdSkill
- setup-icp-mdSkill
- setup-project-mdSkill
- simplify-layoutSkill
- storybookSkill
- subagentsSkill
- tailwindSkill
- tailwind-variantsSkill
- takumiSkill
- tanstack-chartsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Compose UI, don’t pipe props: Prefer children / slots / named parts over threading data, isLoading, and handlers through layout shells.
- Distinctive: line 47
Before finishing a change, answer:
- Distinctive: line 59
Not restyling, a11y primitive design, or general React API docs.
- Very specific: line 60
Not replacing TanStack Query with ad-hoc parent useEffect fetching.
≈ “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
React Boundaries
Own state, data, and side effects at the lowest correct boundary. Parents compose structure; they do not become data hubs.
Principle: a component should own what it needs to render and act—unless another boundary must genuinely coordinate, gate, or load in parallel.
Hard Defaults
- Push down. State and fetches live with the consumer. Lift only via the exception list.
- Pass identity, not payloads. Give children an
id(or stable handle); let them subscribe or query. Do not drill entities through wrappers that never use them. - Compose UI, don’t pipe props. Prefer
children/ slots / named parts over threadingdata,isLoading, and handlers through layout shells. - Shared clients, local hooks. One API or QueryClient; many leaf hooks. Do not centralize “call the API” five layers up.
- Structure over memo theater. Fix ownership and tree shape before spraying
memo/useCallback/useMemo. Prefer patterns that work with React Compiler. - Justify every hoist in one line when you lift or route-fetch (“SEO”, “gate before mount”, “sibling sync”, “anti-waterfall”).
When Hoisting Is Correct
Hoist state or data ownership only for:
| Exception | Own at |
| Route / SSR / SEO needs data before paint or for meta | Router loader, Start server function, or RSC prefetch |
| Auth, permissions, or “don’t mount until X” | Route or parent gate |
| Two+ siblings must share one interactive source of truth | Nearest common parent or a narrow store |
| Parent must know which children exist before they can fetch | Parent / loader (anti-waterfall) |
| Cache already dedupes the same key | Leaves still subscribe; parent may prefetch only |
Everything else stays down. Details: ownership.md.
Workflow
- Scope — feature, route, or component tree the user named.
- Map ownership — for each piece of state and each query/mutation, name the owner and who re-renders when it changes.
- Apply defaults — move ownership down; replace drilled payloads with ids + leaf subscriptions; replace prop pipelines with composition.
- Apply TanStack patterns — tanstack-patterns.md.
- Check composition — composition.md.
- Kill anti-patterns — anti-patterns.md.
- Verify — typecheck/lint/tests for the touched surface; confirm high-churn state no longer sits in page/route shells.
Placement Checklist
Before finishing a change, answer:
- Who re-renders if this state or query updates?
- Who actually uses this data or state?
- Can the leaf own the query/mutation (or subscribe to a shared key)?
- Are intermediates composing UI or only forwarding props?
- If hoisted: which exception applies (one-line justification)?
- Is Context / Store carrying stable deps or high-churn values that should be local?
Non-Goals
- Not “never use Context,” “never use route loaders,” or “never pass props.”
- Not restyling, a11y primitive design, or general React API docs.
- Not replacing TanStack Query with ad-hoc parent
useEffectfetching.
Completion
Report briefly:
- Ownership moves (what moved down or stayed up, and why).
- Prop-drilling or data-hub removals.
- Prefetch vs subscribe split (if any).
- Remaining hoists with their exception justification.
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.

