Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llms-txt-generator

Generate spec-compliant llms.txt and llms-full.txt files from any website or sitemap — so LLMs and AI agents read your content the way you intend, instead of guessing from raw HTML.

License: MIT Node

Hosted, no-install version: https://rapidwombat.com/llms-txt-generator This CLI is the open-source core of that tool. Run it locally, wire it into CI, or use the hosted UI — same pipeline either way.


What is llms.txt, and why generate one?

llms.txt is a small, predictable Markdown file at the root of your site (/llms.txt) that gives language models a clean, curated map of your content. Think of it as robots.txt and sitemap.xml, but written for reading comprehension rather than crawling:

  • llms.txt — a curated index: title, one-line summary, and a sectioned list of your most important URLs with short descriptions.
  • llms-full.txt — the same pages expanded to clean Markdown, concatenated into one file an agent can load wholesale.

As discovery shifts from blue links to AI answers (ChatGPT, Claude, Perplexity, Google AI Overviews), the practice of structuring content for machine readers has picked up names — Generative Engine Optimization (GEO), Answer Engine Optimization (AEO), AI-readiness. llms.txt is the most concrete, standards-track piece of that puzzle. This tool builds one for you.

Want the bigger picture — schema, llms.txt, AI-crawler access, and the rest of a 2026 AI-readiness checklist scored against your live site? Run a free scan with the RapidWombat site audit.


Install

# Run without installing
npx llms-txt https://example.com

# Or add to a project
npm install --save-dev llms-txt-generator

Requires Node.js ≥ 18.17 (uses the built-in fetch).

Usage (CLI)

# Simplest: discover via sitemap.xml, write ./llms.txt and ./llms-full.txt
npx llms-txt https://example.com

# Curate sections and mark low-priority paths as "Optional"
npx llms-txt https://example.com \
  --out ./public \
  --title "Example Docs" \
  --summary "Everything an AI agent needs to use Example." \
  --optional /blog,/changelog,/tag

# Print the index to stdout (good for piping / diffing in CI)
npx llms-txt https://example.com --stdout
Flag Description Default
--out <dir> Output directory .
--title <text> # Title line hostname
--summary <text> > summary blockquote —
--optional <p1,p2> Path prefixes listed under ## Optional —
--max-pages <n> Max pages to fetch 200
--delay <ms> Delay between requests (politeness) 250
--concurrency <n> Concurrent requests 4
--user-agent <ua> Custom User-Agent tool UA
--no-robots Ignore robots.txt (sites you own only) off
--stdout Print llms.txt instead of writing files off

Usage (programmatic)

import { generate } from "llms-txt-generator";

const { llmsTxt, llmsFullTxt, pages, skipped } = await generate({
  site: "https://example.com",
  title: "Example Docs",
  summary: "Everything an AI agent needs to use Example.",
  optionalPrefixes: ["/blog", "/changelog"],
  maxPages: 100,
});

// llmsTxt        -> write to /public/llms.txt
// llmsFullTxt    -> write to /public/llms-full.txt
// pages[].words  -> per-page word counts for token budgeting
// skipped[]      -> { url, reason } for anything excluded (robots, cross-origin, ...)

You can also use the building blocks directly: extract(html, url), buildLlmsTxt(...), buildLlmsFullTxt(...).

Output shape

llms.txt follows the specification exactly:

# Example Docs

> Everything an AI agent needs to use Example.

## Docs

- [Getting started](https://example.com/docs/start): Install and first run.
- [API reference](https://example.com/docs/api): Every endpoint and type.

## Optional

- [Launch week recap](https://example.com/blog/launch): Narrative blog post.

The ## Optional section is special: agents on a tight token budget can drop everything in it and still have the core of your site.

How it works

sitemap.xml ──► fetch (polite, robots-aware) ──► extract readable Markdown ──► assemble
   discover            src/fetch.ts                    src/extract.ts          src/generator.ts
  1. Discover — read sitemap URLs from robots.txt / /sitemap.xml, recursing through sitemap-index files (src/sitemap.ts).
  2. Fetch — same-origin, rate-limited, and respecting robots.txt by default (src/fetch.ts).
  3. Extract — strip nav/chrome, pick the densest content container, and convert it to faithful Markdown (src/extract.ts).
  4. Assemble — group by URL section, render spec-compliant link lists, and build the full-content companion file (src/generator.ts).

See docs/METHODOLOGY.md for the design rationale, the parts of the llms.txt spec we implement, and how we keep extraction faithful and low-noise.

Develop

npm install
npm run build      # tsc -> dist/
npm test           # node:test, no network required
node examples/generate.mjs https://example.com

Good-citizen defaults

  • Respects robots.txt unless you pass --no-robots for a site you own.
  • Rate-limited and same-origin only.
  • Sends an honest, identifiable User-Agent (llms-txt-generator/0.1 (+https://rapidwombat.com/llms-txt-generator)).

Related

Contributing

Issues and PRs welcome. Run npm test and npm run lint before submitting.

License

MIT © RapidWombat

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages