{"id":"cloudflare","kind":"sdk","name":"Cloudflare","slug":"cloudflare","description":"SDKs and APIs for Workers, R2, D1, DNS, Zero Trust, and the Cloudflare platform.","vendor":"Cloudflare","languages":["typescript","nodejs","javascript","python","go"],"categories":["cloud","infrastructure","security"],"homepage":"https://developers.cloudflare.com","docsUrl":"https://developers.cloudflare.com","githubUrl":"https://github.com/cloudflare","packages":[{"registry":"npm","name":"cloudflare","url":"https://www.npmjs.com/package/cloudflare"},{"registry":"pypi","name":"cloudflare","url":"https://pypi.org/project/cloudflare/"}],"tags":["workers","edge","r2"],"skills":[{"name":"cloudflare","url":"https://github.com/cloudflare/skills","install":"npx skills add https://github.com/cloudflare/skills","sdk":"cloudflare","key":"cloudflare/cloudflare","description":"Comprehensive Cloudflare platform skill covering Workers, Pages, storage (KV, D1, R2), AI (Workers AI, Vectorize, Agents SDK), feature flags (Flagship), networking (Tunnel, Spectrum), security (WAF, DDoS), and infrastructure-as-code (Terraform, Pulumi). Use for any Cloudflare development task. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","hasContent":true,"content":"---\nname: cloudflare\ndescription: Comprehensive Cloudflare platform skill covering Workers, Pages, storage (KV, D1, R2), AI (Workers AI, Vectorize, Agents SDK), feature flags (Flagship), networking (Tunnel, Spectrum), security (WAF, DDoS), and infrastructure-as-code (Terraform, Pulumi). Use for any Cloudflare development task. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.\nreferences:\n  - workers\n  - pages\n  - d1\n  - durable-objects\n  - workers-ai\n---\n\n# Cloudflare Platform Skill\n\nConsolidated skill for building on the Cloudflare platform. Use decision trees below to find the right product, then load detailed references.\n\nYour knowledge of Cloudflare APIs, types, limits, and pricing may be outdated. **Prefer retrieval over pre-training** — the references in this skill are starting points, not source of truth.\n\n## Retrieval Sources\n\nFetch the **latest** information before citing specific numbers, API signatures, or configuration options. Do not rely on baked-in knowledge or these reference files alone.\n\n| Source | How to retrieve | Use for |\n|--------|----------------|---------|\n| Cloudflare docs | `cloudflare-docs` search tool or `https://developers.cloudflare.com/` | Limits, pricing, API reference, compatibility dates/flags |\n| Workers types | `npm pack @cloudflare/workers-types` or check `node_modules` | Type signatures, binding shapes, handler types |\n| Wrangler config schema | `node_modules/wrangler/config-schema.json` | Config fields, binding shapes, allowed values |\n| Product changelogs | `https://developers.cloudflare.com/changelog/` | Recent changes to limits, features, deprecations |\n\nWhen a reference file and the docs disagree, **trust the docs**. This is especially important for: numeric limits, pricing tiers, type signatures, and configuration options.\n\n## Quick Decision Trees\n\n### \"I need feature flags\"\n\n```\nNeed feature flags?\n└─ Feature toggles, targeting rules, percentage rollouts → flagship/\n   ├─ Evaluate in Workers → Flagship binding (env.FLAGS)\n   ├─ Evaluate in Node.js / browser → OpenFeature SDK (@cloudflare/flagship)\n   └─ Manage flags via API → Flagship REST API\n```\n\n### \"I need to run code\"\n\n```\nNeed to run code?\n├─ Serverless functions at the edge → workers/\n├─ Full-stack web app with Git deploys → pages/\n├─ Stateful coordination/real-time → durable-objects/\n├─ Long-running multi-step jobs → workflows/\n├─ Run containers → containers/\n├─ Multi-tenant (customers deploy code) → workers-for-platforms/\n├─ Scheduled tasks (cron) → cron-triggers/\n├─ Lightweight edge logic (modify HTTP) → snippets/\n├─ Process Worker execution events (logs/observability) → tail-workers/\n└─ Optimize latency to backend infrastructure → smart-placement/\n```\n\n### \"I need to store data\"\n\n```\nNeed storage?\n├─ Key-value (config, sessions, cache) → kv/\n├─ Relational SQL → d1/ (SQLite) or hyperdrive/ (existing Postgres/MySQL)\n├─ Object/file storage (S3-compatible) → r2/\n├─ Versioned file trees (repos, build outputs, checkpoints) → artifacts/\n├─ Message queue (async processing) → queues/\n├─ Vector embeddings (AI/semantic search) → vectorize/\n├─ Strongly-consistent per-entity state → durable-objects/ (DO storage)\n├─ Secrets management → secrets-store/\n├─ Streaming ETL to R2 → pipelines/\n├─ Managed Apache Iceberg catalog on R2 → r2-data-catalog/\n├─ Serverless SQL analytics over Iceberg tables → r2-sql/\n└─ Persistent cache (long-term retention) → cache-reserve/\n```\n\n### \"I need AI/ML\"\n\n```\nNeed AI?\n├─ Run inference (LLMs, embeddings, images) → workers-ai/\n├─ Vector database for RAG/search → vectorize/\n├─ Build stateful AI agents → agents-sdk/\n├─ Gateway for any AI provider (caching, routing) → ai-gateway/\n└─ AI-powered search widget → ai-search/\n```\n\n### \"I need networking/connectivity\"\n\n```\nNeed networking?\n├─ Expose local service to internet → tunnel/\n├─ TCP/UDP proxy (non-HTTP) → spectrum/\n├─ WebRTC TURN server → turn/\n├─ Private network connectivity → network-interconnect/\n├─ Optimize routing → argo-smart-routing/\n├─ Optimize latency to backend (not user) → smart-placement/\n└─ Real-time video/audio → realtimekit/ or realtime-sfu/\n```\n\n### \"I need security\"\n\n```\nNeed security?\n├─ Web Application Firewall → waf/\n├─ DDoS protection → ddos/\n├─ Bot detection/management → bot-management/\n├─ API protection → api-shield/\n├─ CAPTCHA alternative → turnstile/\n└─ Credential leak detection → waf/ (managed ruleset)\n```\n\n### \"I need media/content\"\n\n```\nNeed media?\n├─ Image optimization/transformation → images/\n├─ Video streaming/encoding → stream/\n├─ Browser automation/screenshots → browser-rendering/\n└─ Third-party script management → zaraz/\n```\n\n### \"I need analytics/metrics data\"\n\n```\nNeed analytics?\n├─ Query across all Cloudflare products (HTTP, Workers, DNS, etc.) → graphql-api/\n├─ Custom high-cardinality metrics from Workers → analytics-engine/\n├─ Client-side (RUM) performance data → web-analytics/\n├─ Workers Logs and real-time debugging → observability/\n├─ SQL over Iceberg data lake (logs, events) → r2-sql/ (+ pipelines/, r2-data-catalog/)\n└─ Raw logs (Logpush to external tools) → Cloudflare docs\n```\n\n### \"I need infrastructure-as-code\"\n\n```\nNeed IaC? → pulumi/ (Pulumi), terraform/ (Terraform), or api/ (REST API)\n```\n\n## Product Index\n\n### Feature Flags\n| Product | Reference |\n|---------|-----------|\n| Flagship | `references/flagship/` |\n\n### Compute & Runtime\n| Product | Reference |\n|---------|-----------|\n| Workers | `references/workers/` |\n| Pages | `references/pages/` |\n| Pages Functions | `references/pages-functions/` |\n| Durable Objects | `references/durable-objects/` |\n| Workflows | `references/workflows/` |\n| Containers | `references/containers/` |\n| Workers for Platforms | `references/workers-for-platforms/` |\n| Cron Triggers | `references/cron-triggers/` |\n| Tail Workers | `references/tail-workers/` |\n| Snippets | `references/snippets/` |\n| Smart Placement | `references/smart-placement/` |\n\n### Storage & Data\n| Product | Reference |\n|---------|-----------|\n| KV | `references/kv/` |\n| D1 | `references/d1/` |\n| R2 | `references/r2/` |\n| Artifacts | `references/artifacts/` |\n| Queues | `references/queues/` |\n| Hyperdrive | `references/hyperdrive/` |\n| DO Storage | `references/do-storage/` |\n| Secrets Store | `references/secrets-store/` |\n| Pipelines | `references/pipelines/` |\n| R2 Data Catalog | `references/r2-data-catalog/` |\n| R2 SQL | `references/r2-sql/` |\n\n### AI & Machine Learning\n| Product | Reference |\n|---------|-----------|\n| Workers AI | `references/workers-ai/` |\n| Vectorize | `references/vectorize/` |\n| Agents SDK | `references/agents-sdk/` |\n| AI Gateway | `references/ai-gateway/` |\n| AI Search | `references/ai-search/` |\n\n### Networking & Connectivity\n| Product | Reference |\n|---------|-----------|\n| Tunnel | `references/tunnel/` |\n| Spectrum | `references/spectrum/` |\n| TURN | `references/turn/` |\n| Network Interconnect | `references/network-interconnect/` |\n| Argo Smart Routing | `references/argo-smart-routing/` |\n| Workers VPC | `references/workers-vpc/` |\n\n### Security\n| Product | Reference |\n|---------|-----------|\n| WAF | `references/waf/` |\n| DDoS Protection | `references/ddos/` |\n| Bot Management | `references/bot-management/` |\n| API Shield | `references/api-shield/` |\n| Turnstile | `references/turnstile/` |\n\n### Media & Content\n| Product | Reference |\n|---------|-----------|\n| Images | `references/images/` |\n| Stream | `references/stream/` |\n| Browser Rendering | `references/browser-rendering/` |\n| Zaraz | `references/zaraz/` |\n\n### Real-Time Communication\n| Product | Reference |\n|---------|-----------|\n| RealtimeKit | `references/realtimekit/` |\n| Realtime SFU | `references/realtime-sfu/` |\n\n### Developer Tools\n| Product | Reference |\n|---------|-----------|\n| Wrangler | `references/wrangler/` |\n| Miniflare | `references/miniflare/` |\n| C3 | `references/c3/` |\n| Observability | `references/observability/` |\n| GraphQL Analytics API | `references/graphql-api/` |\n| Analytics Engine | `references/analytics-engine/` |\n| Web Analytics | `references/web-analytics/` |\n| Sandbox | `references/sandbox/` |\n| Workerd | `references/workerd/` |\n| Workers Playground | `references/workers-playground/` |\n\n### Infrastructure as Code\n| Product | Reference |\n|---------|-----------|\n| Pulumi | `references/pulumi/` |\n| Terraform | `references/terraform/` |\n| API | `references/api/` |\n\n### Other Services\n| Product | Reference |\n|---------|-----------|\n| Email Routing | `references/email-routing/` |\n| Email Workers | `references/email-workers/` |\n| Static Assets | `references/static-assets/` |\n| Bindings | `references/bindings/` |\n| Cache Reserve | `references/cache-reserve/` |\n","contentSource":"skills.sh/api/download/cloudflare/skills/cloudflare","contentFetchedAt":"2026-07-27T08:59:25.029Z"},{"name":"wrangler","url":"https://github.com/cloudflare/skills/tree/main/skills/wrangler","sdk":"cloudflare","key":"cloudflare/wrangler","description":"Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","hasContent":true,"content":"---\nname: wrangler\ndescription: Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.\n---\n\n# Wrangler CLI\n\nYour knowledge of Wrangler CLI flags, config fields, and subcommands may be outdated. **Prefer retrieval over pre-training** for any Wrangler task.\n\n## Retrieval Sources\n\nFetch the **latest** information before writing or reviewing Wrangler commands and config. Do not rely on baked-in knowledge for CLI flags, config fields, or binding shapes.\n\n| Source | How to retrieve | Use for |\n|--------|----------------|---------|\n| Wrangler docs | `https://developers.cloudflare.com/workers/wrangler/` | CLI commands, flags, config reference |\n| Wrangler config schema | `node_modules/wrangler/config-schema.json` | Config fields, binding shapes, allowed values |\n| Cloudflare docs | Search tool or `https://developers.cloudflare.com/workers/` | API reference, compatibility dates/flags |\n\n## FIRST: Check if Wrangler is installed, and if not, install it\n\nCheck if Wrangler is installed by running:\n\n```bash\nwrangler --version  # Requires v4.x+\n```\n\nIf Wrangler is not installed, you should install it by running:\n\n```bash\nnpm install -D wrangler@latest\n```\n\nWherever possible, you should use Wrangler instead of manually constructing API requests.\n\n## Key Guidelines\n\n- **Use `wrangler.jsonc`**: Prefer JSON config over TOML. Newer features are JSON-only.\n- **Set `compatibility_date`**: Use a recent date (within 30 days). Check https://developers.cloudflare.com/workers/configuration/compatibility-dates/\n- **Generate types after config changes**: Run `wrangler types` to update TypeScript bindings.\n- **Local dev defaults to local storage**: Bindings use local simulation unless `remote: true`.\n- **Profile Worker startup**: Run `wrangler check startup` to measure startup time and detect scripts that exceed the startup time limit.\n- **Use environments for staging/prod**: Define `env.staging` and `env.production` in config.\n\n## Quick Start: New Worker\n\n```bash\n# Initialize new project\nnpx wrangler init my-worker\n\n# Or with a framework\nnpx create-cloudflare@latest my-app\n```\n\n## Quick Reference: Core Commands\n\n| Task | Command |\n|------|---------|\n| Start local dev server | `wrangler dev` |\n| Deploy to Cloudflare | `wrangler deploy` |\n| Deploy dry run | `wrangler deploy --dry-run` |\n| Generate TypeScript types | `wrangler types` |\n| Profile Worker startup time | `wrangler check startup` |\n| View live logs | `wrangler tail` |\n| Delete Worker | `wrangler delete` |\n| Auth status | `wrangler whoami` |\n\n---\n\n## Configuration (wrangler.jsonc)\n\n### Minimal Config\n\n```jsonc\n{\n  \"$schema\": \"./node_modules/wrangler/config-schema.json\",\n  \"name\": \"my-worker\",\n  \"main\": \"src/index.ts\",\n  \"compatibility_date\": \"2026-01-01\"\n}\n```\n\n### Full Config with Bindings\n\n```jsonc\n{\n  \"$schema\": \"./node_modules/wrangler/config-schema.json\",\n  \"name\": \"my-worker\",\n  \"main\": \"src/index.ts\",\n  \"compatibility_date\": \"2026-01-01\",\n  \"compatibility_flags\": [\"nodejs_compat\"],\n\n  // Environment variables\n  \"vars\": {\n    \"ENVIRONMENT\": \"production\"\n  },\n\n  // KV Namespace\n  \"kv_namespaces\": [\n    { \"binding\": \"KV\", \"id\": \"<KV_NAMESPACE_ID>\" }\n  ],\n\n  // R2 Bucket\n  \"r2_buckets\": [\n    { \"binding\": \"BUCKET\", \"bucket_name\": \"my-bucket\" }\n  ],\n\n  // D1 Database\n  \"d1_databases\": [\n    { \"binding\": \"DB\", \"database_name\": \"my-db\", \"database_id\": \"<DB_ID>\" }\n  ],\n\n  // Workers AI (always remote)\n  \"ai\": { \"binding\": \"AI\" },\n\n  // Vectorize\n  \"vectorize\": [\n    { \"binding\": \"VECTOR_INDEX\", \"index_name\": \"my-index\" }\n  ],\n\n  // Hyperdrive\n  \"hyperdrive\": [\n    { \"binding\": \"HYPERDRIVE\", \"id\": \"<HYPERDRIVE_ID>\" }\n  ],\n\n  // Durable Objects\n  \"durable_objects\": {\n    \"bindings\": [\n      { \"name\": \"COUNTER\", \"class_name\": \"Counter\" }\n    ]\n  },\n\n  // Cron triggers\n  \"triggers\": {\n    \"crons\": [\"0 * * * *\"]\n  },\n\n  // Environments\n  \"env\": {\n    \"staging\": {\n      \"name\": \"my-worker-staging\",\n      \"vars\": { \"ENVIRONMENT\": \"staging\" }\n    }\n  }\n}\n```\n\n### Generate Types from Config\n\n```bash\n# Generate worker-configuration.d.ts\nwrangler types\n\n# Custom output path\nwrangler types ./src/env.d.ts\n\n# Check types are up to date (CI)\nwrangler types --check\n```\n\n---\n\n## Local Development\n\n### Start Dev Server\n\n```bash\n# Local mode (default) - uses local storage simulation\nwrangler dev\n\n# With specific environment\nwrangler dev --env staging\n\n# Force local-only (disable remote bindings)\nwrangler dev --local\n\n# Remote mode - runs on Cloudflare edge (legacy)\nwrangler dev --remote\n\n# Custom port\nwrangler dev --port 8787\n\n# Live reload for HTML changes\nwrangler dev --live-reload\n\n# Test scheduled/cron handlers\nwrangler dev --test-scheduled\n# Then visit: http://localhost:8787/__scheduled\n```\n\n### Remote Bindings for Local Dev\n\nUse `remote: true` in binding config to connect to real resources while running locally:\n\n```jsonc\n{\n  \"r2_buckets\": [\n    { \"binding\": \"BUCKET\", \"bucket_name\": \"my-bucket\", \"remote\": true }\n  ],\n  \"ai\": { \"binding\": \"AI\", \"remote\": true },\n  \"vectorize\": [\n    { \"binding\": \"INDEX\", \"index_name\": \"my-index\", \"remote\": true }\n  ]\n}\n```\n\n**Recommended remote bindings**: AI (required), Vectorize, Browser Rendering, mTLS, Images.\n\n### Local Secrets\n\nCreate `.dev.vars` for local development secrets:\n\n```\nAPI_KEY=local-dev-key\nDATABASE_URL=postgres://localhost:5432/dev\n```\n\n---\n\n## Deployment\n\n### Deploy Worker\n\n```bash\n# Deploy to production\nwrangler deploy\n\n# Deploy specific environment\nwrangler deploy --env staging\n\n# Dry run (validate without deploying)\nwrangler deploy --dry-run\n\n# Keep dashboard-set variables\nwrangler deploy --keep-vars\n\n# Minify code\nwrangler deploy --minify\n```\n\n### Manage Secrets\n\n> **Security**: Never pass secret values as command arguments or pipe them via `echo`.\n> Use the interactive prompt (preferred), pipe from a file, or use `secret bulk`.\n> Never output, log, or hardcode secret values in commands.\n\n```bash\n# Set secret — interactive prompt (preferred, wrangler will ask for the value securely)\nwrangler secret put API_KEY\n\n# Set secret from a file (useful for PEM keys, CI environments)\nwrangler secret put PRIVATE_KEY < path/to/private-key.pem\n\n# List secrets\nwrangler secret list\n\n# Delete secret\nwrangler secret delete API_KEY\n\n# Bulk secrets from JSON file (do not commit this file to version control)\nwrangler secret bulk secrets.json\n```\n\n### Versions and Rollback\n\n```bash\n# List recent versions\nwrangler versions list\n\n# View specific version\nwrangler versions view <VERSION_ID>\n\n# Rollback to previous version\nwrangler rollback\n\n# Rollback to specific version\nwrangler rollback <VERSION_ID>\n```\n\n---\n\n## KV (Key-Value Store)\n\n### Manage Namespaces\n\n```bash\n# Create namespace\nwrangler kv namespace create MY_KV\n\n# List namespaces\nwrangler kv namespace list\n\n# Delete namespace\nwrangler kv namespace delete --namespace-id <ID>\n```\n\n### Manage Keys\n\n```bash\n# Put value\nwrangler kv key put --namespace-id <ID> \"key\" \"value\"\n\n# Put with expiration (seconds)\nwrangler kv key put --namespace-id <ID> \"key\" \"value\" --expiration-ttl 3600\n\n# Get value\nwrangler kv key get --namespace-id <ID> \"key\"\n\n# List keys\nwrangler kv key list --namespace-id <ID>\n\n# Delete key\nwrangler kv key delete --namespace-id <ID> \"key\"\n\n# Bulk put from JSON\nwrangler kv bulk put --namespace-id <ID> data.json\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"kv_namespaces\": [\n    { \"binding\": \"CACHE\", \"id\": \"<NAMESPACE_ID>\" }\n  ]\n}\n```\n\n---\n\n## R2 (Object Storage)\n\n### Manage Buckets\n\n```bash\n# Create bucket\nwrangler r2 bucket create my-bucket\n\n# Create with location hint\nwrangler r2 bucket create my-bucket --location wnam\n\n# List buckets\nwrangler r2 bucket list\n\n# Get bucket info\nwrangler r2 bucket info my-bucket\n\n# Delete bucket\nwrangler r2 bucket delete my-bucket\n```\n\n### Manage Objects\n\n```bash\n# Upload object\nwrangler r2 object put my-bucket/path/file.txt --file ./local-file.txt\n\n# Download object\nwrangler r2 object get my-bucket/path/file.txt\n\n# Delete object\nwrangler r2 object delete my-bucket/path/file.txt\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"r2_buckets\": [\n    { \"binding\": \"ASSETS\", \"bucket_name\": \"my-bucket\" }\n  ]\n}\n```\n\n---\n\n## D1 (SQL Database)\n\n### Manage Databases\n\n```bash\n# Create database\nwrangler d1 create my-database\n\n# Create with location\nwrangler d1 create my-database --location wnam\n\n# List databases\nwrangler d1 list\n\n# Get database info\nwrangler d1 info my-database\n\n# Delete database\nwrangler d1 delete my-database\n```\n\n### Execute SQL\n\n```bash\n# Execute SQL command (remote)\nwrangler d1 execute my-database --remote --command \"SELECT * FROM users\"\n\n# Execute SQL file (remote)\nwrangler d1 execute my-database --remote --file ./schema.sql\n\n# Execute locally\nwrangler d1 execute my-database --local --command \"SELECT * FROM users\"\n```\n\n### Migrations\n\n```bash\n# Create migration\nwrangler d1 migrations create my-database create_users_table\n\n# List pending migrations\nwrangler d1 migrations list my-database --local\n\n# Apply migrations locally\nwrangler d1 migrations apply my-database --local\n\n# Apply migrations to remote\nwrangler d1 migrations apply my-database --remote\n```\n\n### Export/Backup\n\n```bash\n# Export schema and data\nwrangler d1 export my-database --remote --output backup.sql\n\n# Export schema only\nwrangler d1 export my-database --remote --output schema.sql --no-data\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"d1_databases\": [\n    {\n      \"binding\": \"DB\",\n      \"database_name\": \"my-database\",\n      \"database_id\": \"<DATABASE_ID>\",\n      \"migrations_dir\": \"./migrations\"\n    }\n  ]\n}\n```\n\n---\n\n## Vectorize (Vector Database)\n\n### Manage Indexes\n\n```bash\n# Create index with dimensions\nwrangler vectorize create my-index --dimensions 768 --metric cosine\n\n# Create with preset (auto-configures dimensions/metric)\nwrangler vectorize create my-index --preset @cf/baai/bge-base-en-v1.5\n\n# List indexes\nwrangler vectorize list\n\n# Get index info\nwrangler vectorize get my-index\n\n# Delete index\nwrangler vectorize delete my-index\n```\n\n### Manage Vectors\n\n```bash\n# Insert vectors from NDJSON file\nwrangler vectorize insert my-index --file vectors.ndjson\n\n# Query vectors\nwrangler vectorize query my-index --vector \"[0.1, 0.2, ...]\" --top-k 10\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"vectorize\": [\n    { \"binding\": \"SEARCH_INDEX\", \"index_name\": \"my-index\" }\n  ]\n}\n```\n\n---\n\n## Hyperdrive (Database Accelerator)\n\n### Manage Configs\n\n```bash\n# Create config\nwrangler hyperdrive create my-hyperdrive \\\n  --origin-host db.example.com \\\n  --origin-port 5432 \\\n  --database my-database \\\n  --origin-user db-user \\\n  --origin-password \"$DB_PASSWORD\"\n\n# Or using a connection string from an environment variable\nwrangler hyperdrive create my-hyperdrive \\\n  --connection-string \"$HYPERDRIVE_CONNECTION_STRING\"\n\n# List configs\nwrangler hyperdrive list\n\n# Get config details\nwrangler hyperdrive get <HYPERDRIVE_ID>\n\n# Update config\nwrangler hyperdrive update <HYPERDRIVE_ID> \\\n  --origin-password \"$DB_PASSWORD\"\n\n# Delete config\nwrangler hyperdrive delete <HYPERDRIVE_ID>\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"compatibility_flags\": [\"nodejs_compat\"],\n  \"hyperdrive\": [\n    { \"binding\": \"HYPERDRIVE\", \"id\": \"<HYPERDRIVE_ID>\" }\n  ]\n}\n```\n\n---\n\n## Workers AI\n\n### List Models\n\n```bash\n# List available models\nwrangler ai models\n\n# List finetunes\nwrangler ai finetune list\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"ai\": { \"binding\": \"AI\" }\n}\n```\n\n**Note**: Workers AI always runs remotely and incurs usage charges even in local dev.\n\n---\n\n## Queues\n\n### Manage Queues\n\n```bash\n# Create queue\nwrangler queues create my-queue\n\n# List queues\nwrangler queues list\n\n# Delete queue\nwrangler queues delete my-queue\n\n# Add consumer to queue\nwrangler queues consumer add my-queue my-worker\n\n# Remove consumer\nwrangler queues consumer remove my-queue my-worker\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"queues\": {\n    \"producers\": [\n      { \"binding\": \"MY_QUEUE\", \"queue\": \"my-queue\" }\n    ],\n    \"consumers\": [\n      {\n        \"queue\": \"my-queue\",\n        \"max_batch_size\": 10,\n        \"max_batch_timeout\": 30\n      }\n    ]\n  }\n}\n```\n\n---\n\n## Containers\n\n### Build and Push Images\n\n```bash\n# Build container image\nwrangler containers build -t my-app:latest .\n\n# Build and push in one command\nwrangler containers build -t my-app:latest . --push\n\n# Push existing image to Cloudflare registry\nwrangler containers push my-app:latest\n```\n\n### Manage Containers\n\n```bash\n# List containers\nwrangler containers list\n\n# Get container info\nwrangler containers info <CONTAINER_ID>\n\n# Delete container\nwrangler containers delete <CONTAINER_ID>\n```\n\n### Manage Images\n\n```bash\n# List images in registry\nwrangler containers images list\n\n# Delete image\nwrangler containers images delete my-app:latest\n```\n\n### Manage External Registries\n\n> **Security**: Never hardcode registry credentials in commands. Use environment variables.\n\n```bash\n# List configured registries\nwrangler containers registries list\n\n# Configure external registry (e.g., ECR)\nwrangler containers registries configure <DOMAIN> \\\n  --aws-access-key-id \"$AWS_ACCESS_KEY_ID\"\n\n# Configure DockerHub\nwrangler containers registries configure <DOMAIN> \\\n  --dockerhub-username \"$DOCKERHUB_USERNAME\"\n\n# Delete registry configuration\nwrangler containers registries delete <DOMAIN>\n```\n\n---\n\n## Workflows\n\n### Manage Workflows\n\n```bash\n# List workflows\nwrangler workflows list\n\n# Describe workflow\nwrangler workflows describe my-workflow\n\n# Trigger workflow instance\nwrangler workflows trigger my-workflow\n\n# Trigger with parameters\nwrangler workflows trigger my-workflow --params '{\"key\": \"value\"}'\n\n# Delete workflow\nwrangler workflows delete my-workflow\n```\n\n### Manage Workflow Instances\n\n```bash\n# List instances\nwrangler workflows instances list my-workflow\n\n# Describe instance\nwrangler workflows instances describe my-workflow <INSTANCE_ID>\n\n# Terminate instance\nwrangler workflows instances terminate my-workflow <INSTANCE_ID>\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"workflows\": [\n    {\n      \"binding\": \"MY_WORKFLOW\",\n      \"name\": \"my-workflow\",\n      \"class_name\": \"MyWorkflow\"\n    }\n  ]\n}\n```\n\n---\n\n## Pipelines\n\n### Manage Pipelines\n\n```bash\n# Create pipeline\nwrangler pipelines create my-pipeline --r2 my-bucket\n\n# List pipelines\nwrangler pipelines list\n\n# Show pipeline details\nwrangler pipelines show my-pipeline\n\n# Update pipeline\nwrangler pipelines update my-pipeline --batch-max-mb 100\n\n# Delete pipeline\nwrangler pipelines delete my-pipeline\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"pipelines\": [\n    { \"binding\": \"MY_PIPELINE\", \"pipeline\": \"my-pipeline\" }\n  ]\n}\n```\n\n---\n\n## Secrets Store\n\n### Manage Stores\n\n```bash\n# Create store\nwrangler secrets-store store create my-store\n\n# List stores\nwrangler secrets-store store list\n\n# Delete store\nwrangler secrets-store store delete <STORE_ID>\n```\n\n### Manage Secrets in Store\n\n```bash\n# Add secret to store\nwrangler secrets-store secret put <STORE_ID> my-secret\n\n# List secrets in store\nwrangler secrets-store secret list <STORE_ID>\n\n# Get secret\nwrangler secrets-store secret get <STORE_ID> my-secret\n\n# Delete secret from store\nwrangler secrets-store secret delete <STORE_ID> my-secret\n```\n\n### Config Binding\n\n```jsonc\n{\n  \"secrets_store_secrets\": [\n    {\n      \"binding\": \"MY_SECRET\",\n      \"store_id\": \"<STORE_ID>\",\n      \"secret_name\": \"my-secret\"\n    }\n  ]\n}\n```\n\n---\n\n## Pages (Frontend Deployment)\n\n```bash\n# Create Pages project\nwrangler pages project create my-site\n\n# Deploy directory to Pages\nwrangler pages deploy ./dist\n\n# Deploy with specific branch\nwrangler pages deploy ./dist --branch main\n\n# List deployments\nwrangler pages deployment list --project-name my-site\n```\n\n---\n\n## Observability\n\n### Tail Logs\n\n```bash\n# Stream live logs\nwrangler tail\n\n# Tail specific Worker\nwrangler tail my-worker\n\n# Filter by status\nwrangler tail --status error\n\n# Filter by search term\nwrangler tail --search \"error\"\n\n# JSON output\nwrangler tail --format json\n```\n\n### Config Logging\n\n```jsonc\n{\n  \"observability\": {\n    \"enabled\": true,\n    \"head_sampling_rate\": 1\n  }\n}\n```\n\n---\n\n## Testing\n\n### Local Testing with Vitest\n\n```bash\nnpm install -D @cloudflare/vitest-pool-workers vitest\n```\n\n`vitest.config.ts`:\n```typescript\nimport { defineWorkersConfig } from \"@cloudflare/vitest-pool-workers/config\";\n\nexport default defineWorkersConfig({\n  test: {\n    poolOptions: {\n      workers: {\n        wrangler: { configPath: \"./wrangler.jsonc\" },\n      },\n    },\n  },\n});\n```\n\n### Test Scheduled Events\n\n```bash\n# Enable in dev\nwrangler dev --test-scheduled\n\n# Trigger via HTTP\ncurl http://localhost:8787/__scheduled\n```\n\n---\n\n## Troubleshooting\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| `command not found: wrangler` | Install: `npm install -D wrangler` |\n| Auth errors | Run `wrangler login` |\n| Startup time limit exceeded | Run `wrangler check startup` to profile startup and generate CPU profiles |\n| Type errors after config change | Run `wrangler types` |\n| Local storage not persisting | Check `.wrangler/state` directory |\n| Binding undefined in Worker | Verify binding name matches config exactly |\n\n### Debug Commands\n\n```bash\n# Check auth status\nwrangler whoami\n\n# Profile Worker startup time\nwrangler check startup\n\n# View config schema\nwrangler docs configuration\n```\n\n---\n\n## Best Practices\n\n1. **Version control `wrangler.jsonc`**: Treat as source of truth for Worker config.\n2. **Use automatic provisioning**: Omit resource IDs for auto-creation on deploy.\n3. **Run `wrangler types` in CI**: Add to build step to catch binding mismatches.\n4. **Use environments**: Separate staging/production with `env.staging`, `env.production`.\n5. **Set `compatibility_date`**: Update quarterly to get new runtime features.\n6. **Use `.dev.vars` for local secrets**: Never commit secrets to config.\n7. **Test locally first**: `wrangler dev` with local bindings before deploying.\n8. **Use `--dry-run` before major deploys**: Validate changes without deployment.\n9. **Never embed secrets in commands**: Use interactive prompts (`wrangler secret put`), file-based input (`wrangler secret bulk`), or secure CI environment variables. Never echo, log, or pass secret values as CLI arguments.\n","contentSource":"skills.sh/api/download/cloudflare/skills/wrangler","contentFetchedAt":"2026-07-27T08:59:25.303Z"},{"name":"agents-sdk","url":"https://github.com/cloudflare/skills/tree/main/skills/agents-sdk","sdk":"cloudflare","key":"cloudflare/agents-sdk","description":"Build AI agents on Cloudflare Workers using the Agents SDK. Load when creating stateful agents, durable workflows, real-time WebSocket apps, scheduled tasks, MCP servers, chat applications, voice agents, or browser automation. Covers Agent class, state management, callable RPC, Workflows, durable execution, queues, retries, observability, and React hooks. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.","hasContent":true,"content":"---\nname: agents-sdk\ndescription: Build AI agents on Cloudflare Workers using the Agents SDK. Load when creating stateful agents, durable workflows, real-time WebSocket apps, scheduled tasks, MCP servers, chat applications, voice agents, or browser automation. Covers Agent class, state management, callable RPC, Workflows, durable execution, queues, retries, observability, and React hooks. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.\n---\n\n# Cloudflare Agents SDK\n\nYour knowledge of the Agents SDK may be outdated. **Prefer retrieval over pre-training** for any Agents SDK task.\n\n## Retrieval Sources\n\nCloudflare docs: https://developers.cloudflare.com/agents/\n\n| Topic | Docs URL | Use for |\n|-------|----------|---------|\n| Getting started | [Quick start](https://developers.cloudflare.com/agents/getting-started/quick-start/) | First agent, project setup |\n| Adding to existing project | [Add to existing project](https://developers.cloudflare.com/agents/getting-started/add-to-existing-project/) | Install into existing Workers app |\n| Configuration | [Configuration](https://developers.cloudflare.com/agents/api-reference/configuration/) | `wrangler.jsonc`, bindings, assets, deployment |\n| Agent class | [Agents API](https://developers.cloudflare.com/agents/api-reference/agents-api/) | Agent lifecycle, patterns, pitfalls |\n| State | [Store and sync state](https://developers.cloudflare.com/agents/api-reference/store-and-sync-state/) | `setState`, `validateStateChange`, persistence |\n| Routing | [Routing](https://developers.cloudflare.com/agents/api-reference/routing/) | URL patterns, `routeAgentRequest` |\n| Callable methods | [Callable methods](https://developers.cloudflare.com/agents/api-reference/callable-methods/) | `@callable`, RPC, streaming, timeouts |\n| Scheduling | [Schedule tasks](https://developers.cloudflare.com/agents/api-reference/schedule-tasks/) | `schedule()`, `scheduleEvery()`, cron |\n| Workflows | [Run workflows](https://developers.cloudflare.com/agents/api-reference/run-workflows/) | `AgentWorkflow`, durable multi-step tasks |\n| HTTP/WebSockets | [WebSockets](https://developers.cloudflare.com/agents/api-reference/websockets/) | Lifecycle hooks, hibernation |\n| Chat agents | [Chat agents](https://developers.cloudflare.com/agents/api-reference/chat-agents/) | `AIChatAgent`, streaming, tools, persistence |\n| Client SDK | [Client SDK](https://developers.cloudflare.com/agents/api-reference/client-sdk/) | `useAgent`, `useAgentChat`, React hooks |\n| Client tools | [Client tools](https://developers.cloudflare.com/agents/api-reference/client-tools/) | Client-side tools, `autoContinueAfterToolResult` |\n| Server-driven messages | [Trigger patterns](https://developers.cloudflare.com/agents/api-reference/trigger-patterns/) | `saveMessages`, `waitUntilStable`, server-initiated turns |\n| Resumable streaming | [Resumable streaming](https://developers.cloudflare.com/agents/api-reference/resumable-streaming/) | Stream recovery on disconnect |\n| Email | [Email](https://developers.cloudflare.com/agents/api-reference/email/) | Email routing, secure reply resolver |\n| MCP client | [MCP client](https://developers.cloudflare.com/agents/api-reference/mcp-client-api/) | Connecting to MCP servers |\n| MCP server | [MCP server](https://developers.cloudflare.com/agents/api-reference/mcp-agent-api/) | Building MCP servers with `McpAgent` |\n| MCP transports | [MCP transports](https://developers.cloudflare.com/agents/api-reference/mcp-transports/) | Streamable HTTP, SSE, RPC transport options |\n| Securing MCP servers | [Securing MCP](https://developers.cloudflare.com/agents/api-reference/securing-mcp-servers/) | OAuth, proxy MCP, hardening |\n| Human-in-the-loop | [Human-in-the-loop](https://developers.cloudflare.com/agents/concepts/human-in-the-loop/) | Approval flows, `needsApproval`, workflows |\n| Durable execution | [Durable execution](https://developers.cloudflare.com/agents/api-reference/durable-execution/) | `runFiber()`, `stash()`, surviving DO eviction |\n| Queue | [Queue](https://developers.cloudflare.com/agents/api-reference/queue-tasks/) | Built-in FIFO queue, `queue()` |\n| Retries | [Retries](https://developers.cloudflare.com/agents/api-reference/retries/) | `this.retry()`, backoff/jitter |\n| Observability | [Observability](https://developers.cloudflare.com/agents/api-reference/observability/) | Diagnostics-channel events |\n| Push notifications | [Push notifications](https://developers.cloudflare.com/agents/api-reference/push-notifications/) | Web Push + VAPID from agents |\n| Webhooks | [Webhooks](https://developers.cloudflare.com/agents/api-reference/webhooks/) | Receiving external webhooks |\n| Cross-domain auth | [Cross-domain auth](https://developers.cloudflare.com/agents/api-reference/cross-domain-authentication/) | WebSocket auth, tokens, CORS |\n| Readonly connections | [Readonly](https://developers.cloudflare.com/agents/api-reference/readonly-connections/) | `shouldConnectionBeReadonly` |\n| Voice | [Voice](https://developers.cloudflare.com/agents/api-reference/voice/) | Experimental STT/TTS, `withVoice` |\n| Browse the web | [Browser tools](https://developers.cloudflare.com/agents/api-reference/browse-the-web/) | Experimental CDP browser automation |\n| Think | [Think](https://developers.cloudflare.com/agents/api-reference/think/) | Experimental higher-level chat agent class |\n| Migrations | [AI SDK v5](https://developers.cloudflare.com/agents/guides/migration-to-ai-sdk-v5/), [AI SDK v6](https://developers.cloudflare.com/agents/guides/migration-to-ai-sdk-v6/) | Upgrading `@cloudflare/ai-chat` |\n\n## Capabilities\n\nThe Agents SDK provides:\n\n- **Persistent state** — SQLite-backed, auto-synced to clients via `setState`\n- **Callable RPC** — `@callable()` methods invoked over WebSocket\n- **Scheduling** — One-time, recurring (`scheduleEvery`), and cron tasks\n- **Workflows** — Durable multi-step background processing via `AgentWorkflow`\n- **Durable execution** — `runFiber()` / `stash()` for work that survives DO eviction\n- **Queue** — Built-in FIFO queue with retries via `queue()`\n- **Retries** — `this.retry()` with exponential backoff and jitter\n- **MCP integration** — Connect to MCP servers or build your own with `McpAgent`\n- **Email handling** — Receive and reply to emails with secure routing\n- **Streaming chat** — `AIChatAgent` with resumable streams, message persistence, tools\n- **Server-driven messages** — `saveMessages`, `waitUntilStable` for proactive agent turns\n- **React hooks** — `useAgent`, `useAgentChat` for client apps\n- **Observability** — `diagnostics_channel` events for state, RPC, schedule, lifecycle\n- **Push notifications** — Web Push + VAPID delivery from agents\n- **Webhooks** — Receive and verify external webhooks\n- **Voice** (experimental) — STT/TTS via `@cloudflare/voice`\n- **Browser tools** (experimental) — CDP-powered browsing via `agents/browser`\n- **Think** (experimental) — Higher-level chat agent via `@cloudflare/think`\n\n## FIRST: Verify Installation\n\n```bash\nnpm ls agents  # Should show agents package\n```\n\nIf not installed:\n```bash\nnpm install agents\n```\n\nFor chat agents:\n```bash\nnpm install agents @cloudflare/ai-chat ai @ai-sdk/react\n```\n\n## Wrangler Configuration\n\n```jsonc\n{\n  \"compatibility_flags\": [\"nodejs_compat\"],\n  \"durable_objects\": {\n    \"bindings\": [{ \"name\": \"MyAgent\", \"class_name\": \"MyAgent\" }]\n  },\n  \"migrations\": [{ \"tag\": \"v1\", \"new_sqlite_classes\": [\"MyAgent\"] }]\n}\n```\n\n**Gotchas:**\n- Do NOT enable `experimentalDecorators` in tsconfig (breaks `@callable`)\n- Never edit old migrations — always add new tags\n- Each agent class needs its own DO binding + migration entry\n- Add `\"ai\": { \"binding\": \"AI\" }` for Workers AI\n\n## Agent Class\n\n```typescript\nimport { Agent, routeAgentRequest, callable } from \"agents\";\n\ntype State = { count: number };\n\nexport class Counter extends Agent<Env, State> {\n  initialState = { count: 0 };\n\n  validateStateChange(nextState: State, source: Connection | \"server\") {\n    if (nextState.count < 0) throw new Error(\"Count cannot be negative\");\n  }\n\n  onStateUpdate(state: State, source: Connection | \"server\") {\n    console.log(\"State updated:\", state);\n  }\n\n  @callable()\n  increment() {\n    this.setState({ count: this.state.count + 1 });\n    return this.state.count;\n  }\n}\n\nexport default {\n  fetch: (req, env) => routeAgentRequest(req, env) ?? new Response(\"Not found\", { status: 404 })\n};\n```\n\n## Routing\n\nRequests route to `/agents/{agent-name}/{instance-name}`:\n\n| Class | URL |\n|-------|-----|\n| `Counter` | `/agents/counter/user-123` |\n| `ChatRoom` | `/agents/chat-room/lobby` |\n\nClient: `useAgent({ agent: \"Counter\", name: \"user-123\" })`\n\nCustom routing: use `getAgentByName(env.MyAgent, \"instance-id\")` then `agent.fetch(request)`.\n\n## Core APIs\n\n| Task | API |\n|------|-----|\n| Read state | `this.state.count` |\n| Write state | `this.setState({ count: 1 })` |\n| SQL query | `` this.sql`SELECT * FROM users WHERE id = ${id}` `` |\n| Schedule (delay) | `await this.schedule(60, \"task\", payload)` |\n| Schedule (cron) | `await this.schedule(\"0 * * * *\", \"task\", payload)` |\n| Schedule (interval) | `await this.scheduleEvery(30, \"poll\")` |\n| RPC method | `@callable() myMethod() { ... }` |\n| Streaming RPC | `@callable({ streaming: true }) stream(res) { ... }` |\n| Start workflow | `await this.runWorkflow(\"ProcessingWorkflow\", params)` |\n| Durable fiber | `await this.runFiber(\"name\", async (ctx) => { ... })` |\n| Enqueue work | `this.queue(\"handler\", payload)` |\n| Retry with backoff | `await this.retry(fn, { maxAttempts: 5 })` |\n| Broadcast to clients | `this.broadcast(message)` |\n| Get connections | `this.getConnections(tag?)` |\n\n## React Client\n\n```tsx\nimport { useAgent } from \"agents/react\";\n\nfunction App() {\n  const [state, setLocalState] = useState({ count: 0 });\n\n  const agent = useAgent({\n    agent: \"Counter\",\n    name: \"my-instance\",\n    onStateUpdate: (newState) => setLocalState(newState),\n    onIdentity: (name, agentType) => console.log(`Connected to ${name}`)\n  });\n\n  return (\n    <button onClick={() => agent.setState({ count: state.count + 1 })}>\n      Count: {state.count}\n    </button>\n  );\n}\n```\n\n## References\n\n### Core\n- **[references/state-scheduling.md](references/state-scheduling.md)** — State persistence, scheduling, SQL\n- **[references/callable.md](references/callable.md)** — RPC methods, streaming, timeouts\n- **[references/routing.md](references/routing.md)** — URL patterns, custom routing, `getAgentByName`\n- **[references/configuration.md](references/configuration.md)** — Wrangler config, bindings, Vite setup\n\n### Chat & Streaming\n- **[references/streaming-chat.md](references/streaming-chat.md)** — AIChatAgent, resumable streams, tools\n- **[references/client-sdk.md](references/client-sdk.md)** — `useAgent`, `useAgentChat`, `AgentClient`\n- **[references/server-driven-messages.md](references/server-driven-messages.md)** — Trigger patterns, `saveMessages`\n- **[references/human-in-the-loop.md](references/human-in-the-loop.md)** — Approval flows, `needsApproval`\n\n### Background Processing\n- **[references/workflows.md](references/workflows.md)** — Durable Workflows integration\n- **[references/durable-execution.md](references/durable-execution.md)** — `runFiber`, `stash`, surviving eviction\n- **[references/queue-retries.md](references/queue-retries.md)** — Built-in queue, retry with backoff\n\n### Integrations\n- **[references/mcp.md](references/mcp.md)** — MCP client and server, transports, securing\n- **[references/email.md](references/email.md)** — Email routing and handling\n- **[references/webhooks-push.md](references/webhooks-push.md)** — Webhooks, push notifications\n- **[references/observability.md](references/observability.md)** — Diagnostics-channel events\n\n### Experimental\n- **[references/think.md](references/think.md)** — `@cloudflare/think` higher-level chat agent\n- **[references/voice.md](references/voice.md)** — `@cloudflare/voice` STT/TTS\n- **[references/codemode.md](references/codemode.md)** — Code Mode for tool orchestration\n- **[references/browse-the-web.md](references/browse-the-web.md)** — CDP browser tools\n","contentSource":"skills.sh/api/download/cloudflare/skills/agents-sdk","contentFetchedAt":"2026-07-27T08:59:25.477Z"}],"featured":true,"official":true,"generatedAt":"2026-07-27T09:02:29.956Z"}