avyvar's picture
Add files using upload-large-folder tool
b2cad4f verified
|
Raw
History Blame Contribute Delete
1.36 kB

Refresh managed agent-rules blocks when projects move to a newer Next.js version.

When an AI coding agent is detected during next dev and agent rules are enabled, marker presence alone must not make an outdated block permanent. Compare an installed managed block with the canonical block for the running Next.js version and refresh stale content. Rewrite the file that already hosts the block (AGENTS.md or CLAUDE.md) instead of creating a duplicate in the other file. Preserve all user-authored content around the block, preserve CRLF line endings, and keep subsequent dev-server starts idempotent. Blocks using the legacy NEXT-AGENTS-MD markers must migrate to one current managed block. A malformed current block with a start marker but no end marker must converge to exactly one canonical block within two starts rather than growing on every run.

After @next/codemod upgrade completes the dependency installation and version bump, refresh an already-adopted managed block to the canonical content supplied by the newly installed Next.js package. The upgraded package is the source of truth for this content. Do not create agent files for projects that never adopted the managed block, and no-op when the installed version predates this capability. Refreshing is best-effort and must not turn an otherwise successful upgrade into a failure.