agents-sdk — agents-sdk setup Cloudflare Workers agents-sdk, community, agents-sdk setup Cloudflare Workers, ide skills, agents-sdk npm package, agents-sdk wrangler.jsonc configuration, Claude Code, Cursor, Windsurf

v1.0.0
GitHub

About this Skill

Perfect for Cloudflare Agents needing persistent, stateful AI applications with durable object bindings and SQLite migrations. agents-sdk is an npm package that provides the tools to build persistent, stateful AI agents on Cloudflare Workers. It utilizes Durable Objects for statefulness and requires specific bindings and SQLite migrations in the wrangler.jsonc configuration file.

Features

Installs via npm install agents for immediate use in projects
Requires durable_objects bindings in wrangler.jsonc for state management
Uses class_name binding that must match your Agent class name exactly
Requires SQLite migrations tagged for persistent data storage
Enables building stateful AI agents on the Cloudflare Workers platform

# Core Topics

charl-kruger charl-kruger
[0]
[0]
Updated: 3/7/2026

Agent Capability Analysis

The agents-sdk skill by charl-kruger is an open-source community AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance. Optimized for agents-sdk setup Cloudflare Workers, agents-sdk npm package, agents-sdk wrangler.jsonc configuration.

Ideal Agent Persona

Perfect for Cloudflare Agents needing persistent, stateful AI applications with durable object bindings and SQLite migrations.

Core Value

Empowers agents to build long-lived AI applications on Cloudflare Workers using the `agents` npm package, leveraging durable object bindings and SQLite migrations for robust state management, and targeting developers with wrangler.jsonc configurations.

Capabilities Granted for agents-sdk

Building persistent AI agents with Cloudflare Workers
Managing state with durable object bindings and SQLite migrations
Creating long-lived AI applications with the `agents` npm package

! Prerequisites & Limits

  • Requires durable object bindings
  • Needs SQLite migrations for state management
  • Cloudflare Workers only
  • Requires specific configuration in wrangler.jsonc
Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

agents-sdk

Install agents-sdk, an AI agent skill for AI agent workflows and automation. Works with Claude Code, Cursor, and Windsurf with one-command setup.

SKILL.md
Readonly

Cloudflare Agents SDK

Build persistent, stateful AI agents on Cloudflare Workers using the agents npm package.

FIRST: Verify Installation

bash
1npm install agents

Agents require a binding in wrangler.jsonc:

jsonc
1{ 2 "durable_objects": { 3 // "class_name" must match your Agent class name exactly 4 "bindings": [{ "name": "Counter", "class_name": "Counter" }] 5 }, 6 "migrations": [ 7 // Required: list all Agent classes for SQLite storage 8 { "tag": "v1", "new_sqlite_classes": ["Counter"] } 9 ] 10}

Choosing an Agent Type

Use CaseBase ClassPackage
Custom state + RPC, no chatAgentagents
Chat with message persistenceAIChatAgent@cloudflare/ai-chat
Building an MCP serverMcpAgentagents/mcp

Key Concepts

  • Agent base class provides state, scheduling, RPC, MCP, and email capabilities
  • AIChatAgent adds streaming chat with automatic message persistence and resumable streams
  • Code Mode generates executable code instead of tool calls—reduces token usage significantly
  • this.state / this.setState() - automatic persistence to SQLite, broadcasts to clients
  • this.schedule() - schedule tasks at Date, delay (seconds), or cron expression
  • @callable decorator - expose methods to clients via WebSocket RPC

Quick Reference

TaskAPI
Persist statethis.setState({ count: 1 })
Read statethis.state.count
Schedule taskthis.schedule(60, "taskMethod", payload)
Schedule cronthis.schedule("0 * * * *", "hourlyTask")
Cancel schedulethis.cancelSchedule(id)
Queue taskthis.queue("processItem", payload)
SQL querythis.sql`SELECT * FROM users WHERE id = ${id}`
RPC method@callable() async myMethod() { ... }
Streaming RPC@callable({ streaming: true }) async stream(res) { ... }

Minimal Agent

typescript
1import { Agent, routeAgentRequest, callable } from "agents"; 2 3type State = { count: number }; 4 5export class Counter extends Agent<Env, State> { 6 initialState = { count: 0 }; 7 8 @callable() 9 increment() { 10 this.setState({ count: this.state.count + 1 }); 11 return this.state.count; 12 } 13} 14 15export default { 16 fetch: (req, env) => 17 routeAgentRequest(req, env) ?? new Response("Not found", { status: 404 }) 18};

Streaming Chat Agent

Use AIChatAgent for chat with automatic message persistence and resumable streaming.

Install additional dependencies first:

bash
1npm install @cloudflare/ai-chat ai @ai-sdk/openai

Add wrangler.jsonc config (same pattern as base Agent):

jsonc
1{ 2 "durable_objects": { 3 "bindings": [{ "name": "Chat", "class_name": "Chat" }] 4 }, 5 "migrations": [{ "tag": "v1", "new_sqlite_classes": ["Chat"] }] 6}
typescript
1import { AIChatAgent } from "@cloudflare/ai-chat"; 2import { routeAgentRequest } from "agents"; 3import { streamText, convertToModelMessages } from "ai"; 4import { openai } from "@ai-sdk/openai"; 5 6export class Chat extends AIChatAgent<Env> { 7 async onChatMessage(onFinish) { 8 const result = streamText({ 9 model: openai("gpt-4o"), 10 messages: await convertToModelMessages(this.messages), 11 onFinish 12 }); 13 return result.toUIMessageStreamResponse(); 14 } 15} 16 17export default { 18 fetch: (req, env) => 19 routeAgentRequest(req, env) ?? new Response("Not found", { status: 404 }) 20};

Client (React):

tsx
1import { useAgent } from "agents/react"; 2import { useAgentChat } from "@cloudflare/ai-chat/react"; 3 4const agent = useAgent({ agent: "Chat", name: "my-chat" }); 5const { messages, input, handleSubmit } = useAgentChat({ agent });

Detailed References

When to Use Code Mode

Code Mode generates executable JavaScript instead of making individual tool calls. Use it when:

  • Chaining multiple tool calls in sequence
  • Complex conditional logic across tools
  • MCP server orchestration (multiple servers)
  • Token budget is constrained

See references/codemode.md for setup and examples.

Best Practices

  1. Prefer streaming: Use streamText and toUIMessageStreamResponse() for chat
  2. Use AIChatAgent for chat: Handles message persistence and resumable streams automatically
  3. Type your state: Agent<Env, State> ensures type safety for this.state
  4. Use @callable for RPC: Cleaner than manual WebSocket message handling
  5. Code Mode for complex workflows: Reduces round-trips and token usage
  6. Schedule vs Queue: Use schedule() for time-based, queue() for sequential processing

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is agents-sdk?

Perfect for Cloudflare Agents needing persistent, stateful AI applications with durable object bindings and SQLite migrations. agents-sdk is an npm package that provides the tools to build persistent, stateful AI agents on Cloudflare Workers. It utilizes Durable Objects for statefulness and requires specific bindings and SQLite migrations in the wrangler.jsonc configuration file.

How do I install agents-sdk?

Run the command: npx killer-skills add charl-kruger/charl/agents-sdk. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for agents-sdk?

Key use cases include: Building persistent AI agents with Cloudflare Workers, Managing state with durable object bindings and SQLite migrations, Creating long-lived AI applications with the `agents` npm package.

Which IDEs are compatible with agents-sdk?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for agents-sdk?

Requires durable object bindings. Needs SQLite migrations for state management. Cloudflare Workers only. Requires specific configuration in wrangler.jsonc.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add charl-kruger/charl/agents-sdk. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use agents-sdk immediately in the current project.

Related Skills

Looking for an alternative to agents-sdk or another community skill for your workflow? Explore these related open-source skills.

View All

widget-generator

Logo of f
f

f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.

149.6k
0
AI

flags

Logo of vercel
vercel

flags is a Next.js feature management skill that enables developers to efficiently add or modify framework feature flags, streamlining React application development.

138.4k
0
Browser

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI