building-ai-agent-on-cloudflare
Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
Skill by CommandCodeAI
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/commandcodeai-building-ai-agent-on-cloudflare
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: cloud, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 26, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/building-ai-agent-on-cloudflare
What's inside
- Skill name
building-ai-agent-on-cloudflare- Description
- Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities. Generates production-ready agent code deployed to Workers. Use when: user wants to "build an agent", "AI agent", "chat agent", "stateful agent", mentions "Agents SDK", needs "real-time AI", "WebSocket AI", or asks about agent "state management", "scheduled tasks", or "tool calling".
- License
- MIT
- Instructions
- 381 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (5)
- SKILL.md
- agent-patterns.md · references/
- examples.md · references/
- state-patterns.md · references/
- troubleshooting.md · references/
SKILL.md (first lines)
# Building Cloudflare Agents
Creates AI-powered agents using Cloudflare's Agents SDK with persistent state, real-time communication, and tool integration.
## When to Use
- User wants to build an AI agent or chatbot
- User needs stateful, real-time AI interactions
- User asks about the Cloudflare Agents SDK
- User wants scheduled tasks or background AI work
- User needs WebSocket-based AI communication
## Prerequisites
- Cloudflare account with Workers enabled
- Node.js 18+ and npm/pnpm/yarn
- Wrangler CLI (`npm install -g wrangler`)
## Quick Start
```bash
npm create cloudflare@latest -- my-agent --template=cloudflare/agents-starter
cd my-agent
npm start
```
Agent runs at `http://localhost:8787`
## Core Concepts
### What is an Agent?
An Agent is a stateful, persistent AI service that:
- Maintains state across requests and reconnections
- Communicates via WebSockets or HTTP
- Runs on Cloudflare's edge via Durable Objects
- Can schedule tasks and call tools
- Scales horizontally (each user/session gets own instance)
### Agent Lifecycle
```
Client connects → Agent.onConnect() → Agent processes messages
→ Agent.onMessage()
→ Agent.setState() (persists + syncs)
Client disconnects → State persists → Client reconnects → State restored
```
## Basic Agent Structure
```typescript
import { Agent, Connection } from "agents";
interface Env {
AI: Ai; // Workers AI binding
}
interface State {
messages: Array<{ role: string; content: string }>;
preferences: Record<string, string>;
}
export class MyAgent extends Agent<Env, State> {
// Initial state for new instances
initialState: State = {
messages: [],
preferences: {},
};
// Called when agent starts or resumes
async onStart() {
console.log("Agent started with state:", this.state);
}
// Handle WebSocket connections
async onConnect(connection: Connection) {
connection.send(JSON.stringify({
type: "welcome",
history: this.state.messages,
}));
}
// Handle incoming messages
async onMessage(connection: Connection, message: string) {
const data = JSON.parse(message);
if (data.type === "chat") {
await this.handleChat(connection, data.content);
}
}
// Handle disconnections
async onClose(connection: Connection) {
console.log("Client disconnected");
}
// React to state changes
onStateUpdate(state: State, source: string) {
console.log("State updated by:", source);
}
private async handleChat(connection: Connection, userMessage: string) {
// Add user message to history
const messages = [
...this.state.messages,
{ role: "user", content: userMessage },
];
// Call AI
const response = await this.env.AI.run("@cf/meta/llama-3-8b-instruct", {
messages,
});
// Update state (persists and syncs to all clients)
this.setState({
...this.state,
messages: [
...messages,
{ role: "assistant", content: response.response },From CommandCodeAI/agent-skills, MIT.
More from CommandCodeAI/agent-skills
- 0.606score
aws-cost-operations
CommandCodeAI
This skill provides AWS cost optimization, monitoring, and operational best practices with integrated MCP servers for billing analysis, cost estimation…
SkillDFreshness: D★ 137Claude Code +9 - 0.605score
building-mcp-server-on-cloudflare
CommandCodeAI
Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment.
SkillDFreshness: D★ 137Claude Code +9 - 0.604score
playwright-skill
CommandCodeAI
Complete browser automation with Playwright.
SkillDFreshness: D★ 137Claude Code +9 - 0.604score
aws-agentic-ai
CommandCodeAI
AWS Bedrock AgentCore comprehensive expert for deploying and managing all AgentCore services.
SkillDFreshness: D★ 137Claude Code +9 - 0.522score
raffle-winner-picker
CommandCodeAI
Picks random winners from lists, spreadsheets, or Google Sheets for giveaways, raffles, and contests.
SkillDFreshness: D★ 137Claude Code +9 - 0.522score
invoice-organizer
CommandCodeAI
Automatically organizes invoices and receipts for tax preparation by reading messy files, extracting key information, renaming them consistently, and sorting…
SkillDFreshness: D★ 137Claude Code +9 - 0.522score
video-downloader
CommandCodeAI
Downloads videos from YouTube and other platforms for offline viewing, editing, or archival.
SkillDFreshness: D★ 137Claude Code +9 - 0.519score
welcome-me
commandcodeai
Greet user with a specific message when they say they're new or ask for a welcome message.
SkillDFreshness: D★ 137Claude Code +9 - 0.505score
mcp-builder
CommandCodeAI
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools.
SkillDFreshness: D★ 137Claude Code +9 - 0.500score
canvas-design
CommandCodeAI
Create beautiful visual art in .png and .pdf documents using design philosophy.
SkillDFreshness: D★ 137Claude Code +9 - 0.500score
brand-guidelines
CommandCodeAI
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel.
SkillDFreshness: D★ 137Claude Code +9 - 0.499score
requesting-code-review
CommandCodeAI
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
SkillDFreshness: D★ 137Claude Code +9
Signals
- Stars
- 137
- Forks
- 42
- Open issues
- 4
- Last commit (this folder)
- Dec 24, 2025 (10 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/CommandCodeAI/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
- 0.318score
building-ai-agent-on-cloudflare
PrashamTrivedi
Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
SkillBFreshness: BClaude Code +9 - 0.318score
building-ai-agent-on-cloudflare
Vidoxlabs
Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
SkillBFreshness: BClaude Code +9 - 0.262score
building-ai-agent-on-cloudflare
involvex
Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
SkillDFreshness: D★ 1Claude Code +9 - 0.246score
building-ai-agent-on-cloudflare
involvex
Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
SkillDFreshness: DClaude Code +9
More from CommandCodeAI
- 0.663score
command-code
CommandCodeAI
Terminal coding agent that learns from accept, reject and edit decisions through its taste model.
AgentAFreshness: A★ 4.2K - 0.606score
aws-cost-operations
CommandCodeAI
This skill provides AWS cost optimization, monitoring, and operational best practices with integrated MCP servers for billing analysis, cost estimation…
SkillDFreshness: D★ 137Claude Code +9 - 0.605score
building-mcp-server-on-cloudflare
CommandCodeAI
Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment.
SkillDFreshness: D★ 137Claude Code +9 - 0.604score
playwright-skill
CommandCodeAI
Complete browser automation with Playwright.
SkillDFreshness: D★ 137Claude Code +9 - 0.604score
aws-agentic-ai
CommandCodeAI
AWS Bedrock AgentCore comprehensive expert for deploying and managing all AgentCore services.
SkillDFreshness: D★ 137Claude Code +9 - 0.522score
raffle-winner-picker
CommandCodeAI
Picks random winners from lists, spreadsheets, or Google Sheets for giveaways, raffles, and contests.
SkillDFreshness: D★ 137Claude Code +9
Cite this page
building-ai-agent-on-cloudflare skill. Agent Mart. https://agentmart.dev/skills/commandcodeai-building-ai-agent-on-cloudflare (last updated 2026-10-24)