agentleFS
amirrezaalastiamirrezaalasti/codescribe/skills/coding/nextjs-app-router/SKILL.md

nextjs-app-router

Skill2 starsChanged 4 months agoMITView on GitHub

Build Next.js App Router apps with correct server/client component boundaries, routing, layouts, and file conventions. Use when working on Next.js App Router projects, app/ directories, RSC, layouts, route handlers, or when the user mentions Next.js routing or server components.

9 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use the App Router (app/) unless the repo is Pages Router

    line 19
  2. Very specific:

    Default to Server Components.

    line 20
  3. Very specific:

    Routing: Prefer file-system routes.

    line 43
  4. Very specific:

    Match the Next version: Prefer patterns from the installed Next.js major.

    line 46
  5. Very specific:

    Tag unfinished or risky work: Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, …).

    line 47
  6. Very specific:

    Add "use client" when the module needs:

    line 51
  7. Distinctive:

    Keep data fetching and static structure on the server when possible.

    line 57

“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Next.js App Router

Defaults

  • Use the App Router (app/) unless the repo is Pages Router
  • Default to Server Components; add "use client" only when needed
  • Colocate route UI under app/ with Next file conventions
  • For data fetching details, also apply nextjs-data-fetching

File conventions (common)

app/
  layout.tsx          # Root layout (required)
  page.tsx            # Route UI
  loading.tsx         # Instant loading UI
  error.tsx           # Error boundary
  not-found.tsx
  api/…/route.ts      # Route handlers
  (marketing)/…       # Route groups (no URL segment)
  blog/[slug]/page.tsx

Instructions

  1. Server Components by default. Fetch data and render on the server when possible. Push "use client" to leaves that need state, effects, or browser APIs.
  2. Do not pass non-serializable props from server to client components (functions, class instances). Pass data; define handlers on the client side.
  3. Layouts nest. Shared chrome belongs in layout.tsx. Keep layouts thin; avoid putting all page logic in the root layout.
  4. Routing. Prefer file-system routes. Use route groups (name) for organization without URL impact. Use dynamic segments [param] / [[...optional]] as needed.
  5. Metadata. Export metadata or generateMetadata from server components/pages for titles and SEO.
  6. Errors & loading. Provide error.tsx and loading.tsx for routes with meaningful async work.
  7. Match the Next version. Prefer patterns from the installed Next.js major; do not mix Pages Router APIs into App Router files.
  8. Tag unfinished or risky work. Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, …). Never leave silent stubs. End with an Open follow-ups table so the developer must check P0/P1 before ship.

Client boundary rule of thumb

Add "use client" when the module needs:

  • useState / useReducer / useEffect
  • Browser-only APIs
  • Event handlers on interactive widgets that cannot be isolated lower

Keep data fetching and static structure on the server when possible.

Anti-patterns

  • Marking entire trees "use client" unnecessarily
  • Importing server-only modules into client components
  • Using getServerSideProps / getStaticProps in App Router
  • Huge root layouts with page-specific logic

Additional resources

  • references/checklist.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.