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 PrashamTrivedi
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/prashamtrivedi-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: not checked yet.
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 PrashamTrivedi/CursorPlugin, MIT.
More from PrashamTrivedi/CursorPlugin
- 0.529score
cf-analytics-engine
PrashamTrivedi
Query Cloudflare Workers Analytics Engine datasets using SQL.
SkillBFreshness: BClaude Code - 0.524score
cloudflare-tunnel
PrashamTrivedi
Expose localhost to the internet via Cloudflare Tunnel.
SkillBFreshness: BClaude Code +9 - 0.524score
code-review
PrashamTrivedi
Automatic code review before commits and pushes.
SkillBFreshness: BClaude Code - 0.524score
cheap-browsing
PrashamTrivedi
Token-efficient browser automation — read pages as text, fill forms by ref, extract form structure from saved HTML, and screenshot only when a visual…
SkillBFreshness: BClaude Code +9 - 0.518score
docs
PrashamTrivedi
Update documentation and changelog to reflect codebase changes
SkillBFreshness: BClaude Code +9 - 0.518score
codeplanner-gemini
PrashamTrivedi
Plan and analyze code tasks with comprehensive project understanding with help of Gemini CLI coding agent
SkillBFreshness: BClaude Code +9 - 0.518score
completework
PrashamTrivedi
Complete and finalize task work with validation and documentation updates
SkillBFreshness: BClaude Code +9 - 0.518score
codeplanner
PrashamTrivedi
Plan and analyze code tasks with comprehensive project understanding
SkillBFreshness: BClaude Code +9 - 0.515score
brainstorm
PrashamTrivedi
Brainstorm the requirement to finalize requirements.
SkillBFreshness: BClaude Code +9 - 0.515score
background
PrashamTrivedi
Fires off a full Claude Code instance in the background
SkillBFreshness: BClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Sep 1, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/PrashamTrivedi/CursorPlugin
- 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.609score
building-ai-agent-on-cloudflare
CommandCodeAI
Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
SkillDFreshness: D★ 137Claude 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 PrashamTrivedi
- 0.529score
cf-analytics-engine
PrashamTrivedi
Query Cloudflare Workers Analytics Engine datasets using SQL.
SkillBFreshness: BClaude Code - 0.524score
cloudflare-tunnel
PrashamTrivedi
Expose localhost to the internet via Cloudflare Tunnel.
SkillBFreshness: BClaude Code +9 - 0.524score
code-review
PrashamTrivedi
Automatic code review before commits and pushes.
SkillBFreshness: BClaude Code - 0.524score
cheap-browsing
PrashamTrivedi
Token-efficient browser automation — read pages as text, fill forms by ref, extract form structure from saved HTML, and screenshot only when a visual…
SkillBFreshness: BClaude Code +9 - 0.518score
docs
PrashamTrivedi
Update documentation and changelog to reflect codebase changes
SkillBFreshness: BClaude Code +9 - 0.518score
codeplanner-gemini
PrashamTrivedi
Plan and analyze code tasks with comprehensive project understanding with help of Gemini CLI coding agent
SkillBFreshness: BClaude Code +9
Cite this page
building-ai-agent-on-cloudflare skill. Agent Mart. https://agentmart.dev/skills/prashamtrivedi-building-ai-agent-on-cloudflare (last updated 2026-10-24)