Skip to main content
Glama
README.md
# botglass

See your site exactly as AI crawlers see it.

AI crawlers fetch your HTML and never run JavaScript. A React, Next.js or Vue page can
look finished to you and near-empty to GPTBot, ClaudeBot and PerplexityBot. `botglass`
fetches the same URL as a normal browser and as eight crawlers, compares the text each
one actually receives, checks robots.txt per bot, and prints one verdict per crawler.

No account, no API key, no dashboard, no telemetry. One command, plain HTTP.

It also reads **`Content-Usage`** training preferences in robots.txt, separately from
crawl permission. HTTP response-header preferences are not measured; see the scope below.

## Hand it to your agent

Two ways. As a shell command your agent runs:

```text
Check whether AI crawlers can read our site. Run:

  npx -y botglass <URL> --render --compact

Summarise the verdicts in two sentences and list the fixes it gives.
After we deploy a fix, run the same command again with --baseline .botglass.json
and tell me exactly what changed since the previous run.
```

Or as an MCP server, so the agent calls it as a tool. Add this to your MCP config
(Claude Code: `claude mcp add botglass -- npx -y botglass mcp`;
Cursor and others: the same command in `.cursor/mcp.json` / `mcp.json`):

```json
{
  "mcpServers": {
    "botglass": {
      "command": "npx",
      "args": ["-y", "botglass", "mcp"]
    }
  }
}
```

It exposes two tools: `audit_url` (one page) and `audit_sitemap` (up to 50 pages), both
returning the compact verdicts and fixes. Stdio only; nothing listens on a port.

`--compact` keeps the answer small enough to read in context; `--baseline` turns the
second run into proof that the fix worked.

## Quick start

```bash
npx botglass https://example.com
```

Requires Node 20 or newer. To install globally instead:

```bash
npm install -g botglass
botglass https://example.com
```

From a clone, when you want to change the code:

```bash
git clone https://github.com/yardworkdev/botglass
cd botglass
npm install
npm test          # builds, then runs the whole suite
node dist/src/cli.js https://example.com
```

## What it prints

Real output, from `botglass https://excalidraw.com https://nextjs.org --render` (the
nextjs.org rows are trimmed):

```
botglass 0.3.0  2 page(s), 8 bots, render on

https://excalidraw.com/
  HTTP 200, 3 words in raw HTML, 80 words rendered
  bot                status  words  verdict         note
  GPTBot             200     3      js-dependent    raw HTML carries 3 of the 80 words a browser renders (96% missing)
  OAI-SearchBot      200     3      js-dependent    raw HTML carries 3 of the 80 words a browser renders (96% missing)
  ChatGPT-User       200     3      js-dependent    raw HTML carries 3 of the 80 words a browser renders (96% missing)
  ClaudeBot          200     3      js-dependent    raw HTML carries 3 of the 80 words a browser renders (96% missing)
  PerplexityBot      200     3      js-dependent    raw HTML carries 3 of the 80 words a browser renders (96% missing)
  CCBot              200     3      js-dependent    raw HTML carries 3 of the 80 words a browser renders (96% missing)
  Googlebot          200     3      js-dependent    raw HTML carries 3 of the 80 words a browser renders (96% missing)
  meta-externalagent 200     3      js-dependent    raw HTML carries 3 of the 80 words a browser renders (96% missing)

https://nextjs.org/
  HTTP 200, 653 words in raw HTML, 619 words rendered
  GPTBot             200     653    ok              server-rendered content, bot allowed
  ClaudeBot          200     653    ok              server-rendered content, bot allowed
  ...
```

The exit code stays 0 until you ask for a gate with `--fail-on` or `--max-js-only`.

## Verdicts

| verdict | meaning | how it is decided |
| --- | --- | --- |
| `ok` | the crawler gets the page | 2xx, robots allows it, text matches a browser |
| `js-dependent` | content arrives only after JavaScript | measured with `--render` (raw text under half of the rendered text, rendered page at least 50 words), otherwise a labelled heuristic (near-empty body plus an app mount node) |
| `cloaked` | the crawler gets different text than a browser | 5-word-shingle Jaccard similarity below 0.5, both versions at least 30 words, crawler sees less text |
| `robots-blocked` | robots.txt forbids this crawler here | RFC 9309 matching: longest path wins, `Allow` wins ties, `*` groups respected |
| `ua-blocked` | the server refuses the crawler | 401/403/406/429/451 for the bot while a browser gets 2xx |
| `error` | nothing useful to say about the content | fetch failure or the URL fails for a browser too |

Every verdict carries the numbers that produced it, and the JSON and HTML reports keep
`confidence: "measured"` or `"heuristic"` so a heuristic is never mistaken for a fact.

## AI usage preferences (`Content-Usage`)

robots.txt used to answer one question: may this crawler fetch this page? The `Content-Usage`
signal in the IETF `aipref` draft answers a second one: may this content be used for training?
Anthropic, OpenAI, Google and Microsoft committed to it in November 2026.

```txt
User-agent: *
Allow: /
Content-Usage: train-ai=n, search=y
```

Crawl permission and usage preferences answer different questions. Allowing retrieval
while declining training is valid; botglass does not recommend blocking search or other
retrieval just because `train-ai=n` is declared.

botglass reads **robots.txt only**. It does not inspect HTTP `Content-Usage` response
headers, which are another attachment mechanism defined by the draft. A missing robots.txt
preference therefore does not establish that the page has no preference.

The audit and index resolve usage for the **generic baseline crawler**, not separately for
every bot. Bot-specific Content-Usage groups may therefore differ from the displayed value.
The resolver follows the attachment draft's worked path examples and separates crawl
permission from usage. Explicit preference tokens in the current vocabulary are `y` and `n`;
other values mean unknown, not “contact the owner”. `--compact` carries the resolved
robots.txt training preference as `trainAi`. This is a draft-specific implementation, not
a claim of complete Structured Fields conformance or provider compliance.

## Crawlers it imitates

GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, PerplexityBot, CCBot, Googlebot,
meta-externalagent — plus a plain Chrome baseline. `--list-bots` prints the set.
User-Agent strings come from each vendor's public documentation and the `docs` URL is in
`src/bots.ts`.

## Options

```bash
botglass <url> [options]
botglass <url> <url> [options]   # several URLs in one run

--sitemap <url|file>   Audit every URL in a sitemap (index files are followed)
--urls <file>          Audit a newline-separated URL list (# comments allowed)
--max-pages <n>        Cap the number of pages audited (default 10)
--bots <a,b>           Only these crawlers (default: all)
--render               Also render with JavaScript (needs Playwright)
--samples              Print the first missing sentences for js-dependent pages
--json <file>          Write the full report as JSON
--html <file>          Write a standalone HTML report
--compact              Agent-sized output: verdicts and fixes, no page text
--baseline <file>      Compare against a saved baseline and list what changed
--update-baseline      Overwrite the baseline file with this run
--fail-on <verdicts>   Comma-separated verdicts that should exit 1
--max-js-only <0..1>   Fail when more than this share of rendered text is JS-only
--timeout <ms>         Per-request timeout (default 15000)
--delay <ms>           Delay between requests to the same host (default 400)
--concurrency <n>      Pages audited in parallel (default 1)
--no-robots            Skip robots.txt
--no-color             Plain output even on a TTY
--quiet                Write no terminal report
--list-bots            Print the crawler identities and exit
```

## Batch mode

```bash
botglass --sitemap https://example.com/sitemap.xml --max-pages 50 --html report.html
botglass --urls pages.txt --bots GPTBot,ClaudeBot --json report.json
```

Requests go out one page at a time by default with a 400 ms gap, so a run does not look
like an attack. Raise `--concurrency` only when you own the site.

## Rendering once, measuring properly

`--render` uses Playwright to load the page in Chromium and compare the rendered text with
the raw HTML. It is not installed by default:

```bash
npm install --save-dev playwright
npx playwright install chromium
botglass https://example.com --render --samples
```

Without Playwright the tool still runs; `js-dependent` then comes from the shell heuristic
and says `confidence: "heuristic"`.

## CI

```yaml
- name: Crawler visibility gate
  run: npx -y botglass https://example.com --fail-on ua-blocked,error,cloaked
```

Exit codes: `0` pass, `1` gate failed, `2` usage or runtime error. `--json` writes a
report you can archive; `--html` writes one a human can read without the tool.

## Proving a fix

The first run tells you what is wrong. The second run proves it changed.

```bash
botglass https://example.com --render --baseline .botglass.json   # writes it
# ...deploy the fix...
botglass https://example.com --render --baseline .botglass.json   # compares, then updates
```

```
Changes since yesterday: 2
  https://example.com/
     ClaudeBot: ok → js-dependent
     ClaudeBot: 80 → 3 words
```

The baseline file holds verdicts and word counts only — never page text — so it is safe to
commit or keep in CI. `--update-baseline` overwrites it; plain `--baseline` also refreshes
it after comparing, so the next run measures against the newest state.

## Limits (read these)

- **User-Agent is a claim, not a proof.** A site that blocks real GPTBot by IP range will
  still answer a request that merely says `User-Agent: GPTBot`. `botglass` tells you what
  the server does with that identity, which is what a crawler-visible content problem
  usually depends on.
- **robots.txt is parsed, not obeyed.** The tool fetches anyway, because seeing whether the
  server enforces its own rules is useful. A compliant crawler would stop at the block.
- **`cloaked` and shell-based `js-dependent` are heuristics.** They name the numbers behind
  them; if the numbers look wrong, the verdict is wrong. `--render` moves `js-dependent`
  from heuristic to measured.
- **One fetch is a snapshot.** CDNs, A/B tests and bot management change answers. The
  report prints the fetch time for that reason.
- **JavaScript-rendered text is not "visible to crawlers".** Googlebot renders JS; GPTBot,
  ClaudeBot and PerplexityBot do not. A green Googlebot row does not help the others.

## Development

```bash
npm install
npm test              # 140 tests: unit, fixture-server integration, real CLI subprocess
npm run build         # tsc -> dist/
```

The test suite starts a local fixture server with a server-rendered page, a client-only
shell, a page that cloaks per User-Agent, a bot-only 403, a robots-blocked path, a redirect
and a 404, then asserts every verdict and the CLI exit codes against it. No network access
is needed to run the tests.

Layout: `src/audit.ts` (verdict rules, pure), `src/robots.ts`, `src/html.ts`,
`src/diff.ts` (shingles and missing sentences), `src/report/` (text, HTML, gate),
`src/cli.ts` (arguments and exit codes).

## Sample report

[docs/index.html](docs/index.html) — two live pages, eight bots, rendering on.

## AI Access Index

[The November 2026 edition](https://yardworkdev.github.io/botglass/ai-access-index/) measures the
300 most-visited domains on the web: who blocks which AI crawler, who declares a
`Content-Usage` preference, and how many homepages have no server-rendered text at all.
Raw data sits next to it as JSON.

Reproduce or extend it:

```bash
node scripts/ai-access-index.mjs --domains tranco.csv --limit 300 --out docs/ai-access-index
```

`tranco.csv` is any `rank,domain` file — the [Tranco list](https://tranco-list.eu/) works. The
run makes two requests per domain, sends `botglass` as its User-Agent, and takes about a
minute at the default concurrency.

## License

MIT. See [LICENSE](LICENSE).