/engineering-paved-path:frontend-architecturefrom engineering-paved-path
Folder structure and code organization for React + Next.js (App Router) projects. Use this skill whenever the user asks where files should live (components, hooks, utils, helpers, lib, services, constants, types), how to break a component into smaller pieces, how to organize a feature folder, where to put business logic, when to use a barrel index, or how to lay out app/ in Next.js (route groups, private folders). Trigger on phrases like 'folder structure', 'project structure', 'where should I put', 'how to organize', 'where do constants go', 'utils vs helpers', 'app router structure'. Covers organization decisions only — NOT React hook rules or render patterns (use engineering-paved-path:react-best-practices) and NOT Next-specific runtime behavior (use engineering-paved-path:next-best-practices).
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.
Where files should live in a React + Next.js (App Router) project. Organization decisions only — not hook rules (see engineering-paved-path:react-best-practices), not RSC / runtime behavior (see engineering-paved-path:next-best-practices).
For concrete folder-tree examples, see examples.md. For sources, version history, and relationship to other skills, see README.md.
Each rule is tagged for use by consuming agents:
src/ for non-trivial appssrc/; Next.js looks for src/app if app/ is not at the rootapp/ at root and src/app/ togethersrc/
├── app/ # Next.js: routing only. Vite: not used
├── components/ # Shared, generic UI (Button, Card, Modal)
├── features/ # Domain-scoped modules (one folder per feature)
├── hooks/ # Shared, generic hooks (useDebounce, useMediaQuery)
├── lib/ # Wrappers around external libs (axios.ts, db.ts, auth.ts)
├── utils/ # Pure, generic, project-agnostic functions
├── types/ # Shared types (only if not feature-scoped)
└── constants/ # Cross-feature constants (routes, env keys, enums)
Each of these folders is optional — introduce it only when there are ≥2 things to put in it.
features/Add features/ once the app has ≥2 distinct domains (e.g. "billing", "settings", "team"). Before that, a flat components/ + hooks/ is fine. Don't pre-create features/ on day 1.
| Style | When | Trade-off |
|---|---|---|
By type (components/, hooks/, utils/) | Small apps (<30 files) | Easy start, breaks down past ~50 files |
| Feature-based | Default for product apps | Best balance of discoverability and scope |
| Layer-based / FSD | Large, multi-team apps with enforced boundaries | High ceremony; real wins only past ~500 files |
| Atomic design | Design systems / component libraries only | Ambiguous boundaries when applied to whole apps |
Default: feature-based. Atomic design belongs in a separate design-system package, not in your product app.
Place code as close to where it's relevant as possible.
X.test.tsx)X.module.css or Tailwind inline)useX.ts)_components/)# Barrel style
Button/
├── index.ts # re-exports Button
├── Button.tsx
├── Button.test.tsx
└── _components/
└── ButtonIcon.tsx
# Flat style
Button.tsx
Button.test.tsx
Decision rule:
index.ts files inside utils/ and components/ui/ — they hurt Next.js tree-shaking (vercel/next.js#92926)| Constant scope | Where |
|---|---|
| Used by one component, static | Module-level (top of component file, outside the function) |
| Used by multiple files in one feature | features/<feature>/constants.ts |
| Globally meaningful (routes, env keys, shared enums) | src/constants/ |
| Depends on props/state | Inline (computed in component) |
Never declare static constants inside the component function body — they're re-created on every render.
Pick one convention per project and document it. The most defensible split:
| Folder | What goes in | Example |
|---|---|---|
lib/ | Wrappers around external libraries; mini-packages (could be extracted as npm) | lib/axios.ts, lib/db.ts, lib/cn.ts |
utils/ | Pure, generic, project-agnostic functions | utils/format-date.ts, utils/range.ts |
services/ | Functions that do work (I/O, API calls, business actions) | services/billing.ts, services/auth.ts |
helpers/ | Avoid — overlaps with utils/. If used, restrict to project-specific glue |
utils/lib/services/Components render UI. Hooks own logic. Services do work. Components should not contain business logic.
View (presentational component)
↑ props
Container (wires hook + view)
↑ uses
Hook (logic, state, derived values)
↑ calls
Service / API layer (lib/, services/, or features/<f>/api/)
| Logic kind | Goes in |
|---|---|
| Stateful UI behavior (toggles, debounces, form state) | Custom hook |
| Client-side server-data fetching (React Query) | Custom hook wrapping a service |
| Server-side data fetching (RSC) | lib/ async fn or colocated with the route |
| Pure transform of input → output | utils/ |
| Side effect (network, storage, analytics) | services/ or lib/ |
| Cross-feature state (auth, theme) | Context + hook in lib/ or providers/ |
In Next.js App Router, server-side data fetching commonly lives inside the route segment (page.tsx) or in lib/ async functions. Client mutations + React Query still benefit from the hook layer.
Split a component when any of these is true:
Parent/_components/Sub.tsx (private folder)features/<f>/_components/src/components/UserCard.tsx)use-prefixed (useUser.ts)format-date.ts)auth-flow/), PascalCase only for component folders (UserCard/)Everything in app/ is one of:
page.tsx, layout.tsx, loading.tsx, error.tsx, route.ts, not-found.tsx, template.tsx_anything/ — excluded from routing(name)/ — affects organization, NOT the URLInside app/ only if it's used only by that segment:
app/(dashboard)/billing/
├── page.tsx
├── _components/InvoiceTable.tsx # used only by this route
└── _hooks/useInvoices.ts
Outside app/ if it's shared:
src/features/billing/ # shared by app/billing AND app/admin/billing
src/components/ui/ # generic UI used everywhere
Use route groups to share a layout across pages without nesting in the URL:
app/
├── (marketing)/ # public marketing pages
│ ├── layout.tsx # marketing layout
│ ├── page.tsx # /
│ └── pricing/page.tsx # /pricing
└── (app)/ # authenticated app
├── layout.tsx # app shell layout
└── dashboard/page.tsx # /dashboard
"use client" directive does"use client" as low in the tree as possible (leaves, not roots)asyncNEW FILE → WHAT IS IT?
├── React component
│ ├── Used by one route → app/<route>/_components/ (Next)
│ │ features/<f>/_components/ (Vite)
│ ├── Shared in one feature → features/<f>/_components/
│ └── Used across features → src/components/
│
├── Custom hook
│ ├── Used by one feature → features/<f>/hooks/
│ └── Generic → src/hooks/
│
├── Pure function
│ ├── Project-agnostic → src/utils/
│ └── Wraps an external lib → src/lib/
│
├── Function with I/O / side effects → src/services/ or features/<f>/api/
│
├── Constant
│ ├── Used by one file → top of that file (outside the component)
│ ├── Shared in one feature → features/<f>/constants.ts
│ └── Cross-feature → src/constants/
│
└── Type / DTO
├── Used by one feature → features/<f>/types.ts
└── Cross-feature → src/types/
For folder-tree examples (small Vite, mid-size Next, bulletproof-react style), see examples.md.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub yamchinsky/dev-digest-ai-marketplace --plugin engineering-paved-path12 skills in this plugin
/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./nestjs-best-practicesNestJS application patterns for TypeScript backends — modules and providers, dependency injection and injection tokens, the composition root, thin controllers, guards/interceptors/pipes/filters and their execution order, validation at the edge, ConfigModule and typed configuration, lifecycle hooks, exception filters, and testing with Test.createTestingModule. Use when building, wiring, reviewing or debugging a NestJS application: adding a module or a provider, resolving 'Nest can't resolve dependencies of X', choosing an injection scope, registering a global guard, shaping an error response, writing a testing module, or upgrading a NestJS major. Trigger terms: NestJS, Nest, @nestjs/common, @nestjs/core, app.module.ts, @Module, @Injectable, @Controller, provider, injection token, forwardRef, ValidationPipe, exception filter, APP_GUARD, Test.createTestingModule, nest build, nest start. NestJS runtime and wiring ONLY — NOT which layer a file belongs to (use engineering-paved-path:onion-architecture), NOT TypeORM query, migration or entity mechanics (use engineering-paved-path:typeorm-patterns), NOT PostgreSQL schema design (use engineering-paved-path:postgresql-table-design), NOT Zod schema mechanics (use engineering-paved-path:zod)./next-best-practicesNext.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling/onion-architectureLayering and dependency-rule conventions for TypeScript backends, with an optional pure-engine package. Use whenever editing or adding backend code; whenever adding a new module / use case / repository / adapter / outbound port / shared contract; whenever the question is *where should this live* on the backend (HTTP edge vs service vs repository vs adapter vs platform vs shared); whenever reviewing a backend PR for layer violations (ORM in a service, SDK import in a controller, `process.env` in a pure engine package, services importing other modules' services, SDK imports leaking past the adapter boundary). Trigger phrases: 'new endpoint', 'new module', 'where should this go', 'add a repository', 'add an adapter', 'wire up a port', 'consume X from a service', 'the engine needs to read', 'service is doing too much'. Layering and dependency placement ONLY — NOT NestJS runtime and wiring mechanics (use engineering-paved-path:nestjs-best-practices), NOT TypeORM query and migration mechanics (use engineering-paved-path:typeorm-patterns), NOT Zod schema mechanics (use engineering-paved-path:zod). For the client side use engineering-paved-path:frontend-architecture./postgresql-table-designUse this skill when designing or reviewing a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features/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, data fetching, and code organization.Other plugins' skills for the same job