Skip to content

chore: untrack apps/docs/next-env.d.ts - #134

Merged
os-elon merged 1 commit into
mainfrom
claude/issue-124-untrack-next-env
Aug 19, 2026
Merged

chore: untrack apps/docs/next-env.d.ts#134
os-elon merged 1 commit into
mainfrom
claude/issue-124-untrack-next-env

Conversation

@os-elon

@os-elon os-elon commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Fixes #124

Untrack apps/docs/next-env.d.ts — the untrack route adjudicated in the triage comment on the issue.

Next.js regenerates this file inside its own commands, and it writes a different variant per mode: next build and next typegen write the .next/types/routes.d.ts import, next dev writes the .next/dev/types/routes.d.ts one. The committed copy was the build variant, so starting the docs dev server flipped a tracked file whose own header says it must not be edited — a git add -A trap landing precisely on agents doing the browser verification AGENTS.md asks for.

Diff is two files: one .gitignore line (plus a comment) and the index removal. The file stays on disk; only the index entry goes.

The premise was verified first, in a genuinely fresh clone

Triage made this a fork, not a fallback: from a clean tree with the file absent, the type-check path and the Cloudflare deploy path must still work. Measured in a fresh git clone of this branch (file absent, no .next/, then pnpm install --frozen-lockfile) — not in the warm worktree, where git rm --cached leaves the file on disk and hides the question:

check, in the fresh clone result
pnpm install --frozen-lockfile (runs the fumadocs-mdx postinstall) exit 0 — and it does not create the file; state after install is genuinely file-absent
bare tsc --noEmit, no Next command run at all, file absent exit 0 (1768 files in the program, 16 app sources)
same, with the previously tracked copy restored exit 0 — identical, so the tracked copy was never load-bearing
pnpm turbo run type-check --continue --force exit 0; next typegen regenerates the file before tsc runs
pnpm turbo run build --force exit 0
pnpm turbo run test --force exit 0
pnpm exec opennextjs-cloudflare build from a pristine tree (the deploy script's first half) exit 0; next build regenerates the file inside it

The bare-tsc legs were run non-incrementally, and the run was shown able to go red (an injected TS2322 in apps/docs/lib/i18n.ts, then reverted) — an exit 0 from a tsc that cannot fail would prove nothing.

One limit, stated plainly: the upload half, opennextjs-cloudflare deploy, was not executed — it needs CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID, which this environment does not have. It was verified from configuration and CLI source instead: deployCommand consumes the compiled OpenNext config and .open-next/ artifacts and shells out to wrangler deploy; wrangler.jsonc points main at .open-next/worker.js and assets at .open-next/assets. Nothing on that path reads the app's next-env.d.ts. (The next-env string that does appear in @opennextjs/cloudflare is next-env.mjs, its generated env-vars module — unrelated.)

Before/after, reproduced rather than asserted

The issue measured the flip on 69204ab; reproduced here on current main (0246b2f), same triple:

after pnpm install:                          (clean)
after pnpm --filter @objectos/docs dev:       M apps/docs/next-env.d.ts
after pnpm turbo run build --force:          (clean)

with the diff being exactly the routes-import line flipping to its .next/dev/ form.

After this change, the same dev-server run (next dev on port 3124, Ready, /docs served HTTP 200), then:

git status --porcelain   ->  (empty)
git add -A --dry-run     ->  (empty)

while the file on disk had in fact flipped to the dev variant. That is the deliverable's proof: the file still changes, and git no longer notices.

Notes

  • Not chased, per the dispatch: the third option in the issue (a newer Next writing a mode-independent line). One data point in passing — in Next 16.2.6 the written path is path.posix.join(distDir, 'types/routes.d.ts') in writeAppTypeDeclarations, and dev mode's distDir is .next/dev. The flip follows Next 16's separate dev dist directory, so it does not read like something a patch release removes.
  • AGENTS.md deliberately untouched — governed surface, and PR docs(agents): correct the documented docs dev-server port to 3000 #123 is awaiting the maintainer there.

Gates run at 343fbaf: pnpm install --frozen-lockfile (0), pnpm turbo run type-check --continue --force (0), pnpm turbo run build --force (0), pnpm turbo run test --force (0), check-translations.mjs (0), check-translation-ownership.mjs --actor os-elon (0), check-translation-output.mjs --files (0) and --self-test (0). Changed-file list for the translation gates was computed against the real origin/main merge-base (0246b2f): .gitignore, apps/docs/next-env.d.ts.


Generated by Claude Code

Next.js regenerates this file inside its own commands and writes a different
variant per mode: `next build` / `next typegen` write
`import "./.next/types/routes.d.ts";` while `next dev` writes
`import "./.next/dev/types/routes.d.ts";`. The tracked copy is the build
variant, so running the docs dev server flips a tracked file that the file's
own header says must not be edited.

Add it to .gitignore and drop it from the index. Nothing checks it in from a
fresh clone: `type-check` runs `next typegen` before `tsc --noEmit`, and the
Cloudflare deploy path runs `next build` inside `opennextjs-cloudflare build`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Yaqu7kmKZM3tRPd9Y4xivo
@os-elon
os-elon marked this pull request as ready for review August 19, 2026 00:57
@os-elon
os-elon merged commit 64d4b55 into main Aug 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants