Skip to content

finding: next dev rewrites the tracked apps/docs/next-env.d.ts, so browser-verifying leaves a spurious diff #124

Description

@os-elon

Observation, found while verifying #97 — measuring which port npm run dev actually binds. Low severity: it breaks nothing, it plants a false-positive modification in the working tree of any agent who follows the AGENTS.md instruction to test in a real browser.

What happens

apps/docs/next-env.d.ts is tracked. .gitignore covers .next/ and .open-next/ but not this file. Next.js regenerates it, and dev mode and build mode write different content into it:

commandline written
next build, next typegen (what type-check runs)import "./.next/types/routes.d.ts";
next devimport "./.next/dev/types/routes.d.ts";

The committed version is the build variant. So starting the docs dev server flips a tracked file and git status reports a change nobody made:

 M apps/docs/next-env.d.ts
-import "./.next/types/routes.d.ts";
+import "./.next/dev/types/routes.d.ts";

Running any build-side command flips it back. That is why it never appears in CI, and never appears for an agent who only runs pnpm turbo run build.

Why it is worth recording

The file carries the comment // NOTE: This file should not be edited, so an agent who sees it modified has to work out that a tool did it, not them. The likely outcomes are both bad in a small way: git add -A sweeps the flip into an unrelated PR, or the agent spends time proving it was not their change. It lands specifically on agents who do the browser verification AGENTS.md asks for, which is the step the repository most wants performed.

Options, not a recommendation

  • Untrack it — add apps/docs/next-env.d.ts to .gitignore and git rm --cached it. Next regenerates it on every run and its own docs say it should not be hand-edited, so there is little value in a tracked copy that is wrong half the time. Worth checking first whether the Cloudflare deploy path or tsc --noEmit needs the file present before any Next command has run.
  • Keep it tracked, document the flip in AGENTS.md so the discard is expected rather than investigated.
  • Check whether a newer Next writes a mode-independent line, making this self-closing on the next upgrade.

Measured on 69204ab, Next 16.2.6, Node v22.22.2, in a clean worktree: tree clean after pnpm install, modified after pnpm --filter @objectos/docs dev, clean again after pnpm turbo run build.

Not folded into the port PR — that change is one line in AGENTS.md and this is a repository-tracking question with three routes behind it.

Checked for duplicates first: no open issue in this repository covers next-env.d.ts or the dev-server working-tree diff.


Generated by Claude Code

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions