davila7/claude-code-templates / cli-tool/components/skills/development/cloudflare-deploy
cloudflare-deploy
FlaggedDeploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.
references/durable-objects/configuration.md
View on GitHub# Durable Objects Configuration
## Basic Setup
```jsonc
{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2025-01-01", // Use latest; ≥2024-04-03 for RPC
"durable_objects": {
"bindings": [
{
"name": "MY_DO", // Env binding name
"class_name": "MyDO" // Class exported from this worker
},
{
"name": "EXTERNAL", // Access DO from another worker
"class_name": "ExternalDO",
"script_name": "other-worker"
}
]
},
"migrations": [
{ "tag": "v1", "new_sqlite_classes": ["MyDO"] } // Prefer SQLite
]
}
```
## Binding Options
```jsonc
{
"name": "BINDING_NAME",
"class_name": "ClassName",
"script_name": "other-worker", // Optional: external DO
"environment": "production" // Optional: isolate by env
}
```
## Jurisdiction (Data Locality)
Specify jurisdiction at ID creation for data residency compliance:
```typescript
// EU data residency
const id = env.MY_DO.idFromName("user:123", { jurisdiction: "eu" })
// Available jurisdictions
const jurisdictions = ["eu", "fedramp"] // More may be added
// All operations on this DO stay within jurisdiction
const stub = env.MY_DO.get(id)
await stub.someMethod() // Data stays in EU
```
**Key points:**
- Set at ID creation time, immutable afterward
- DO instance physically located within jurisdiction
- Storage and compute guaranteed within boundary
- Use for GDPR, FedRAMP, other compliance requirements
- No cross-jurisdiction access (requests fail if DO in different jurisdiction)
## Migrations
```jsonc
{
"migrations": [
{ "tag": "v1", "new_sqlite_classes": ["MyDO"] }, // Create SQLite (recommended)
// { "tag": "v1", "new_classes": ["MyDO"] }, // Create KV (paid only)
{ "tag": "v2", "renamed_classes": [{ "from": "Old", "to": "New" }] },
{ "tag": "v3", "transferred_classes": [{ "from": "Src", "from_script": "old", "to": "Dest" }] },
{ "tag": "v4", "deleted_classes": ["Obsolete"] } // Destroys ALL data!
]
}
```
**Migration rules:**
- Tags must be unique and sequential (v1, v2, v3...)
- No rollback supported (test with `--dry-run` first)
- Auto-applied on deploy
- `new_sqlite_classes` recommended over `new_classes` (SQLite vs KV)
- `deleted_classes` immediately destroys ALL data (irreversible)
## Environment Isolation
Separate DO namespaces per environment (staging/production have distinct object instances):
```jsonc
{
"durable_objects": {
"bindings": [{ "name": "MY_DO", "class_name": "MyDO" }]
},
"env": {
"production": {
"durable_objects": {
"bindings": [
{ "name": "MY_DO", "class_name": "MyDO", "environment": "production" }
]
}
}
}
}
```
Deploy: `npx wrangler deploy --env production`
## Limits & Settings
```jsonc
{
"limits": {
"cpu_ms": 300000 // Max CPU time: 30s default, 300s max
}
}
```
See [Gotchas](./gotchas.md) for complete limits table.
## Types
```typescript
import { DurableObject } from "cloudflare:workers";
interface Env {
MY_DO: DurableObjectNamespace<MyDO>;
}
export class MyDO extends DurableObject<Env> {}
type DurableObjectNamespace<T> = {
newUniqueId(options?: { jurisdiction?: string }): DurableObjectId;
idFromName(name: string): DurableObjectId;
idFromString(id: string): DurableObjectId;
get(id: DurableObjectId): DurableObjectStub<T>;
};
```
## Commands
```bash
# Development
npx wrangler dev # Local dev
npx wrangler dev --remote # Test against production DOs
# Deployment
npx wrangler deploy # Deploy + auto-apply migrations
npx wrangler deploy --dry-run # Validate migrations without deploying
npx wrangler deploy --env production
# Management
npx wrangler durable-objects list # List namespaces
npx wrangler durable-objects info <namespace> <id> # Inspect specific DO
npx wrangler durable-objects delete <namespace> <id> # Delete DO (destroys data)
```
## See Also
- **[API](./api.md)** - DurableObjectState and lifecycle handlers
- **[Patterns](./patterns.md)** - Multi-environment patterns
- **[Gotchas](./gotchas.md)** - Migration caveats, limits
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |