Skip to content
OpenAgentSkill
Browsing is open · Catalog captured 2026-11-21 · Automatic updates and account services are paused.
Security

nextjs-app-architecture

Build or audit Next.js 16 App Router apps using a next-beats-style React Server Components architecture. Use when scaffolding a new app, adding a feature, reviewing an existing app, refactoring route-loader-shaped pages into feature-owned async server components, deciding where queries/actions/components live, keeping pages synchronous with `params.then()`, placing Suspense boundaries, choosing the client/server boundary, designing skeletons, preventing CLS, or enabling Cache Components. Also use when the user asks about RSC composition, components receiving IDs instead of route params, `'use cache'`, `cacheTag`, `updateTag`, static-shell prerendering, or making an app easier for AI agents to modify.

aurorascharff · Static checks on file

Installation

Read the source and dependencies before running a command. Copying does not install or execute anything.

npx skills add aurorascharff/nextjs-app-architecture-skill --skill nextjs-app-architecture

About this skill


name: nextjs-app-architecture description: Build or audit Next.js 16 App Router apps using a next-beats-style React Server Components architecture. Use when scaffolding a new app, adding a feature, reviewing an existing app, refactoring route-loader-shaped pages into feature-owned async server components, deciding where queries/actions/components live, keeping pages synchronous with params.then(), placing Suspense boundaries, choosing the client/server boundary, designing skeletons, preventing CLS, or enabling Cache Components. Also use when the user asks about RSC composition, components receiving IDs instead of route params, 'use cache', cacheTag, updateTag, static-shell prerendering, or making an app easier for AI agents to modify. license: MIT metadata: author: aurorascharff version: "1.3.10"

Next.js App Architecture

A workflow for building and auditing Next.js 16+ App Router apps so they follow one consistent, feature-sliced RSC architecture like next-beats.

Follow the workflow below step by step — it produces the invariants by construction. Load the reference a step names for the decision it depends on. Get framework mechanics (API signatures, config options, hook contracts) from the linked docs — don't restate or improvise them.

Prerequisite

Before changing a Next.js app, make sure the project is set up for AI agents to read version-matched docs. Follow the AI Coding Agents guide: prefer the project's AGENTS.md / bundled docs, and create or refresh them when missing. Then use this skill for architecture decisions.

Architecture target

Build pages that describe the loading experience, not pages that act like route loaders:

  • app/**/page.tsx and layout.tsx are synchronous composition surfaces: static chrome, section headings, <Suspense> boundaries, error boundaries, and transition wrappers.
  • Feature components own their reads on the server. They receive minimal stable inputs (id, slug, handle, parsed filter values) or already-fetched records, never raw params / searchParams.
  • Queries and actions live in the feature folder. Components import queries; client leaves import actions directly.
  • When server tags and client query keys describe the same feature data, a pure feature-local cache contract owns those identities.
  • Stable chrome, wrappers, and skeletons preserve layout: cards/panels stay outside Suspense, and fallbacks swap only the data-dependent body.

Invariants (what every change must satisfy)

The non-negotiables. The workflow produces them; the final check verifies them.

  1. Pages compose, they never fetch. A page/layout imports feature components and places <Suspense>. No queries or domain logic inline. Tiny route-local control-flow helpers are allowed only when they exist to place a boundary around connection(), redirect(), or a resolved route prop.
  2. Pages stay synchronous. Use params.then() / searchParams.then() or Promise.all([params, searchParams]).then(...), never await params at the top — so chrome paints into the static shell and only data-dependent sections suspend.
  3. Feature components receive IDs, not route props. Resolve params / searchParams at the page boundary and pass plain values (id, slug, query) into features.
  4. Async server component is the default. 'use client' only for hooks, event handlers, or browser APIs — and only on leaves, never on parents of server content.
  5. The page owns the Suspense boundary; the feature owns the skeleton. Features never pre-wrap themselves in <Suspense>; stable wrappers/cards/chrome wrap the boundary instead of being duplicated in fallback and final content.
  6. Skeletons live in the same file as the component, exported alongside it, defined at the end. Feed and FeedSkeleton are siblings.
  7. Queries live in <domain>-queries.ts (import 'server-only'); actions live in <domain>-actions.ts ('use server'). The file name matches the folder, even for sub-concepts.
  8. Feature folders follow product ownership. Entity-owned sub-concepts (favorite, like, vote, bookmark) fold into their parent. A route-level experience that composes multiple domains may own its UI and state in a separate feature while each domain keeps its queries and actions.
  9. Client components import actions directly — never receive a server action as a prop just to call it.
  10. Feature-local cache coordination stays with its domain. Put pure tags/keys in <domain>-cache.ts, client query definitions in <domain>-query-options.ts, hook wrappers in hooks/use-*.ts, and tiny client leaves in components/; promote support code only after real cross-feature reuse.
  11. Interactive async UI keeps server data on the server and client state local to the interaction. Use useOptimistic, useTransition, reducers, URL/search params, and form actions instead of mirrored prop state, derived-state effects, or hand-rolled pending arrays.

Workflow

Run these in order for build-from-scratch, feature work, or audits. Each step names the reference to consult and the check it must pass.

  1. Choose mode.
    • Build from scratch: sketch routes, real domain nouns, static shell, and expected loading groups before writing code.
    • Audit/refactor: scan current app/ pages first; list every async page, page-level query import, route prop leak, missing Suspense boundary, and feature folder mismatch. → references/example.md for the target shape; references/feature-folders.md for placement. ✓ You know whether you are creating the architecture or converting loader-shaped code into it.
  2. Place the work. Decide the feature folder before writing anything. → references/feature-folders.md (decision tree + merge rules). ✓ A real domain, a cross-domain product experience, or folded into the right parent.
  3. **Write the query and, when a clien
Read the complete source ↗