/engineering-paved-path:frontend-ui-architecturefrom engineering-paved-path
Frontend UI architecture and code organization for React and Next.js (App Router) apps — where components, hooks, constants, helpers/utils, types and business logic live; when and how to split a component; feature vs shared folders and one-way import rules; barrel/index.ts files; file naming and import style; enforcing boundaries with lint. Use when creating files or folders in a React/Next.js codebase, deciding where a piece of code belongs, extracting or splitting a component, moving code into a shared folder, reviewing a change for structure, or setting up architecture lint rules. Does not cover hook misuse, state anti-patterns or render performance — those belong to a React best-practices skill.
Ships in engineering-paved-path. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Rules for deciding where frontend code lives and how it is cut into pieces. They apply to any React / Next.js App Router codebase.
The project's own documents win. If the repository documents a structure (an agent guidance file, an architecture doc, an existing lint config), follow it and use this skill only for the questions it leaves open. Items marked Convention below have no single right answer. Pick one, write it down in the project, and apply it consistently.
shared → features → app/routes. Features
never import each other; they are composed at the route or app level.Answer these questions in order and stop at the first yes.
| # | Question | Put it… |
|---|---|---|
| 1 | Is it a routing file (page, layout, route, loading, error)? | in app/, and keep it thin: it composes, it does not compute |
| 2 | Is it used by exactly one component? | in that component's file or folder (constants.ts, helpers.ts, types.ts, use-x.ts) |
| 3 | Is it used by several components of one feature or route? | at the root of that feature (features/<f>/… or the route's _components/, _lib/) |
| 4 | Is it used by two or more features? | in the shared layer: components/, hooks/, lib/, utils/, config/, types/ |
| 5 | Does it need a sibling feature's internals? | nowhere yet. Compose both features in the route, or move the shared part down into the shared layer |
Default layout, used only when the project has none:
src/
app/ routes only; route-private UI in app/**/_components/
features/<feature>/ add once the app outgrows flat folders
components/ hooks/ api/ lib/ constants.ts types.ts
components/ shared UI (primitives, layout chrome)
hooks/ shared hooks
lib/ configured libraries: API client, query client, i18n
utils/ small, pure, framework-free functions
config/ env access and app-wide constants
types/ only truly global types
Grow into this layout step by step rather than scaffolding it all at once. See folder-structure.md.
Impact: CRITICAL (causes bugs or architecture rot), HIGH (causes scaling or maintainability pain), MEDIUM (hurts readability), LOW (style). Convention marks a choice to make once per project.
| ID | Rule | Impact |
|---|---|---|
struct-one-way | Imports go shared → features → app; never the reverse | CRITICAL |
struct-no-cross-feature | A feature never imports another feature | CRITICAL |
struct-colocate | Code starts next to its only consumer | HIGH |
struct-promote | Promote to the nearest common ancestor on the second real consumer | HIGH |
struct-thin-routes | Route files compose components; logic lives in components, hooks and helpers | HIGH |
struct-private-folders | Non-route code inside app/ goes in _private folders | MEDIUM |
struct-grow-by-size | Move from flat folders to feature folders as the app grows, not before | MEDIUM |
struct-shallow | Keep nesting at 3–4 levels or fewer below src/ | LOW |
struct-feature-vs-type | Feature folders vs type folders — Convention | — |
| ID | Rule | Impact |
|---|---|---|
split-no-nested-definitions | Never define a component inside another component | CRITICAL |
split-pure | Rendering is pure; side effects go in handlers or effects | CRITICAL |
split-on-trigger | Split for reuse, re-render cost, tangled state, hard-to-test logic or a client boundary | HIGH |
split-client-leaves | 'use client' on small interactive leaves, not on whole pages | HIGH |
split-named-subcomponents | Compound parts are named exports, not static properties (Menu.Item) | HIGH |
split-hooks-not-containers | Use a custom hook or a Server Component instead of a container/presentational split | MEDIUM |
split-composition-order | Props, then children/slots, then context | MEDIUM |
split-one-per-file | One exported component per file; small private helpers may share it | MEDIUM |
split-size-limit | Line or prop limits — Convention; no source gives a number | — |
| ID | Rule | Impact |
|---|---|---|
place-env-literal | Read process.env.NEXT_PUBLIC_X by literal property access only | CRITICAL |
place-constants-local | A constant starts in its consumer's file or constants.ts, and moves to config/ only when app-wide | HIGH |
place-as-const | Use as const objects or schema enums, not TypeScript enum | HIGH |
place-no-dumping-ground | Shared utils/ holds focused modules, never a grab-bag utils.ts | HIGH |
place-helper-not-hook | A function that calls no hooks is a helper, without the use prefix | HIGH |
place-lib-vs-utils | lib/ wraps configured libraries; utils/ holds pure generic functions | MEDIUM |
place-types-colocated | Types live next to their use; types/ only for truly global types | MEDIUM |
place-schema-type-name | A runtime schema and its inferred type share one name | MEDIUM |
| ID | Rule | Impact |
|---|---|---|
logic-pure-domain | Business rules are plain, framework-free, unit-tested functions | CRITICAL |
logic-no-effect-derivation | Derive values during render and handle events in handlers; effects only sync external systems | CRITICAL |
logic-no-server-state-copy | Never copy server data into useState; form initial values are the one exception | CRITICAL |
logic-one-data-path | Pick one data-fetching approach and one API client per app | HIGH |
logic-hooks-wire | Custom hooks connect domain functions to React and to data | HIGH |
logic-server-only | Server-only data access is guarded with import 'server-only' | HIGH |
logic-state-ladder | Place state as low as possible: derived → local → lifted → URL → context → store | HIGH |
logic-query-options | Data modules export query-key factories and queryOptions; hooks stay thin | MEDIUM |
logic-layers-proportionate | Add domain or gateway layers only when real client-side rules exist | MEDIUM |
| ID | Rule | Impact |
|---|---|---|
import-no-aggregating-barrel | No folder-level index.ts that re-exports many modules in app code | HIGH |
import-no-mixed-barrel | Never re-export server and client modules from one file | HIGH |
import-siblings-by-path | Inside a folder, import siblings by file path, never through its own index | MEDIUM |
import-alias | Use @/ for cross-folder imports and relative paths for siblings | MEDIUM |
name-react-rules | Components are PascalCase, hooks useX, handlers handleX, handler props onX | MEDIUM |
name-file-case | File-name case — Convention; enforce it with a linter | — |
import-single-index | A one-line per-component index.ts — Convention | — |
Once a structure is agreed, encode struct-one-way, struct-no-cross-feature,
import-no-aggregating-barrel and cycles as lint rules. A rule that only lives in prose drifts.
invoice-totals.ts), not by what kind of thing it is
(misc.ts).struct-no-cross-feature: features/billing imports features/auth/hooks."README.md (opens in a new tab)evals/evals.json (opens in a new tab)evals/results-1.0.0.md (opens in a new tab)references/component-splitting.md (opens in a new tab)references/constants-helpers-types.md (opens in a new tab)references/enforcement.md (opens in a new tab)references/folder-structure.md (opens in a new tab)references/logic-and-data.md (opens in a new tab)references/naming-and-imports.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub yrazub/gen-bin --plugin engineering-paved-path10 skills in this plugin
/fastify-best-practicesGuides development of Fastify Node.js backend servers and REST APIs using TypeScript or JavaScript. Use when building, configuring, or debugging a Fastify application — including defining routes, implementing plugins, setting up JSON Schema validation, handling errors, optimising performance, managing authentication, configuring CORS and security headers, integrating databases, working with WebSockets, and deploying to production. Covers the full Fastify request lifecycle (hooks, serialization, logging with Pino) and TypeScript integration via strip types. Trigger terms: Fastify, Node.js server, REST API, API routes, backend framework, fastify.config, server.ts, app.ts./mermaid-diagramCreate Mermaid diagrams in markdown. Use when the user wants to visualize workflows, architectures, API flows, data models, state machines, or system designs. Covers flowcharts, sequence diagrams, class diagrams, ER diagrams, state diagrams, and more./next-best-practicesNext.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling/onion-architectureOnion (ports-and-adapters) architecture for a TypeScript backend (Fastify, Drizzle/Postgres, Zod, a hand-written DI container, adapters). Decides which layer a piece of backend code belongs to, which way a dependency may point, where a port interface lives, how a service gets its dependencies, where transactions start, where Zod parses, and how dependency-cruiser can enforce all of it. Use when adding or moving a route, service, repository, adapter, port or domain rule in a backend; when a service needs the database, an external API or an LLM; when reviewing a backend diff for layering; or when an architecture check fails. Does not cover Fastify, Drizzle or Zod API usage — use fastify-best-practices, drizzle-orm-patterns and zod for that./react-best-practicesModern React best practices and anti-pattern catalog (2025-26). Use when writing, reviewing, or refactoring React components, hooks, and state management. Covers component design, state patterns, hooks misuse, performance and data fetching. For where files, constants, helpers and business logic live, use frontend-ui-architecture./react-testing-libraryGeneral-purpose React Testing Library guide with Vitest. Use when writing, reviewing, or setting up React component and hook tests. Covers project setup from scratch, RTL query priority, userEvent, async patterns, mocking strategies, and common anti-patterns. Applicable to any Vite + React project.