robots-txt

robots-txt is a command for coding agents from huifer/claude-code-seo. It costs 6 tokens per session (3,938 once invoked), scanned A, original, MIT.

A command that creates or improves robots.txt, a website file that tells search-engine and other crawlers which areas they may access.

In plain words
What is it for?
Use it in a Next.js project to generate public/robots.txt with crawler rules, sitemap information, directory exclusions, and optional crawl-delay settings.
Why use it?
It provides standard crawler rules and can point crawlers to the site's sitemap, while helping keep common private or internal paths out of crawling.

Command

Part of the claude-code-seo plugin — 7 skills, 37 commands, 2 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/huifer/claude-code-seo/robots-txt
Clone the repo
git clone --depth 1 https://github.com/huifer/claude-code-seo

Or install claude-code-seo, the plugin that ships this one along with the rest of its 7 skills, 37 commands, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for robots-txt

README.md
[![agentmods](https://agentmods.dev/badge/commands/huifer/claude-code-seo/robots-txt.svg)](https://agentmods.dev/commands/huifer/claude-code-seo/robots-txt)
Your own site
<a href="https://agentmods.dev/commands/huifer/claude-code-seo/robots-txt"><img src="https://agentmods.dev/badge/commands/huifer/claude-code-seo/robots-txt.svg" alt="Measured on agentmods" height="20"></a>
Per session 6 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,938 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00006 $0.03938
Opus 5 $0.00003 $0.01969
Sonnet 5 $0.00001 $0.00788
Haiku 4.5 $0.00001 $0.00394

Measured 5d ago against content hash 2d1b23015c68, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

robots-txt scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl http://localhost:3000/robots.txt
commands/robots-txt.md · 729 lines

How it starts

The opening of the file, as written. The whole thing — 729 lines — stays where its author put it; the contents beside it link to each section on GitHub.

为 Next.js 项目生成 SEO 友好的 robots.txt 文件。包含基本的爬虫规则、Sitemap 引用和常见目录的禁止规则。

功能

  • ✅ 生成标准的 robots.txt 文件
  • ✅ 自动包含 Sitemap 引用
  • ✅ 禁止敏感目录和文件
  • ✅ 允许所有主要爬虫
  • ✅ 支持爬虫延迟设置
  • ✅ 适配 Next.js 项目结构

参数

  • $1$ARGUMENTS: 网站域名(可选)
    • 用于生成 Sitemap URL
    • 示例:https://yourdomain.com
    • 如果不提供,Sitemap 行会被注释或省略

使用示例

示例 1:基本用法

/robots-txt

输出:

# robots.txt 文件

为你的 Next.js 项目生成的 robots.txt 文件:

```txt
# Allow all crawlers
User-agent: *
Allow: /

# Disallow common Next.js and private directories
Disallow: /api/
Disallow: /_next/
Disallow: /static/
Disallow: /.well-known/

# Disallow admin and private areas (if applicable)
# Disallow: /admin/
# Disallow: /private/
# Disallow: /dashboard/

# Sitemap (uncomment and update with your domain)
# Sitemap: https://yourdomain.com/sitemap.xml

文件位置

将此文件放置在项目根目录的 public/ 文件夹中:

路径: public/robots.txt

复制上面的内容到 public/robots.txt 文件。

验证

创建后,访问 https://yourdomain.com/robots.txt 验证文件可访问。

Next.js 自动生成

如果你使用 Next.js 13.3+,也可以使用 generateRobotTxt 函数自动生成:

app/robots.ts (推荐):

import { MetadataRoute } from 'next'

export default function robots(): MetadataRoute.Robots {
  return {
    rules: [
      {
        userAgent: '*',
        allow: '/',
        disallow: ['/api/', '/_next/', '/static/'],
      },
    ],
    sitemap: 'https://yourdomain.com/sitemap.xml',
  }
}

这会自动生成 /robots.txt 路由。


### 示例 2:指定域名

```bash
/robots-txt https://yourdomain.com

输出:

# robots.txt 文件(包含 Sitemap)

```txt
# Allow all crawlers
User-agent: *
Allow: /

# Disallow common Next.js directories
Disallow: /api/
Disallow: /_next/
Disallow: /static/

# Disallow private areas
Disallow: /admin/
Disallow: /_next/image/
Disallow: /private/

# Crawl delay (optional)
# Crawl-delay: 1

# Sitemap
Sitemap: https://yourdomain.com/sitemap.xml

部署

将上述内容保存到 public/robots.txt,部署后可通过以下 URL 访问: https://yourdomain.com/robots.txt

注意事项

  • robots.txt 文件必须位于网站根目录
  • 文件名必须小写:robots.txt
  • 文件更新后可能需要几天才能被搜索引擎重新抓取
  • 使用 Google Search Console 的 robots.txt 测试工具验证

Read the full file on GitHub · 729 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 729 lines · 6 tokens per session scan A 2d1b23015c68

Subscribe to this mod's changes

robots-txt is a command published in the GitHub repository huifer/claude-code-seo (110 stars, last pushed 8mo ago), licensed MIT. It adds 6 tokens to every session and 3,938 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.