
# AI export (--llms)

`--llms` writes, alongside the viewer, the [llms.txt](https://llmstxt.org/)
family — so language models and agents can read your documentation as plain
files instead of scraping a single-page app.

## What it emits

| File | Contents |
|------|----------|
| `llms.txt` | a link index: an `H1` title, a one-line summary, then one section per book listing every page as `- [title](md/…): description`, in TOC order |
| `llms-full.txt` | every page's Markdown inline (with provenance comments), for one-shot ingestion |
| `md/<docset>/<page>.md` | each page as clean Markdown, fetchable on its own |

## Where the Markdown comes from

The export uses each page's **original Markdown source** — the optional `md`
column a compiler may store. A docset that carries none falls back to
the page's plain text, so the export always works; it's just nicer with the real
source. Books compiled by the bundled `khb compile` carry it.

> [!NOTE]
> Nothing here is loaded by the viewer — these are extra static files sitting next
> to it (though the viewer does _link_ to them from a menu item; see
> [In the viewer](#in-the-viewer)). They are also written as plain text even under
> [`--mode compact`](pack-mode.md): they're meant to be fetched and read as-is.

## In the viewer

When the export is present, the viewer gains a **File → Copy links for LLMs** menu
item. It copies a small, paste-ready block for the page you're on: its title, the
page's `md/<docset>/<page>.md` URL **and** the in-app deep link, and a line pointing
at `llms.txt` for the full index — handy for handing a single page (or the whole
book) to a chat assistant.

The item keys off the same `<link rel="llms-txt">` discovery hook `pack` injects, so
it appears **only** on an `--llms` build — a dev server or a plain `pack` hides it,
and never offers links to files that don't exist.

## Why

A `.khb` is a SQLite database rendered by a client-side app — perfect for humans,
opaque to a crawler. The `--llms` export is the **static counterpart to a future
MCP server**: the same content as plain files any static host serves without a
backend, today.
