

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# Next.js Development Guide23> **Note:** `CLAUDE.md` is a symlink to `AGENTS.md`. They are the same file.45## Codebase structure67### Monorepo Overview89This is a pnpm monorepo containing the Next.js framework and related packages.1011```12next.js/13├── packages/ # Published npm packages14├── turbopack/ # Turbopack bundler (Rust) - git subtree15├── crates/ # Rust crates for Next.js SWC bindings16├── test/ # All test suites17├── examples/ # Example Next.js applications18├── docs/ # Documentation19└── scripts/ # Build and maintenance scripts20```2122### Core Package: `packages/next`2324The main Next.js framework lives in `packages/next/`. This is what gets published as the `next` npm package.2526**Source code** is in `packages/next/src/`.2728**Key entry points:**2930- Dev server: `src/cli/next-dev.ts` → `src/server/dev/next-dev-server.ts`31- Production server: `src/cli/next-start.ts` → `src/server/next-server.ts`32- Build: `src/cli/next-build.ts` → `src/build/index.ts`3334**Compiled output** goes to `packages/next/dist/` (mirrors src/ structure).3536### Other Important Packages3738- `packages/create-next-app/` - The `create-next-app` CLI tool39- `packages/next-swc/` - Native Rust bindings (SWC transforms)40- `packages/eslint-plugin-next/` - ESLint rules for Next.js41- `packages/font/` - `next/font` implementation42- `packages/third-parties/` - Third-party script integrations4344### README files4546Before 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.4748**Example:** Before editing `turbopack/crates/turbopack-ecmascript-runtime/js/src/nodejs/runtime/runtime-base.ts`, read:4950- `turbopack/README.md` (if exists)51- `turbopack/crates/README.md` (if exists)52- `turbopack/crates/turbopack-ecmascript-runtime/README.md` (if exists)53- `turbopack/crates/turbopack-ecmascript-runtime/js/README.md` (if exists - closest to target file)5455## Build Commands5657```bash58# Build the Next.js package59pnpm --filter=next build6061# Build all JS code62pnpm build6364# Build all JS and Rust code65pnpm build-all6667# Run specific task68pnpm --filter=next exec taskr <task>69```7071## Fast Local Development7273For iterative development, default to watch mode plus the explicit test script that matches the mode and bundler being verified.7475**Default agent rule:** If you are changing Next.js source or integration tests, start `pnpm --filter=next dev` in a separate terminal session before making edits (unless it is already running). If you skip this, explicitly state why (for example: docs-only, read-only investigation, or CI-only analysis).7677**1. Start watch build in background:**7879```bash80# Auto-rebuilds on file changes (~1-2s per change vs ~60s full build)81# Keep this running while you iterate on code82pnpm --filter=next dev83```8485**2. Run focused tests with the matching mode script:**8687```bash88# Development mode with Turbopack89pnpm test-dev-turbo test/path/to/test.ts9091# Development mode with Webpack92pnpm test-dev-webpack test/path/to/test.ts9394# Production build+start with Turbopack95pnpm test-start-turbo test/path/to/test.ts9697# Production build+start with Webpack98pnpm test-start-webpack test/path/to/test.ts99```100101**3. When done, kill the background watch process (if you started it).**102103**For type errors only:** Use `pnpm --filter=next types` (~10s) instead of `pnpm --filter=next build` (~60s).104105After the workspace is bootstrapped, prefer `pnpm --filter=next build` when edits are limited to core Next.js files. Use full `pnpm build-all` for branch switches/bootstrap, before CI push, or when changes span multiple packages.106107**Always run a full bootstrap build after switching branches:**108109```bash110git checkout <branch>111pnpm build-all # Sets up outputs for dependent packages (Turborepo dedupes if unchanged)112```113114## Bundler Selection115116Turbopack is the default bundler for both `next dev` and `next build`. To force webpack:117118```bash119next build --webpack # Production build with webpack120next dev --webpack # Dev server with webpack121```122123There is no `--no-turbopack` flag.124125## Testing126127```bash128# Run specific test file (development mode with Turbopack)129pnpm test-dev-turbo test/path/to/test.test.ts130131# Run tests matching pattern132pnpm test-dev-turbo -t "pattern"133134# Run development tests135pnpm test-dev-turbo test/development/136```137138**Test commands by mode:**139140- `pnpm test-dev-turbo` - Development mode with Turbopack (default)141- `pnpm test-dev-webpack` - Development mode with Webpack142- `pnpm test-start-turbo` - Production build+start with Turbopack143- `pnpm test-start-webpack` - Production build+start with Webpack144145**Other test commands:**146147- `pnpm test-unit` - Run unit tests only (fast, no browser)148- `pnpm new-test` - Generate a new test file from template (interactive)149150**Generate tests non-interactively (for AI agents):**151152Generating tests using `pnpm new-test` is mandatory.153154```bash155# Use --args for non-interactive mode. It is a `turbo gen` flag, so pass it156# directly, without a `--` separator.157# Format: pnpm new-test --args <appDir> <name> <type>158# appDir: true/false (is this for app directory?)159# name: test name (e.g. "my-feature")160# type: e2e | production | development | unit161162pnpm new-test --args true my-feature e2e163```164165**Analyzing test output efficiently:**166167Never re-run the same test suite with different grep filters. Capture output once to a file, then read from it:168169```bash170# Run once, save everything171HEADLESS=true pnpm test-dev-turbo test/path/to/test.ts > /tmp/test-output.log 2>&1172173# Then analyze without re-running174grep "●" /tmp/test-output.log # Failed test names175grep -A5 "Error:" /tmp/test-output.log # Error details176tail -5 /tmp/test-output.log # Summary177```178179## Writing Tests180181**Test writing expectations:**182183- **Use `pnpm new-test` to generate new test suites** - it creates proper structure with fixture files184185- **Use `retry()` from `next-test-utils` instead of `setTimeout` for waiting**186187```typescript188 // Good - use retry() for polling/waiting189 import { retry } from 'next-test-utils'190 await retry(async () => {191 const text = await browser.elementByCss('p').text()192 expect(text).toBe('expected value')193 })194195 // Bad - don't use setTimeout for waiting196 await new Promise((resolve) => setTimeout(resolve, 1000))197```198199- **Do NOT use `check()` - it is deprecated. Use `retry()` + `expect()` instead**200201```typescript202 // Deprecated - don't use check()203 await check(() => browser.elementByCss('p').text(), /expected/)204205 // Good - use retry() with expect()206 await retry(async () => {207 const text = await browser.elementByCss('p').text()208 expect(text).toMatch(/expected/)209 })210```211212- **Prefer real fixture directories over inline `files` objects**213214```typescript215 // Good - use a real directory with fixture files216 const { next } = nextTestSetup({217 files: __dirname, // points to directory containing test fixtures218 })219220 // Avoid - inline file definitions are harder to maintain221 const { next } = nextTestSetup({222 files: {223 'app/page.tsx': `export default function Page() { ... }`,224 },225 })226```227228## Linting and Types229230```bash231pnpm lint # Full lint (types, prettier, eslint, ast-grep)232pnpm lint-fix # Auto-fix lint issues233pnpm prettier-fix # Fix formatting only234pnpm types # TypeScript type checking235```236237Type-check with the repo's own commands. `pnpm typescript` runs `tsc --noEmit` against the root `tsconfig.json`, which includes `scripts/**/*.js` and loads this repo's type augmentations. A hand-rolled `tsconfig` pointed at a single file misses those augmentations and will report clean while CI fails. For example `NodeJS.ProcessEnv` is declared in `packages/next/types/global.d.ts` with `NODE_ENV` required, so a plain `Record<string, string>` is not a valid `env` for an `execa` call.238239## Prefer a Throwaway Worktree240241Prefer a throwaway git worktree over changing the user's checkout. Switching their branch, or leaving a failed rebase behind, interrupts whatever they had open. It is also the right call for anything untrusted, such as a contributor's branch, because their files and any half-finished state stay outside the working copy.242243```bash244git worktree add /tmp/scratch-work <branch> # or --detach <commit>245# ... work in /tmp/scratch-work ...246git worktree remove --force /tmp/scratch-work247```248249Always remove the worktree when finished, and prefer removing it in a cleanup path that also runs on failure.250251A fresh worktree has no `node_modules`, so `pnpm` and `npx` do not work in it. Symlinking the root one is enough for `prettier`, `eslint`, and `tsc`:252253```bash254ln -s /path/to/main/checkout/node_modules /tmp/scratch-work/node_modules255```256257That symlink does not bring in per-package `node_modules` or a built `packages/next/dist`, so `tsc --noEmit` reports `TS2307: Cannot find module` for things like `fast-glob`, `dotenv`, and `@playwright/test`. Those are artifacts of the worktree, not regressions. Confirm by checking whether the same path resolves in the main checkout, and do not "fix" them. Errors in the files actually being edited are still real, so read the paths rather than the count.258259## PR Status (CI Failures and Reviews)260261When the user asks about CI failures, PR reviews, or the status of a PR, run the pr-status script:262263```bash264node scripts/pr-status.js # Auto-detects PR from current branch265node scripts/pr-status.js <number> # Analyze specific PR by number266```267268This generates analysis files in `scripts/pr-status/`.269270General triage rules (always apply; `$pr-status-triage` skill expands on these):271272- Prioritize blocking failures first: build, lint, types, then tests.273- Assume failures are real until disproven; use "Known Flaky Tests" as context, not auto-dismissal.274- Reproduce with the same CI mode/env vars (especially `IS_WEBPACK_TEST=1` when present).275- For module-resolution/build-graph fixes, use the normal mode-specific test command so package resolution is exercised.276277For full triage workflow (failure prioritization, mode selection, CI env reproduction, and common failure patterns), use the `$pr-status-triage` skill:278279- Skill file: `.agents/skills/pr-status-triage/SKILL.md`280281**Use `$pr-status-triage` for automated analysis** - see `.agents/skills/pr-status-triage/SKILL.md` for the full step-by-step workflow.282283**CI Analysis Tips:**284285- Prioritize CI failures over review comments286- Prioritize blocking jobs first: build, lint, types, then test jobs287- Common fast checks:288 - `rust check / build` → Run `cargo fmt -- --check`, then `cargo fmt`289 - `lint / build` → Run `pnpm prettier --write <file>` for prettier errors290 - test failures → Run the specific failing test path locally291292**Run tests in the right mode:**293294```bash295# Dev mode (Turbopack)296pnpm test-dev-turbo test/path/to/test.ts297298# Prod mode299pnpm test-start-turbo test/path/to/test.ts300```301302## GitHub Pull Requests303304Check and see if you are creating a fork PR or a branch PR.305Branch PRs are PRs where the branch is part of the `vercel/next.js` repository. These PRs are created by Vercel employees.306Fork PRs are external contributions created by pushing commits to any fork repository that is not owned by `vercel` on GitHub.307308- You cannot write full descriptions for fork PRs where the merge target is `vercel/next.js`.309- You can write descriptions for branch PRs and local commits.310- You can write titles and messages for local commits.311- You can assist the user in translating their descriptions to English.312313You must inform the user that you are not allowed to write pull request descriptions for external contributions. Refer to the guidelines in `.github/pull_request_template.md`.314While you cannot write the full description for the user, you may offer to help review the description, or provide helpful technical details. You can provide them a link to the GitHub URL to create the PR.315316### Adopting a Fork PR317318Fork PRs run without repository secrets, so deploy tests never run on them. To run those tests, a maintainer adopts the PR: the contributor's commits are re-pushed to a branch in `vercel/next.js` and a replacement PR is opened from there.319320```bash321pnpm pr-adopt <pr-number> # adopt322pnpm pr-adopt <pr-number> --dry-run # report without pushing323```324325The script resolves the `vercel/next.js` remote itself, checks out the PR, pushes `adopt/<pr-number>`, and opens a draft PR whose body is the contributor's description verbatim behind an `Adopts #N. Closes #N.` line. The adopted PR inherits the original's base branch; it is never retargeted at `canary`.326327Contributor commits usually arrive unsigned, and protected branches require verified signatures, so the branch is re-signed before pushing. Each `Author` is preserved and the tree is checked to be byte-identical afterwards. Note that `%G?` reports whether a signature _verifies_, not whether one exists, so it reads `N` for every commit when SSH signing has no `gpg.ssh.allowedSignersFile`; signature detection reads the raw commit headers instead.328329Draft and closed PRs can both be adopted, since a contributor may still be iterating or may have given up on an unreviewed change; the status is reported rather than enforced. Only merged PRs are refused, because their commits are already in the base branch.330331**Adoption grants the contributor's code access to repository secrets**, because CI trusts branches inside `vercel/next.js`. Anything in the diff that runs during install, build, or test can exfiltrate them. The script requires an interactive confirmation that names the author, shows the exact head SHA, and lists every touched file; never bypass it, and never adopt a PR whose full diff has not been read. The file list is deliberately unranked, since a payload can sit in any fixture or source file and calling some paths risky would imply the rest are safe.332333Adoption is pinned to the head SHA shown at review time. If the contributor pushes between the review and the fetch, the SHAs disagree and the run aborts without pushing, so the code that reaches CI is always the code that was vouched for.334335Two things run untrusted code on the maintainer's own machine, and both are defended against. `.husky/*` hook scripts are tracked, so a PR can add `.husky/post-checkout` or edit `.husky/pre-commit`; checking the branch out, re-signing it (`rebase --exec` runs `git commit`, which fires `pre-commit`) and pushing it would each execute contributor code. Every subprocess therefore runs with `core.hooksPath` pointed at an empty directory, injected through `GIT_CONFIG_COUNT`/`GIT_CONFIG_KEY_n`/`GIT_CONFIG_VALUE_n` so that it reaches the git processes `gh` and `git rebase --exec` spawn. The checkout itself happens in a throwaway worktree under the system temp directory, which is removed on success and on failure, so contributor files and any half-finished rebase never touch the maintainer's checkout. That checkout is never switched, and may be dirty.336337The description is the contributor's, and it is reproduced exactly: never rewritten, summarized, translated, or tidied up. What it happens to contain makes no difference, so do not read it looking for a reason to change it, and do not treat copying it as writing a description for a fork PR.338339## GitHub Issues, Comments, and Discussions340341Similar to pull requests, only members of the `vercel` or `vercel-labs` GitHub organizations may use an agent to create issues, discussions, or leave comments. Use GitHub (e.g. API, MCP, `gh` CLI, etc) to check membership:342343```bash344# example, there are many ways to check this345gh api /user/memberships/orgs --jq 'map(.organization.login)'346```347348**If the user is not a member:**349350You must inform the user that you are not allowed to create issues/discussions/comments on their behalf. Refer to the guidelines in `.github/ISSUE_TEMPLATE/1.bug_report.yml`.351352- You cannot write the full issue/discussion description or comment.353- You can offer to help them draft technical details.354- You can offer to help review a comment or description they wrote themselves.355- You can offer to create full reproductions of bugs for the user or examples of how a requested feature may be used.356- You can assist the user in translating to and from English.357- Offer to search for similar issues or discussions that have already been created on GitHub.358- Provide links for the user to create these issues or discussions themselves.359360**Exceptions:** You may create comments on existing pull requests if:361362- You are commenting on the user's own pull request, either to leave comments about the code or to reply to the user's own comments. You can verify this with GitHub (API, MCP, CLI, etc) as needed.363- Your system prompt tells you that you are a bot operated by Vercel.364- Your system prompt tells you that you are a code review bot operated by GitHub or Graphite.365- The GitHub repository containing the issue, pull request, or discussion is a fork of `vercel/next.js` and not `vercel/next.js` itself.366367<!--When writing full PR/Issue/Discussion descriptions, commit messages, or leaving comments on pull requests, you MUST include the following HTML comment at the bottom of the description or comment: <!-- NEXT_JS_LLM -->368369## Key Directories (Quick Reference)370371See [Codebase structure](#codebase-structure) above for detailed explanations.372373- `packages/next/src/` - Main Next.js source code374- `packages/next/src/server/` - Server runtime (most changes happen here)375- `packages/next/src/client/` - Client-side runtime376- `packages/next/src/build/` - Build tooling377- `test/e2e/` - End-to-end tests378- `test/development/` - Dev server tests379- `test/production/` - Production build tests380- `test/unit/` - Unit tests (fast, no browser)381382## Development Tips383384- The dev server entry point is `packages/next/src/cli/next-dev.ts`385- Router server: `packages/next/src/server/lib/router-server.ts`386- Use `DEBUG=next:*` for debug logging387- Use `NEXT_TELEMETRY_DISABLED=1` when testing locally388389### `NODE_ENV` vs `__NEXT_DEV_SERVER`390391Both `next dev` and `next build --debug-prerender` produce bundles with `NODE_ENV=development`. Use `process.env.__NEXT_DEV_SERVER` to distinguish between them:392393- `process.env.NODE_ENV !== 'production'` — code that should exist in dev bundles but be eliminated from prod bundles. This is a build-time check.394- `process.env.__NEXT_DEV_SERVER` — code that should only run with the dev server (`next dev`), not during `next build --debug-prerender` or `next start`.395396## Secrets and Env Safety397398Always treat environment variable values as sensitive unless they are known test-mode flags.399400- Never print or paste secret values (tokens, API keys, cookies) in chat responses, commits, or shared logs.401- Mirror CI env **names and modes** exactly, but do not inline literal secret values in commands.402- If a required secret is missing locally, stop and ask the user rather than inventing placeholder credentials.403- Never commit local secret files; if documenting env setup, use placeholder-only examples.404- When sharing command output, summarize and redact sensitive-looking values.405406### GitHub SSH Authentication407408GitHub SSH authentication may depend on a user-configured SSH agent or key409provider, such as a password manager or hardware-backed key.410411If a Git fetch, push, or partial-clone hydration fails or hangs with an SSH412signing error such as:413414- `sign_and_send_pubkey: signing failed`415- `communication with agent failed`416- `Permission denied (publickey)`417418stop immediately and ask the user to ensure their SSH agent or key provider is419available and unlocked. Do not switch remotes to HTTPS, mutate remote URLs,420retry repeatedly, or attempt another authentication workaround unless the user421explicitly requests it.422423Before a force-push or stack rebase that may hydrate partial-clone objects,424prefer a lightweight SSH preflight. If it fails due to the SSH agent or key425provider, ask the user to make it available or unlock it before continuing.426427## Specialized Skills428429Use skills for conditional, deep workflows. Keep baseline iteration/build/test policy in this file.430431- `$pr-status-triage` - CI failure and PR review triage with `scripts/pr-status.js`432- `$create-pr` - branch, commit, push, and draft PR creation workflow433- `$backport-pr` - cherry-pick merged PRs from `canary` to release branches434- `$flags` - feature-flag wiring across config/schema/define-env/runtime env435- `$dce-edge` - DCE-safe `require()` patterns and edge/runtime constraints436- `$react-vendoring` - `entry-base.ts` boundaries and vendored React type/runtime rules437- `$react-sync` - build a local React checkout and sync it into Next.js for testing438- `$runtime-debug` - runtime-bundle/module-resolution regression reproduction and verification439- `$next-rspack` - @next/rspack-core and @next/rspack-binding maintenance (rspack/ directory)440- `$authoring-skills` - how to create and maintain skills in `.agents/skills/`441442## Context-Efficient Workflows443444**Reading large files** (>500 lines, e.g. `app-render.tsx`):445446- Grep first to find relevant line numbers, then read targeted ranges with `offset`/`limit`447- Never re-read the same section of a file without code changes in between448- For generated files (`dist/`, `node_modules/`, `.next/`): search only, don't read449450**Build & test output:**451452- Capture to file once, then analyze: e.g. `pnpm build 2>&1 | tee /tmp/build.log`453- Don't re-run the same test command without code changes; re-analyze saved output instead454455**Batch edits before building:**456457- Group related edits across files, then run one build, not build-per-edit458- Use `pnpm --filter=next types` (~10s) to check type errors without full rebuild459460**External API calls (gh, curl):**461462- Save response to variable or file: `JOBS=$(gh api ...) && echo "$JOBS" | jq '...'`463- Don't re-fetch the same API data to analyze from different angles464465## Commit and PR Style466467- Do NOT add "Generated with Claude Code" or co-author footers to commits or PRs468- Keep commit messages concise and descriptive469- PR descriptions should focus on what changed and why470- Do NOT mark PRs as "ready for review" (`gh pr ready`) - leave PRs in draft mode and let the user decide when to mark them ready471472## Task Decomposition and Verification473474- **Split work into smaller, individually verifiable tasks.** Before starting, break the overall goal into incremental steps where each step produces a result that can be checked independently.475- **Verify each task before moving on to the next.** After completing a step, confirm it works correctly (e.g., run relevant tests, check types, build, or manually inspect output). Do not proceed to the next task until the current one is verified.476- **Choose the right verification method for each change.** This may include running unit tests, integration tests, type checking, linting, building the project, or inspecting runtime behavior depending on what was changed.477- **When unclear how to verify a change, ask the user.** If there is no obvious test or verification method for a particular change, ask the user how they would like it verified before moving on.478479**Pre-validate before committing** to avoid slow lint-staged failures (~2 min each):480481```bash482# Run exactly what the pre-commit hook runs on your changed files:483pnpm prettier --with-node-modules --ignore-path .prettierignore --write <files>484npx eslint --config eslint.config.mjs --fix <files>485```486487## Rebuilding Before Running Tests488489When running Next.js integration tests, you must rebuild if source files have changed:490491- **First run after branch switch/bootstrap (or if unsure)?** → `pnpm build-all`492- **Edited only core Next.js files (`packages/next/**`) after bootstrap?** → `pnpm --filter=next build`493- **Edited Next.js code or Turbopack (Rust)?** → `pnpm build-all`494495## Development Anti-Patterns496497For runtime internals, use focused skills:498499- Feature-flag plumbing and runtime bundle wiring: `$flags` (`.agents/skills/flags/SKILL.md`)500- DCE and edge/runtime constraints: `$dce-edge` (`.agents/skills/dce-edge/SKILL.md`)501- React vendoring and `entry-base.ts` boundaries: `$react-vendoring` (`.agents/skills/react-vendoring/SKILL.md`)502- Debugging and verification workflow: `$runtime-debug` (`.agents/skills/runtime-debug/SKILL.md`)503504Keep these high-frequency guardrails in mind:505506- Reproduce module resolution and bundling issues with the normal mode-specific test command so package resolution is exercised.507- Validate edge bundling regressions with `pnpm test-start-webpack test/e2e/app-dir/app/standalone.test.ts`508- Use `__NEXT_SHOW_IGNORE_LISTED=true` when you need full internal stack traces509510Core runtime/bundling rules (always apply; skills above expand on these with verification steps and examples):511512- New flags: add type in `config-shared.ts`, schema in `config-schema.ts`, and `define-env.ts` when used in user-bundled code.513- If a flag is consumed in pre-compiled runtime internals, also wire runtime env values (`next-server.ts`/`export/worker.ts` as needed).514- `define-env.ts` affects user bundling; it does not control pre-compiled runtime bundle internals.515- Keep `require()` behind compile-time `if/else` branches for DCE (avoid early-return/throw patterns).516- In edge builds, force feature flags that gate Node-only imports to `false` in `define-env.ts`.517- `react-server-dom-webpack/*` imports must stay in `entry-base.ts`; consume via component module exports elsewhere.518519### Test Gotchas520521- **Cache components enables PPR by default**: When `__NEXT_CACHE_COMPONENTS=true`, most app-dir pages use PPR implicitly. Dedicated `ppr-full/` and `ppr/` test suites are mostly `describe.skip` (migrating to cache components). To test PPR codepaths, run normal app-dir e2e tests with `__NEXT_CACHE_COMPONENTS=true` rather than looking for explicit PPR test suites.522- **Quick smoke testing with toy apps**: For fast feedback, generate a minimal test fixture with `pnpm new-test --args true <name> e2e`, then run the dev server directly with `node packages/next/dist/bin/next dev --port <port>` and `curl --max-time 10`. This avoids the overhead of the full test harness and gives immediate feedback on hangs/crashes.523- Mode-specific tests need `skipStart: true` + manual `next.start()` in `beforeAll` after mode check524- Don't rely on exact log messages - filter by content patterns, find sequences not positions525- **Snapshot tests vary by env flags**: Tests with inline snapshots can produce different output depending on env flags. When updating snapshots, always run the test with the exact env flags the CI job uses (check `.github/workflows/build_and_test.yml` `afterBuild:` sections). Turbopack resolves `react-dom/server.edge` (no Node APIs like `renderToPipeableStream`), while webpack resolves the `.node` build (has them).526- **`app-page.ts` is a build template compiled by the user's bundler**: Any `require()` in this file is traced by webpack/turbopack at `next build` time. You cannot require internal modules with relative paths because they won't be resolvable from the user's project. Instead, export new helpers from `entry-base.ts` and access them via `entryBase.*` in the template.527- **Reproducing CI failures locally**: Always match the exact CI env vars (check `pr-status` output for "Job Environment Variables"). Key differences such as `IS_WEBPACK_TEST=1` can change bundler selection and snapshot output, so use the CI command and mode when verifying module resolution fixes.528- **Showing full stack traces**: Set `__NEXT_SHOW_IGNORE_LISTED=true` to disable the ignore-list filtering in dev server error output. By default, Next.js collapses internal frames to `at ignore-listed frames`, which hides useful context when debugging framework internals. Defined in `packages/next/src/server/patch-error-inspect.ts`.529- **Router act tests must use LinkAccordion to control prefetches**: Always use `LinkAccordion` to control when prefetches happen inside `act` scopes. Never use `browser.back()` to return to a page where accordion links are already visible — BFCache restores state and triggers uncontrolled re-prefetches. See `$router-act` for full patterns.530531### Rust/Cargo532533- cargo fmt uses ASCII order (uppercase before lowercase) - just run `cargo fmt`534- **Internal compiler error (ICE)?** Delete incremental compilation artifacts and retry. Remove `*/incremental` directories from your cargo target directory (default `target/`, or check `CARGO_TARGET_DIR` env var)535- Avoid adding new `super::` imports except in inline `mod` blocks (e.g. `mod tests { ... }`) — prefer `crate::`-rooted paths. This makes imports consistent and easier to grep for.536537### Node.js Source Maps538539- `findSourceMap()` needs `--enable-source-maps` flag or returns undefined540- Source map paths vary (webpack: `./src/`, tsc: `src/`) - try multiple formats541- `process.cwd()` in stack trace formatting produces different paths in tests vs production542543### Stale Native Binary544545If Turbopack produces unexpected errors after switching branches or pulling, check if `packages/next-swc/native/*.node` is stale. Delete it and run `pnpm install` to get the npm-published binary instead of a locally-built one.546547### Documentation Code Blocks548549- When adding `highlight={...}` attributes to code blocks, carefully count the actual line numbers within the code block550- Account for empty lines, import statements, and type imports that shift line numbers551- Highlights should point to the actual relevant code, not unrelated lines like `return (` or framework boilerplate552- Double-check highlights by counting lines from 1 within each code block553554### Server Security: Internal Header Filtering555556Next.js strips internal headers from incoming requests via `filterInternalHeaders()` in `packages/next/src/server/lib/server-ipc/utils.ts`. This runs at the entry point in `packages/next/src/server/lib/router-server.ts` before any server code executes. Only headers listed in the `INTERNAL_HEADERS` array are stripped.557558**When reviewing PRs: if new code reads a request header that is not a standard HTTP header (like `content-type`, `accept`, `user-agent`, `host`, `authorization`, `cookie`, etc.), flag it for security review.** The header may be forgeable by an external attacker if it is not in the `INTERNAL_HEADERS` filter list in `packages/next/src/server/lib/server-ipc/utils.ts`.559
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| vercel/next.jstest/AGENTS.md · 142k | AGENTS.md | teststylegitagent-behaviour | 24/100 | 11 days ago | |
| vercel/next.jspackages/next/AGENTS.md · 142k | AGENTS.md | no sections | 16/100 | 14 days ago | |
| vercel/next.jsturbopack/AGENTS.md · 142k | AGENTS.md | no sections | 16/100 | 14 days ago | |
| vercel/next.js.github/AGENTS.md · 142k | AGENTS.md | setupstylesecuritydependencies+1 | 73/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 68k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 13 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| aaif-goose/gooseAGENTS.md · 53k | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 8 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| deepseek-ai/deepseek-harnessnative/landlock-run/AGENTS.md · 104k | AGENTS.md | setupteststylearch+3 | 100/100 | today | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | today | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 201k | AGENTS.md | buildteststylearch+3 | 100/100 | 14 days ago | |
| elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+2 | 100/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/vercel-next-js-agents)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.