Next.js project config (nextjs-config-01)
Apply this skill together with Next.js Best Practices for App Router mechanics (routing, RSC, caching, Server Actions, next/script, etc.).
Additional detail for this skill lives in:
| Document |
Contents |
| resources/architecture.md |
Service provider architecture, metadata (SEO) , monitoring & observability, release, and TypeScript |
| resources/convention.md |
Naming, folder tree, imports, Zod, formats, anti-patterns, enforcement, testing, docs |
When instructions conflict, follow the guidances in this skill and the referenced resources; use this file as a compressed checklist.
Stack (fixed choices)
| Category |
Technology |
| Language |
TypeScript (strict; no any on public APIs without justification) |
| Framework |
Next.js (App Router) — frontend + server |
| UI |
React |
| UI components |
shadcn/ui |
| Styling |
Tailwind CSS |
| Validation |
Zod — definitions only under /lib/validation/ |
| Forms |
React Hook Form |
| Local UI state |
React Context + hooks |
| Session |
iron-session |
| Password hashing |
bcrypt.js |
| Database ORM |
Prisma |
| Server/async client state |
@tanstack/react-query |
| Testing |
Vitest (unit/integration); Playwright (E2E) |
Runtime and data boundaries
Prisma targets Node. Use Prisma from Server Components, Server Actions, and route.ts on the default Node runtime. Do not rely on Prisma in Edge (proxy / middleware or runtime = 'edge') unless you adopt an edge-compatible data client. See runtime-selection.md.
Server vs client: Prefer Server Components; use 'use client' only where hooks, events, or browser APIs require it; prefer server parent + client child for mixed routes.
Data: Database reads in server code; HTTP with explicit cache/revalidate where applicable; mutations via Server Actions (and/or route handlers) with Zod validation from /lib/validation/.
Hooks: Logic-only, composable, under hooks/ per convention; do not return JSX, import UI for unrelated concerns, or mix unrelated responsibilities in one hook.
Anti-patterns (align with Next.js skill): Avoid 'use client' on large trees, client-fetching for core reads where RSC suffices, and missing loading.tsx / error.tsx where UX needs them.
Folder layout (high level)
Follow resources/convention.md for the full tree. Important roots:
app/ — routes, layouts, pages, loading/error/not-found, route.ts APIs
components/ — reusable UI (ui/, forms/, layout/, ui-mobile/, …)
lib/ — utilities, prisma.ts, shared logic; lib/validation/*.schemas.ts for Zod
services/ — domain types, *_interface.ts, *_prisma.ts implementations
providers/ — factories (e.g. user_crud_providers.ts)
business-layer/ — app config/, types/, queries/, mutations/, utils/
hooks/ — browser/ vs mobile/ as needed
tests/ — unit area; E2E under tests/e2e/
- Root:
proxy.ts (Next.js 16+) or middleware.ts (14–15) for edge auth/redirects — one pattern matching the installed version, not both active. See file-conventions.md.
Reserved App Router filenames (exact names, lowercase): page.tsx, layout.tsx, loading.tsx, error.tsx, not-found.tsx, global-error.tsx, route.ts, template.tsx, default.tsx. Do not rename to PascalCase. Do not put route.ts and page.tsx in the same segment.
Private route folders: leading _ (e.g. _components/, _tests/) — excluded from the URL.
Naming (quick reference)
| Area |
Rule |
| Route segments (public) |
kebab-case |
| Private folders |
_name/ |
| Your React component modules |
PascalCase.tsx matching the primary export |
| Lib / hooks / utilities |
camelCase.ts |
| Type-only modules |
camelCase.types.ts |
| Prisma |
PascalCase models; plural snake_case tables @@map; DB columns snake_case with @map on camelCase fields |
| REST API paths |
Lowercase, hyphenated segments, no trailing slash |
| JSON / TS objects |
camelCase keys |
| DB |
snake_case; transform at boundary |
Imports and validation
@/ for project imports; relative only for same-directory (./).
Order: external packages → next/* → internal @/ → import type for types-only.
Zod: Single source of truth in /lib/validation/ (e.g. auth.schemas.ts). Never duplicate schema definitions in components; optional barrels may re-export only. Same schema on client (forms) and server (actions/routes).
Components: Co-locate component-only types/helpers; import schemas from @/lib/validation/....
Monitoring and analytics
Primary product analytics: Vercel Analytics (@vercel/analytics) — <Analytics /> in root layout; track() for custom events.
Other scripts: Use next/script and loading strategies per scripts.md; avoid raw <script> where the skill prescribes otherwise.
Observability baseline: Frontend RUM/CWV (e.g. Vercel Analytics), server logs for API routes, error boundaries + optional Sentry/LogRocket; Lighthouse CI in GitHub Actions per architecture.
For additional details and examples, see resources/architecture.md - Monitoring & Observability.
Non-functional requirements (baseline)
Performance (primary): LCP under 2.5s, INP under 200ms, CLS under 0.1. Secondary: initial load under 2s where measured; lab TBT under 200ms; client navigations under 500ms.
Security: HTTPS in production; cookies HttpOnly, Secure, SameSite=Lax; no sensitive data in logs.
Browsers: Modern evergreen; latest two of Chrome, Firefox, Safari, Edge.
Accessibility: WCAG 2.1 Level A baseline — keyboard, semantic HTML, visible focus, form labels — global unless explicitly scoped otherwise.
Privacy / compliance: GDPR/CCPA-oriented architecture; consent-aware handling; deletion/export in later phases per product.
Graceful degradation: Fault-tolerant integration boundaries; one external dependency failure must not break overall UX.
Release: Clean next build, no TypeScript errors; verify NEXT_PUBLIC_* vs server-only secrets; Lighthouse/PageSpeed as needed for CWV goals.
Testing
- Unit:
*.test.ts / *.test.tsx; components: ComponentName.test.tsx.
- Page tests: co-located
app/.../_tests/PageName.test.tsx.
- E2E:
tests/e2e/*.spec.ts.
Documentation
- JSDoc on public APIs; explain why, not what.
- Session and shared types: ISO 8601 strings where convention shows
loginTimestamp, etc.
Anti-patterns (reject in review)
- Duplicate Zod outside
/lib/validation/.
- Cross-directory relative imports instead of
@/.
- camelCase physical DB columns without
@map to snake_case.
- Mismatched component filename vs export (except reserved App Router files).
- Prisma or Node-only APIs on Edge without an explicit compatible approach.
- Inconsistent REST paths (wrong casing, trailing slashes).
Mandatory agent behaviors (enforcement)
- Follow naming and folder conventions (including reserved
app/ filenames).
- Import validation schemas — never duplicate Zod definitions.
- Follow project structure (components, lib, app, services, providers, business-layer).
- Use
@/ for internal imports.
- Co-locate page tests in
_tests/ beside the route.
- Match component file names to exports (
SignupForm → SignupForm.tsx).
Agent checklist
- Stack matches the fixed table; Prisma used only on Node server contexts unless otherwise designed.
- Files live where convention.md specifies;
proxy.ts vs middleware.ts matches Next version.
- Zod only under
/lib/validation/; JSON camelCase; DB snake_case with Prisma mapping.
- Imports use
@/ and prescribed order; import type for type-only imports.
- Services use interfaces + factories; default CRUD factory Prisma-only unless Supabase appendix applies.
- Metadata via
generateMetadata / metadata export; Vercel Analytics pattern when adding analytics.
- For large features or refactors, read generate-skills-artifacts/architecture.md and convention.md in full first.
Resources
1---2name: nextjs-config-013description: Defines this repository's Next.js App Router stack, boundaries, and conventions: strict TypeScript, shadcn/ui, Tailwind, Zod definitions only under lib/validation, React Hook Form, iron-session, bcrypt.js, Prisma (Node runtime only), TanStack Query, Vitest and Playwright, service-provider pattern with interfaces and factories, kebab-case routes and _private folders, @/ imports, Prisma snake_case DB mapping, REST and JSON naming, metadata/SEO, Vercel Analytics, Core Web Vitals and security baselines, and release gates. Use when implementing, reviewing, refactoring, planning stories, or generating project code; when the user mentions architecture, conventions, folder layout, business-layer, providers, validation schemas, Prisma, proxy vs middleware, or aligning with this project's standards—even if they do not name this skill.4---56# Next.js project config (nextjs-config-01)78Apply this skill together with [Next.js Best Practices](@.agents/skills/next-best-practices/SKILL.md) for App Router mechanics (routing, RSC, caching, Server Actions, `next/script`, etc.).910**Additional detail** for *this* skill lives in:1112| Document | Contents |13|----------|----------|14| [resources/architecture.md](./resources/architecture.md) | Service provider architecture, metadata (SEO) , monitoring & observability, release, and TypeScript |15| [resources/convention.md](./resources/convention.md) | Naming, folder tree, imports, Zod, formats, anti-patterns, enforcement, testing, docs |1617When instructions conflict, follow the **guidances** in this skill and the referenced resources; use this file as a compressed checklist.1819---2021## Stack (fixed choices)2223| Category | Technology |24|----------|------------|25| Language | TypeScript (strict; no `any` on public APIs without justification) |26| Framework | Next.js (App Router) — frontend + server |27| UI | React |28| UI components | shadcn/ui |29| Styling | Tailwind CSS |30| Validation | Zod — **definitions only** under `/lib/validation/` |31| Forms | React Hook Form |32| Local UI state | React Context + hooks |33| Session | iron-session |34| Password hashing | bcrypt.js |35| Database ORM | Prisma |36| Server/async client state | @tanstack/react-query |37| Testing | Vitest (unit/integration); Playwright (E2E) |3839---4041## Runtime and data boundaries4243- **Prisma targets Node.** Use Prisma from Server Components, Server Actions, and `route.ts` on the **default Node** runtime. Do **not** rely on Prisma in **Edge** (`proxy` / `middleware` or `runtime = 'edge'`) unless you adopt an edge-compatible data client. See [runtime-selection.md](@.agents/skills/next-best-practices/runtime-selection.md).4445- **Server vs client:** Prefer Server Components; use `'use client'` only where hooks, events, or browser APIs require it; prefer **server parent + client child** for mixed routes.4647- **Data:** Database reads in server code; HTTP with explicit cache/revalidate where applicable; mutations via Server Actions (and/or route handlers) with Zod validation from `/lib/validation/`.4849- **Hooks:** Logic-only, composable, under `hooks/` per convention; do **not** return JSX, import UI for unrelated concerns, or mix unrelated responsibilities in one hook.5051- **Anti-patterns (align with Next.js skill):** Avoid `'use client'` on large trees, client-fetching for core reads where RSC suffices, and missing `loading.tsx` / `error.tsx` where UX needs them.5253---5455## Folder layout (high level)5657Follow [resources/convention.md](@./resources/convention.md) for the full tree. Important roots:5859- `app/` — routes, layouts, pages, loading/error/not-found, `route.ts` APIs60- `components/` — reusable UI (`ui/`, `forms/`, `layout/`, `ui-mobile/`, …)61- `lib/` — utilities, `prisma.ts`, shared logic; **`lib/validation/*.schemas.ts`** for Zod62- `services/` — domain types, `*_interface.ts`, `*_prisma.ts` implementations63- `providers/` — factories (e.g. `user_crud_providers.ts`)64- `business-layer/` — app `config/`, `types/`, `queries/`, `mutations/`, `utils/`65- `hooks/` — `browser/` vs `mobile/` as needed66- `tests/` — unit area; E2E under `tests/e2e/`67- Root: `proxy.ts` (**Next.js 16+**) *or* `middleware.ts` (**14–15**) for edge auth/redirects — **one** pattern matching the installed version, not both active. See [file-conventions.md](@.agents/skills/next-best-practices/file-conventions.md).6869**Reserved App Router filenames** (exact names, lowercase): `page.tsx`, `layout.tsx`, `loading.tsx`, `error.tsx`, `not-found.tsx`, `global-error.tsx`, `route.ts`, `template.tsx`, `default.tsx`. Do **not** rename to PascalCase. Do **not** put `route.ts` and `page.tsx` in the **same** segment.7071**Private route folders:** leading `_` (e.g. `_components/`, `_tests/`) — excluded from the URL.7273---7475## Naming (quick reference)7677| Area | Rule |78|------|------|79| Route segments (public) | `kebab-case` |80| Private folders | `_name/` |81| Your React component modules | `PascalCase.tsx` matching the primary export |82| Lib / hooks / utilities | `camelCase.ts` |83| Type-only modules | `camelCase.types.ts` |84| Prisma | PascalCase models; plural **snake_case** tables `@@map`; DB columns **snake_case** with `@map` on camelCase fields |85| REST API paths | Lowercase, hyphenated segments, no trailing slash |86| JSON / TS objects | **camelCase** keys |87| DB | **snake_case**; transform at boundary |8889---9091## Imports and validation9293- **`@/`** for project imports; **relative** only for same-directory (`./`).9495- **Order:** external packages → `next/*` → internal `@/` → `import type` for types-only.9697- **Zod:** **Single source of truth** in `/lib/validation/` (e.g. `auth.schemas.ts`). **Never** duplicate schema definitions in components; optional barrels may **re-export** only. Same schema on client (forms) and server (actions/routes).9899- **Components:** Co-locate component-only types/helpers; import schemas from `@/lib/validation/...`.100101---102103## Monitoring and analytics104105- **Primary product analytics:** **Vercel Analytics** (`@vercel/analytics`) — `<Analytics />` in root layout; `track()` for custom events.106107- **Other scripts:** Use `next/script` and loading strategies per [scripts.md](@.agents/skills/next-best-practices/scripts.md); avoid raw `<script>` where the skill prescribes otherwise.108109- **Observability baseline:** Frontend RUM/CWV (e.g. Vercel Analytics), server logs for API routes, error boundaries + optional Sentry/LogRocket; Lighthouse CI in GitHub Actions per architecture.110111- For additional details and examples, see [resources/architecture.md](@resources/architecture.md) - Monitoring & Observability.112113---114115## Non-functional requirements (baseline)116117**Performance (primary):** LCP under 2.5s, INP under 200ms, CLS under 0.1. Secondary: initial load under 2s where measured; lab TBT under 200ms; client navigations under 500ms.118119**Security:** HTTPS in production; cookies **HttpOnly**, **Secure**, **SameSite=Lax**; no sensitive data in logs.120121**Browsers:** Modern evergreen; latest two of Chrome, Firefox, Safari, Edge.122123**Accessibility:** WCAG 2.1 Level A baseline — keyboard, semantic HTML, visible focus, form labels — global unless explicitly scoped otherwise.124125**Privacy / compliance:** GDPR/CCPA-oriented architecture; consent-aware handling; deletion/export in later phases per product.126127**Graceful degradation:** Fault-tolerant integration boundaries; one external dependency failure must not break overall UX.128129**Release:** Clean `next build`, no TypeScript errors; verify `NEXT_PUBLIC_*` vs server-only secrets; Lighthouse/PageSpeed as needed for CWV goals.130131---132133## Testing134135- Unit: `*.test.ts` / `*.test.tsx`; components: `ComponentName.test.tsx`.136- Page tests: co-located `app/.../_tests/PageName.test.tsx`.137- E2E: `tests/e2e/*.spec.ts`.138139---140141## Documentation142143- JSDoc on **public** APIs; explain *why*, not *what*.144- Session and shared types: ISO 8601 strings where convention shows `loginTimestamp`, etc.145146---147148## Anti-patterns (reject in review)149150- Duplicate Zod outside `/lib/validation/`.151- Cross-directory relative imports instead of `@/`.152- camelCase physical DB columns without `@map` to snake_case.153- Mismatched component filename vs export (except reserved App Router files).154- Prisma or Node-only APIs on Edge without an explicit compatible approach.155- Inconsistent REST paths (wrong casing, trailing slashes).156157---158159## Mandatory agent behaviors (enforcement)1601611. Follow **naming** and **folder** conventions (including reserved `app/` filenames).1622. **Import** validation schemas — never duplicate Zod definitions.1633. Follow **project structure** (components, lib, app, services, providers, business-layer).1644. Use **`@/`** for internal imports.1655. **Co-locate** page tests in `_tests/` beside the route.1666. Match **component** file names to exports (`SignupForm` → `SignupForm.tsx`).167168---169170## Agent checklist1711721. Stack matches the fixed table; Prisma used only on **Node** server contexts unless otherwise designed.1732. Files live where **convention.md** specifies; `proxy.ts` vs `middleware.ts` matches Next version.1743. Zod only under `/lib/validation/`; JSON camelCase; DB snake_case with Prisma mapping.1754. Imports use `@/` and prescribed order; `import type` for type-only imports.1765. Services use interfaces + factories; default CRUD factory Prisma-only unless Supabase appendix applies.1776. Metadata via `generateMetadata` / `metadata` export; Vercel Analytics pattern when adding analytics.1787. For large features or refactors, read **generate-skills-artifacts/architecture.md** and **convention.md** in full first.179180---181182## Resources183184- [Architecture & NFRs](./resources/architecture.md)185- [Convention](./resources/convention.md)186- [Next.js Best Practices](@.agents/skills/next-best-practices/SKILL.md)