cloudflare

Verified·Scanned 2/18/2026

This skill is a comprehensive Cloudflare platform reference for Workers, AI, storage, networking, and tooling. It includes runnable CLI commands (e.g., npx wrangler deploy, curl), instructs storing/using secrets (CLOUDFLARE_API_TOKEN, OPENAI_API_KEY), and exposes API endpoints such as https://api.cloudflare.com/....

by dmmulroy·v97a85fd·1.3 MB·257 installs
Scanned from main at 97a85fd · Transparency log ↗
$ vett add dmmulroy/cloudflare-skill/cloudflare

Cloudflare Agents SDK

Cloudflare Agents SDK enables building AI-powered agents on Durable Objects with state, WebSockets, SQL, scheduling, and AI integration.

Core Value

Build stateful, globally distributed AI agents with persistent memory, real-time connections, scheduled tasks, and async workflows.

When to Use

  • Persistent state + memory required
  • Real-time WebSocket connections
  • Long-running workflows (minutes/hours)
  • Chat interfaces with AI models
  • Scheduled/recurring tasks with state
  • DB queries with agent state

What Type of Agent?

Use CaseClassKey Features
AI chat interfaceAIChatAgentAuto-streaming, tools, message history, resumable
MCP tool providerAgent + MCPExpose tools to AI systems
Custom logic/routingAgentFull control, WebSockets, email, SQL
Real-time collaborationAgentWebSocket state, broadcasts
Email processingAgentonEmail() handler

Quick Start

AI Chat Agent:

import { AIChatAgent } from "agents";
import { openai } from "@ai-sdk/openai";

export class ChatAgent extends AIChatAgent<Env> {
  async onChatMessage(onFinish) {
    return this.streamText({
      model: openai("gpt-4"),
      messages: this.messages,
      onFinish,
    });
  }
}

Base Agent:

import { Agent } from "agents";

export class MyAgent extends Agent<Env> {
  onStart() {
    this.sql`CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY)`;
  }
  
  async onRequest(request: Request) {
    return Response.json({ state: this.state });
  }
}

Reading Order

TaskFiles to Read
Quick startREADME only
Build chat agentREADME → api.md (AIChatAgent) → patterns.md
Setup projectREADME → configuration.md
Add React frontendREADME → api.md (Client Hooks) → patterns.md
Build MCP serverapi.md (MCP) → patterns.md
Background tasksapi.md (Scheduling, Task Queue) → patterns.md
Debug issuesgotchas.md

Package Entry Points

ImportPurpose
agentsServer-side Agent classes, lifecycle
agents/reactuseAgent() hook for WebSocket connections
agents/ai-reactuseAgentChat() hook for AI chat UIs

In This Reference

  • configuration.md - SDK setup, wrangler config, routing
  • api.md - Agent classes, lifecycle, client hooks
  • patterns.md - Common workflows, best practices
  • gotchas.md - Common issues, limits

See Also

  • durable-objects - Agent infrastructure
  • d1 - External database integration
  • workers-ai - AI model integration
  • vectorize - Vector search for RAG patterns