Files
next.js/packages/create-next-app/helpers/generate-agent-files.ts
Jude GaoandGitHub 8d418beb48 [create-next-app] Improve AGENTS.md prompt wording (#90118)
Updates the `AGENTS.md` content generated by `create-next-app` to use
clearer wording that better signals to models that their training data
may be outdated.

The prompt wording was determined by running evals continuously until we
found a prompt that is objectively unbiased and shows no signs of
regression on any tests across all models.

**Before:**
> Next.js: ALWAYS read docs before coding
> Before any Next.js work, find and read the relevant doc in
`node_modules/next/dist/docs/`. Your training data is outdated — the
docs are the source of truth.

**After:**
> This is NOT the Next.js you know
> This version has breaking changes — APIs, conventions, and file
structure may all differ from your training data. Read the relevant
guide in `node_modules/next/dist/docs/` before writing any code. Heed
deprecation notices.
2026-02-18 06:42:13 -08:00

25 lines
872 B
TypeScript

import fs from 'fs'
import path from 'path'
/**
* Generate AGENTS.md and CLAUDE.md in the project root.
* AGENTS.md contains the instructions, CLAUDE.md references it using @ syntax.
*/
export function generateAgentFiles(root: string): void {
const agentsMdContent = `<!-- BEGIN:nextjs-agent-rules -->
# This is NOT the Next.js you know
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in \`node_modules/next/dist/docs/\` before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->
`
const claudeMdContent = `@AGENTS.md
`
const agentsMdPath = path.join(root, 'AGENTS.md')
const claudeMdPath = path.join(root, 'CLAUDE.md')
fs.writeFileSync(agentsMdPath, agentsMdContent, 'utf-8')
fs.writeFileSync(claudeMdPath, claudeMdContent, 'utf-8')
}