cloudflare-workers-runtime-apis

cloudflare-workers-runtime-apis is a skill for Claude Code from secondsky/claude-skills. It costs 54 tokens per session (2,122 once invoked), scanned B, original, MIT.

A guide to the built-in Cloudflare Workers runtime APIs for HTTP requests, data streams, cryptography, caching, WebSockets, and text encoding. WebSockets support two-way connections for features such as chat and live updates.

In plain words
What is it for?
Use it to call external APIs, proxy requests, process large or live data, encrypt or sign values, cache responses, and build real-time connections.
Why use it?
It helps use Workers’ supported request and response features correctly and avoid runtime compatibility or stream-handling errors.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the cloudflare-workers plugin — 10 skills, 5 commands shipped together

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 skills/secondsky/claude-skills/cloudflare-workers-runtime-apis
Any agent
npx skills add secondsky/claude-skills --skill cloudflare-workers-runtime-apis
Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills

Made for: Claude Code.

Or install cloudflare-workers, the plugin that ships this one along with the rest of its 10 skills, 5 commands.

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 cloudflare-workers-runtime-apis

README.md
[![agentmods](https://agentmods.dev/badge/skills/secondsky/claude-skills/cloudflare-workers-runtime-apis.svg)](https://agentmods.dev/skills/secondsky/claude-skills/cloudflare-workers-runtime-apis)
Your own site
<a href="https://agentmods.dev/skills/secondsky/claude-skills/cloudflare-workers-runtime-apis"><img src="https://agentmods.dev/badge/skills/secondsky/claude-skills/cloudflare-workers-runtime-apis.svg" alt="Measured on agentmods" height="20"></a>
Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,122 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 findings. 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.1 $0.00054 $0.02122
Opus 5 $0.00027 $0.01061
Sonnet 5 $0.00011 $0.00424
Haiku 4.5 $0.00005 $0.00212

Measured 2d ago against content hash f4a3c1bed4b3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade B, and why

cloudflare-workers-runtime-apis scanned grade B with 2 findings 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 2d ago.

The scan reads SKILL.md. This mod also ships 4 executable files (templates/crypto-operations.ts, templates/fetch-patterns.ts, templates/stream-processing.ts, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Sends data to an external URLmediumData exfiltration

A POST to an outside endpoint may be telemetry or may be exfiltration; either way the mod talks to somewhere, and you should know where.

const postResponse = await fetch('https://api.example.com/users', { method: 'POST',

Makes network callslowCapability

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

async fetch(request: Request, env: Env): Promise<Response> {
plugins/cloudflare-workers/skills/cloudflare-workers-runtime-apis/SKILL.md · 291 lines

How it starts

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

Cloudflare Workers Runtime APIs

Master the Workers runtime APIs: Fetch, Streams, Crypto, Cache, WebSockets, and text encoding.

Quick Reference

API Purpose Common Use
Fetch HTTP requests External APIs, proxying
Streams Data streaming Large files, real-time
Crypto Cryptography Hashing, signing, encryption
Cache Response caching Performance optimization
WebSockets Real-time connections Chat, live updates
Encoding Text encoding UTF-8, Base64

Quick Start: Fetch API

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    // Basic fetch
    const response = await fetch('https://api.example.com/data');

    // With options
    const postResponse = await fetch('https://api.example.com/users', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${env.API_KEY}`,
      },
      body: JSON.stringify({ name: 'John' }),
    });

    // Clone for multiple reads
    const clone = response.clone();
    const json = await response.json();
    const text = await clone.text();

    return Response.json(json);
  }
};

Critical Rules

  1. Always set timeouts for external requests - Workers have a 30s limit, external APIs can hang
  2. Clone responses before reading body - Body can only be read once
  3. Use streaming for large payloads - Don't buffer entire response in memory
  4. Cache external API responses - Reduce latency and API costs
  5. Handle Crypto operations in try/catch - Invalid inputs throw errors
  6. WebSocket hibernation for cost - Use Durable Objects with hibernation

Top 10 Errors Prevented

Error Symptom Prevention
Body already read TypeError: Body has already been consumed Clone response before reading
Fetch timeout Request hangs, worker times out Use AbortController with timeout
Invalid JSON SyntaxError: Unexpected token Check content-type before parsing
Stream locked TypeError: ReadableStream is locked Don't read stream multiple times
Crypto key error DOMException: Invalid keyData Validate key format and algorithm
Cache miss Returns undefined instead of response Check cache before returning
WebSocket close Connection drops unexpectedly Handle close event, implement reconnect
Encoding error TypeError: Invalid code point Use TextEncoder/TextDecoder properly
CORS blocked Browser rejects response Add proper CORS headers
Request size 413 Request Entity Too Large Stream large uploads

Read the full file on GitHub · 291 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. 2d ago First seen · 291 lines · 54 tokens per session scan B f4a3c1bed4b3

Subscribe to this mod's changes

cloudflare-workers-runtime-apis is a skill published in the GitHub repository secondsky/claude-skills (214 stars, last pushed 3d ago), licensed MIT. It adds 54 tokens to every session and 2,122 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it B with 2 findings (sends data to an external url, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.