Agents SDK
hodgef/apiker
Build AI agents on Cloudflare Workers using the Agents SDK. An agent skill from hodgef/apiker.
Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
$ npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install CommandCodeAI/agent-skills building-ai-agent-on-cloudflare --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/CommandCodeAI/agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/building-ai-agent-on-cloudflare .claude/skills/building-ai-agent-on-cloudflare && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "building-ai-agent-on-cloudflare" agent skill from https://github.com/CommandCodeAI/agent-skills/tree/main/skills/building-ai-agent-on-cloudflare into .claude/skills/building-ai-agent-on-cloudflare/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "building-ai-agent-on-cloudflare", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/CommandCodeAI/agent-skills/tree/main/skills/building-ai-agent-on-cloudflareType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install CommandCodeAI/agent-skills building-ai-agent-on-cloudflare --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/CommandCodeAI/agent-skills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/building-ai-agent-on-cloudflare .agents/skills/building-ai-agent-on-cloudflare && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "building-ai-agent-on-cloudflare" agent skill from https://github.com/CommandCodeAI/agent-skills/tree/main/skills/building-ai-agent-on-cloudflare into .agents/skills/building-ai-agent-on-cloudflare/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "building-ai-agent-on-cloudflare", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install CommandCodeAI/agent-skills building-ai-agent-on-cloudflare --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/CommandCodeAI/agent-skills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/building-ai-agent-on-cloudflare .cursor/skills/building-ai-agent-on-cloudflare && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "building-ai-agent-on-cloudflare" agent skill from https://github.com/CommandCodeAI/agent-skills/tree/main/skills/building-ai-agent-on-cloudflare into .cursor/skills/building-ai-agent-on-cloudflare/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "building-ai-agent-on-cloudflare", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/CommandCodeAI/agent-skills.git --path skills/building-ai-agent-on-cloudflare--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install CommandCodeAI/agent-skills building-ai-agent-on-cloudflare --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/CommandCodeAI/agent-skills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/building-ai-agent-on-cloudflare .gemini/skills/building-ai-agent-on-cloudflare && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "building-ai-agent-on-cloudflare" agent skill from https://github.com/CommandCodeAI/agent-skills/tree/main/skills/building-ai-agent-on-cloudflare into .gemini/skills/building-ai-agent-on-cloudflare/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "building-ai-agent-on-cloudflare", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install CommandCodeAI/agent-skills building-ai-agent-on-cloudflareInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/CommandCodeAI/agent-skills.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/building-ai-agent-on-cloudflare .github/skills/building-ai-agent-on-cloudflare && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "building-ai-agent-on-cloudflare" agent skill from https://github.com/CommandCodeAI/agent-skills/tree/main/skills/building-ai-agent-on-cloudflare into .github/skills/building-ai-agent-on-cloudflare/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "building-ai-agent-on-cloudflare", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install CommandCodeAI/agent-skills building-ai-agent-on-cloudflare --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/CommandCodeAI/agent-skills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/building-ai-agent-on-cloudflare .opencode/skills/building-ai-agent-on-cloudflare && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "building-ai-agent-on-cloudflare" agent skill from https://github.com/CommandCodeAI/agent-skills/tree/main/skills/building-ai-agent-on-cloudflare into .opencode/skills/building-ai-agent-on-cloudflare/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "building-ai-agent-on-cloudflare", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
building-ai-agent-on-cloudflareBuilds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
Building AI Agent On Cloudflare is an agent skill from CommandCodeAI/agent-skills. 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".
Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `references/agent-patterns.md`, `references/examples.md` and `references/state-patterns.md`).
It sits in Backend & APIs, covering Realtime and WebSockets, Building AI agents and Scheduled and recurring tasks. It works with Cloudflare and Cloudflare Workers. The repository describes itself as: A curated list of awesome Skills, resources, and tools for customizing coding agent workflows. The licence is MIT.
Read from SKILL.md and the folder at commit f490dd9. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Shell commands in SKILL.md call:
npmnpxwranglercurlFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use npm, npx, wrangler and curl, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Building AI Agent On Cloudflare loads about 2.3k tokens when it runs, and up to ~11k if it reads all its reference files. Until then it costs about 118 tokens; SKILL.md has 232 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from CommandCodeAI/agent-skills at commit f490dd9, republished under its MIT licence (© CommandCodeAI). 232 words, ~2,322 tokens.
.claude/skills/building-ai-agent-on-cloudflare/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.Creates AI-powered agents using Cloudflare's Agents SDK with persistent state, real-time communication, and tool integration.
npm install -g wrangler)npm create cloudflare@latest -- my-agent --template=cloudflare/agents-starter
cd my-agent
npm startAgent runs at http://localhost:8787
An Agent is a stateful, persistent AI service that:
Client connects → Agent.onConnect() → Agent processes messages
→ Agent.onMessage()
→ Agent.setState() (persists + syncs)
Client disconnects → State persists → Client reconnects → State restoredimport { 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 },
],
});
// Send response
connection.send(JSON.stringify({
type: "response",
content: response.response,
}));
}
}// src/index.ts
import { routeAgentRequest } from "agents";
import { MyAgent } from "./agent";
export default {
async fetch(request: Request, env: Env) {
// routeAgentRequest handles routing to /agents/:class/:name
return (
(await routeAgentRequest(request, env)) ||
new Response("Not found", { status: 404 })
);
},
};
export { MyAgent };Clients connect via: wss://my-agent.workers.dev/agents/MyAgent/session-id
name = "my-agent"
main = "src/index.ts"
compatibility_date = "2024-12-01"
[ai]
binding = "AI"
[durable_objects]
bindings = [{ name = "AGENT", class_name = "MyAgent" }]
[[migrations]]
tag = "v1"
new_classes = ["MyAgent"]// Current state is always available
const currentMessages = this.state.messages;
const userPrefs = this.state.preferences;// setState persists AND syncs to all connected clients
this.setState({
...this.state,
messages: [...this.state.messages, newMessage],
});
// Partial updates work too
this.setState({
preferences: { ...this.state.preferences, theme: "dark" },
});For complex queries, use the embedded SQLite database:
// Create tables
await this.sql`
CREATE TABLE IF NOT EXISTS documents (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`;
// Insert
await this.sql`
INSERT INTO documents (title, content)
VALUES (${title}, ${content})
`;
// Query
const docs = await this.sql`
SELECT * FROM documents WHERE title LIKE ${`%${search}%`}
`;Agents can schedule future work:
async onMessage(connection: Connection, message: string) {
const data = JSON.parse(message);
if (data.type === "schedule_reminder") {
// Schedule task for 1 hour from now
const { id } = await this.schedule(3600, "sendReminder", {
message: data.reminderText,
userId: data.userId,
});
connection.send(JSON.stringify({ type: "scheduled", taskId: id }));
}
}
// Called when scheduled task fires
async sendReminder(data: { message: string; userId: string }) {
// Send notification, email, etc.
console.log(`Reminder for ${data.userId}: ${data.message}`);
// Can also update state
this.setState({
...this.state,
lastReminder: new Date().toISOString(),
});
}// Delay in seconds
await this.schedule(60, "taskMethod", { data });
// Specific date
await this.schedule(new Date("2025-01-01T00:00:00Z"), "taskMethod", { data });
// Cron expression (recurring)
await this.schedule("0 9 * * *", "dailyTask", {}); // 9 AM daily
await this.schedule("*/5 * * * *", "everyFiveMinutes", {}); // Every 5 min
// Manage schedules
const schedules = await this.getSchedules();
await this.cancelSchedule(taskId);For chat-focused agents, extend AIChatAgent:
import { AIChatAgent } from "agents/ai-chat-agent";
export class ChatBot extends AIChatAgent<Env> {
// Called for each user message
async onChatMessage(message: string) {
const response = await this.env.AI.run("@cf/meta/llama-3-8b-instruct", {
messages: [
{ role: "system", content: "You are a helpful assistant." },
...this.messages, // Automatic history management
{ role: "user", content: message },
],
stream: true,
});
// Stream response back to client
return response;
}
}Features included:
saveMessages() for persistenceimport { useAgent } from "agents/react";
function Chat() {
const { state, send, connected } = useAgent({
agent: "my-agent",
name: userId, // Agent instance ID
});
const sendMessage = (text: string) => {
send(JSON.stringify({ type: "chat", content: text }));
};
return (
<div>
{state.messages.map((msg, i) => (
<div key={i}>{msg.role}: {msg.content}</div>
))}
<input onKeyDown={(e) => e.key === "Enter" && sendMessage(e.target.value)} />
</div>
);
}const ws = new WebSocket("wss://my-agent.workers.dev/agents/MyAgent/user123");
ws.onopen = () => {
console.log("Connected to agent");
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log("Received:", data);
};
ws.send(JSON.stringify({ type: "chat", content: "Hello!" }));See references/agent-patterns.md for:
# Deploy
npx wrangler deploy
# View logs
wrangler tail
# Test endpoint
curl https://my-agent.workers.dev/agents/MyAgent/test-userSee references/troubleshooting.md for common issues.
© CommandCodeAI, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 4 other files (references) in skills/building-ai-agent-on-cloudflare of CommandCodeAI/agent-skills.
Open the folder on GitHubat commit f490dd9
Building AI Agent On Cloudflare next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Building AI Agent On Cloudflare this skillCommandCodeAI/agent-skills | 132 | — | ~2.3k | Automated safety check: Pass | MIT | |
| Agents SDKhodgef/apiker | 127 | 3 repos | ~3k | Automated safety check: Pass | MIT | |
| Cloudflare Browser Renderingcloudflare/moltworker | 10k | — | ~742 | Automated safety check: Pass | Apache-2.0 | |
| Durable Objectshodgef/apiker | 127 | 4 repos | ~1.5k | Automated safety check: Pass | MIT | |
| Cloudflare WorkersEpicenterHQ/epicenter | 4.8k | — | ~576 | Automated safety check: Pass | Custom licence | |
| HonoEpicenterHQ/epicenter | 4.8k | — | ~513 | Automated safety check: Pass | Custom licence |
hodgef/apiker
Build AI agents on Cloudflare Workers using the Agents SDK. An agent skill from hodgef/apiker.
cloudflare/moltworker
Drives headless Chrome through Cloudflare Browser Rendering over a CDP WebSocket to take screenshots, navigate and scrape pages, and record multi-page videos.
hodgef/apiker
Create and review Cloudflare Durable Objects. An agent skill from hodgef/apiker.
EpicenterHQ/epicenter
Cloudflare Workers patterns for Worker runtime APIs, Durable Objects, KV, R2, D1, Queues, WebSockets, streaming responses, bindings, wrangler configuration, and deployment limits.
EpicenterHQ/epicenter
Hono patterns for TypeScript API routes, middleware, request and response typing, streaming, WebSockets, and Cloudflare Workers deployment.
getsentry/sentry-for-ai
Instrument an application with Sentry — detect the platform, install and initialize the SDK if needed, and wire up any signal — error monitoring, tracing/performance, logging, metrics, profiling…
CommandCodeAI/agent-skills
Download YouTube video transcripts when user provides a YouTube URL or asks to download/get/fetch a transcript from YouTube.
CommandCodeAI/agent-skills
Builds remote MCP (Model Context Protocol) servers on Cloudflare Workers with tools, OAuth authentication, and production deployment.
CommandCodeAI/agent-skills
AWS Bedrock AgentCore comprehensive expert for deploying and managing all AgentCore services.
CommandCodeAI/agent-skills
Greet user with a specific message when they say they're new or ask for a welcome message.
Works with
Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities. Building AI Agent On Cloudflare is an agent skill from CommandCodeAI/agent-skills. Builds AI agents on Cloudflare using the Agents SDK with state management, real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.
Building AI Agent On Cloudflare fits situations like: : user wants to build an agent; mentions Agents SDK; needs real-time AI; asks about agent state management.
Run `npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a claude-code`. Or copy the skill folder (skills/building-ai-agent-on-cloudflare in CommandCodeAI/agent-skills) into .claude/skills/building-ai-agent-on-cloudflare in your project. Claude Code loads it when a task matches its description.
Run `npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a codex`. Or copy the skill folder (skills/building-ai-agent-on-cloudflare in CommandCodeAI/agent-skills) into .agents/skills/building-ai-agent-on-cloudflare in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add CommandCodeAI/agent-skills --skill building-ai-agent-on-cloudflare -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/building-ai-agent-on-cloudflare, .gemini/skills/building-ai-agent-on-cloudflare, .github/skills/building-ai-agent-on-cloudflare and .opencode/skills/building-ai-agent-on-cloudflare in your project.
Going by SKILL.md and its folder, Building AI Agent On Cloudflare needs the command-line tools its instructions call (npm, npx, wrangler and curl). Our summary lists: Node.js.
SKILL.md contains no URLs. Its commands use npm, npx and curl, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Building AI Agent On Cloudflare is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.3k tokens (SKILL.md is roughly 9.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 8.2k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with Building AI Agent On Cloudflare: Agents SDK (hodgef/apiker, 127 stars), Cloudflare Browser Rendering (cloudflare/moltworker, 10k stars), Durable Objects (hodgef/apiker, 127 stars) and Cloudflare Workers (EpicenterHQ/epicenter, 4.8k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
CommandCodeAI (a GitHub organization) maintains it in CommandCodeAI/agent-skills, which has 132 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on March 10, 2026.
Source: CommandCodeAI/agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.