Each AI crawler is switched on or off by its own line in the file: a User-agent line carrying the token that the company publishes, followed by Disallow: / to refuse it or an empty Disallow: to admit it. A robots.txt only works when you pick the token for the job you mean, because the same company runs separate bots for model training, for search answers and for fetching a page when a person asks. Below is the grammar that decides which group a bot obeys, the tokens OpenAI and Anthropic list, a complete example, what Cloudflare adds on top, and a check you can run against both versions of your hostname.
How a crawler picks its group
The file is a list of groups. A group starts with one or more User-agent lines and holds the rules beneath them. The Robots Exclusion Protocol, published as RFC 9309, says a crawler looks for the group whose token matches its own name, ignoring letter case, and obeys only that group. If two groups name the same token, their rules are merged. A bot that no group names falls back to the * group, and if there is no * group either, nothing is restricted (RFC 9309).
The consequence catches many files. Adding a group for one bot does not extend your * rules to it; the named group replaces them. If * keeps crawlers out of /account/, a separate group for a training bot must repeat that line, or that bot is allowed in.
Inside a group, the most specific path match decides, meaning the one that covers the most characters, and when an Allow and a Disallow tie, Allow is used. A missing file with a 4xx status means the crawler may take anything, while a server error means it must assume everything is disallowed. The same document states that these rules are not access control, and that listing a path in the file makes it visible to anyone who reads it.
The tokens, by what each bot is for
Use the exact tokens from the operator's own page, and keep the three purposes apart.
OpenAI publishes a training crawler and a search crawler, and states that you can treat them separately: admit one, refuse the other. GPTBot collects content that may be used to train its foundation models; disallowing it signals that your pages should stay out of training. OAI-SearchBot is what surfaces sites in ChatGPT search results; a site that refuses it is not shown in those answers, though it can still appear as a plain link. There is also ChatGPT-User, used when a person asks ChatGPT or a custom GPT something and a page gets visited. OpenAI says this agent is not used for automatic crawling, and because a user starts the visit, robots rules may not apply to it. A fourth token, OAI-AdsBot, only checks landing pages submitted as ads. After you edit the file, search systems can take around 24 hours to adjust (OpenAI crawler overview).
Anthropic lists three robots. ClaudeBot gathers content that could feed model training; restricting it tells Anthropic to leave your future pages out of training sets. Claude-User fetches a page when someone asks Claude a question, and blocking it can lower your visibility for that kind of lookup. Claude-SearchBot indexes pages to improve search answers, and blocking it can lower your visibility there too. Anthropic asks that you add the rule on every subdomain you want to opt out, and warns that refusing its IP addresses instead of using the file can stop it from reading your rules at all (Anthropic help center). The same page says a rule that names ClaudeBot is followed even when a more general preference signal says something different.
Notice the pattern. The training tokens are GPTBot and ClaudeBot; the search tokens are OAI-SearchBot and Claude-SearchBot; the fetch-on-request tokens are ChatGPT-User and Claude-User. Refusing the first group does not touch the other two.
One policy, written out
Say you want out of training, in for search answers, and open to visits that a person triggers, while /account/ stays off limits to everyone:
User-agent: *
Disallow: /account/
User-agent: GPTBot
User-agent: ClaudeBot
Disallow: /
User-agent: OAI-SearchBot
User-agent: Claude-SearchBot
User-agent: ChatGPT-User
User-agent: Claude-User
Disallow: /account/
Sitemap: https://www.example.com/sitemap.xml
Two details matter. The four bots that are admitted each have their own group, so the * group no longer applies to them, and the /account/ line is repeated for exactly that reason. The training bots get a full refusal, so no repeat is needed. The sitemap address is absolute and sits outside any group.
If you would rather refuse everything AI-related, put every token above under Disallow: /. If you want the opposite, delete the training group; the * rules then cover those bots again, as long as no group names them. Our earlier report on models misreading crawler access tests shows why a line like this should be read back from the live site rather than trusted from memory.
What Cloudflare changes
If your site sits behind Cloudflare, the file a crawler receives may not be the file in your repository. Cloudflare's managed robots.txt puts its own directives in front of yours, but only when Bot Preference Sync is switched on and you have chosen a blocking option for Search, Agent or Training. If every policy allows, visitors get your file exactly as it is. When the origin has no file, Cloudflare writes one. In its own example the managed block names crawlers such as ClaudeBot and GPTBot with Disallow: /, and it places a Content Signals line above them (Cloudflare managed robots.txt).
The same page is blunt that compliance is voluntary: the file states a preference and does not stop a crawler technically. For enforcement, Cloudflare points to AI Crawl Control, where you pick allow or block per crawler, and a block there is carried out through a WAF custom rule (Cloudflare AI Crawl Control with WAF). So the two layers can disagree: your file may admit a bot that the edge refuses. When a crawler seems to be missing from search answers, look at both.
A check that can fail
Read the file the way a crawler does, on every host name a crawler might use. The RFC ties a file to one scheme, host and port, so the apex and the www host can serve different files, or one can redirect to the other.
- Fetch both hosts with a raw request, no body text:
curl -sL https://example.com/robots.txtandcurl -sL https://www.example.com/robots.txt, using your own domain. - Check the status of each, and compare the two bodies line by line. A difference is a finding, even if both look reasonable alone.
- In each body, find the group for every token you care about and confirm that the private paths appear inside it.
- Look for lines you never wrote above your own. They show that an edge layer is adding directives in front.
- Give the check a way to fail: put a deliberately wrong token, such as a misspelled
GPTBotXgroup, to a staging copy and confirm your review spots that no real bot is covered. A check that passes on that file is reading the wrong thing.
For a deeper test, ask for a page with a crawler's user-agent string and a control request and compare the answers; a status code alone proves little, and our write-up on models writing llms.txt and RSS files shows the same lesson for a neighbouring file type.
Our skills for this topic
- Robots.txt writer: converts a crawl policy given in words into a finished file, and keeps the group mistakes out of it.
- Crawler access reader: takes status codes gathered per bot and says whether each kind of bot is let in, shut out or unclear.
- Llms.txt writer: produces an llms.txt list of pages from a site description.
- Sitemap writer: produces an XML sitemap holding only the pages worth indexing.
- Empty-page finder: locates why a page looks blank to a reader that does not run scripts, and suggests the fix.
When this does not apply
Remember first that the file is a request. Crawlers that ignore it can still read your pages, and the standard itself says it is not access authorization (RFC 9309); for real secrets use a login. Tokens and policies change, so treat the vendor pages as the authority, as they stood on 26 November 2026, and re-read them before a big edit. Some operators say a user-triggered fetch may skip the file, so a rule for ChatGPT-User or Claude-User is a statement of intent, not a guarantee. We did not test any bot's real behaviour for this guide, and the Cloudflare example comes from its documentation, not from a zone we changed. Search engines such as Google and Bing use their own tokens, which are outside this guide.
Read this post as Markdown: /blog/robots-txt-ai-crawlers-gptbot-claudebot.md · Atom feed.
