Agent skill

Cloudflare Email Routing

by secondsky in secondsky/claude-skills

Cloudflare Email Routing for receiving/sending emails via Workers.

MITAuto-check passed

Install Cloudflare Email Routing

skills CLI
$ npx skills add secondsky/claude-skills --skill cloudflare-email-routing -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install secondsky/claude-skills cloudflare-email-routing --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/secondsky/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/cloudflare-email-routing/skills/cloudflare-email-routing .claude/skills/cloudflare-email-routing && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cloudflare-email-routing
GitHub stars
227
Token cost
~2.8k tokens
SKILL.md length
501 words
Files
12 (incl. references)
Skills in repo
169
Repo updated
First seen
Licence
MIT

At a glance

Cloudflare Email Routing for receiving/sending emails via Workers.

  • Works in 2 steps: Email Workers - Receive and process… → Send Email - Send emails from Workers to…
  • Encountering Email Trigger errors
  • SKILL.md covers What Is Email Routing?, Quick Start (10 Minutes), Critical Rules and Common Patterns, plus 6 more sections
  • Runs TypeScript scripts from its folder; calls bun and bunx

What it does

Cloudflare Email Routing is an agent skill from secondsky/claude-skills. Cloudflare Email Routing for receiving/sending emails via Workers. Use for email workers, forwarding, allowlists, or encountering Email Trigger errors, worker call failures, SPF issues.

Its SKILL.md is about 2.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 13 other files, including reference files (for example `references/common-errors.md`, `references/dns-setup.md` and `references/local-development.md`).

It works with Cloudflare and Node.js. The repository describes itself as: Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations. The licence is MIT.

When your agent uses it

  • Encountering Email Trigger errors
  • Worker call failures

Example prompts

  • “/cloudflare-email-routing”

Requirements

  • Node.js

Workflow steps

2 steps, taken from the first numbered list in SKILL.md.

  1. Email Workers - Receive and process incoming emails (allowlists, forwarding, parsing)
  2. Send Email - Send emails from Workers to verified addresses

What it can do on your machine

Read from SKILL.md and the folder at commit 8837836. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (TypeScript), which the agent can run.

    Shell commands in SKILL.md call:

    • bun
    • bunx

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • developers.cloudflare.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cloudflare Email Routing loads about 2.8k tokens when it runs, and up to ~15k if it reads all its reference files. Until then it costs about 53 tokens; SKILL.md has 501 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~53
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~15k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from secondsky/claude-skills at commit 8837836, republished under its MIT licence (© secondsky). 501 words, ~2,804 tokens.

Download SKILL.mdSave it as .claude/skills/cloudflare-email-routing/SKILL.md (or your agent's skills folder). This skill also uses 11 other files; get the full folder from GitHub.
name
cloudflare-email-routing
description
Cloudflare Email Routing for receiving/sending emails via Workers. Use for email workers, forwarding, allowlists, or encountering Email Trigger errors, worker call failures, SPF issues.
license
MIT
metadata.version
2.0.0
metadata.last_verified
2025-11-18
metadata.production_tested
true
metadata.token_savings
~60%
metadata.errors_prevented
8
metadata.templates_included
0
metadata.references_included
1
metadata.keywords
Cloudflare Email Routing, Email Workers, send email, receive email, email forwarding, email allowlist, email blocklist, postal-mime, mimetext…

Cloudflare Email Routing

Status: Production Ready ✅ | Last Verified: 2025-11-18


What Is Email Routing?

Two capabilities:

  1. Email Workers - Receive and process incoming emails (allowlists, forwarding, parsing)
  2. Send Email - Send emails from Workers to verified addresses

Both free and work together for complete email functionality.


Quick Start (10 Minutes)

Part 1: Enable Email Routing

Dashboard setup:

  1. Dashboard → Domain → Email → Email Routing
  2. Enable Email Routing → Add records and enable
  3. Create destination address:
    • Custom: hello@yourdomain.com
    • Destination: Your email
    • Verify via email
  4. ✅ Basic forwarding active
Part 2: Receiving Emails (Email Workers)

Install dependencies:

bash
bun add postal-mime@2.5.0 mimetext@3.0.27

Create email worker:

typescript
// src/email.ts
import { EmailMessage } from 'cloudflare:email';
import PostalMime from 'postal-mime';

export default {
  async email(message, env, ctx) {
    const parser = new PostalMime.default();
    const email = await parser.parse(await new Response(message.raw).arrayBuffer());

    console.log('From:', message.from);
    console.log('Subject:', email.subject);

    // Forward to destination
    await message.forward('you@gmail.com');
  }
};

Configure wrangler.jsonc:

jsonc
{
  "name": "email-worker",
  "main": "src/email.ts",
  "compatibility_date": "2025-10-11",  // must be >= 2024-09-23 for nodejs_compat
  "compatibility_flags": ["nodejs_compat"]  // Required! postal-mime needs Node.js compat
}

Deploy and connect:

bash
bunx wrangler deploy

Dashboard → Email Workers → Create address → Select worker

Part 3: Sending Emails

Add send email binding:

jsonc
{
  "name": "my-worker",
  "main": "src/index.ts",
  "compatibility_date": "2025-10-11",
  "send_email": [
    {
      "name": "SES",
      "destination_address": "user@example.com"
    }
  ]
}

Send from worker:

typescript
import { EmailMessage } from 'cloudflare:email';
import { createMimeMessage } from 'mimetext';

const msg = createMimeMessage();
msg.setSender({ name: 'App', addr: 'noreply@yourdomain.com' });
msg.setRecipient('user@example.com');
msg.setSubject('Hello!');
msg.addMessage({
  contentType: 'text/plain',
  data: 'Email body here'
});

const message = new EmailMessage(
  'noreply@yourdomain.com',
  'user@example.com',
  msg.asRaw()
);

await env.SES.send(message);

Load references/setup-guide.md for complete walkthrough.


Critical Rules

Always Do ✅
  1. Enable compatibility_flags: ["nodejs_compat"] for postal-mime (requires compatibility_date >= 2024-09-23)
  2. Verify destination addresses before sending
  3. Parse with postal-mime for email content
  4. Use mimetext for creating emails
  5. Check message.from for allowlists
  6. Forward with message.forward() (not manual)
  7. Handle errors (email delivery can fail)
  8. Test with real emails (not just dashboard)
  9. Add MX records (automatic via dashboard)
  10. Log email activity for debugging
Never Do ❌
  1. Never skip nodejs_compat (postal-mime requires the Node.js compat flag)
  2. Never send without verification (delivery fails)
  3. Never hardcode email addresses in public code
  4. Never skip parsing (raw email is hard to work with)
  5. Never ignore spam (implement allowlists/blocklists)
  6. Never exceed Gmail limits (500 emails/day to Gmail)
  7. Never skip error handling (emails can fail)
  8. Never modify DNS manually (use dashboard)
  9. Never expose email content in logs (PII)
  10. Never assume instant delivery (email is async)

Common Patterns

Allowlist
typescript
const allowlist = ['approved@domain.com'];

if (!allowlist.includes(message.from)) {
  message.setReject('Not on allowlist');
  return;
}

await message.forward('you@gmail.com');
Blocklist
typescript
const blocklist = ['spam@bad.com'];

if (blocklist.includes(message.from)) {
  message.setReject('Blocked');
  return;
}

await message.forward('you@gmail.com');
Reply to Email
typescript
const msg = createMimeMessage();
msg.setSender({ addr: 'noreply@yourdomain.com' });
msg.setRecipient(message.from);
msg.setSubject(`Re: ${email.subject}`);
msg.addMessage({
  contentType: 'text/plain',
  data: 'Thanks for your email!'
});

const reply = new EmailMessage(
  'noreply@yourdomain.com',
  message.from,
  msg.asRaw()
);

await env.SES.send(reply);
Parse Attachments
typescript
const parser = new PostalMime.default();
const email = await parser.parse(await new Response(message.raw).arrayBuffer());

for (const attachment of email.attachments) {
  console.log('Filename:', attachment.filename);
  console.log('Type:', attachment.mimeType);
  console.log('Size:', attachment.content.byteLength);
}
Custom Routing Logic
typescript
async email(message, env, ctx) {
  const parser = new PostalMime.default();
  const email = await parser.parse(await new Response(message.raw).arrayBuffer());

  // Route based on subject
  if (email.subject.includes('[Support]')) {
    await message.forward('support@yourdomain.com');
  } else if (email.subject.includes('[Sales]')) {
    await message.forward('sales@yourdomain.com');
  } else {
    await message.forward('general@yourdomain.com');
  }
}

Email Message Properties

Incoming Messages (ForwardableEmailMessage)
typescript
message.from        // Sender email
message.to          // Recipient email
message.headers     // Email headers
message.raw         // Raw email stream
message.rawSize     // Size in bytes

// Methods
message.forward(address)        // Forward to address
message.setReject(reason)       // Reject email
Parsed Email (PostalMime)
typescript
email.from          // { name, address }
email.to            // [{ name, address }]
email.subject       // Subject line
email.text          // Plain text body
email.html          // HTML body
email.attachments   // Array of attachments
email.headers       // All headers

Show full SKILL.md (200 more words)Show less

Top 5 Errors Prevented

  1. "Email Trigger not available": Enable compatibility_flags: ["nodejs_compat"] (with compatibility_date >= 2024-09-23)
  2. Destination not verified: Verify all send destinations
  3. Gmail rate limit: Max 500 emails/day to Gmail
  4. SPF permerror: Use dashboard to configure DNS
  5. Worker call failed: Check logs for parsing errors

Use Cases

Use Case 1: Support Ticket System
typescript
async email(message, env, ctx) {
  const parser = new PostalMime.default();
  const email = await parser.parse(await new Response(message.raw).arrayBuffer());

  // Create ticket in database
  await env.DB.prepare(
    'INSERT INTO tickets (email, subject, body, created_at) VALUES (?, ?, ?, ?)'
  ).bind(message.from, email.subject, email.text, Date.now()).run();

  // Send confirmation
  const msg = createMimeMessage();
  msg.setSender({ addr: 'support@yourdomain.com' });
  msg.setRecipient(message.from);
  msg.setSubject('Ticket Created');
  msg.addMessage({
    contentType: 'text/plain',
    data: 'Your support ticket has been created.'
  });

  const confirmation = new EmailMessage(
    'support@yourdomain.com',
    message.from,
    msg.asRaw()
  );

  await env.SES.send(confirmation);
}
Use Case 2: Email Notifications
typescript
export default {
  async fetch(request, env, ctx) {
    // User signup
    const { email, name } = await request.json();

    const msg = createMimeMessage();
    msg.setSender({ name: 'App', addr: 'noreply@yourdomain.com' });
    msg.setRecipient(email);
    msg.setSubject('Welcome!');
    msg.addMessage({
      contentType: 'text/html',
      data: `<h1>Welcome, ${name}!</h1>`
    });

    const message = new EmailMessage(
      'noreply@yourdomain.com',
      email,
      msg.asRaw()
    );

    await env.SES.send(message);

    return new Response('Welcome email sent!');
  }
};
Use Case 3: Email Forwarding with Filtering
typescript
async email(message, env, ctx) {
  const parser = new PostalMime.default();
  const email = await parser.parse(await new Response(message.raw).arrayBuffer());

  // Filter spam keywords
  const spamKeywords = ['viagra', 'lottery', 'prince'];
  const isSpam = spamKeywords.some(keyword =>
    email.subject.toLowerCase().includes(keyword) ||
    email.text.toLowerCase().includes(keyword)
  );

  if (isSpam) {
    message.setReject('Spam detected');
    return;
  }

  await message.forward('you@gmail.com');
}

When to Load References

Load references/setup-guide.md when:
  • First-time Email Routing setup
  • Configuring MX records
  • Setting up email workers
  • Configuring send email binding
  • Complete walkthrough needed

Using Bundled Resources

References (references/):

  • setup-guide.md - Complete setup walkthrough (enabling routing, email workers, send email)
  • common-errors.md - All 8 documented errors with solutions and prevention
  • dns-setup.md - MX records, SPF, DKIM configuration guide
  • local-development.md - Local testing and development patterns

Templates (templates/):

  • receive-basic.ts - Basic email receiving worker
  • receive-allowlist.ts - Email allowlist implementation
  • receive-blocklist.ts - Email blocklist implementation
  • receive-reply.ts - Auto-reply email worker
  • send-basic.ts - Basic send email example
  • send-notification.ts - Notification email pattern
  • wrangler-email.jsonc - Wrangler configuration for email routing

Official Documentation


Questions? Issues?

  1. Check references/setup-guide.md for complete setup
  2. Verify compatibility_flags: ["nodejs_compat"] in wrangler.jsonc
  3. Confirm destination addresses verified
  4. Check logs for errors

© secondsky, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 11 other files (references) in plugins/cloudflare-email-routing/skills/cloudflare-email-routing of secondsky/claude-skills.

  • SKILL.md
  • references/common-errors.md
  • references/dns-setup.md
  • references/local-development.md
  • references/setup-guide.md
  • templates/receive-allowlist.ts
  • templates/receive-basic.ts
  • templates/receive-blocklist.ts
  • templates/receive-reply.ts
  • templates/send-basic.ts
  • templates/send-notification.ts
  • templates/wrangler-email.jsonc

Open the folder on GitHubat commit 8837836

Compare with similar skills

Cloudflare Email Routing next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cloudflare Email Routing compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cloudflare Email Routing this skillsecondsky/claude-skills227—~2.8kAutomated safety check: PassMIT
Cloudflare Email Servicehodgef/apiker1273 repos~2kAutomated safety check: PassMIT
Fumadocsbetter-notify/better-notify313—~2.3kAutomated safety check: PassMIT
Workers Best Practiceshodgef/apiker1276 repos~1.8kAutomated safety check: PassMIT
Chart Visualizationbytedance/deer-flow83k2 repos~840Automated safety check: PassMIT
Web Access via Browser CDPeze-is/web-access9.1k4 repos~2.2kAutomated safety check: PassMIT

Similar skills

  • Send and receive transactional emails with Cloudflare Email Service (Email Sending + Email Routing).

    127 GitHub starsUsed in 3 repos~2k tokens
    Backend & APIsAuto-check passed
  • Fumadocs

    better-notify/better-notify

    A skill your agent uses when writing MDX documentation pages for a Fumadocs project — frontmatter, meta.json, page ordering, and fumadocs-ui React components available inside MDX content.

    313 GitHub stars~2.3k tokensUpdated 1 mo ago
    Frontend & DesignAuto-check passed
  • Reviews and authors Cloudflare Workers code against production best practices.

    127 GitHub starsUsed in 6 repos~1.8k tokens
    DevOps & CloudAuto-check passed
  • Chart Visualization

    bytedance/deer-flow

    Picks a suitable chart type from 26 options for your data, maps the data to that chart's parameters and generates a chart image through a JavaScript script.

    83k GitHub starsUsed in 2 repos~840 tokens
    Data & AnalyticsAuto-check passed
  • Routes every web task, from searching to logged-in browsing, through a tiered choice of search, fetch, curl or a real Chrome or Edge session driven over CDP.

    9.1k GitHub starsUsed in 4 repos~2.2k tokens
    Productivity & AutomationAuto-check passed
  • Knap Markdown Templates

    kepano/obsidian-skills

    Renders Markdown notes from Knap templates and JSON data on the command line, including notes built from Defuddle web page output.

    49k GitHub starsUsed in 2 repos~986 tokens
    Documents & OfficeAuto-check passed

More from secondsky/claude-skills

All 169 skills in this repo
  • Tanstack AI

    secondsky/claude-skills

    TanStack AI (alpha) provider-agnostic type-safe chat with streaming for OpenAI, Anthropic, Gemini, Ollama.

    227 GitHub starsUsed in 1 repo~3.6k tokens
    Auto-check: notes
  • Auto Animate

    secondsky/claude-skills

    AutoAnimate (@formkit/auto-animate) zero-config animations for React.

    227 GitHub stars~2.9k tokensUpdated 9 days ago
    Auto-check passed
  • Base UI React

    secondsky/claude-skills

    MUI Base UI unstyled React components with Floating UI. An agent skill from secondsky/claude-skills.

    227 GitHub stars~1.9k tokensUpdated 9 days ago
    Auto-check passed
  • Cloudflare Images

    secondsky/claude-skills

    This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants"…

    227 GitHub stars~3.6k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Nextjs

    secondsky/claude-skills

    Deploy Next.js to Cloudflare Workers via the OpenNext adapter (@opennextjs/cloudflare).

    227 GitHub stars~5.3k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Sandbox

    secondsky/claude-skills

    Cloudflare Sandboxes SDK for secure code execution in Linux containers at edge.

    227 GitHub stars~4.5k tokensUpdated 9 days ago
    Auto-check passed

Questions about Cloudflare Email Routing

What does Cloudflare Email Routing do?

Cloudflare Email Routing for receiving/sending emails via Workers. Cloudflare Email Routing is an agent skill from secondsky/claude-skills. Cloudflare Email Routing for receiving/sending emails via Workers.

When should I use Cloudflare Email Routing?

Cloudflare Email Routing fits situations like: encountering Email Trigger errors; worker call failures.

How do I install Cloudflare Email Routing in Claude Code?

Run `npx skills add secondsky/claude-skills --skill cloudflare-email-routing -a claude-code`. Or copy the skill folder (plugins/cloudflare-email-routing/skills/cloudflare-email-routing in secondsky/claude-skills) into .claude/skills/cloudflare-email-routing in your project. Claude Code loads it when a task matches its description.

How do I install Cloudflare Email Routing in Codex?

Run `npx skills add secondsky/claude-skills --skill cloudflare-email-routing -a codex`. Or copy the skill folder (plugins/cloudflare-email-routing/skills/cloudflare-email-routing in secondsky/claude-skills) into .agents/skills/cloudflare-email-routing in your project. Codex loads it when a task matches its description.

Can I use Cloudflare Email Routing in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add secondsky/claude-skills --skill cloudflare-email-routing -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cloudflare-email-routing, .gemini/skills/cloudflare-email-routing, .github/skills/cloudflare-email-routing and .opencode/skills/cloudflare-email-routing in your project.

What does Cloudflare Email Routing need to run?

Going by SKILL.md and its folder, Cloudflare Email Routing needs TypeScript for the scripts in its folder and the command-line tools its instructions call (bun and bunx). Our summary lists: Node.js.

Does Cloudflare Email Routing access the network?

SKILL.md names 1 domain. As links in the text: developers.cloudflare.com. This is read from the text; nothing was executed.

Is Cloudflare Email Routing safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cloudflare Email Routing use?

Cloudflare Email Routing is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cloudflare Email Routing use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 12k tokens, read only when the agent opens those files.

What are the alternatives to Cloudflare Email Routing?

Skills that share tags, products or a category with Cloudflare Email Routing: Cloudflare Email Service (hodgef/apiker, 127 stars), Fumadocs (better-notify/better-notify, 313 stars), Workers Best Practices (hodgef/apiker, 127 stars) and Chart Visualization (bytedance/deer-flow, 83k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cloudflare Email Routing?

secondsky (a GitHub user) maintains it in secondsky/claude-skills, which has 227 GitHub stars. The repository holds 169 skills in this directory. The repository was last updated on September 28, 2026.

Source: secondsky/claude-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.