← All runbooks
cloudflare / durable-objects★ Featured · worked examples

Cloudflare Durable Objects

Implement a production-ready Cloudflare Durable Object in TypeScript from a spec, and get it right where most implementations get it wrong. Durable Objects combine compute with strongly-consistent, co-located storage in globally-unique, single-threaded…

agent claude-codemodel claude-sonnet-4-6snapshot python312-uveval programmatic6 stepsv1.0.0

Deploy Cloudflare Durable Objects to your jetty.io

One-click installs this runbook into a collection on your Jetty account. You can run it from the Spot dashboard, schedule it, or pipe inputs in via the API.

Run time2–4 mins
Headline outputdurable_object.ts

Runs on Jetty's managed sandbox. No setup. Free for your first 10 runs.

Worked examples · 2

Real runs, real outputs.

The shape of the run

6 steps · start to finish.

  1. 1
    Step 1

    Environment Setup

    mkdir -p "{{results_dir}}"
    S="{{spec}}"
    [ -n "$S" ] && [ "$S" != "{{spec}}" ] || { echo "ERROR: no spec provided"; exit 1; }
    echo "Building Durable Object for spec (first 120 chars): ${S:0:120}"
    
  2. 2
    Step 2

    Understand the Spec

    Identify, from the spec: the DO's state (what must persist), any scheduling (→ alarm, not setTimeout), any concurrency-sensitive mutations (→ atomic SQL / blockConcurrencyWhile), any WebSocket usage…

  3. 3
    Step 3

    Implement `durable_object.ts`

    Write the full TypeScript implementation. Apply the Rules, the API, and the Gotchas above. In particular: persist anything that must survive idle; schedule with setAlarm; make counters atomic; use…

  4. 4
    Step 4

    Configure `wrangler.jsonc`

    Write the Workers config: the DO binding and a new_sqlite_classes migration (unique, sequential tag). Set compatibility_date >= 2024-04-03.

  5. 5
    Step 5

    Self-Review Against the Gotchas

    Write {{results_dir}}/self_review.md: for each relevant gotcha, state how the implementation guards against it (or why it does not apply). Be specific — quote the line that handles it. If you find a…

  6. 6
    Step 6

    Evaluate & Validate

    Evaluate the implementation against the gotcha checklist, then write {{results_dir}}/validation_report.json: