Skip to main content

Platform SDKs

Budget guardrails for Cloudflare Workers.

Two packages — a lightweight SDK for each Worker and a CLI scaffolder for the backend. Circuit breakers, budget enforcement, anomaly detection, and distributed tracing. Zero production dependencies.

Cloudflare SDK In Testing

What it stops

Catches runaway costs before they reach your invoice

Infinite loops

A D1 write loop ran for four days before I noticed. 4.8 billion rows. Circuit breakers would have stopped it in minutes.

Catch infinite loops before they write billions of rows

Budget overruns

Daily and monthly spend limits with warnings at 70% and 90%. Hard stop at 100% — no more invoice surprises.

Get warnings at 70% spend instead of surprises at invoice time

Anomaly spikes

Flags unusual resource spikes — sudden D1 write volume, unexpected AI call patterns — before they become invoices.

See exactly which Worker feature is burning through your budget

Silent failures

Standard tier auto-creates GitHub issues from Worker errors. Full tier adds AI-powered pattern discovery for transient vs real failures.

Kill everything with one KV write when something goes wrong at 2am

What Platform SDKs includes

  • Three-tier circuit breakers

    Global kill switch, project-level breakers, and per-feature breakers. Any level can stop expensive operations instantly.

  • Budget enforcement

    Daily and monthly limits with progressive warnings at 70%, 90%, and hard stop at 100%. Per-invocation request caps prevent runaway handlers.

  • Anomaly detection

    Flags unusual resource spikes without blocking. Configurable thresholds per feature — catch problems before they become invoices.

  • W3C distributed tracing

    Full traceparent/tracestate propagation across service bindings. Trace a request from entry to every downstream Worker.

  • Structured JSON logging

    Log levels, correlation ID extraction, timed operations, and child loggers. Built for production debugging, not console.log.

  • AI Gateway tracking

    Automatic provider and model detection for 10+ AI providers. Track cost per model, per feature, per day.

  • Automatic binding telemetry

    Every D1, KV, R2, AI, Vectorize, Queue, Durable Object, and Workflow call tracked without code changes.

  • Multi-account support

    Consumer SDKs across separate Cloudflare accounts send telemetry to one centralised admin backend. One dashboard for everything.

  • Health checks and heartbeats

    Dual-plane validation: control plane (KV + circuit breaker) and data plane (queue delivery). Durable Object alarm-based heartbeats with Gatus integration.

  • Error collection

    Standard tier tail worker auto-creates GitHub issues from production errors. Full tier adds AI pattern discovery for transient vs real failures.

How it works

Two packages — one per Worker, one per account. Your infrastructure, your data.

Consumer SDK in each Worker
Admin backend on your account
Circuit breakers trip automatically
Free and open source
What exactly does it access?

What it accesses

  • Cloudflare Workers binding usage (D1, KV, R2, AI, Vectorize, Queue, DO, Workflow)
  • Invocation counts, error rates, and cost metrics per feature

Where it stores

  • Usage data: D1 database on your Cloudflare account
  • Circuit breaker state: KV namespace on your Cloudflare account
  • Configuration: wrangler.toml and budgets.yaml in your project

Delete the admin Worker and D1 database from your Cloudflare dashboard to remove all data

Network calls

  • Worker-to-Worker service bindings within your Cloudflare account
  • No Little Bear Apps servers involved — everything runs on your infrastructure

Remove the withFeatureBudget() wrapper to disable tracking

Get notified when Platform SDKs is ready

Leave your details and I'll let you know when it's available.

No spam, ever. Privacy Policy

"An infinite D1 write loop ran for four days. 4.8 billion rows. $4,868 bill."

Nathan
N
Nathan

Questions about Platform SDKs

What is Platform SDKs?
Two npm packages for Cloudflare Workers cost protection. The Consumer SDK wraps your handlers to track binding usage and enforce budgets. The Admin SDK scaffolds a backend for aggregation, error collection, and alerts. Both are free, open source, and MIT licensed.
Is this free?
Yes. Both packages are MIT licensed and free to use. The Admin SDK's Minimal and Standard tiers run entirely on Cloudflare's free tier (~$0/month). The Full tier with AI pattern discovery costs roughly $5/month.
What's the difference between Consumer SDK and Admin SDK?
Consumer SDK is a lightweight library you install in each Worker — it wraps your handlers and tracks binding calls. Admin SDK is a CLI scaffolder you run once to generate your backend infrastructure (usage aggregation, error collection, circuit breaker management). Consumer sends telemetry to Admin.
What Cloudflare bindings does it track?
D1 (reads, writes, rows), KV (reads, writes, deletes, lists), R2 (class A and B operations), Workers AI (requests per model), Vectorize (queries, inserts), Queues (messages), Durable Objects (requests, latency), and Workflows (invocations).
Does this send data to Little Bear Apps?
No. Everything runs on your Cloudflare account — the Consumer SDK in your Workers, the Admin backend in your own Workers and D1. No data leaves your infrastructure.
What happens when a circuit breaker trips?
The wrapped handler throws a CircuitBreakerError instead of executing the expensive operation. Your code catches it and returns a 503 or graceful fallback. Breakers auto-reset after a configurable period (default 24 hours), or you can reset them manually via KV.
Can I use this with multiple Cloudflare accounts?
Yes. Consumer SDKs in separate accounts can send telemetry to a single centralised Admin backend. You can also run federated (per-account backends) or hybrid setups.
What was the $4,868 billing incident?
An infinite D1 write loop ran for four days in January 2026. It wrote 4.8 billion rows before I noticed. Cloudflare's billing dashboard doesn't alert in real time, so I found out when the invoice arrived. Platform SDKs exists so that doesn't happen to anyone else.
Is there a Claude Code plugin for Platform SDKs?
Yes. The Platform SDK Plugin adds always-active rules, on-demand skills, autonomous agents, and automated hooks to Claude Code. It enforces correct SDK usage during development — catches missing budgets, unsafe binding patterns, and configuration drift before you deploy. Install it with /plugin install platform-sdk@lba-plugins.

What changes

  • Instead of discovering runaway costs on your monthly invoice, get warnings at 70% and hard stops at 100%.
  • Instead of hoping Cloudflare's billing alerts catch problems in time, circuit breakers trip per-request.
  • Instead of guessing which Worker is responsible for a cost spike, see per-feature breakdowns.
  • Instead of building your own usage tracking, scaffold the entire backend with one CLI command.
  • Instead of manually monitoring Worker health, get automatic heartbeats and dual-plane health checks.