React/Next.js frontend architecture & code organization (2025-26): where files live, how to split components, feature-based structure, co-location, constants/utils/helpers/types/hooks placement, where business logic goes, import boundaries, barrel files, path aliases, and naming conventions. Use when structuring a new frontend, deciding where a file or piece of logic belongs, splitting an oversized component/module, reviewing folder layout, or naming files. Stack-agnostic (React 19 + Next.js 15 App Router aware).
How this skill is triggered — by the user, by Claude, or both
Slash command
/engineering-paved-path:react-frontend-architectureThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
How a React/Next.js frontend should be *organized* — where code lives, how it's split, and what to name it. This is about **structure and placement**, not component runtime correctness. For code examples (good/bad per rule) see [examples.md](examples.md); for sources see [references.md](references.md).
How a React/Next.js frontend should be organized — where code lives, how it's split, and what to name it. This is about structure and placement, not component runtime correctness. For code examples (good/bad per rule) see examples.md; for sources see references.md.
Sibling skills (do not duplicate):
engineering-paved-path:react-best-practices → component purity, hooks misuse, memoization, keys, derive-don't-store.engineering-paved-path:next-best-practices → App Router file conventions, RSC mechanics, metadata, image/font optimization.Colocation: place code as close to where it's used as possible. A file's location is a claim about its scope. Promote code to a shared layer only when a second consumer actually appears — not in anticipation. Premature shared abstractions (AHA: Avoid Hasty Abstractions) are as harmful as duplication.
features/checkout/ beats a global components/, hooks/, utils/ split once the app has more than a handful of screens.components/, hooks/, utils/ at the root) is fine for small apps but scales poorly: working on one feature forces edits across many directories (low cohesion, high coupling).api/, components/, hooks/, stores/, types/, utils/.shared/, components/ui/, lib/) for genuinely cross-feature primitives only.app → pages → widgets → features → entities → shared) makes boundaries explicit. Adopt the layering, not necessarily the full vocabulary.components/ within the feature, or a flat shared components/ for cross-cutting UI. Avoid Atomic-Design buckets (atoms/molecules/organisms) — categorizing wastes time and the boundaries are arbitrary.hooks/ (feature-local) or alongside the component that owns them. One hook per file, file named after the hook (useCart.ts).constants.ts (feature-local) or shared/constants/. Never scatter magic values inline; never dump everything into one global constants.ts with thousands of lines — split by domain.types.ts colocated with the feature; shared contracts in a shared types module. Co-locate a type with its consumer until a second consumer appears.utils/.helpers.ts.utils/ should hold pure functions only. A function with side effects is not a util — it belongs in a hook, service, or data layer.api/ or lib/ module (a Data Access Layer), never inline in components.server-only so they can't be imported into the client bundle.shared → features → app. Lower layers never import from higher layers. This keeps the dependency graph acyclic and prevents tangled coupling.import/no-restricted-paths or equivalent), not by convention alone.index.ts that re-exports a folder's contents) for internal modules. They break tree-shaking, slow dev servers/bundlers, and create circular-import hazards. Import directly from the source file.@/features/..., @/shared/...) instead of deep relative chains (../../../).children/slots over adding ever more boolean/config props. A component accreting many flags (isModal, isCompact, hasHeader...) wants to be split or composed.children prop and composition to avoid prop drilling before reaching for context. Lift content up; pass elements as props/slots.<Tabs><Tabs.List/><Tabs.Tab/></Tabs>) express related parts that share implicit state — use them for cohesive widget families instead of one mega-component with a giant prop list.any/broad objects. Provide defaults for optional props.useState/Redux/Zustand.useState/useReducer), URL state (search params for filters/pagination/sorting), server cache (TanStack Query/SWR), app-wide client state (Zustand/Jotai/Redux only when warranted).useOrders, useCreateOrder) so components depend on an intent-revealing API, not raw fetch/query plumbing.useEffect — derive it. (Detail lives in engineering-paved-path:react-best-practices; relevant here because it dictates that derived values get no storage location at all.)PascalCase — UserCard, UserCard.tsx.useCamelCase, file useCart.ts. The name must convey intent ("what it does/returns"), not implementation. A hook you can't name clearly is probably too coupled to one component.camelCase. Booleans: prefix is/has/should (isLoading, hasAccess).UPPER_SNAKE_CASE for true constants; PascalCase/objects for enums/config maps.kebab-case for folders, PascalCase for component folders). Pick one and don't mix.validation.helpers.ts, order.constants.ts, cart.types.ts beat a dozen ambiguous index.ts/utils.ts.index.ts re-exporting everything.../../../../).server-only guard).utils.ts/constants.ts instead of domain-split files.Guides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
npx claudepluginhub syukpublic/dev-digest-ai-marketplace --plugin engineering-paved-path