AgentLint Verified 100/100439 Next.js (App Router) repos analyzed

    Next.js (App Router) CLAUDE.md & AGENTS.md Template

    Server vs Client component boundaries, App Router caching, and fast Vitest/Playwright checks from 439 Next.js repos.

    # Next.js App Router Project — Next.js Harness
    
    Next.js 15 App Router web application using React Server Components, TypeScript strict mode, Tailwind CSS, and Vitest.
    
    ## Commands
    
    - Install: `pnpm install --frozen-lockfile`
    - Fast single test: `npx vitest run src/lib/pricing.test.ts`
    - Typecheck & lint: `npx tsc --noEmit && pnpm lint`
    - Production build check: `pnpm next build`
    
    ## Rules
    
    - Don't add `'use client'` to top-level pages or layouts. Instead push interactivity into small leaf client components. Because unnecessary client boundaries bloat JS bundles and break server data fetching.
    - Don't read `process.env` secrets inside client components or expose unvalidated Server Actions. Instead validate every action payload with Zod and verify the user session on the server. Because Server Actions are public HTTP endpoints.
    - Don't edit generated `.next/` files or rely on `dev` mode alone to prove type safety. Instead run `npx tsc --noEmit && pnpm next build` before opening a PR.
    - When changing auth middleware or caching tags, read `docs/caching-and-auth.md` first.
    
    ## Continuity & Safety
    
    - Keep `.env.local` and `CLAUDE.local.md` in `.gitignore` — never commit secrets or personal paths.
    - Record verified build/test outputs and route diffs in `HANDOFF.md` before ending a session.

    Most Adopted Next.js (App Router) Rules Across Real Open-Source Repos

    Measured across 439 public Next.js (App Router) repositories in the 4,533-repo harness study:

    nextjsframework

    Next.js App Router & server rendering conventions (measured in 1,533 TS repos)

    28.6%439 repos
    reactframework

    React Server & Client component boundaries

    61.3%940 repos
    tailwindcsstooling

    Tailwind CSS utility tokens

    38.8%595 repos
    eslinttooling

    ESLint + next/core-web-vitals checks

    36.9%565 repos
    vitesttesting

    Vitest for fast unit & route handler tests

    32.6%499 repos
    Essential Commands (Checks W1 & W7)
    install
    pnpm install --frozen-lockfile
    fastTest
    npx vitest run src/app/billing/page.test.tsx
    fullTest
    pnpm test && pnpm exec playwright test
    lint
    pnpm lint && npx tsc --noEmit
    build
    pnpm next build
    Common Next.js (App Router) Agent Pitfalls
    • 01Agents slap 'use client' at the top of layout or page files, shipping server secrets or bloating browser bundles.
    • 02Editing .next/ generated output or skipping next build hides Server Component serialization errors until Vercel deploy.
    • 03Unscoped Server Actions lack Zod input validation and auth session checks.

    More Verified Stack Templates