401-cloudflare-workers

401-cloudflare-workers is a cursor rule for coding agents from d-padmanabhan/agent-engineering-handbook. It costs 91 tokens per session (4,185 once invoked), scanned A, original, MIT.

A set of mandatory rules for writing or reviewing Cloudflare Workers in TypeScript, Cloudflare's code that runs on its edge network. It covers module syntax, typed environment bindings, secrets, background work, and request limits.

In plain words
What is it for?
Use it when building or reviewing Workers, Durable Objects, queues, scheduled jobs, email handlers, or Pages Functions.
Why use it?
It prevents common Worker-specific mistakes, such as exposing secrets in logs or exceeding Cloudflare's subrequest limits.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/d-padmanabhan/agent-engineering-handbook/401-cloudflare-workers
Clone the repo
git clone --depth 1 https://github.com/d-padmanabhan/agent-engineering-handbook

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 401-cloudflare-workers

README.md
[![agentmods](https://agentmods.dev/badge/rules/d-padmanabhan/agent-engineering-handbook/401-cloudflare-workers.svg)](https://agentmods.dev/rules/d-padmanabhan/agent-engineering-handbook/401-cloudflare-workers)
Your own site
<a href="https://agentmods.dev/rules/d-padmanabhan/agent-engineering-handbook/401-cloudflare-workers"><img src="https://agentmods.dev/badge/rules/d-padmanabhan/agent-engineering-handbook/401-cloudflare-workers.svg" alt="Measured on agentmods" height="20"></a>
Per session 91 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,185 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00091 $0.04185
Opus 5 $0.00046 $0.02093
Sonnet 5 $0.00018 $0.00837
Haiku 4.5 $0.00009 $0.00419

Measured 5d ago against content hash de27cac88f7c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

401-cloudflare-workers scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- **Module Workers** (`export default { fetch(req, env, ctx) { ... } }`) - the modern model. Bindings come through `env`; lifecycle through `ctx`; supports TypeScript natively; supports RPC via `WorkerEntrypoint`; suppor
rules/401-cloudflare-workers.mdc · 354 lines

How it starts

The opening of the file, as written. The whole thing — 354 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cloudflare Workers (TypeScript, Module Workers, typed bindings)

Audience: anyone authoring or reviewing a Cloudflare Worker - default-export Worker, named entrypoint, Durable Object, Workflow, Queue consumer, Cron Trigger, Email Worker, or Pages Function.

Relationship to other rules:

  • 400-cloudflare.mdc - broad Cloudflare platform playbook (Workers + Access + AOP + WAF + Workflows + etc.). This file is the file-scoped Worker-authoring tightening.
  • 405-cloudflare-waf-rules.mdc - file-scoped WAF rule playbook. Same pattern (file-scoped tactical rule).
  • 225-javascript-typescript.mdc - general JavaScript and TypeScript gates. This file layers Workers-specific TypeScript rules on top.
  • 320-api-design.mdc - REST API design. Applies when the Worker exposes HTTP endpoints.
  • 325-networking.mdc - HTTP / gRPC client reuse, idle timeouts. Workers have specific subrequest semantics covered here.

Companion skill: cloudflare-workers-author walks through the bootstrap, bindings choice, routing, testing, and deployment workflow. This rule is the gate; the skill is the workflow through the gate.

[!IMPORTANT] The non-negotiables below are file-scoped. They auto-load when editing wrangler.jsonc (or common Worker entry-point names). If you're authoring a Worker in an unusual location, invoke this rule explicitly or trigger topic discovery by mentioning Cloudflare Workers in the conversation.


Non-negotiables

NN-1: Module Workers syntax only (Service Worker syntax is forbidden in new code)

Cloudflare Workers has two execution models:

  • Module Workers (export default { fetch(req, env, ctx) { ... } }) - the modern model. Bindings come through env; lifecycle through ctx; supports TypeScript natively; supports RPC via WorkerEntrypoint; supports Durable Objects, Workflows, RPC, Queues, Cron, Email, etc.
  • Service Worker (addEventListener("fetch", event => { ... })) - the original model. Deprecated for new development. Bindings come through global scope; no RPC; no named entrypoints; no cloudflare:workers module imports.

Read the full file on GitHub · 354 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 354 lines · 91 tokens per session scan A de27cac88f7c

Subscribe to this mod's changes

401-cloudflare-workers is a cursor rule published in the GitHub repository d-padmanabhan/agent-engineering-handbook (16 stars, last pushed 5d ago), licensed MIT. It adds 91 tokens to every session and 4,185 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.