MCPcopy
hub / github.com/vercel/next.js / generateClaudeMdIndex

Function generateClaudeMdIndex

packages/next-codemod/lib/agents-md.ts:250–273  ·  view source on GitHub ↗
(data: ClaudeMdIndexData)

Source from the content-addressed store, hash-verified

248}
249
250export function generateClaudeMdIndex(data: ClaudeMdIndexData): string {
251 const { docsPath, sections, outputFile } = data
252
253 const parts: string[] = []
254
255 parts.push('[Next.js Docs Index]')
256 parts.push(`root: ${docsPath}`)
257 parts.push(
258 'STOP. What you remember about Next.js is WRONG for this project. Always search docs and read before any task.'
259 )
260 const targetFile = outputFile || 'CLAUDE.md'
261 parts.push(
262 `If docs missing, run this command first: npx @next/codemod agents-md --output ${targetFile}`
263 )
264
265 const allFiles = collectAllFilesFromSections(sections)
266 const grouped = groupByDirectory(allFiles)
267
268 for (const [dir, files] of grouped) {
269 parts.push(`${dir}:{${files.join(',')}}`)
270 }
271
272 return parts.join('|')
273}
274
275function collectAllFilesFromSections(sections: DocSection[]): string[] {
276 const files: string[] = []

Callers 1

runAgentsMdFunction · 0.90

Calls 4

groupByDirectoryFunction · 0.85
pushMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected