Logo di Cloudflare Workers

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.

Add to TypingMind

Panoramica

Pubblicato daOmar-Obando
Repositoryqwen-orchestrator
Nome della skillcloudflare-workers
Stelle
53
Fork
13
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da Omar-Obando su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Cloudflare Workers in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/cloudflare-workers
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

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
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Cloudflare Workers in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Cloudflare Workers non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Cloudflare Workers non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

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

Domande frequenti

Cosa fa la skill IA 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.

Perché usare Cloudflare Workers su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Cloudflare Workers è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Cloudflare Workers in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/cloudflare-workers. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Cloudflare Workers?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Cloudflare Workers?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Cloudflare Workers: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Cloudflare Workers è gratuita?

Sì. È pubblicata su GitHub da Omar-Obando con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇