Cloudflare Workers logo

Cloudflare Workers

Community
Omar-Obando
cloudflare-workers

Use when developing and deploying Cloudflare Workers, implementing edge computing logic, optimizing performance, and configuring global distribution. Includes Workers API, KV storage, Durable Objects, and performance optimization. Based on Cloudflare Certified Developer and edge computing best practices.

Overview

PublisherOmar-Obando
Repositoryqwen-orchestrator
Skill namecloudflare-workers
Stars
53
Forks
13
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Omar-Obando on GitHub. Read the source before you install it.

Installation

Install the Cloudflare Workers AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/cloudflare-workers
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Omar-Obando/qwen-orchestrator.git /tmp/qwen-orchestrator
mkdir -p .claude/skills
cp -r /tmp/qwen-orchestrator/skills/cloudflare-workers .claude/skills/cloudflare-workers
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Cloudflare Workers in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Cloudflare Workers on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Cloudflare Workers is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Cloudflare Workers Skill — Edge Computing & Global Distribution

Overview

This skill provides comprehensive guidance for developing and deploying Cloudflare Workers, implementing edge computing logic, optimizing performance, and configuring global distribution. It includes Workers API, KV storage, Durable Objects, and performance optimization. Based on Cloudflare Certified Developer and edge computing best practices.

When to Use

Use this skill when:

  • Developing Cloudflare Workers for edge computing
  • Implementing edge computing logic (authentication, routing, caching)
  • Optimizing performance and cold starts for Workers
  • Configuring global distribution with Cloudflare's edge network
  • Using KV storage for fast read operations
  • Using Durable Objects for stateful operations
  • Using D1 database for structured data
  • Implementing authentication and JWT validation at edge
  • Implementing rate limiting and bot protection
  • Setting up edge caching strategies
  • Creating middleware for request/response modification
  • Implementing A/B testing and feature flags
  • Using Cloudflare Analytics and monitoring
  • Configuring Workers with Wrangler CLI
  • Setting up local development environment
  • Deploying Workers with Git integration
  • Using Cloudflare Queues for async processing
  • Implementing WebSockets at the edge
  • Using R2 storage for edge data

Do NOT use this skill when:

  • Writing application business logic (use developer skill or specific framework skill)
  • Designing database schema (use database-design skill)
  • Creating UI components (use frontend-design skill)
  • Managing non-Cloudflare infrastructure (use aws-serverless, azure-cloud, or gcp-cloud skills)
  • Performing security audits (use security-auditor skill)
  • Setting up Kubernetes deployments (use devops-pipeline skill)
  • Deploying to Cloudflare Pages (use cloudflare-pages skill - different use case)
  • Deploying to Vercel (use vercel-deployment skill)

Why avoid: Cloudflare Workers is for full edge computing. For Pages deployment or other platforms, use targeted skills.

Workers Architecture

Basic Worker

javascript
// worker.js
export default {
  async fetch(request, env, ctx) {
    return new Response('Hello World!');
  },
};

Edge Function

typescript
// worker.ts
export default {
  async fetch(
    request: Request,
    env: Env,
    ctx: ExecutionContext
  ): Promise<Response> {
    const url = new URL(request.url);

    // Route requests
    if (url.pathname === '/api/data') {
      return handleData(request, env);
    }

    return new Response('Not Found', { status: 404 });
  },
};

async function handleData(request: Request, env: Env): Promise<Response> {
  // Handle data request
  return new Response(JSON.stringify({ data: 'value' }));
}

Performance Optimization

Cold Start Optimization

javascript
// ✅ GOOD: Cold start optimization
let cachedData = null;

export default {
  async fetch(request, env, ctx) {
    // Initialize expensive resources once
    if (!cachedData) {
      cachedData = await env.DB.prepare('SELECT * FROM data').all();
    }

    return new Response(JSON.stringify(cachedData));
  },
};

Minimal Dependencies

javascript
// ✅ GOOD: Minimal dependencies
export default {
  async fetch(request, env, ctx) {
    // No external dependencies
    const result = processRequest(request);
    return new Response(JSON.stringify(result));
  },
};

function processRequest(request) {
  // Simple, focused logic
  return { processed: true };
}

Streaming

javascript
// ✅ GOOD: Streaming for large data
export default {
  async fetch(request, env, ctx) {
    const stream = new ReadableStream({
      async start(controller) {
        // Stream data
        controller.enqueue('data');
        controller.close();
      },
    });

    return new Response(stream, {
      headers: { 'Content-Type': 'text/event-stream' },
    });
  },
};

Storage Options

KV Storage

javascript
// ✅ GOOD: KV storage for fast reads
export default {
  async fetch(request, env, ctx) {
    const { KV } = env;

    // Fast read from KV
    const value = await KV.get('key');

    return new Response(value);
  },
};

Durable Objects

javascript
// ✅ GOOD: Durable Objects for stateful operations
export default {
  async fetch(request, env, ctx) {
    const { DO } = env;

    // Create durable object stub
    const id = env.DO.idFromName('my-object');
    const stub = env.DO.get(id);

    // Perform stateful operations
    const response = await stub.fetch(request);

    return response;
  },
};

D1 Database

javascript
// ✅ GOOD: D1 database for structured data
export default {
  async fetch(request, env, ctx) {
    const { D1 } = env;

    // Query D1 database
    const result = await D1.prepare('SELECT * FROM users').all();

    return new Response(JSON.stringify(result));
  },
};

Authentication at Edge

JWT Validation

javascript
// ✅ GOOD: JWT validation at edge
export default {
  async fetch(request, env, ctx) {
    const authHeader = request.headers.get('Authorization');

    if (!authHeader) {
      return new Response('Unauthorized', { status: 401 });
    }

    const token = authHeader.replace('Bearer ', '');

    try {
      // Validate JWT at edge
      const payload = await validateJWT(token, env.JWT_SECRET);

      // Add user info to request
      request.headers.set('X-User-ID', payload.userId);

      // Continue to next handler
      return fetch(request);
    } catch (error) {
      return new Response('Unauthorized', { status: 401 });
    }
  },
};

async function validateJWT(token, secret) {
  // Validate JWT at edge
  // Return payload
}

Session Management

javascript
// ✅ GOOD: Session management at edge
export default {
  async fetch(request, env, ctx) {
    const session = await getSession(request, env);

    if (!session && request.url.includes('/api')) {
      return new Response('Unauthorized', { status: 401 });
    }

    // Continue to next handler
    return fetch(request);
  },
};

async function getSession(request, env) {
  // Get session from KV
  const cookie = request.headers.get('Cookie');
  const sessionId = parseCookie(cookie, 'session_id');

  if (!sessionId) {
    return null;
  }

  return await env.KV.get(`session:${sessionId}`);
}

Routing Strategies

Path-based Routing

javascript
// ✅ GOOD: Path-based routing
export default {
  async fetch(request, env, ctx) {
    const url = new URL(request.url);

    switch (url.pathname) {
      case '/api/users':
        return handleUsers(request, env);
      case '/api/products':
        return handleProducts(request, env);
      case '/api/orders':
        return handleOrders(request, env);
      default:
        return new Response('Not Found', { status: 404 });
    }
  },
};

async function handleUsers(request, env) {
  // Handle users API
}

async function handleProducts(request, env) {
  // Handle products API
}

async function handleOrders(request, env) {
  // Handle orders API
}

Method-based Routing

javascript
// ✅ GOOD: Method-based routing
export default {
  async fetch(request, env, ctx) {
    const url = new URL(request.url);

    if (url.pathname === '/api/data') {
      switch (request.method) {
        case 'GET':
          return getData(request, env);
        case 'POST':
          return createData(request, env);
        case 'PUT':
          return updateData(request, env);
        case 'DELETE':
          return deleteData(request, env);
        default:
          return new Response('Method Not Allowed', { status: 405 });
      }
    }

    return new Response('Not Found', { status: 404 });
  },
};

async function getData(request, env) {
  // Handle GET request
}

async function createData(request, env) {
  // Handle POST request
}

async function updateData(request, env) {
  // Handle PUT request
}

async function deleteData(request, env) {
  // Handle DELETE request
}

Common Anti-Patterns

❌ Bad: Large Dependencies

javascript
// ❌ BAD: Large dependencies
import { bigLibrary } from 'big-library';

export default {
  async fetch(request, env, ctx) {
    // Heavy initialization
    const result = bigLibrary.process(request);
    return new Response(JSON.stringify(result));
  },
};

Problems:

  • Slow cold starts
  • High memory usage
  • Expensive execution

✅ Good: Minimal Dependencies

javascript
// ✅ GOOD: Minimal dependencies
export default {
  async fetch(request, env, ctx) {
    // Lightweight processing
    const result = processRequest(request);
    return new Response(JSON.stringify(result));
  },
};

function processRequest(request) {
  // Simple, focused logic
  return { processed: true };
}

❌ Bad: No Caching

javascript
// ❌ BAD: No caching
export default {
  async fetch(request, env, ctx) {
    // Always fetch from origin
    const response = await fetch(request);
    return response;
  },
};

Problems:

  • High latency
  • Origin server load
  • No global distribution

✅ Good: With Caching

javascript
// ✅ GOOD: With caching
export default {
  async fetch(request, env, ctx) {
    // Try to serve from cache
    const cached = await caches.default.match(request);
    if (cached) {
      return cached;
    }

    // Fetch from origin
    const response = await fetch(request);

    // Cache at edge
    ctx.waitUntil(caches.default.put(request, response.clone()));

    return response;
  },
};

Real-World Impact

Before this skill:

  • Slow cold starts
  • High latency
  • Origin server load
  • No global distribution

After this skill:

  • Fast cold starts
  • Low latency
  • Edge processing
  • Global distribution

Cross-References

  • cloudflare-pages - For Pages deployment
  • devops-pipeline - For CI/CD integration
  • testing-strategy - For testing edge functions

References

Frequently asked questions

What does the Cloudflare Workers AI skill do?

Use when developing and deploying Cloudflare Workers, implementing edge computing logic, optimizing performance, and configuring global distribution. Includes Workers API, KV storage, Durable Objects, and performance optimization. Based on Cloudflare Certified Developer and edge computing best practices.

Why use Cloudflare Workers on TypingMind?

Because you install it once and use it with any model. Cloudflare Workers is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Cloudflare Workers in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/cloudflare-workers. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Cloudflare Workers?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Cloudflare Workers?

As many as you like. As long as a model supports skills, you can use Cloudflare Workers with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Cloudflare Workers AI skill free?

Yes. It is published on GitHub by Omar-Obando under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇