FormingSkillcli_toolclaude-codepublished fresh until

How do I upgrade my Next.js app to a new major version with an agent?

Summary As of November 2026, the Next.js docs describe an experimental npx next@canary upgrade --agent=latest: it picks a target by policy, copies the migration guides for every major crossed and hands a task to Claude Code or Codex. The plain codemod upgrade still exists.

Not for upgrading React alone; see react-19-upgrade-18-3-first-then-codemods

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The options

Same job, different trade-offs. Pick one in Try it.

Option
ASkill · v1.0.0Next.js 16 breaking-change scan (read-only)
Bcli_tool · v16.4.2Next.js codemod CLI
How you use itYou ask for itcli_tool
What it can doinstalls software · writes files · network · runs shellinstalls software · network
What's inside
ASkill · v1.0.0Next.js 16 breaking-change scan (read-only)
How you use it
You ask for it
What it can do
installs software · writes files · network · runs shell
What's inside
Bcli_tool · v16.4.2Next.js codemod CLI
How you use it
cli_tool
What it can do
installs software · network
What's inside

What this thread does

The problem

You are on an older Next.js (13, 14 or 15) and want 15 or 16. Bumping next in package.json and letting an agent fix errors one by one tends to skip breaking changes that only show at runtime (async cookies(), headers(), params, searchParams, the middleware to proxy rename, lint changes).

What the official docs say

The Next.js docs (page last updated 2 October 2026, marked Experimental) describe two routes.

1. Agent-driven: next upgrade --agent

npx next@canary upgrade --agent=latest
# from a workspace root, name the app:
npx next@canary upgrade apps/web --agent=latest
  • next@canary runs the newest upgrade tooling even if your app is on an older Next.js.
  • The policy is one of security (default; the latest safe release in the earliest eligible major), latest (npm's latest stable, or canary for canary apps) or experimental-future (latest, then adopt planned defaults such as Cache Components). Omit it and the CLI uses experimental.agentUpgrade from next.config, otherwise security. --agent cannot be combined with --revision.
  • Before starting, the CLI checks your installed version, release metadata and security data. For a major upgrade, the task it prepares includes the migration guide for every major version crossed, and asks the agent to check for duplicate work, use a separate git worktree when available, run the relevant checks and verify the result.
  • In an interactive terminal it can start an installed Codex or Claude Code session (you choose model, effort and whether to use a worktree) or copy the prompt for another agent. Run from inside an agent, it prints the task for that agent. In a non-interactive shell it just prints the task.
  • The task also asks the agent to save the chosen policy as experimental.agentUpgrade so Next.js can show upgrade reminders later; set it to false to turn reminders off.

2. Codemods without an agent

npx @next/codemod upgrade major   # or minor, patch, canary, or an exact version like 16

It runs the relevant codemods and updates Next.js, React and React DOM. It is non-interactive when stdin is not a TTY (CI, an agent). Useful flags: --skip-react-upgrade, --skip-eslint-upgrade, -y. Individual transforms exist, for example next-async-request-api (async dynamic APIs), middleware-to-proxy and remove-unstable-prefix (16.0), --dry and --print to preview.

How to ask your agent

Run npx next@canary upgrade --agent=latest in this repo, in a new git worktree. Do every migration step the generated task lists. When next build, tsc and the test suite all pass, list every file that still has an @next-codemod-error comment or an UnsafeUnwrapped cast and fix them before reporting done.

Mistakes to check

  • Codemods cannot always migrate a call. next-async-request-api then leaves an @next-codemod-error comment and may add an UnsafeUnwrapped* cast; your build errors until they are resolved. Search for both before you call it done.
  • Skipping majors. The agent task carries the guide for each major crossed; a hand bump does not.
  • Running in a monorepo root without naming the app directory.
  • Treating a green next dev as proof. Run next build; some changes only fail there.
  • The 16.3 codemods cache-components-instant-false and remove-partial-prefetch report 0 ok instead of an error when you pass a wrong path (the docs say to check the file count; use ./src/app in a src/ project).

Limits

  • Pinning: the commands above use Next.js's own next@canary and @next/codemod forms, which resolve to whatever is newest when you run them. The WhatWorks package card for this thread pins @next/codemod@16.4.2 in a locked install with scripts off (checked 2026-10-29); pin an exact version the same way when you need a repeatable run.

Not run by me: this summarises the official docs only, and the agent flow is labelled experimental. React 19 specifics are in a separate thread.

Sources

Primary sources, read on 18 October 2026: Next.js docs Upgrade with a coding agent (last updated 2026-10-02, badge Experimental) and Codemods (last updated 2026-10-02).

  • Confirms: npx next@canary upgrade --agent=latest and the workspace form; the three policies security, latest, experimental-future, the fallback to experimental.agentUpgrade then security, and that --agent cannot be combined with --revision; the prepared task including the migration guide for every major version crossed, worktree and verification requests, saving the policy to next.config, and interactive, inside-agent and non-interactive behaviour; npx @next/codemod upgrade [revision] with patch, minor, major, a dist tag or an exact version, --skip-react-upgrade, --skip-eslint-upgrade, -y and automatic non-interactive mode when stdin is not a TTY; next-async-request-api leaving @next-codemod-error comments and UnsafeUnwrapped casts; middleware-to-proxy and remove-unstable-prefix under 16.0; --dry and --print.
  • Corrections: the codemod upgrade command defaults to minor on stable versions, so name major explicitly. The "0 ok on a wrong path" note is documented for the 16.3 codemods (cache-components-instant-false and remove-partial-prefetch), not for every codemod newer than 16.3.

Started from a post by @Next.js (Vercel) docs, packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I upgrade my Next.js app to a new major version with an agent?
Summary: As of November 2026, the Next.js docs describe an experimental `npx next@canary upgrade --agent=latest`: it picks a target by policy, copies the migration guides for every major crossed and hands a task to Claude Code or Codex. The plain codemod upgrade still exists.

## Options
- A · Next.js 16 breaking-change scan (read-only) · early, no verdict yet · installs software · writes files · network · runs shell
- B · Next.js codemod CLI · early, no verdict yet · installs software · network
Copy for agent
get the whatworks thread nextjs-major-upgrade-next-upgrade-agent-flag and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread nextjs-major-upgrade-next-upgrade-agent-flag

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · Next.js 16 breaking-change scan (read-only)

Read-only stdlib Python scan of a project for Next.js 16 breaking changes from the official upgrade guide (next lint, Turbopack flags and custom webpack, runtime config, middleware to proxy, sync cookies/headers, revalidateTag, PPR flags, parallel route defaults). Prints file:line and the guide section; self-test uses bundled fixtures.

Format
Skill
Source
—
Pinned
v1.0.0 · sha256:965ce
Content hash
965ce463a5c1ef7b
Audit
scan passed
Can do
installs software · writes files · network · runs shell
Works with
claude-code
Check
Runs bundled positive and negative fixtures in a temp dir; reads no project files.
Author
@WhatWorks
Kudos
0

This package has no public source link yet.

Are you @WhatWorks? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package ww-nextjs16-scan before installing

B · Next.js codemod CLI

Runs Next.js version-migration codemods. Pinned @next/codemod@16.4.2 from npm, run from a locked install: WhatWorks checks only its --version and --help.

Format
cli_tool
Source
—
Pinned
v16.4.2 · npm:@next/co
Content hash
sha256:424c84a53
Audit
scan warned
Can do
installs software · network
Check
node_modules/.bin/codemod --version; node_modules/.bin/codemod --help
Author
editor
Kudos
0

This package has no public source link yet.

Ask your agent
show me the whatworks package next-codemod-cli-tool before installing
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp