A docs folder is a bad thing to hand a model cold. Dozens to thousands of markdown files, no ranking, no summary, no map — nothing crawls all of it and nothing should have to. llms.txt is the index you hand it instead: one file at your site root that names the project, summarizes it in a sentence, and lists the pages worth reading with a one-line description of each.
This guide is that script — a single dependency-free Node file that walks a docs directory and emits a spec-compliant llms.txt in one command. It's MIT-licensed, and the version printed below is the one we actually ran. For the wider context — where llms.txt sits alongside schema, rendering, and the rest of answer-engine work — it's chapter four of our AEO 101 guide; this is the build script that chapter points at.
Scope check: this is for teams with a real markdown corpus — Docusaurus, Nextra, Mintlify, VitePress, or a plain repo full of READMEs. If you run a marketing site with no docs folder to point a script at, there's nothing here to walk; use the form-based llms.txt generator instead and skip to the ship checklist.
Chapter 01What the file actually has to look like
llms.txt was proposed by Jeremy Howard (Answer.AI / fast.ai) and published September 3, 2024 at llmstxt.org. It's a community convention, not an RFC — no W3C, no IETF, no registry, no enforcement. That sets how much ceremony you owe it: none. Plain markdown, UTF-8, no HTML.
The structure is strict in order, loose in what's required:
- An optional byte-order mark.
- An H1 — the project or site name. This is the only mandatory element.
- A blockquote — one or two sentences on what this is.
- Zero or more free markdown sections for detail.
- Zero or more H2 "file list" sections — markdown link lists in the form
- [name](url): description.
## Optional sectionOne H2 carries defined meaning: a section literally titled ## Optional. Links under it are droppable — a consumer working against a tight context window may skip them for a shorter, cheaper read. Use it deliberately for the pages a model can live without.
Ship it at the root: /llms.txt. The spec also permits /.well-known/llms.txt, but root is what real implementations and Chrome's Lighthouse check, so root is where it goes. Keep the index lean — recommended under 50KB, hard cap 256KB. That's the short index. Its bigger cousin, llms-full.txt, is a separate convention: the entire corpus concatenated into one file, no links, no truncation. More on that below.
Chapter 02Does anyone actually read it in 2026?
Here's the honest answer, because we sell accuracy and it would be strange to oversell this.
- Not Google Search. Gary Illyes, at Google's Search Central Deep Dive APAC on July 23, 2025: "Google doesn't support LLMs.txt and isn't planning to." John Mueller has separately said no AI system currently relies on it for ranking — normal SEO is what feeds Google's AI Overviews.
llms.txtis not a search lever. Don't ship it expecting rankings to move. - Not the live chat crawlers, mostly. The bots that fetch pages while answering a user's question in real time — GPTBot, ClaudeBot, PerplexityBot, OAI-SearchBot, Google-Extended — overwhelmingly crawl your HTML directly and rarely reach for
/llms.txtmid-answer. Industry monitoring through 2026 putsllms.txtfetches in the low hundreds against crawl volumes in the hundreds of millions. (Those counts circulate across 2026 write-ups without tracing to a primary study — treat the ratio as directional, not gospel.) - But agents and IDEs do read it. This is the real audience. Cursor, Claude Code, Copilot, Windsurf, and MCP-based tooling fetch these files when working against a codebase or docs site. And Mintlify published first-party server-log data — the strongest concrete numbers going — tracking 25 companies over 7 days. The full file gets pulled roughly 5–6x more than the short index; agents prefer one dense file over chasing links.
- And Chrome now scores it. Lighthouse 13.3.0 (shipped May 7, 2026, on by default) added an "Agentic Browsing" audit category that checks for a valid
llms.txtat root. A retrievable, spec-shaped file passes; a server error fails; a plain 404 is marked not applicable, not a failure — the file is still optional.
| Metric (7 days, n=25 sites) | llms.txt | llms-full.txt |
|---|---|---|
| Median visits | 14 | 79 |
| Mean visits | 62 | 248 |
| Mintlify's own site | 436 | 967 |
Google's dev-tools org validating the file for agents while Google Search declines to rank on it is the whole 2026 status in one sentence.
Net: llms.txt is a cheap, real signal for the agent/IDE/MCP audience and a scored Lighthouse check. It is not a promise that ChatGPT will start describing you accurately tomorrow. Ship it because it costs almost nothing and someone real consumes it — not because a blog told you it moves answers.
See what models say about you
llms.txt reaches agents and IDEs. Model accuracy is a different question — the free scan checks it across ChatGPT, Gemini, and Perplexity.
Chapter 03The script
Five lines under the shebang, one job each:
- Import the three
node:fscalls it needs. - Read the docs directory and base URL from
argv. - Walk the tree for every
.md, and for each file lift the first H1 as the title and the first prose line as the description, formatted as a spec-compliant- [title](url): descriptionlink — then sort. - Write the H1 and blockquote header, then the sorted links, to
llms.txt. - Print the count.
The whole thing is Node 20+ (tested on v22.17.1), node:fs only, no npm install. readdirSync(root, { recursive: true }) is native in Node 20+, so there's no glob dependency to add — and building the read path with a template string means no node:path either.
#!/usr/bin/env node
import { readFileSync, readdirSync, writeFileSync } from "node:fs";
const [root = "docs", base = "https://example.com"] = process.argv.slice(2);
const links = readdirSync(root, { recursive: true }).filter((f) => f.endsWith(".md")).map((f) => { const t = readFileSync(`${root}/${f}`, "utf8"); return `- [${t.match(/^#\s+(.+)$/m)?.[1]?.trim() ?? f}](${base}/${f.replace(/\.md$/, "")}): ${t.match(/^#.+\n+([^\n#].+)/m)?.[1]?.trim().slice(0, 140) ?? ""}`; }).sort();
writeFileSync("llms.txt", `# ${process.env.SITE_NAME ?? "Docs"}\n\n> ${process.env.SITE_SUMMARY ?? "Add a one-line summary via SITE_SUMMARY."}\n\n## Docs\n\n${links.join("\n")}\n`);
console.log(`Wrote llms.txt (${links.length} links)`);Line 3 does the real work and it's dense on purpose — walk, title regex, description regex, format, sort, all chained. It takes the docs directory and base URL from argv, the site name and summary from environment variables, and its two regexes skip a YAML frontmatter block cleanly: a file that opens with ---
title: …
---
# Webhooks still resolves to the real H1 and first prose line, not the frontmatter fields. Verified against a fixture.
One command:
SITE_NAME="Acme Docs" SITE_SUMMARY="Acme is a widget API for developers." node gen-llms-txt.mjs docs https://docs.acme.com
Run against a four-file fixture — quickstart.md, pricing.md, api/reference.md, and one file carrying a frontmatter block — it writes 619 bytes:
# Acme Docs > Acme is a widget API for developers. ## Docs - [API Reference](https://docs.acme.com/api/reference): Complete endpoint reference for the v2 API, including auth, rate limits, and error codes. - [Pricing](https://docs.acme.com/pricing): Plans start at $19/month for the Starter tier and scale to custom enterprise pricing. - [Quickstart](https://docs.acme.com/quickstart): Get up and running with the API in under five minutes. Install the CLI, set your key, and run your first request. - [Webhooks](https://docs.acme.com/frontmatter-test): Receive real-time events for every order, refund, and dispute.
That validates against the spec: H1, blockquote, one H2 file-list section, links with descriptions. The frontmatter file resolved to its real # Webhooks H1, proving the title regex skips the YAML.
The extraction is deliberately dumb — first H1, first prose line. Good enough for most docs pages. The one case to spot-check before shipping: a page whose first paragraph is a warning or admonition rather than a summary. The script will happily lift "Deprecated: use the v2 endpoint instead" as your description. Read the generated file once and fix the two or three pages that misfire, by hand or by giving them a proper opening sentence.
Chapter 04Going further
llms-full.txt. Same walk, one change: in the map, instead of emitting a link, concatenate each file's full body under its own## {title}heading. A few lines' difference from the script above — and per Mintlify's data it's the file agents pull most, so generate it alongside the index, not instead of it.- Automate regeneration. A hand-maintained manifest rots exactly like an unmaintained sitemap. Run the script as a pre-commit hook or a CI step on every docs merge so
llms.txtnever drifts from the tree. It takes milliseconds, and it's the difference between a manifest that's true and one that's a year stale. - Filter and curate. Add knobs to exclude drafts and internal folders, and to cap total links if the tree is huge. The spec favors curation over completeness, and Mintlify's read on real implementations agrees: the good ones rank by how often a page is actually used and organize around workflows; the mediocre ones dump every page. Rank by frequency of use, not by totality.
Chapter 05Ship checklist
- File lives at site root,
/llms.txt. - It validates as clean markdown — H1 present, blockquote present, links resolve.
curl -sI yourdomain.com/llms.txtreturns200.- You've eyeballed the generated descriptions and fixed the admonition-block misfires.
- Regeneration runs on every docs change, via the hook or CI step above.
Once it's live, the honest next question isn't "is the file there" — Lighthouse answers that — it's "are the models saying true things about you." Different questions, and the second is the one that matters. Run a free AI Readiness Scan: three live models (ChatGPT, Gemini, Perplexity) checked against what your site actually says. And if you want the full picture of how we measure accuracy rather than mere presence, the methodology is public, formula by formula.
Get a free AI Readiness Scan
Three live models — ChatGPT, Gemini, Perplexity — checked against what your site actually says. Read the methodology, then see your score.