Skip to content

Commit 25ba1a4

Browse files
authored
skill: add cloudflare and wrangler skills, refresh typescript-advanced-types (#777)
* chore: update skills * skill: cloudflare/skills - wrangler * skill: cloudflare/skills cloudflare
1 parent ec3debf commit 25ba1a4

327 files changed

Lines changed: 50131 additions & 479 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/cloudflare/SKILL.md

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
---
2+
name: cloudflare
3+
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.
4+
references:
5+
- workers
6+
- pages
7+
- d1
8+
- durable-objects
9+
- workers-ai
10+
---
11+
12+
# Cloudflare Platform Skill
13+
14+
Consolidated skill for building on the Cloudflare platform. Use decision trees below to find the right product, then load detailed references.
15+
16+
Your 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.
17+
18+
## Retrieval Sources
19+
20+
Fetch the **latest** information before citing specific numbers, API signatures, or configuration options. Do not rely on baked-in knowledge or these reference files alone.
21+
22+
| Source | How to retrieve | Use for |
23+
|--------|----------------|---------|
24+
| Cloudflare docs | `cloudflare-docs` search tool or `https://developers.cloudflare.com/` | Limits, pricing, API reference, compatibility dates/flags |
25+
| Workers types | `npm pack @cloudflare/workers-types` or check `node_modules` | Type signatures, binding shapes, handler types |
26+
| Wrangler config schema | `node_modules/wrangler/config-schema.json` | Config fields, binding shapes, allowed values |
27+
| Product changelogs | `https://developers.cloudflare.com/changelog/` | Recent changes to limits, features, deprecations |
28+
29+
When a reference file and the docs disagree, **trust the docs**. This is especially important for: numeric limits, pricing tiers, type signatures, and configuration options.
30+
31+
## Quick Decision Trees
32+
33+
### "I need feature flags"
34+
35+
```
36+
Need feature flags?
37+
└─ Feature toggles, targeting rules, percentage rollouts → flagship/
38+
├─ Evaluate in Workers → Flagship binding (env.FLAGS)
39+
├─ Evaluate in Node.js / browser → OpenFeature SDK (@cloudflare/flagship)
40+
└─ Manage flags via API → Flagship REST API
41+
```
42+
43+
### "I need to run code"
44+
45+
```
46+
Need to run code?
47+
├─ Serverless functions at the edge → workers/
48+
├─ Full-stack web app with Git deploys → pages/
49+
├─ Stateful coordination/real-time → durable-objects/
50+
├─ Long-running multi-step jobs → workflows/
51+
├─ Run containers → containers/
52+
├─ Multi-tenant (customers deploy code) → workers-for-platforms/
53+
├─ Scheduled tasks (cron) → cron-triggers/
54+
├─ Lightweight edge logic (modify HTTP) → snippets/
55+
├─ Process Worker execution events (logs/observability) → tail-workers/
56+
└─ Optimize latency to backend infrastructure → smart-placement/
57+
```
58+
59+
### "I need to store data"
60+
61+
```
62+
Need storage?
63+
├─ Key-value (config, sessions, cache) → kv/
64+
├─ Relational SQL → d1/ (SQLite) or hyperdrive/ (existing Postgres/MySQL)
65+
├─ Object/file storage (S3-compatible) → r2/
66+
├─ Versioned file trees (repos, build outputs, checkpoints) → artifacts/
67+
├─ Message queue (async processing) → queues/
68+
├─ Vector embeddings (AI/semantic search) → vectorize/
69+
├─ Strongly-consistent per-entity state → durable-objects/ (DO storage)
70+
├─ Secrets management → secrets-store/
71+
├─ Streaming ETL to R2 → pipelines/
72+
└─ Persistent cache (long-term retention) → cache-reserve/
73+
```
74+
75+
### "I need AI/ML"
76+
77+
```
78+
Need AI?
79+
├─ Run inference (LLMs, embeddings, images) → workers-ai/
80+
├─ Vector database for RAG/search → vectorize/
81+
├─ Build stateful AI agents → agents-sdk/
82+
├─ Gateway for any AI provider (caching, routing) → ai-gateway/
83+
└─ AI-powered search widget → ai-search/
84+
```
85+
86+
### "I need networking/connectivity"
87+
88+
```
89+
Need networking?
90+
├─ Expose local service to internet → tunnel/
91+
├─ TCP/UDP proxy (non-HTTP) → spectrum/
92+
├─ WebRTC TURN server → turn/
93+
├─ Private network connectivity → network-interconnect/
94+
├─ Optimize routing → argo-smart-routing/
95+
├─ Optimize latency to backend (not user) → smart-placement/
96+
└─ Real-time video/audio → realtimekit/ or realtime-sfu/
97+
```
98+
99+
### "I need security"
100+
101+
```
102+
Need security?
103+
├─ Web Application Firewall → waf/
104+
├─ DDoS protection → ddos/
105+
├─ Bot detection/management → bot-management/
106+
├─ API protection → api-shield/
107+
├─ CAPTCHA alternative → turnstile/
108+
└─ Credential leak detection → waf/ (managed ruleset)
109+
```
110+
111+
### "I need media/content"
112+
113+
```
114+
Need media?
115+
├─ Image optimization/transformation → images/
116+
├─ Video streaming/encoding → stream/
117+
├─ Browser automation/screenshots → browser-rendering/
118+
└─ Third-party script management → zaraz/
119+
```
120+
121+
### "I need analytics/metrics data"
122+
123+
```
124+
Need analytics?
125+
├─ Query across all Cloudflare products (HTTP, Workers, DNS, etc.) → graphql-api/
126+
├─ Custom high-cardinality metrics from Workers → analytics-engine/
127+
├─ Client-side (RUM) performance data → web-analytics/
128+
├─ Workers Logs and real-time debugging → observability/
129+
└─ Raw logs (Logpush to external tools) → Cloudflare docs
130+
```
131+
132+
### "I need infrastructure-as-code"
133+
134+
```
135+
Need IaC? → pulumi/ (Pulumi), terraform/ (Terraform), or api/ (REST API)
136+
```
137+
138+
## Product Index
139+
140+
### Feature Flags
141+
| Product | Reference |
142+
|---------|-----------|
143+
| Flagship | `references/flagship/` |
144+
145+
### Compute & Runtime
146+
| Product | Reference |
147+
|---------|-----------|
148+
| Workers | `references/workers/` |
149+
| Pages | `references/pages/` |
150+
| Pages Functions | `references/pages-functions/` |
151+
| Durable Objects | `references/durable-objects/` |
152+
| Workflows | `references/workflows/` |
153+
| Containers | `references/containers/` |
154+
| Workers for Platforms | `references/workers-for-platforms/` |
155+
| Cron Triggers | `references/cron-triggers/` |
156+
| Tail Workers | `references/tail-workers/` |
157+
| Snippets | `references/snippets/` |
158+
| Smart Placement | `references/smart-placement/` |
159+
160+
### Storage & Data
161+
| Product | Reference |
162+
|---------|-----------|
163+
| KV | `references/kv/` |
164+
| D1 | `references/d1/` |
165+
| R2 | `references/r2/` |
166+
| Artifacts | `references/artifacts/` |
167+
| Queues | `references/queues/` |
168+
| Hyperdrive | `references/hyperdrive/` |
169+
| DO Storage | `references/do-storage/` |
170+
| Secrets Store | `references/secrets-store/` |
171+
| Pipelines | `references/pipelines/` |
172+
| R2 Data Catalog | `references/r2-data-catalog/` |
173+
| R2 SQL | `references/r2-sql/` |
174+
175+
### AI & Machine Learning
176+
| Product | Reference |
177+
|---------|-----------|
178+
| Workers AI | `references/workers-ai/` |
179+
| Vectorize | `references/vectorize/` |
180+
| Agents SDK | `references/agents-sdk/` |
181+
| AI Gateway | `references/ai-gateway/` |
182+
| AI Search | `references/ai-search/` |
183+
184+
### Networking & Connectivity
185+
| Product | Reference |
186+
|---------|-----------|
187+
| Tunnel | `references/tunnel/` |
188+
| Spectrum | `references/spectrum/` |
189+
| TURN | `references/turn/` |
190+
| Network Interconnect | `references/network-interconnect/` |
191+
| Argo Smart Routing | `references/argo-smart-routing/` |
192+
| Workers VPC | `references/workers-vpc/` |
193+
194+
### Security
195+
| Product | Reference |
196+
|---------|-----------|
197+
| WAF | `references/waf/` |
198+
| DDoS Protection | `references/ddos/` |
199+
| Bot Management | `references/bot-management/` |
200+
| API Shield | `references/api-shield/` |
201+
| Turnstile | `references/turnstile/` |
202+
203+
### Media & Content
204+
| Product | Reference |
205+
|---------|-----------|
206+
| Images | `references/images/` |
207+
| Stream | `references/stream/` |
208+
| Browser Rendering | `references/browser-rendering/` |
209+
| Zaraz | `references/zaraz/` |
210+
211+
### Real-Time Communication
212+
| Product | Reference |
213+
|---------|-----------|
214+
| RealtimeKit | `references/realtimekit/` |
215+
| Realtime SFU | `references/realtime-sfu/` |
216+
217+
### Developer Tools
218+
| Product | Reference |
219+
|---------|-----------|
220+
| Wrangler | `references/wrangler/` |
221+
| Miniflare | `references/miniflare/` |
222+
| C3 | `references/c3/` |
223+
| Observability | `references/observability/` |
224+
| GraphQL Analytics API | `references/graphql-api/` |
225+
| Analytics Engine | `references/analytics-engine/` |
226+
| Web Analytics | `references/web-analytics/` |
227+
| Sandbox | `references/sandbox/` |
228+
| Workerd | `references/workerd/` |
229+
| Workers Playground | `references/workers-playground/` |
230+
231+
### Infrastructure as Code
232+
| Product | Reference |
233+
|---------|-----------|
234+
| Pulumi | `references/pulumi/` |
235+
| Terraform | `references/terraform/` |
236+
| API | `references/api/` |
237+
238+
### Other Services
239+
| Product | Reference |
240+
|---------|-----------|
241+
| Email Routing | `references/email-routing/` |
242+
| Email Workers | `references/email-workers/` |
243+
| Static Assets | `references/static-assets/` |
244+
| Bindings | `references/bindings/` |
245+
| Cache Reserve | `references/cache-reserve/` |
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Cloudflare Agents SDK
2+
3+
Cloudflare Agents SDK enables building AI-powered agents on Durable Objects with state, WebSockets, SQL, scheduling, and AI integration.
4+
5+
## Core Value
6+
Build stateful, globally distributed AI agents with persistent memory, real-time connections, scheduled tasks, and async workflows.
7+
8+
## When to Use
9+
- Persistent state + memory required
10+
- Real-time WebSocket connections
11+
- Long-running workflows (minutes/hours)
12+
- Chat interfaces with AI models
13+
- Scheduled/recurring tasks with state
14+
- DB queries with agent state
15+
16+
## What Type of Agent?
17+
18+
| Use Case | Class | Key Features |
19+
|----------|-------|--------------|
20+
| AI chat interface | `AIChatAgent` | Auto-streaming, tools, message history, resumable |
21+
| MCP tool provider | `Agent` + MCP | Expose tools to AI systems |
22+
| Custom logic/routing | `Agent` | Full control, WebSockets, email, SQL |
23+
| Real-time collaboration | `Agent` | WebSocket state, broadcasts |
24+
| Email processing | `Agent` | `onEmail()` handler |
25+
26+
## Quick Start
27+
28+
**AI Chat Agent:**
29+
```typescript
30+
import { AIChatAgent } from "@cloudflare/ai-chat";
31+
import { openai } from "@ai-sdk/openai";
32+
33+
export class ChatAgent extends AIChatAgent<Env> {
34+
async onChatMessage(onFinish) {
35+
return this.streamText({
36+
model: openai("gpt-4"),
37+
messages: this.messages,
38+
onFinish,
39+
});
40+
}
41+
}
42+
```
43+
44+
**Base Agent:**
45+
```typescript
46+
import { Agent } from "agents";
47+
48+
export class MyAgent extends Agent<Env> {
49+
onStart() {
50+
this.sql`CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY)`;
51+
}
52+
53+
async onRequest(request: Request) {
54+
return Response.json({ state: this.state });
55+
}
56+
}
57+
```
58+
59+
## Reading Order
60+
61+
| Task | Files to Read |
62+
|------|---------------|
63+
| Quick start | README only |
64+
| Build chat agent | README → api.md (AIChatAgent) → patterns.md |
65+
| Setup project | README → configuration.md |
66+
| Add React frontend | README → api.md (Client Hooks) → patterns.md |
67+
| Build MCP server | api.md (MCP) → patterns.md |
68+
| Background tasks | api.md (Scheduling, Task Queue) → patterns.md |
69+
| Debug issues | gotchas.md |
70+
71+
## Package Entry Points
72+
73+
| Import | Purpose |
74+
|--------|---------|
75+
| `agents` | Server-side Agent classes, lifecycle |
76+
| `agents/react` | `useAgent()` hook for WebSocket connections |
77+
| `agents/ai-react` | `useAgentChat()` hook for AI chat UIs |
78+
79+
## In This Reference
80+
- [configuration.md](./configuration.md) - SDK setup, wrangler config, routing
81+
- [api.md](./api.md) - Agent classes, lifecycle, client hooks
82+
- [patterns.md](./patterns.md) - Common workflows, best practices
83+
- [gotchas.md](./gotchas.md) - Common issues, limits
84+
85+
## See Also
86+
- durable-objects - Agent infrastructure
87+
- d1 - External database integration
88+
- workers-ai - AI model integration
89+
- vectorize - Vector search for RAG patterns

0 commit comments

Comments
 (0)