All skills
openai avatar

/cloudflare-deploy

@bf9e226 official
by openaiopenai/skills28k stars
1,891

Deploy 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.

Use this Skill: https://skilld.dev/gh/openai/skills/cloudflare-deploy

This session only. Nothing lands on disk.

referencesemail-routinggotchas.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Gotchas & Troubleshooting

Critical Pitfalls

Stream Consumption (MOST COMMON)

Problem: "stream already consumed" or worker hangs

Cause: message.raw is ReadableStream - consume once only

Solution:

// ❌ WRONG
const email1 = await parser.parse(await message.raw.arrayBuffer());
const email2 = await parser.parse(await message.raw.arrayBuffer()); // FAILS

// ✅ CORRECT
const raw = await message.raw.arrayBuffer();
const email = await parser.parse(raw);

Consume message.raw immediately before any async operations.

Destination Verification

Problem: Emails not forwarding

Cause: Destination unverified

Solution: Add destination, check inbox for verification email, click link. Verify status: GET /zones/{id}/email/routing/addresses

Mail Authentication

Problem: Legitimate emails rejected

Cause: Missing SPF/DKIM/DMARC on sender domain

Solution: Configure sender DNS:

example.com. IN TXT "v=spf1 include:_spf.example.com ~all"
selector._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=..."
_dmarc.example.com. IN TXT "v=DMARC1; p=quarantine"

Envelope vs Header

Problem: Filtering on wrong address

Solution:

// Routing/auth: envelope
if (message.from === "trusted@example.com") { }

// Display: headers
const display = message.headers.get("from");

SendEmail Limits

Issue Limit Solution
From domain Must own Use Email Routing domain
Volume ~100/min Free Upgrade or throttle
Attachments Not supported Link to R2
Type Transactional No bulk

Common Errors

CPU Time Exceeded

Cause: Heavy parsing, large emails

Solution:

const size = parseInt(message.headers.get("content-length") || "0") / 1024 / 1024;
if (size > 20) {
  message.setReject("Too large");
  return;
}

ctx.waitUntil(expensiveWork());
await message.forward("dest@example.com");

Rule Not Triggering

Causes: Priority conflict, matcher error, catch-all override

Solution: Check priority (lower=first), verify exact match, confirm destination verified

Undefined Property

Cause: Missing header

Solution:

// ❌ WRONG
const subj = message.headers.get("subject").toLowerCase();

// ✅ CORRECT
const subj = message.headers.get("subject")?.toLowerCase() || "";

Limits

Resource Free Paid
Email size 25 MB 25 MB
Rules 200 200
Destinations 200 200
CPU time 10ms 50ms
SendEmail ~100/min Higher

Debugging

Local

npx wrangler dev

curl -X POST 'http://localhost:8787/__email' \
  --header 'content-type: message/rfc822' \
  --data 'From: test@example.com
To: you@yourdomain.com
Subject: Test

Body'

Production

npx wrangler tail

Pattern

export default {
  async email(message, env, ctx) {
    try {
      console.log("From:", message.from);
      await process(message, env);
    } catch (err) {
      console.error(err);
      message.setReject(err.message);
    }
  }
} satisfies ExportedHandler;

Auth Troubleshooting

Check Status

const auth = message.headers.get("authentication-results") || "";
console.log({
  spf: auth.includes("spf=pass"),
  dkim: auth.includes("dkim=pass"),
  dmarc: auth.includes("dmarc=pass")
});

if (!auth.includes("pass")) {
  message.setReject("Failed auth");
  return;
}

SPF Issues

Causes: Forwarding breaks SPF, too many lookups (>10), missing includes

Solution:

; ✅ Good
example.com. IN TXT "v=spf1 include:_spf.google.com ~all"

; ❌ Bad - too many
example.com. IN TXT "v=spf1 include:a.com include:b.com ... ~all"

DMARC Alignment

Cause: From domain must match SPF/DKIM domain

Best Practices

  1. Consume message.raw immediately
  2. Verify destinations
  3. Handle missing headers (?.)
  4. Use envelope for routing
  5. Check spam scores
  6. Test locally first
  7. Use ctx.waitUntil for background work
  8. Size-check early

Source: SKILL.md on GitHub

2 warnings17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides comprehensive guidance for deploying and managing infrastructure on the Cloudflare platform. It includes extensive educational material on secure development practices, such as preventing SQL injection and managing secrets effectively. No malicious patterns or security risks were identified.

  • Socket17d

    2 alerts: gptAnomaly

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    310/310 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at bf9e226. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Activeupdated 8 months ago

README badge

README badge for openai/skills/cloudflare-deploy

Deploys applications and infrastructure to Cloudflare's platform, including Workers, Pages, D1, R2, Durable Objects, KV, and other services. Use decision trees to route to the right Cloudflare product based on compute, storage, AI, networking, security, or media needs.

Generated from the current SKILL.md.

Does this skill cover all Cloudflare products?
The skill is a consolidated index covering compute, storage, AI, networking, security, media, and developer tools on Cloudflare. It uses decision trees to route you to the right product reference, then loads detailed guidance for that product.
What authentication is required before deploying?
Run `npx wrangler whoami` to check if authenticated. For local deployment, use `wrangler login` (one-time OAuth). For CI/CD, set the `CLOUDFLARE_API_TOKEN` environment variable.
What should I do if deployment fails due to network issues?
Rerun the deploy with `sandbox_permissions=require_escalated` to grant elevated network access, which is required for outbound requests to Cloudflare during deployment.
How long does a Cloudflare deployment typically take?
Deployments may take several minutes. Use appropriate timeout values in your configuration or CI/CD environment.

Generated from the current SKILL.md. These answers refresh after source changes.