build-agent

A command for creating an AI agent on Cloudflare using the Agents SDK, Cloudflare's software toolkit for running agents. It directs the setup of the project, routing, configuration, and the relevant implementation guides.

In plain words
What is it for?
Use it to start a Cloudflare agent project and configure capabilities such as streaming chat, scheduled state, remote procedures, workflows, email, webhooks, approvals, voice, browser tools, or MCP.
Why use it?
It organizes the setup work and points to the documentation needed for features such as chat, state, background jobs, webhooks, MCP, browsing, or voice.

Command

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/cloudflare/skills/build-agent
Clone the repo
git clone --depth 1 https://github.com/cloudflare/skills
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 581 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00011 $0.00581
Opus 5 $0.00005 $0.00291
Sonnet 5 $0.00002 $0.00116
Haiku 4.5 $0.00001 $0.00058

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

Security

Grade A, and why

build-agent scanned grade A with 0 findings 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 3d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/build-agent.md · 58 lines

How it starts

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

Build AI Agent on Cloudflare

Arguments

The user invoked this command with: $ARGUMENTS

Instructions

When this command is invoked:

  1. Read the skill file at agents-sdk/SKILL.md for core SDK guidance, APIs, and wrangler config
  2. Based on what the user wants to build, read the relevant references from agents-sdk/references/:
    • For chat/AI agents: streaming-chat.md, client-sdk.md
    • For state management: state-scheduling.md
    • For RPC methods: callable.md
    • For background work: workflows.md, durable-execution.md, queue-retries.md
    • For MCP integration: mcp.md
    • For email handling: email.md
    • For webhooks/push: webhooks-push.md
    • For approval flows: human-in-the-loop.md
    • For voice: voice.md
    • For browser tools: browse-the-web.md
    • For higher-level chat: think.md
  3. Fetch the relevant pages from https://developers.cloudflare.com/agents/ for the latest API details
  4. Always start with configuration.md and routing.md for project setup

Scaffold Steps

  1. Create project: npx create-cloudflare@latest --template cloudflare/agents-starter
  2. Configure wrangler.jsonc: DO bindings, migrations, AI binding, assets
  3. Implement agent class: extend Agent or AIChatAgent depending on use case
  4. Wire routing: routeAgentRequest in the default export
  5. Build client: useAgent + useAgentChat React hooks
  6. Deploy: npx wrangler deploy

Key Decision: Agent vs AIChatAgent vs Think

Need Use Package
Custom stateful logic, RPC, scheduling Agent agents
AI chat with streaming, tools, persistence AIChatAgent @cloudflare/ai-chat
AI chat with automatic tool loop, built-in workspace Think @cloudflare/think (experimental)

Example Usage

/build-agent a customer support chatbot with tool calling
/build-agent a real-time collaborative editor with state sync
/build-agent a background processing agent with scheduled tasks
/build-agent a voice assistant that can browse the web

Read the full file on GitHub · 58 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. 3d ago First seen · 58 lines · 11 tokens per session scan A 4d2f9777e0bf

Subscribe to this mod's changes

build-agent is a command published in the GitHub repository cloudflare/skills (2,759 stars, last pushed 25d ago), licensed Apache-2.0. It adds 11 tokens to every session and 581 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.