Build This Now
Build This Now
Was ist der Claude Code?Claude Code installierenClaude Code Native InstallerDein erstes Claude Code-Projekt
Next.js DevTools MCPNext.js Agent SetupSubscription BillingMulti-Tenant SaaSAI Chat FeatureRate LimitingStripe WebhooksSemantic SearchRealtime UpdatesDrip Email Sequencesv2.1.122 Release NotesClaude Code Dynamic Workflows: 1.000 Subagents auf einer echten Codebase orchestrierenClaude Code Best PracticesClaude Opus 4.7 Best PracticesClaude Code auf einem VPSGit-IntegrationClaude Code ReviewClaude Code WorktreesClaude Code Remote ControlClaude Code ChannelsChannels, Routines, Teleport, DispatchGeplante Aufgaben mit Claude CodeClaude Code BerechtigungenClaude Code Auto-ModusStripe-Zahlungen mit Claude Code einbauenFeedback-LoopsTodo-WorkflowsClaude Code TasksProjekt-TemplatesClaude Code Preise und Token-NutzungClaude Code Preise: Was du wirklich zahlstClaude Code Ultra ReviewEine Next.js-App mit Claude Code bauenSupabase DatabaseVercel DeepsecTest-Driven DevelopmentSo baust du ein SaaS-MVP mit Claude CodeAuthentifizierung mit Claude Code einbauen (Supabase Auth)Transaktions-E-Mails mit Claude Code einbauen (Resend + React Email)Eine typsichere API mit Claude Code bauen (oRPC + Zod)File UploadsBackground Jobs (Inngest)Admin DashboardFull-Text SearchClaude Agent SDKKiro Migration GuideClaude Research AgentLeave Grok BuildRoute Subagent ModelsClaude Monorepo SetupCI Repair AgentVisual Regression TestsAgent Cost DashboardCursor Migration GuideAgentic Commerce: Wie du eine App baust, für die KI-Agents bezahlen können1M ContextUser API KeysAudit LogsCSV Import PipelineDatabase MigrationsProduction Error TrackingFeature FlagsGitHub ActionsHeadless ModeMax Plan vs APICaching and RevalidationIn-App NotificationsOutbound WebhooksPrompt CachingRoles & PermissionsMarketplace PaymentsUsage-Based BillingWas es 2026 kostet, ein SaaS mit Claude Code zu bauenParallel AI AgentsCoding Agent Injection
speedy_devvkoen_salo
Blog/Handbook/Workflow/Next.js Agent Setup

Next.js CLAUDE.md and AGENTS.md: A Production Setup

Set up CLAUDE.md, AGENTS.md, and Next.js DevTools MCP so Claude Code reads version-matched docs, inspects runtime errors, and verifies its work.

Sie möchten das Framework hinter diesen Projekten?

Holen Sie sich das Claude Code System, mit dem wir produktionsreife Software planen, bauen, testen und ausliefern.

Sehen Sie, was wir für Unternehmen bauen →
speedy_devvkoen_salo
speedy_devvWritten by speedy_devvPublished Jul 28, 202612 min readHandbook hubWorkflow index

A strong Next.js setup gives Claude Code two kinds of truth. AGENTS.md points it to documentation that matches the installed Next.js version. CLAUDE.md explains your architecture, commands, and non-negotiable conventions. The Next.js DevTools MCP then gives the agent live evidence from the running application.

Together, those three pieces solve different failures: stale framework knowledge, missing project context, and code that looks correct without surviving the runtime.

Why Next.js needs version-matched agent context

Next.js moves quickly enough that a coding model can know the framework and still use yesterday's API. App Router conventions, caching behavior, request APIs, and upgrade steps change between releases.

Next.js now ships its own documentation inside the installed next package at:

node_modules/next/dist/docs/

The official Next.js guide for AI coding agents recommends a small AGENTS.md instruction that makes those local docs the source of truth. Because the documentation comes from the installed package, it matches the version in your lockfile instead of the newest website or a model's training data.

That is better than pasting dozens of framework rules into a prompt. Rules copied by hand go stale. Versioned docs update with the dependency.

Create the framework-level AGENTS.md

Recent create-next-app can generate the agent files for new projects. For an existing project, create AGENTS.md in the repository root:

<!-- BEGIN:nextjs-agent-rules -->

# Next.js: ALWAYS read docs before coding

Before any Next.js work, find and read the relevant doc in
`node_modules/next/dist/docs/`.
Your training data is outdated. The installed docs are the source of truth.

<!-- END:nextjs-agent-rules -->

Keep the managed block intact. The markers allow framework tooling to recognize and update that section later.

Add your own cross-agent rules below it:

## Repository checks

- Run `pnpm typecheck` after TypeScript changes.
- Run targeted tests before the full suite.
- Run `pnpm build` before declaring a route complete.
- Preserve Server Components unless interactivity requires a client boundary.
- Never expose server-only environment variables to client modules.

AGENTS.md is the shared contract. Claude Code, Cursor, and other compatible agents can all consume it.

Import AGENTS.md from CLAUDE.md

Create CLAUDE.md beside it:

@AGENTS.md

# Project context

This is a subscription application built with:

- Next.js App Router and TypeScript
- PostgreSQL through Supabase
- Stripe Billing
- Tailwind CSS and shadcn/ui

## Architecture

- Server Components fetch data.
- Client Components own browser state and event handlers.
- Mutations go through Server Actions in `app/**/actions.ts`.
- Shared domain logic lives in `lib/domain/`.
- Database access stays in `lib/data/`.

## Commands

- Development: `pnpm dev`
- Type check: `pnpm typecheck`
- Tests: `pnpm test`
- Production build: `pnpm build`

## Definition of done

- The happy path works in the browser.
- Loading, empty, and error states are handled.
- Authorization is enforced on the server.
- Typecheck, relevant tests, and build pass.

The @AGENTS.md line imports the framework and repository instructions without duplication. This is the division to keep:

FilePurposeGood content
AGENTS.mdShared instructions for coding agentsVersioned docs, repo commands, universal safety rules
CLAUDE.mdClaude-specific project memoryArchitecture, workflows, verification, preferred interaction
PromptOne taskOutcome, constraints, acceptance criteria

Do not turn either file into a wiki. Every permanent instruction competes for attention. Keep the facts that change implementation choices and remove advice that any competent developer already knows.

For a deeper comparison, read AGENTS.md vs CLAUDE.md.

Add runtime evidence separately

AGENTS.md and CLAUDE.md explain what the project expects. They do not prove that a page works.

Next.js 16 and later can expose live development errors, logs, route metadata, Server Action information, and framework tooling through next-devtools-mcp. Keep that runtime integration in .mcp.json, not in either instruction file.

The dedicated Next.js DevTools MCP with Claude Code guide covers installation, live error diagnosis, browser verification, and upgrade workflows. The separation is useful:

  • Agent files define durable instructions.
  • The task prompt defines the current outcome.
  • MCP supplies live runtime evidence.

Make the files specific to your stack

The best project instructions prevent recurring mistakes.

Authentication

## Authentication

- Read the session on the server.
- Treat middleware or proxy checks as navigation convenience, not authorization.
- Every mutation verifies the authenticated user and resource ownership.
- Never trust a user ID sent by the browser.

Data fetching

## Data

- Fetch in Server Components when possible.
- Parallelize independent reads.
- Do not add a client-side data library for server-owned state.
- Invalidate the narrowest cache tag after a mutation.

UI boundaries

## UI

- Keep pages and layouts as Server Components.
- Put "use client" at the smallest interactive boundary.
- Use the existing components and tokens before adding variants.
- Every asynchronous view needs loading, empty, error, and success states.

Billing

## Billing

- Stripe webhooks are the source of truth.
- Verify webhook signatures before parsing event data.
- Make handlers idempotent.
- Never grant entitlements from a browser redirect.

These instructions are concrete enough to alter implementation. "Use best practices" is not.

Avoid the two common extremes

A CLAUDE.md that is too thin

A file containing only the stack list forces Claude to rediscover architecture on every task. Add the paths, commands, boundaries, and checks that determine a correct change.

A CLAUDE.md that is too long

Do not paste your entire handbook into session memory. Link to focused documents when the agent needs them:

## Conditional references

- For billing work, read `docs/billing.md`.
- For database migrations, read `docs/migrations.md`.
- For design changes, read `docs/design-system.md`.

The root file should route attention, not absorb every detail.

A production-ready starter template

@AGENTS.md

# Product

[One sentence explaining what the app does and for whom.]

## Stack

- Next.js App Router, TypeScript
- [database and ORM]
- [authentication]
- [billing]
- [UI system]

## Architecture

- Server Components by default.
- Client Components only for browser APIs and interaction.
- Reads live in `[path]`.
- Mutations live in `[path]`.
- Domain logic lives in `[path]`.

## Security

- Authorize every server mutation.
- Validate untrusted input at the boundary.
- Never expose server secrets to client code.
- Treat webhooks as untrusted until signatures pass.

## Commands

- Dev: `[command]`
- Typecheck: `[command]`
- Test: `[command]`
- Build: `[command]`

## Workflow

1. Read the relevant installed framework docs.
2. Inspect existing patterns before creating a new abstraction.
3. Plan changes that cross data, auth, billing, or public APIs.
4. Implement the smallest coherent change.
5. Run checks and inspect runtime errors through Next.js DevTools MCP.
6. Verify the user flow in a browser.

## Definition of done

- Acceptance criteria are demonstrably met.
- No new runtime, console, type, or build errors.
- Error and empty states are covered.
- The diff contains no unrelated changes.

Replace every bracket. Generic placeholders left in permanent instructions create false confidence.

Next.js agent setup FAQs

Does Next.js automatically create AGENTS.md?

Newer create-next-app can generate AGENTS.md and CLAUDE.md. Existing apps can add them manually. Check the current Next.js agent guide for the required version because the canary threshold changes over time.

Is the Next.js DevTools MCP required?

No. Claude Code can build a Next.js app without it. The MCP server improves the feedback loop by exposing live errors, logs, metadata, migration tools, and framework knowledge.

Should I copy the entire Next.js documentation into CLAUDE.md?

No. Point the agent to node_modules/next/dist/docs/. The installed documentation is version-matched and avoids bloating permanent project memory.

Can other coding agents use the same setup?

Yes. Put shared guidance in AGENTS.md. Keep Claude-specific imports and behavior in CLAUDE.md. MCP support depends on the client, but the repository instructions remain portable.

What if the MCP server does not connect?

Confirm the app uses Next.js 16 or later, verify .mcp.json, start the development server, and restart the coding agent. Then check that the agent loaded project-scoped MCP configuration.

Build This Now uses the same principle at product scale: one source of truth for architecture, explicit implementation boundaries, and checks that prove a feature works. The agent files are the local version of that discipline.

The winning setup is deliberately small. Version-matched framework truth in AGENTS.md, project truth in CLAUDE.md, and runtime truth through MCP.

Posted by @speedy_devv

Continue in Workflow

  • Agentic Commerce: Wie du eine App baust, für die KI-Agents bezahlen können
    Ein Guide in einfachem Deutsch zu Agentic Commerce im Jahr 2026: Was x402, ACP und das Machine Payments Protocol tun, plus eine Wochenend-Anleitung, um eine bezahlte API auszuliefern, von der KI-Agents kaufen können.
  • Claude Code Best Practices
    Fünf Gewohnheiten trennen Entwickler, die mit Claude Code liefern: PRDs, modulare CLAUDE.md-Regeln, Custom-Slash-Commands, /clear-Resets und eine System-Evolutions-Denkweise.
  • Claude Code Auto-Modus
    Ein zweites Sonnet-Modell prüft jeden Claude Code-Tool-Aufruf, bevor er ausgeführt wird. Was der Auto-Modus blockiert, was er erlaubt, und die Erlaubnisregeln, die er in deine Einstellungen schreibt.
  • Channels, Routines, Teleport, Dispatch
    Die vier Claude-Code-Features, die Anthropic im März und April 2026 ausgeliefert hat und die die CLI in eine ereignisgesteuerte Koordinationsschicht über Handy, Web und Desktop verwandeln.
  • Claude Code 1M Context in Practice: When Bigger Isn't Better
    The 1M-token context window is GA at flat pricing, but bigger isn't always better. A decision framework, token-cost math, and when to use /compact, subagents, and dynamic workflows instead.
  • How to Build an Admin Dashboard With Claude Code
    Ship an internal admin panel with Claude Code: role-gated routes, a searchable users and orders table with pagination, impersonation-safe RLS, and metrics tiles pulled through a type-safe API.

More from Handbook

  • Deep Thinking Techniken
    Trigger-Phrasen wie think harder, ultrathink und think step by step bringen Claude Code in erweitertes Denken und mehr Test-Time-Compute, gleiches Modell.
  • Effizienz-Muster
    Permutations-Frameworks verwandeln 8 bis 12 manuelle Builds in eine CLAUDE.md-Vorlage, mit der Claude Code Varianten 11, 12 und 13 auf Abruf generiert. Einmal festgehalten.
  • Claude Code Fast Mode
    Fast Mode leitet deine Opus 4.6 Anfragen in Claude Code über einen Prioritäts-Serving-Pfad. Gleiche Gewichte, gleiche Qualitätsobergrenze, Antworten 2,5-mal schneller bei höherem Token-Preis.
  • Optimierung der Geschwindigkeit
    Die Auswahl des Modells, die Größe des Kontexts und die Spezifität der Aufforderung sind die drei Hebel, die darüber entscheiden, wie schnell Claude Code antwortet. /Modell-Haiku, /Kompakt und /Klar abgedeckt.

Sie möchten das Framework hinter diesen Projekten?

Holen Sie sich das Claude Code System, mit dem wir produktionsreife Software planen, bauen, testen und ausliefern.

Sehen Sie, was wir für Unternehmen bauen →
speedy_devvkoen_salo

Next.js DevTools MCP

Connect Claude Code to Next.js DevTools MCP for live runtime errors, logs, route metadata, browser verification, and safer Next.js 16 upgrades.

Subscription Billing

Ship recurring plans end to end with Claude Code: tiered pricing, Stripe Checkout for subscriptions, proration on plan changes, the customer portal, and webhook-driven entitlement sync into Supabase.

On this page

Why Next.js needs version-matched agent context
Create the framework-level AGENTS.md
Import AGENTS.md from CLAUDE.md
Add runtime evidence separately
Make the files specific to your stack
Authentication
Data fetching
UI boundaries
Billing
Avoid the two common extremes
A CLAUDE.md that is too thin
A CLAUDE.md that is too long
A production-ready starter template
Next.js agent setup FAQs
Does Next.js automatically create AGENTS.md?
Is the Next.js DevTools MCP required?
Should I copy the entire Next.js documentation into CLAUDE.md?
Can other coding agents use the same setup?
What if the MCP server does not connect?

Sie möchten das Framework hinter diesen Projekten?

Holen Sie sich das Claude Code System, mit dem wir produktionsreife Software planen, bauen, testen und ausliefern.

Sehen Sie, was wir für Unternehmen bauen →