next.js AGENTS.md

Development instructions for working on the Next.js codebase, including its monorepo structure. A monorepo is one repository that contains multiple related packages and projects.

In plain words
What is it for?
Use it when changing Next.js itself, locating the main framework package, understanding the repository layout, or finding the development and production entry points.
Why use it?
It gives contributors a map of where the framework, command-line tools, tests, examples, documentation, and build code live.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/vercel/next.js/agents-md
Clone the repo
git clone --depth 1 https://github.com/vercel/next.js

Made for: Codex, OpenCode.

Per session 7,296 This file is loaded in full into every session.
When invoked 7,296 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.07296 $0.07296
Opus 5 $0.03648 $0.03648
Sonnet 5 $0.01459 $0.01459
Haiku 4.5 $0.00730 $0.00730

Measured yesterday against content hash cd6cb00dca2d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

next.js AGENTS.md scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

**External API calls (gh, curl):**
AGENTS.md · 561 lines

How it starts

The opening of the file, as written. The whole thing — 561 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Next.js Development Guide

Note: CLAUDE.md is a symlink to AGENTS.md. They are the same file.

Codebase structure

Monorepo Overview

This is a pnpm monorepo containing the Next.js framework and related packages.

next.js/
├── packages/           # Published npm packages
├── turbopack/          # Turbopack bundler (Rust) - git subtree
├── crates/             # Rust crates for Next.js SWC bindings
├── test/               # All test suites
├── examples/           # Example Next.js applications
├── docs/               # Documentation
└── scripts/            # Build and maintenance scripts

Core Package: packages/next

The main Next.js framework lives in packages/next/. This is what gets published as the next npm package.

Source code is in packages/next/src/.

Key entry points:

  • Dev server: src/cli/next-dev.tssrc/server/dev/next-dev-server.ts
  • Production server: src/cli/next-start.tssrc/server/next-server.ts
  • Build: src/cli/next-build.tssrc/build/index.ts

Compiled output goes to packages/next/dist/ (mirrors src/ structure).

Other Important Packages

  • packages/create-next-app/ - The create-next-app CLI tool
  • packages/next-swc/ - Native Rust bindings (SWC transforms)
  • packages/eslint-plugin-next/ - ESLint rules for Next.js
  • packages/font/ - next/font implementation
  • packages/third-parties/ - Third-party script integrations

README files

Before editing or creating files in any subdirectory (e.g., packages/*, crates/*), read all README.md files in the directory path from the repo root up to and including the target file's directory. This helps identify any local patterns, conventions, and documentation.

Example: Before editing turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime/runtime-base.ts, read:

  • turbopack/README.md (if exists)
  • turbopack/crates/README.md (if exists)
  • turbopack/crates/turbopack-ecmascript-runtime/README.md (if exists)
  • turbopack/crates/turbopack-ecmascript-runtime/js/README.md (if exists - closest to target file)

Read the full file on GitHub · 561 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 561 lines · 7,296 tokens per session scan A cd6cb00dca2d

Subscribe to this mod's changes

next.js AGENTS.md is an instructions file published in the GitHub repository vercel/next.js (142,020 stars, last pushed yesterday), licensed MIT. It adds 7,296 tokens to every session, about $0.0365 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.