Uh oh!
There was an error while loading. Please reload this page.
fix(docs): stop next dev writing untracked AGENTS.md / CLAUDE.md into apps/docs - #10780
Merged
Conversation
…to apps/docs `next dev` (Next 16.3.1) runs `ensureAgentRulesForDev` on boot and, whenever it detects an AI coding agent, scaffolds `apps/docs/AGENTS.md` and `apps/docs/CLAUDE.md`. Neither path is tracked or ignored, so both land as `??` and any `git add -A` after booting the docs server sweeps them into an unrelated PR. Those two filenames are load-bearing here: the root `AGENTS.md` is the binding playbook and agents are told to read the `AGENTS.md` governing the files they touch. A Next-authored stub pointing at `node_modules/next/dist/docs/` can be read as this repo's discipline, and its own text argues for committing itself. The generated `CLAUDE.md` is the single line `@AGENTS.md`, an import directive that pulls the stub in. Set `agentRules: false` in `apps/docs/next.config.mjs`, turning generation off at the source rather than gitignoring the paths: an ignore rule for `apps/docs/AGENTS.md` would silently swallow a future repo-authored `AGENTS.md` for this app, failing invisibly at exactly the moment someone was adding real guidance there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DdCnBGcHeufjrq7drTD3wt
os-zhuang
marked this pull request as ready for review
August 21, 2026 11:23
os-zhuang
enabled auto-merge
August 21, 2026 11:23
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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#10249
What
Sets
agentRules: falseinapps/docs/next.config.mjs.next dev(Next16.3.1) callsensureAgentRulesForDevon boot and, whenever@vercel/detect-agentreports an AI coding agent, scaffoldsapps/docs/AGENTS.mdandapps/docs/CLAUDE.md. Neither path is tracked or ignored, so both land as??and anygit add -Aafter booting the docs server sweeps them into an unrelated PR.Those two filenames are load-bearing in this repo: the root
AGENTS.mdis the bindingplaybook and agents are told to read the
AGENTS.mdgoverning the files they touch. ANext-authored stub pointing at
node_modules/next/dist/docs/can be read as this repo'sdiscipline, and the generated text argues for committing itself, which nudges an agent the
wrong way. The generated
CLAUDE.mdis the single line@AGENTS.md— an import directivethat pulls the stub in.
Why disable rather than ignore
Turned off at the source instead of adding a
.gitignoreentry, and this is a deliberatechoice rather than a cost comparison. An ignore rule for
apps/docs/AGENTS.mdwouldsilently swallow a future repo-authored
AGENTS.mdfor the docs app, and that failurewould be invisible at exactly the moment someone was trying to add real guidance there. A
visible untracked file is a better failure than an invisibly ignored one for this filename
specifically. The reasoning is recorded in the config comment so the next reader does not
re-litigate it.
Evidence
Measured in a dedicated worktree off
origin/main@01c50322a1. The detector wasconfirmed live in this shell first —
determineAgent()returns{"isAgent":true,"agent":{"name":"claude-code_2-1-238_agent"}}— so a clean tree after thefix cannot be a false negative caused by non-detection.
Baseline, all four checks from the issue, in a checkout that had not run
next dev:git ls-files apps/docs | grep -iE 'AGENTS|CLAUDE'git check-ignore -v apps/docs/AGENTS.md apps/docs/CLAUDE.mdgrep -n agentRules apps/docs/next.config.mjsls apps/docs/AGENTS.md apps/docs/CLAUDE.mdBoot 1 — base config, both files absent, port 31249:
Boot 2 — with
agentRules: false, both files deleted first so the run starts from thesame state, port 31250:
No
Generated ...line, no new files. Deleting the two files before boot 2 is the load-bearingpart of the control:
ensureAgentRulesForDevalso returns early when the current block isalready present, so leaving them in place would have produced a clean tree whether or not the
flag worked.
The server still starts and serves after the config change —
Ready in 417ms,/docsand/both HTTP 200, and
/docsreturned 220754 bytes, byte-identical in size to the pre-fix boot.Next's zod config schema accepts the key (
agentRules: z.boolean().optional()), and✓ Running next.config.mjs took 282msconfirms the config parsed with no validation warning.Residue
agentRules: falsestops future generation; it does not delete copies from a checkout thatalready ran
next dev. No cleanup script: the affected population is small, self-limiting andalready visible as
??, and once this lands the files are never rewritten, so removing themonce is permanent. Handled with a sentence in the config comment naming the one command
(
rm -f apps/docs/AGENTS.md apps/docs/CLAUDE.md), which is where someone asking "why do I havethese files" will be reading. No copies exist anywhere in the container this was built in.
Gates
Derived with
node scripts/pm/dispatch-gates.mjsfrom the real change set (it reads the mergebase itself), re-run after the final commit at
d2c46c1c2d. Exit codes captured before anypipe; verdict lines are each gate's own output.
pnpm check:test-source-aliascheck-test-source-alias OK — 72 packages with tests scannedpnpm check:type-source-resolutioncheck-type-source-resolution OK — 76 packages with a tsconfig.json scannedpnpm check:nul-bytescheck-nul-bytes: OK (scanned 6237 text file(s) -- 6237 tracked, 0 untracked-not-ignored ...)The first two are the families
dispatch-gatesmatched forapps/docs/next.config.mjs(both via gate source
apps/*);check:nul-bytesis run because the diff touches a text file.No changeset
A dev-server config flag publishes nothing — no package behaviour changes for any consumer.
Labelled
skip-changeset.Generated by Claude Code