Skip to content

next dev writes untracked, non-gitignored apps/docs/AGENTS.md and apps/docs/CLAUDE.md — agent-instruction filenames a git add -A can sweep into any PR #10249

Description

@os-elon

Found while running the docs dev server to render-verify a sidebar change (#10209). Filed unassigned; not fixed there — out of that card's file surface.

What happens

Booting the documented docs dev server (pnpm docs:devnext dev, Next 16.3.1) creates two files that are untracked and not gitignored:

?? apps/docs/AGENTS.md
?? apps/docs/CLAUDE.md

The server announces it:

✓ Generated AGENTS.md and CLAUDE.md for AI agents. Set `agentRules: false` in next.config to disable.

Content is a Next.js-authored block, self-describing:

<!-- BEGIN:nextjs-agent-rules -->
# This is NOT the Next.js you know
... Read the relevant guide in `node_modules/next/dist/docs/` ...
This block is written and re-added by `next dev` — verify at
`node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff
only re-creates the uncommitted change; committing it with your work keeps the tree clean.
<!-- END:nextjs-agent-rules -->

Verified on origin/main @ 502dc6fe7135:

  • git ls-files apps/docs | grep -iE 'AGENTS|CLAUDE' → nothing tracked
  • git check-ignore -v apps/docs/AGENTS.md apps/docs/CLAUDE.md → not ignored
  • grep -n agentRules apps/docs/next.config.mjs → not set
  • Neither file exists in a checkout that has not run next dev

Why it is worth a card

AGENTS.md and CLAUDE.md are load-bearing filenames in this repo — the root ones are the binding playbook, and agents are instructed to read the AGENTS.md governing the files they touch. A tool-generated stub at apps/docs/AGENTS.md that says "read node_modules/next/dist/docs/" is not this repo's discipline, and an agent working in apps/docs may read it as if it were.

The delivery risk is the ordinary one: any agent that boots the docs dev server and then runs git add -A (or git commit -a) lands both files in an unrelated PR. Nothing currently prevents that — no ignore rule, no gate. Note Next's own text actively argues for committing them, so an agent that reads the file before deciding is nudged the wrong way for this repo.

Options (not decided here — taxonomy call)

  1. Ignore them — add both paths to .gitignore (or apps/docs/.gitignore). Cheapest; keeps the tree clean for every agent; loses the Next guidance.
  2. Disable generationagentRules: false in apps/docs/next.config.mjs. Removes the surprise at the source; the files never appear.
  3. Track them deliberately — commit both, with a repo-authored header pointing at the real AGENTS.md so the stub cannot mislead. Highest effort; only worth it if the Next guidance is judged useful here.

My read is 2 or 1: the docs app is not where agents need Next-version guidance, and neither option costs anything to maintain. But which one is a devx-seat preference, not something to settle inside an unrelated nav card.

Repro: pnpm --filter @objectstack/docs dev (any port), then git status --porcelain.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions