next.js
c6c7eae0 - create-next-app: write agent feedback block to AGENTS.md when enabled (#99813)

Commit
3 days ago
create-next-app: write agent feedback block to AGENTS.md when enabled (#99813) ### What When `experimental.agentFeedback` is enabled, create-next-app now writes the `nextjs-agent-feedback` block into `AGENTS.md` along with the `nextjs-agent-rules` block. ### Why Before this change, create-next-app enabled the flag in `next.config.ts` but only wrote the rules block. The feedback block was added later by `next dev`, and only when `@vercel/detect-agent` found a coding agent (`syncAgentFeedbackForDev` in `app-info-log.ts`). As a result: - An agent that read `AGENTS.md` before running `next dev` never saw the feedback instructions. - The block then appeared as an uncommitted `AGENTS.md` change on top of the "Initial commit from Create Next App". ### How - `generateAgentFiles(root, { agentFeedback })` adds the feedback block after the rules block. The text is copied from `packages/next/src/server/lib/generate-agent-files.ts`, with a comment saying to keep them in sync. `next dev` compares the block byte-for-byte. - `create-app.ts` passes `agentFeedback: !example && agentFeedback`, because examples don't get `experimental.agentFeedback` written to their config. - `--no-agents-md` still writes no `AGENTS.md`. ### Verification I ran the new helper next to `next dev`'s `writeAgentFiles` + `writeAgentFeedbackFiles`, with the flag on and off: - The output is byte-identical in both cases. - `hasCurrentAgentRules` / `hasCurrentAgentFeedback` return true on create-next-app's output. - Running `next dev`'s writers again on that output returns `unchanged`. Tests in `test/production/create-next-app/index.test.ts`: - `--agents-md --agent-feedback` writes the rules block, then the feedback block, and `next dev`'s `writeAgentFiles` / `writeAgentFeedbackFiles` both report `unchanged`. This catches drift between the two copies of the text. - `--agents-md --no-agent-feedback` writes only the rules block. - `--no-agents-md --agent-feedback` creates no `AGENTS.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Author
Parents
Loading