Home › Next.js › Next.js AGENTS.md

Next.js AGENTS.md

AGENTS.md for Next.js 16 App Router projects: commands, folder layout, data access, auth, and done criteria.

AGENTS.mdNext.js

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

AGENTS.mdDownload  
# AGENTS.md: Next.js app

## Commands
- `pnpm dev` · `pnpm build` · `pnpm lint` (`eslint .`) · `pnpm typecheck` (`tsc --noEmit`) · `pnpm test` (Vitest) · `pnpm e2e` (Playwright)

## Layout
- `app/` routes only (pages, layouts, `route.ts` handlers, `loading.tsx`, `error.tsx`).
- `components/ui/` primitives, `components/<feature>/` composites.
- `lib/server/` data access and services (import `server-only` at the top), `lib/` shared utils, `actions/` Server Actions.

## Rules
- Data is fetched in Server Components or route handlers through `lib/server/*` functions. Client Components receive data as props or call Server Actions; they never import DB clients.
- Every Server Action and route handler: validate input with zod, check auth (`await auth()` or the project's helper), check ownership, then act.
- Env vars validated in `lib/env.ts`; only `NEXT_PUBLIC_*` vars reach the browser.
- Use `next/link`, `next/image`, `next/font`; set metadata per route.
- Keep `"use client"` boundaries small; no `useEffect` data fetching for data the server can provide.
- Prefer existing components over new dependencies; ask before adding a UI kit or state library.

## Don't
- Don't disable TypeScript or ESLint errors in `next.config.ts`.
- Don't commit `.env*` files except `.env.example`.

## Done
Typecheck, lint, unit tests, and `pnpm build` pass; UI changes are checked in the browser.

More: all Next.js rules · all AGENTS.md rules

Related rules

Next.js 16 rules (Cache Components, proxy.ts)

Cursor rules for Next.js 16 App Router: Cache Components with "use cache", proxy.ts, async request APIs, Turbopack.

CursorNext.js

Next.js App Router (TypeScript) rules

Cursor project rules for Next.js 15 App Router apps with TypeScript, Server Components, and Tailwind.

CursorNext.js

Next.js CLAUDE.md

A CLAUDE.md for Claude Code working in a Next.js + Prisma + Tailwind codebase.

Claude Code (CLAUDE.md)Next.js

Next.js Server Actions Copilot path instructions

Path-specific Copilot instructions for Next.js Server Actions and route handlers: validation, auth, and revalidation.

GitHub CopilotNext.js

Next.js Windsurf rules

Windsurf (Cascade) workspace rules for Next.js + shadcn/ui projects.

WindsurfNext.js

Browser extension with WXT AGENTS.md

AGENTS.md for cross-browser Manifest V3 extensions built with WXT: entrypoints, messaging, storage, and permissions.

AGENTS.mdChrome extensions

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.