Run agent-assisted Next.js security upgrades - #98562
Draft
devjiwonchoi wants to merge 5 commits into
Draft
Conversation
devjiwonchoi
added this pull request to stack #98564
September 11, 2026 13:22
Contributor
Failing test suitesCommit: 167d186 | About building and testing Next.js
Expand output● instant-nav-panel › SPA captures › should capture when CookieStore writes are not reflected in document.cookie
Expand output● instant validation › dev - client navigation › invalid - loading.js covers page, but not layout at the same level
Expand output● next-server-nft › with output:standalone › should not trace too many files in next-server.js.nft.json Other failing CI jobs |
devjiwonchoi
removed this pull request from stack #98564
September 11, 2026 13:31
devjiwonchoi
changed the base branch from
jiwon/agent-upgrade/codemods
to
jiwon/agent-upgrade/docs
September 11, 2026 13:31
devjiwonchoi
added this pull request to stack #98567
September 11, 2026 13:31
devjiwonchoi
force-pushed
the
jiwon/agent-upgrade/setup
branch
from
September 11, 2026 14:16
7e72fc9 to
dd858a0
Compare
devjiwonchoi
removed this pull request from stack #98567
September 11, 2026 14:32
devjiwonchoi
added this pull request to stack #98572
September 11, 2026 14:33
devjiwonchoi
force-pushed
the
jiwon/agent-upgrade/setup
branch
from
September 11, 2026 14:43
dd858a0 to
a8faf6d
Compare
devjiwonchoi
force-pushed
the
jiwon/agent-upgrade/setup
branch
2 times, most recently
from
September 11, 2026 15:02
64be173 to
02315c3
Compare
devjiwonchoi
force-pushed
the
jiwon/agent-upgrade/setup
branch
2 times, most recently
from
September 11, 2026 15:54
6c80ab4 to
8d37a7e
Compare
devjiwonchoi
removed this pull request from stack #98572
September 11, 2026 15:54
devjiwonchoi
added this pull request to stack #98574
September 11, 2026 15:55
devjiwonchoi
force-pushed
the
jiwon/agent-upgrade/setup
branch
7 times, most recently
from
September 11, 2026 21:41
16c320d to
8a22f84
Compare
devjiwonchoi
force-pushed
the
jiwon/agent-upgrade/setup
branch
from
September 11, 2026 23:14
8a22f84 to
9d5c8f1
Compare
A security upgrade must establish whether the app is affected and select an exact safe target before an agent edits it. Wire the experimental CLI option to the resolver so this checkpoint exposes its real caller. Read the opt-in config and installed version, query reviewed advisories with npm fallback, select a supported safe release, and check its Node requirement. Reset loaded dotenv values before handoff and pin the codemod command without running a compatibility probe. Keep CLI-only upgrade files out of production traces. Retain deterministic security-target tests and preserve normal upgrade behavior.
devjiwonchoi
force-pushed
the
jiwon/agent-upgrade/setup
branch
from
September 11, 2026 23:27
9d5c8f1 to
22b79bd
Compare
Installing a safe version does not complete a migration, and replacing Next can erase its installed guides. Turn the resolved target into retained context and a handoff to the current agent. Copy bundled workflow files and download relevant canonical guides, using Pages Router paths for versions through 13. Retain evidence outside app dependencies. The workflow requires codemods, contextual repairs, verification and commit checkpoints; experimental dry-run stops at local commits. Introduce the dry-run flag with its first execution consumer; terminal background launch follows in the next checkpoint.
Let developers interact with the upgrade agent in their current terminal. Offer installed agents, printed instructions, and cancellation; preserve existing-agent handoff and avoid launching a REPL without an interactive terminal.
devjiwonchoi
force-pushed
the
jiwon/agent-upgrade/setup
branch
from
September 12, 2026 07:19
22b79bd to
4723ad0
Compare
Keep the CLI focused on app scope, retained instructions and agent handoff so the coding agent can assess security eligibility and perform contextual repairs. Replace the resolver and context file with bundled workflow guides, make dry-run enable agent mode, and support existing sessions, interactive launch and clipboard handoff.
Give agents explicit migration outcomes and common-issue guidance without duplicating the public upgrade explanations or changing rendered checklist content. Add marked MDX comments for Next.js 15 and 16, have the workflow consume them, and explain how to verify image-quality behavior after upgrading.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #98565.
Why?
Fixing a vulnerable Next.js app can require application-specific migration work beyond installing a patched version. The upgrade command needs to select a safe target and give a coding agent the evidence and guidance needed to complete that work.
How?
Add
next upgrade --experimental-agentfor apps that enableexperimental.agenticAutoUpgrade: 'security'. Check the selected app and its installed version, fetch reviewed GitHub advisories with npm fallback, select a supported safe stable release, and verify its Node.js requirement. Disabled, unaffected or blocked apps exit before agent handoff.Prepare an exact codemod command with
--yes --skip-adoption. Retain the resolved inputs, advisory evidence, bundled workflow instructions and relevant migration guides outside app dependencies so they survive the upgrade. Canonical guides come from GitHub canary; the bundled workflow matches the installed CLI.Continue in an existing Codex or Claude session, or let a terminal user select an installed agent and launch it in the background. New sessions use Luna for Codex and Haiku for Claude. Receipts provide session, log, stop and continuation information; Codex resume requires its background process to finish or stop. Existing sessions retain their model and permissions.
The workflow directs the agent to check for existing upgrade PRs, run codemods, complete contextual repairs, verify behavior and create commits.
--experimental-agent-dry-run, used with--experimental-agent, stops at local commits without pushing or opening a PR. Publication otherwise follows the session's existing permissions.Preserve the caller's environment for child commands, support Windows process launching, and exclude upgrade tooling from production traces. Include focused unit coverage for security-target selection.