Claude-Code user agent
Operated by Anthropic
Claude-Code is a user agent reported for Claude Code, Anthropic's AI coding agent, when it fetches web pages.
The Claude-Code bot at a glance
- Claude-Code is operated by Anthropic and loads web pages in a browser to complete tasks on behalf of a user.
- The robots.txt token for Claude-Code is Claude-Code.
- Blocking an AI agent has no effect on search rankings.
- Claude-Code robots.txt support: Not documented.
- Recommendation for Generative Engine Optimization (GEO): Your choice.
What is Claude-Code?
Claude Code reads documentation and pages while working on a developer’s task.
Anthropic’s crawler page does not list this name.
Should you block Claude-Code?
Blocking Claude-Code is a business decision: it protects your content but can lower how well AI products know your brand.
| Effect on search rankings | Blocking an AI agent has no effect on search rankings. |
|---|---|
| Effect on AI visibility | Blocking stops agents from completing tasks on your website for their users, which can cost bookings or sales that agents would have made. |
| Follows robots.txt | Not documented |
| Recommendation | Your choice |
How to block or allow Claude-Code
Put the robots.txt rule in the file at the root of every domain and subdomain, for example https://example.com/robots.txt. The token Claude-Code is matched case-insensitively. robots.txt alone may not stop Claude-Code, so add the Nginx, Apache or Cloudflare rule as well.
robots.txt: block
# Block Claude-Code
User-agent: Claude-Code
Disallow: /robots.txt: allow
# Allow Claude-Code
User-agent: Claude-Code
Allow: /robots.txt: partial
# Keep Claude-Code out of private areas only
User-agent: Claude-Code
Disallow: /wp-admin/
Disallow: /cart/
Disallow: /checkout/
Disallow: /my-account/
Allow: /Nginx
# Nginx: return 403 to Claude-Code
if ($http_user_agent ~* "(Claude\-Code)") {
return 403;
}Apache
# Apache .htaccess: return 403 to Claude-Code
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (Claude\-Code) [NC]
RewriteRule .* - [F,L]Cloudflare WAF
# Cloudflare > Security > WAF > Custom rule, action: Block
(http.user_agent contains "Claude-Code")How to verify real Claude-Code traffic
Anthropic publishes no IP list or reverse DNS pattern for Claude-Code, so the user agent cannot be verified. Anyone can send the same string. Rate-limit unusual volume instead of trusting the name.
How to find Claude-Code in your server logs
Search the web server access log for the token. The command below counts Claude-Code requests per URL on Nginx or Apache.
grep -i "Claude-Code" access.log | awk '{print $7}' | sort | uniq -c | sort -rn | head -20For a full report per AI bot, upload the log to the AI Log File Analyzer, a free tool by Justin Hà.
Claude-Code FAQ
Claude-Code uses the robots.txt token "Claude-Code". Anthropic does not publish a full user-agent string, so match the token inside the User-Agent header.
Anthropic has not documented how Claude-Code treats robots.txt. Add a robots.txt rule and back it with a server rule if the traffic matters to you.
Blocking an AI agent has no effect on search rankings. Blocking stops agents from completing tasks on your website for their users, which can cost bookings or sales that agents would have made.
Add two lines to the robots.txt file at the root of each domain and subdomain: "User-agent: Claude-Code" followed by "Disallow: /". The token is case-insensitive. Changes can take up to 24 hours to be picked up.
Not reliably. Anthropic publishes no IP list or reverse DNS pattern for Claude-Code, so anyone can send the same user agent. Rate-limit unusual volume instead of trusting the name.
Search your server access log for "Claude-Code", for example with: grep -i "Claude-Code" access.log. The AI Log File Analyzer by Justin Hà counts visits per AI bot from an uploaded log file.
Sources: Public bot registry. Last reviewed by Justin Hà.
See which of these bots actually reach your website
The AI Log File Analyzer by Justin Hà counts visits from GPTBot, ClaudeBot, PerplexityBot and other AI crawlers in your server log, for free. The GEO Technical Package sets up robots.txt, llms.txt and crawler access for AI search.