cloudflare-agents — Claude Code skill: AI agents on Cloudflare Workers
A skill for building AI agents on Cloudflare Workers with tools, MCP and LLM providers. Useful when the agent runs inside a worker.
npx skills add secondsky/claude-skills --skill cloudflare-agents -a claude-codeWhat cloudflare-agents does
The skill hands your coding agent reference material and templates for Cloudflare Agents. It covers patterns and concepts, configuration, the Agent class API, MCP integration, HTTP and Server-Sent Events, WebSockets, state management, scheduled tasks and workflows. A separate file goes into browser automation, RAG, calling other agents and client APIs. There is also an error catalog with fixes.
Thirteen templates ship with it: basic agent, browser agent, streaming chat, human-in-the-loop, MCP server, RAG, scheduled tasks, state sync, WebSocket, workflows, calling other agents, a React client and a wrangler config. Cloudflare bindings named in the docs are D1, KV, R2 and Durable Objects; LLM providers are OpenAI, Anthropic and Google Gemini. The model is set as a string on the agent object, gpt-4o in the example.
Everything assumes TypeScript and workers, so if you have not touched wrangler or bindings before, expect a slow start. Check that the bindings you need are declared in the worker config, otherwise the agent gets no storage.
What it helps with
- scaffold an agent on Cloudflare Workers
- wire an MCP server into a worker
- build a streaming chat agent over SSE or WebSocket
- connect an agent to D1, KV, R2 or Durable Objects
- add RAG or browser automation to an agent
Example prompts for the agent
- Scaffold a basic Cloudflare Workers agent from the skill template
- Add MCP integration and tools to my agent
- Build a streaming chat agent with state sync
How to install cloudflare-agents
1Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill cloudflare-agents -a claude-code2Manually: put the files in place
~/.claude/skills/cloudflare-agents/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/cloudflare-agents/
1Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill cloudflare-agents -a codex2Manually: put the files in place
.agents/skills/cloudflare-agents/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill cloudflare-agents -a cursor2Manually: put the files in place
.cursor/skills/cloudflare-agents/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install secondsky/claude-skills cloudflare-agents2Manually: put the files in place
.github/skills/cloudflare-agents/SKILL.md1Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill cloudflare-agents -a gemini-cli2Platform CLI
gemini skills install https://github.com/secondsky/claude-skills --path plugins/cloudflare-agents/skills/cloudflare-agentsManually: put the files in place
.devin/skills/cloudflare-agents/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add secondsky/claude-skills --skill cloudflare-agents -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about cloudflare-agents
How do I install cloudflare-agents in Claude?
Run npx skills add secondsky/claude-skills --skill cloudflare-agents -a claude-code. The skill file lands at ~/.claude/skills/cloudflare-agents/SKILL.md.
What does cloudflare-agents do?
It helps you write AI agents on Cloudflare Workers: tool registration, MCP support, LLM providers and Cloudflare bindings. References, templates and an error catalog are included.
Which LLM providers are supported?
The skill names OpenAI, Anthropic and Google Gemini. The model is set on the agent object, gpt-4o in the example.
Source text
SKILL.md · MIT
---
name: cloudflare-agents
description: Build AI agents on Cloudflare Workers with MCP integration, tool use, and LLM providers.
license: MIT
---
# Cloudflare Agents
**Last Updated**: 2025-11-21
## Quick Start
```typescript
export default {
async fetch(request, env, ctx) {
const agent = {
tools: [
{ name: 'getTodo', handler: async ({id}) => ({id, title: 'Task'}) }
],
async run(input) {
return await processWithLLM(input, this.tools);
}
};
return Response.json(await agent.run(await request.text()));
}
};
```
## Core Features
- **Tool Integration**: Register and execute tools
- **LLM Providers**: OpenAI, Anthropic, Google Gemini
- **MCP Protocol**: Model Context Protocol support
- **Cloudflare Bindings**: D1, KV, R2, Durable Objects
## Agent Pattern
```typescript
const agent = {
tools: [...],
model: 'gpt-4o',
async run(input) {
// Process with LLM
}
};
```
## Resources
### Core Documentation
- `references/patterns-concepts.md` (317 lines) - What is Cloudflare Agents, patterns & concepts, critical rules, known issues prevention
- `references/configuration-guide.md` (152 lines) - Complete configuration deep dive
- `references/agent-api.md` (115 lines) - Complete Agent Class API reference
### Integration Guides
- `references/http-sse-guide.md` (74 lines) - HTTP & Server-Sent Events
- `references/websockets-guide.md` (110 lines) - WebSocket integration
- `references/state-management.md` (388 lines) - State management, scheduled tasks, workflows
- `references/mcp-integration.md` (130 lines) - Model Context Protocol integration
### Advanced Features
- `references/advanced-features.md` (637 lines) - Browser automation, RAG, AI model integration, calling agents, client APIs
### Error Reference
- `references/error-catalog.md` (10 lines) - Common errors and solutions
### Templates
- `templates/basic-agent.ts` - Basic agent setup
- `templates/browser-agent.ts` - Browser automation
- `templates/calling-agents-worker.ts` - Calling other agents
- `templates/chat-agent-streaming.ts` - Streaming chat agent
- `templates/hitl-agent.ts` - Human-in-the-loop
- `templates/mcp-server-basic.ts` - MCP server integration
- `templates/rag-agent.ts` - RAG implementation
- `templates/react-useagent-client.tsx` - React client integration
- `templates/scheduled-agent.ts` - Scheduled tasks
- `templates/state-sync-agent.ts` - State synchronization
- `templates/websocket-agent.ts` - WebSocket agent
- `templates/workflow-agent.ts` - Workflows integration
- `templates/wrangler-agents-config.jsonc` - Wrangler configuration
**Official Docs**: https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-agents/
© secondsky · MIT · secondsky/claude-skills