Skip to content

chore(next): commit the managed agent block and untrack next-env.d.ts - #816

Merged
d-oit merged 2 commits into
mainfrom
chore/next-generated-files-best-practice
Sep 24, 2026
Merged

d-oit merged 2 commits into
mainfrom
chore/next-generated-files-best-practice

Conversation

@d-oit

@d-oit d-oit commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Why

Two tracked files churned on every dev command, so the tree was dirty after any pnpm dev or pnpm build. Both are files Next.js owns, so I went to the official docs rather than picking a tidy-looking option.

What the official docs say

Agent rules block → commit it. nextjs.org/docs/app/guides/ai-agents: next dev auto-generates/upserts the managed block when it detects an agent, "content outside the managed block is preserved", and the block's own text says "committing it with your work keeps the tree clean." There is an opt-out (agentRules: false in next.config.ts), but the docs argue against it: "We believe leaving auto-generation on is a good default. Benchmark results on nextjs.org/evals show agents do better when they read the bundled docs." This repo relies on agents reading version-matched guidance, so the block stays.

next-env.d.ts → gitignore it, generate on demand. typescript config reference: "next-env.d.ts is managed by Next.js. Its contents are an implementation detail and may change over time. Add it to .gitignore." next CLI reference: "To ensure next-env.d.ts is present before type-checking run next typegen." The Next team confirmed the same in vercel/next.js#58877 — including this exact dev-vs-build import-path flip.

Changes

File Change
AGENTS.md managed block committed, produced by calling Next's own writeAgentFiles() (the function next dev calls) so it is byte-identical
.gitignore next-env.d.ts added, with the doc citation in a comment
next-env.d.ts untracked (git rm --cached)
package.json typecheck → next typegen && tsc --noEmit -p tsconfig.app.json

Not changed: agentRules: false (docs recommend against), and lint/test (neither needs the file — verified by deleting it and running both).

Verification

Check Result
hasCurrentAgentRules(repo) before → after false → true (so next dev skips the write entirely)
writeAgentFiles(repo) re-run unchanged
git status after next build clean — no AGENTS.md, no next-env.d.ts
pnpm run typecheck with the file deleted regenerates via next typegen (0.95 s), tsc exit 0
pnpm run lint, vitest type-tested files, both without the file exit 0 / 146 passed, no type errors
Fresh-checkout simulation (git worktree add from this branch, shared node_modules, no .next, no next-env.d.ts) typecheck ✓, lint ✓, hasCurrentAgentRules ✓, full quality gate ✓
pnpm run build ✓

The fresh-checkout run is the one that matters: CI starts from a clone with neither file present, and now regenerates what it needs instead of relying on a committed artifact.

Plan: plans/150-next-generated-files-official-practice-2026-09-24.md. Post-merge check: the next Vercel production deploy runs next build, which writes its own next-env.d.ts (plans/098's lesson — verify the deployed commit, not the PR).


📝 Summary by GitNexus

Summary

This appears to be a build and repository-configuration maintenance change, centered on generated Next.js files and project guidance. Its graph reach is contained, with no dependent or execution-flow impact reported.

🟡 MEDIUM blast radius. A build-configuration and repository-maintenance change across .gitignore, next-env.d.ts, package.json, AGENTS.md, and plans/150-next-generated-files-official-practice-2026-09-24.md, with no graph dependents.

The symbol changes are concentrated in AGENTS.md, specifically Verify build passes locally, Skills, and Available Skills. Review the managed-agent guidance alongside the generated-file handling in .gitignore, next-env.d.ts, and package.json.

No affected flows or cross-repo consumers were found. The file-level risk is MEDIUM, with no HIGH or CRITICAL risk files.

Added by GitNexus for PR #816. Edit freely — this block is replaced on the next review, everything above it is left untouched.

@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
do-knowledge-studio Ready Ready Preview, v0 Sep 24, 2026 1:54pm UTC

@github-actions github-actions Bot added documentation Documentation improvements config labels Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Blocked merge diagnosis — blocked
⏳ Check run(s) still in progress: ["Codacy Static Code Analysis","Detect Changes","labeler","Diagnose Blocked Merge State","Secret Detection","Trivy Filesystem Security Scan","Infrastructure as Code Security","commitlint","Shell Script Security Analysis","Analyze (javascript-typescript)","Analyze (actions)"]

@nexuscheck

nexuscheck Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor
Akon Labs

GitNexus Review · PR #816

GitNexus reviewed 5 changed files.

🤖 Agent context — 3 symbols · 5 files

Summary

This appears to be a build and repository-configuration maintenance change, centered on generated Next.js files and project guidance. Its graph reach is contained, with no dependent or execution-flow impact reported.

🟡 MEDIUM blast radius. A build-configuration and repository-maintenance change across .gitignore, next-env.d.ts, package.json, AGENTS.md, and plans/150-next-generated-files-official-practice-2026-09-24.md, with no graph dependents.

The symbol changes are concentrated in AGENTS.md, specifically Verify build passes locally, Skills, and Available Skills. Review the managed-agent guidance alongside the generated-file handling in .gitignore, next-env.d.ts, and package.json.

No affected flows or cross-repo consumers were found. The file-level risk is MEDIUM, with no HIGH or CRITICAL risk files.

🟡 MEDIUM blast radius — no downstream dependents were found in the code graph; a spot-check of the dependents should cover it.

Blast Level Dependents Modules Files
🟡 MEDIUM 0 0 5

What changed

Symbol Changes (3)
Kind Symbol Location
Section Verify build passes locally AGENTS.md:267
Section Skills AGENTS.md:340
Section Available Skills AGENTS.md:347
Changed Files (5)
File Status
.gitignore 🟡 modified
AGENTS.md 🟡 modified
next-env.d.ts 🔴 removed
package.json 🟡 modified
plans/150-next-generated-files-official-practice-2026-09-24.md 🟢 added

What to check

File Risk (3)
File Risk Category
.gitignore 🟢 LOW Dev Tooling
package.json 🟡 MEDIUM Dependencies
plans/150-next-generated-files-official-practice-2026-09-24.md 🟢 LOW Documentation

Full detail lives in the GitNexus check run for this commit.

@codacy-production

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@d-oit
d-oit merged commit 1bba386 into main Sep 24, 2026
25 checks passed
@d-oit
d-oit deleted the chore/next-generated-files-best-practice branch September 24, 2026 14:03

This branch was successfully deployed

1 active deployment
Preview — d075d858 Deployed Sep 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config documentation Documentation improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants