Technical SEO

Robots.txt skill: validate, generate and audit

The robots.txt skill helps you manage how search engines and AI bots crawl your website. You can validate an existing robots.txt to detect syntax errors and logical issues, generate one from scratch adapted to your CMS, or audit it with SEO criteria to identify dangerous blocks, crawl budget problems or incorrect directives. Compatible with WordPress, Shopify, static sites and any technology.

$ https://github.com/jorgejaramillo/seoskills/blob/master/robots/SKILL.md
---
name: robots-txt
description: >
  Validates, audits and generates robots.txt files for SEO and AI bots. Use it when the
  user mentions robots.txt, crawl directives, blocking bots (GPTBot, ClaudeBot,
  PerplexityBot…), crawl budget, or pastes a robots.txt and asks "is this OK?".
  Works with any CMS.
---

# robots.txt

Three modes: **audit** the published robots.txt, **validate** a draft, **generate** a new one.
All three end in the report. robots.txt is small: read it in full, no script needed.

## When to use

- "Check my robots.txt" / "why isn't Google crawling X?" → audit.
- The user pastes a robots.txt → validate.
- "Make me a robots.txt" / "block the AI bots" → generate, then validate with the same steps.

## Inputs

1. Domain (or the robots.txt text if they paste it).
2. To generate: platform (WordPress, Shopify, Next…) and **AI policy** (block training, block everything, allow everything). robots.txt **only denies access**: the "allow" option is not written, it is omitted — the absence of rules already allows everything. If they don't mention it, don't add AI blocks.
3. Optional: paths the user wants to check.

## Flow

### 1. Data

```bash
D=example.com
curl -sL -o /dev/null -w 'HTTP %{http_code} · %{size_download} bytes · %{url_effective}\n' "https://$D/robots.txt"
curl -sL "https://$D/robots.txt"
```

For each `Sitemap:` line, check that it responds and grab a sample of URLs to test:

```bash
SM=https://example.com/sitemap.xml
curl -sL -o /dev/null -w '%{http_code}\n' "$SM"
curl -sL "$SM" | grep -oE '[^<]+' | sed 's///' | head -30
```

If it's a sitemap index (``), repeat the second command with 1–2 child sitemaps.

### 2. How to read it (Google semantics, RFC 9309)

**Syntax**
- Valid directives: `User-agent`, `Allow`, `Disallow`, `Sitemap`, `Crawl-delay` (Google ignores it). Anything else is an error.
- A group = one or more consecutive `User-agent` lines plus their rules. A rule before any `User-agent` is an error.
- Directives are case-insensitive; **paths are case-sensitive** (`/Admin/` ≠ `/admin/`).
- Empty `Disallow:` = allow everything. `Sitemap:` is independent of the groups and must be an absolute URL.
- HTTP status: 404 = everything allowed · 5xx = Google stops crawling the site · >500 KiB = Google ignores the rest.

**Which group applies to a bot**
- The group whose `User-agent` most specifically matches the bot's name (case-insensitive) is used.
- If a bot has its own group, it **completely ignores** the `*` group (they don't combine). Google does combine several groups with the same user-agent.

**Which rule wins for a URL** (test path + query, e.g. `/productos?orden=precio`)
1. Take all the rules from the group whose pattern matches the **start** of the path. `*` = any sequence; `$` at the end = end of the URL.
2. The **longest pattern** (in characters) wins.
3. On a tie, `Allow` wins. No matching rules → allowed.

Example: `Disallow: /cart` + `Allow: /cart/public$` → `/cart/x` blocked, `/cart/public` allowed, `/cart/public/x` blocked.

### 3. Analysis (Claude)

Check, in this order:
1. **Indexing**: apply Googlebot's rules to the sitemap sample and the user's paths. Any blocked sitemap URL is a high or critical finding. Are the CSS/JS needed for rendering blocked?
2. **Sitemaps**: declared, absolute URL, respond 200, and contain the pages that exist.
3. **Crawl budget**: internal search, filters/facets, and sorting parameters left unblocked on large sites.
4. **AI bots**: for each bot in the reference table, decide whether it is **blocked** (`Disallow`) or has no rules of its own (uses `*`). Never write rules to "allow" a bot: with no rule it is already allowed by default. Typical mistake: blocking search bots when the goal was to block only training.
5. **Security**: sensitive paths exposed (robots.txt is public).
6. **Misunderstandings**: `Disallow` is not `noindex`; blocking a URL stops Google from seeing its canonical or noindex.

**Reference bots (2026)**

| Type | Bots |
|------|------|
| AI training | GPTBot, ClaudeBot, anthropic-ai, Google-Extended, Applebot-Extended, CCBot, Bytespider, Meta-ExternalAgent, FacebookBot, Amazonbot, cohere-training-data-crawler, Diffbot, AI2Bot |
| AI search / user | OAI-SearchBot, ChatGPT-User, Claude-SearchBot, Claude-User, PerplexityBot, Perplexity-User, DuckAssistBot |
| Search engines | Googlebot, Bingbot |

The table only serves to decide **blocking**; it doesn't imply creating a `User-agent` group for each bot. Rules are only written for what you want to deny.

### 4. Report section

Write `report/data//robots-txt.json` (contract in `report/SCHEMA.md`). No charts.

```json
{
  "skill": "robots-txt", "title": "robots.txt", "site": "example.com", "generated": "YYYY-MM-DD",
  "source": "https://example.com/robots.txt · HTTP 200",
  "score": 85, "summary": "2-4 sentences.",
  "kpis": [
    {"label": "HTTP Status", "value": 200, "status": "good", "hint": "404 = everything allowed; 5xx = Google stops crawling"},
    {"label": "Syntax errors", "value": 0, "status": "good"},
    {"label": "Declared sitemaps", "value": 1, "status": "good"},
    {"label": "Blocked sitemap URLs", "value": 0, "status": "good", "hint": "of 30 tested with Googlebot"},
    {"label": "AI training bots blocked", "value": "0 of 13", "status": "info"}
  ],
  "charts": [],
  "findings": [{"severity": "high", "title": "…", "evidence": "…", "impact": "…", "recommendation": "…", "urls": ["…"]}],
  "tables": [
    {"title": "AI bots and search engines", "columns": ["Bot", "Type", "Status"], "rows": [["GPTBot", "Training", "No rules of its own"]]},
    {"title": "URL testing (Googlebot)", "columns": ["Path", "Result", "Winning rule"], "rows": [["/carrito", "BLOCKED", "Disallow: /carrito"]]},
    {"title": "Declared sitemaps", "columns": ["URL", "Status"], "rows": [["https://example.com/sitemap.xml", 200]]}
  ],
  "actions": [{"priority": 1, "title": "…", "impact": "high", "effort": "low"}],
  "code": [
    {"title": "Current robots.txt", "lang": "text", "content": "…full text…"},
    {"title": "Proposed robots.txt", "lang": "text", "content": "…only if you propose changes…"}
  ]
}
```

Afterwards: `python3 report/build_report.py  --open`.

## Scoring

Start at 100: −40 if it blocks the whole site or important sitemap URLs · −25 if it responds 5xx ·
−15 for blocking render CSS/JS · −10 for no declared sitemap or a broken sitemap · −5 for each syntax error ·
−5 for an incoherent AI policy. Minimum 0.

## Generating a robots.txt

- **Only** `Disallow` for paths confirmed on the site (sitemap, navigation, or the user). Never invent paths.
- robots.txt **doesn't invite or allow bots**: it only denies access. Write `User-agent: *` and only `User-agent` groups for bots you're going to **block** (`Disallow`). Don't add groups for allowed bots — with no rules they're already allowed.
- No comments or headers. Order: `User-agent: *`, then the blocked bot groups (training and search per the policy), `Sitemap:` last.
- Example with the "block training" policy (only the blocks are written; the remaining bots stay allowed by the absence of rules):
  ```text
  User-agent: *
  Allow: /

  User-agent: GPTBot
  Disallow: /
  User-agent: ClaudeBot
  Disallow: /
  User-agent: CCBot
  Disallow: /
  Sitemap: https://example.com/sitemap.xml
  ```
  Don't add `User-agent: Googlebot` with `Allow` (Google already crawls by default), nor groups for bots you won't block.
- Before delivering it, run steps 2 and 3 (syntax + testing the sitemap sample) and confirm it doesn't block anything indexable.

## Rules

- Don't modify the site's robots.txt: the proposed one is delivered in the report and in the chat for copying.
- When testing URLs, show the winning rule in the table: it's the evidence for the finding.
- If the sample is small, say so (e.g. "30 of 1,200 URLs tested").