agentleFS
qyndexqyndex/claude-init/.claude/skills/nextjs/SKILL.md

nextjs

Skill2 starsChanged 5 months agoMITView on GitHub

Use when project is Next.js (App Router or Pages Router). Covers Server vs Client Components, Server Actions, Suspense boundaries, route handlers, middleware, next/image discipline, revalidation. Round 9 B.

39 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use nuqs, msw and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • thongdn-itSkill

    nuqs

    nuqs (type-safe URL query state) best practices for Next.js applications. This skill should be used when writing, reviewing, or refactoring code that uses nuqs for URL state management. Triggers on tasks involving useQueryState, useQueryStates, search params, URL state, query parameters, nuqs parsers, or Next.js routing with state.

    Also in 3 projects that use this

  • thongdn-itSkill

    msw

    MSW (Mock Service Worker) best practices for API mocking in tests (formerly test-msw). This skill should be used when setting up MSW, writing request handlers, or mocking HTTP APIs. This skill does NOT cover general testing patterns (use test-vitest or test-tdd skills) or test methodology.

    Also in 3 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 10 projects that use this

  • rawvegSkill

    laravel

    Laravel v12 - The PHP Framework For Web Artisans

    Also in 3 projects that use this

  • MicrosoftSkill

    typescript

    TypeScript best practices for this monorepo. Use this skill when: (1) writing new TypeScript code, (2) reviewing TypeScript code, (3) working with API responses, fetch calls, or JSON parsing, (4) adding or modifying types and interfaces.

    Also in 5 projects that use this

  • klauswgSkill

    shadcn-ui

    Expert guidance for integrating and building applications with shadcn/ui components, including component discovery, installation, customization, and best practices.

    Also in 4 projects that use this

  • +3 more from thongdn-it

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 3 are distinctive, and 10 are very specific to this project.

  • 0

    Common

    Most of the 35 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 10

    Very specific

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

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

    When working in a Next.js codebase, enforce App Router idioms (RSC by default), Suspense + error boundary co-location, next/image for all …

    line 14
  2. Very specific:

    Server Components by default: Add "use client" ONLY at leaf interactivity (form, hook, event handler).

    line 19
  3. Very specific:

    Server Actions for mutations: No client-side fetch to /api/route for form posts.

    line 20
  4. Very specific:

    Suspense boundaries co-located: Every route segment ships loading.tsx + error.tsx next to page.tsx.

    line 22
  5. Distinctive:

    Middleware sparingly: Only for auth gating, header injection, redirects.

    line 23
  6. Very specific:

    Create page.tsx (RSC by default) — fetch data with async/await, no useEffect

    line 51
  7. Very specific:

    If interactivity needed → split into Client Component leaf, mark "use client"

    line 53
  8. Distinctive:

    Test: Playwright covers user journey.

    line 56
  9. Very specific:

    Use next/image for raster.

    line 60
  10. Very specific:

    Use next/font for fonts; never link to Google Fonts CDN (privacy + perf)

    line 61
  11. Very specific:

    Use Server Actions for mutations.

    line 62
  12. Very specific:

    Run next build locally before merging — production-only optimizations catch issues next dev doesn't

    line 64
  13. Distinctive:

    All new routes use App Router unless explicitly migrating from Pages

    line 84

“Common” is measured: kept by at least 6 in 10 of the 35 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

Mandate

When working in a Next.js codebase, enforce App Router idioms (RSC by default), Suspense + error boundary co-location, next/image for all raster, Server Actions for mutations, and pinned framework version.

Decisions encoded

  • App Router default. Pages Router only if the project is already there and a migration is out of scope.
  • Server Components by default. Add "use client" ONLY at leaf interactivity (form, hook, event handler).
  • Server Actions for mutations. No client-side fetch to /api/route for form posts; use action functions + revalidatePath/revalidateTag.
  • next/image always. Raw <img> is an anti-pattern (no LCP optimization, no AVIF/WebP).
  • Suspense boundaries co-located. Every route segment ships loading.tsx + error.tsx next to page.tsx.
  • Middleware sparingly. Only for auth gating, header injection, redirects. NOT for data transforms (use route handlers).
  • Pinned Next version. No "latest" in package.json; bump deliberately via /upgrade nextjs --to <ver>.

Project structure (App Router)

src/app/
├── layout.tsx              # root layout (must export metadata, fonts)
├── page.tsx                # /
├── loading.tsx + error.tsx # global Suspense + error boundaries
├── (marketing)/            # route group (no URL segment)
│   ├── about/page.tsx
│   └── pricing/page.tsx
├── (app)/                  # authed
│   ├── dashboard/
│   │   ├── page.tsx
│   │   ├── loading.tsx
│   │   ├── error.tsx
│   │   └── actions.ts      # Server Actions
│   └── settings/page.tsx
├── api/
│   └── webhooks/route.ts   # route handlers (NOT for app-internal data)
└── middleware.ts           # auth/redirect gating only

Procedure (new feature)

  1. Determine route segment + group ((marketing), (app), etc.)
  2. Create page.tsx (RSC by default) — fetch data with async/await, no useEffect
  3. Co-locate loading.tsx + error.tsx
  4. If interactivity needed → split into Client Component leaf, mark "use client"
  5. Mutations → Server Action in actions.ts, return revalidation tag
  6. Images → next/image with explicit width/height; priority for above-fold
  7. Test: Playwright covers user journey; Vitest covers Server Action logic

Hard rules

  • Use next/image for raster; never <img>
  • Use next/font for fonts; never link to Google Fonts CDN (privacy + perf)
  • Use Server Actions for mutations; not fetch('/api/...') from forms
  • Match React 19's use() hook for promise unwrapping in Client Components
  • Run next build locally before merging — production-only optimizations catch issues next dev doesn't
  • Pin next exact version in package.json; bumps require /upgrade nextjs

Common pitfalls

  1. Adding "use client" to the root layout — kills the whole RSC tree. Apply at leaves only.
  2. useEffect in RSC — won't even compile. Symptom: "useEffect is not defined in server components."
  3. Mutating in route handlers when Server Action would do — splits the surface area; Server Actions also auto-revalidate.
  4. <img> slipping through — set ESLint rule @next/next/no-img-element to error.
  5. Forgetting revalidatePath/revalidateTag after mutation — UI stays stale.
  6. Edge runtime for data-heavy work — Edge has no Node APIs; use runtime: 'nodejs' for DB queries.

References

Done means

  • All new routes use App Router unless explicitly migrating from Pages
  • next/image everywhere; no <img>
  • Suspense + error boundaries co-located with every page
  • next build passes locally before push

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.