chore(site): ignore the AGENTS.md/CLAUDE.md that next dev mints, and turn the minting off at the source (#4160) - #4172
Merged
Conversation
…d turn the minting off `next dev` >= 16.3 (the #4094 bump) detects an AI coding agent from the environment and writes apps/site/AGENTS.md + apps/site/CLAUDE.md via next/dist/server/lib/generate-agent-files.js. They were neither tracked nor gitignored, and the generated block tells the reader that committing it keeps the tree clean -- a `git add -A` contamination trap in a repo worked by parallel agents. Opt out upstream with `agentRules: false`, and gitignore both paths as the belt to that braces since the flag is upstream-owned. Pinned by scripts/__tests__/site-next-agent-files-4160.test.ts. Fixes #4160
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
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.
Fixes #4160
Running the docs site left two untracked files behind that were neither committed nor gitignored, and whose own generated text asks the reader to commit them. This lands the direction the card settled on: ignore, don't commit — plus the upstream opt-out, so the files stop being written at all.
Reproduced on this branch's base
apps/site/CLAUDE.mdis one line,@AGENTS.md. The generatedapps/site/AGENTS.mdcarries the managed block, which ends:That last sentence is what makes this a live trap rather than noise: a file that appears from merely running the app, is invisible to
git check-ignore, and tells its reader that committing it is the tidy move — in a repo where parallel agents stage withgit add -A. Same shape as objectui#3430.Trigger, and why now
next devcallsensureAgentRulesForDev(next/dist/server/lib/app-info-log.js), which asks@vercel/detect-agentwhether an AI coding agent is driving the session — it keys on environment variables includingCLAUDECODE,CLAUDE_CODE,CURSOR,CODEX_THREAD_ID,GEMINI_CLIandAI_AGENT, all true for the agents that work this repo — and then writes both files beside the app'snext.config.It is new with the #4094 bump. Next's own bundled guide (
node_modules/next/dist/docs/01-app/02-guides/ai-agents.md) says so directly:So 16.2.12 minted nothing and 16.3.0 does; the premise is current, not expired.
An upstream opt-out exists, so this uses both belts
The call site is gated:
if (initResult.agentRules !== false).agentRulesis a documented top-level config key (agentRules?: boolean, defaulttrue), declared in next's config schema, and the dev server itself names it in the message above.agentRules: falseinapps/site/next.config.mjs— stops the write at the source instead of hiding it..gitignore(next to the existingapps/site/.next/.map.ts/.sourceblock) andapps/site/.gitignore(next tonext-env.d.ts). Those two files are ignored in both places today, so this matches the placement the repo already uses for this app's dev-time artifacts.Half 2 is not redundant with half 1:
agentRulesis upstream-owned and can be renamed or dropped by any bump — and next validates config against a strict object where an unknown key only warns at startup, so losing the flag would be silent. Other entry points (create-next-app,@next/codemod agents-md) write the same files too.Committing them was rejected for the reason the card gives: the block is minted per next version, and
apps/site/CLAUDE.mdbeing a bare@AGENTS.mdimport would splice framework-owned prose into this repo's own binding instruction chain.Exposure sweep
apps/siteis the only workspace member that runs Next.js — it is the solepackage.jsonin the repo declaringnext(packages/componentsdeclaresnext-themes, which is unrelated).apps/consoleis Vite;examples/*contains no Next.js app. No other exposed path.Pin
scripts/__tests__/site-next-agent-files-4160.test.ts(8 cases) holds both halves, and — because the filenames are upstream literals — does not treat its own list as the source of truth:next.config.mjsstill setsagentRules: false;.mdfilename literal read back out of the installed next is covered by the ignore — so a bump that renamesAGENTS.mdor adds a third file goes red instead of silently re-exposing the trap;agentRulesin its config schema — the drift that would otherwise turn the opt-out into a warning nobody reads.Verification
Dev server after the change, with the site's dependency closure built (
pnpm --filter '@object-ui/site^...' build):Reverse verification — the two halves fail differently, which is the point
Directions predicted before running. Removals done with
git checkout origin/main -- path, nevergit stash.is gitignoredcases and the upstream-derivedignores every filename the installed next actually writes.agentRules: falseremoved (ignore kept): the config case goes red, and a realnext devrun mints both files again — but the tree stays clean, which is the ignore half doing its job in isolation:next devmints nothing, so the tree looks fine right up until the flag stops working. That silence is exactly why the ignore is pinned here instead of left for a dev-server run to notice.Notes
.gitignore, a private app's config and a scripts test change no released package'ssrc/; the presence script arbitrates and says none is owed (output above).skip-changesetlabel — decorative in this repo (objectui#3724).content/docs/releases/untouched.Generated by Claude Code