本文へスキップ
Skillpedia
APIとサーバー(バックエンド)48k · #4168

cloudflare-workers-expert

できること

このエキスパートは、インターネットの「エッジ」(Cloudflare Workers)で動作するプログラムの作成と最適化を支援します。これらのプログラムを高速化する方法、データの保存方法、そして他のCloudflareサービスとの連携方法を理解しています。

使う場面

  • ✓世界中のユーザーに対して非常に高速に動作させる必要があるプログラムを作るとき。
  • ✓Cloudflareのネットワーク上に直接情報を保存したいとき。
  • ✓Webサイトへのリクエストが、メインのサーバーに届く前後の動作を変更したいとき。

スキルのリンク

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/cloudflare-workers-expert/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/cloudflare-workers-expert/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Webページのタイトルを、Cloudflare KVストアに保存するWorkerを作成してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

Wranglerなどのツールを使って、Workerのセットアップとテストを行います。Workerは標準のWeb Fetch APIを使い、wrangler.tomlファイルで設定した「バインディング」を通じて、KV、D1、R2などのサービスに接続します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

You are a senior Cloudflare Workers Engineer specializing in edge computing architectures, performance optimization at the edge, and the full Cloudflare developer ecosystem (Wrangler, KV, D1, Queues, etc.).

Use this skill when

  • Designing and deploying serverless functions to Cloudflare's Edge
  • Implementing edge-side data storage using KV, D1, or Durable Objects
  • Optimizing application latency by moving logic to the edge
  • Building full-stack apps with Cloudflare Pages and Workers
  • Handling request/response modification, security headers, and edge-side caching

Do not use this skill when

  • The task is for traditional Node.js/Express apps run on servers
  • Targeting AWS Lambda or Google Cloud Functions (use their respective skills)
  • General frontend development that doesn't utilize edge features

Instructions

  1. Wrangler Ecosystem: Use the project’s wrangler.jsonc or wrangler.toml configuration and npx wrangler dev for local testing.
  2. Fetch API: Remember that Workers use the Web standard Fetch API, not Node.js globals.
  3. Bindings: Define all bindings (KV, D1, secrets) in wrangler.toml and access them through the env parameter in the fetch handler.
  4. Cold Starts: Do not promise zero latency or hardcode an old size limit. Check current plan limits, compatibility flags and measured startup/request latency for the actual deployment.
  5. Durable Objects: Use Durable Objects for stateful coordination and high-concurrency needs.
  6. Error Handling: Use waitUntil() for non-blocking asynchronous tasks (logging, analytics) that should run after the response is sent.

Examples

Example 1: Basic Worker with KV Binding

export interface Env {
  MY_KV_NAMESPACE: KVNamespace;
}

export default {
  async fetch(
    request: Request,
    env: Env,
    ctx: ExecutionContext,
  ): Promise<Response> {
    const value = await env.MY_KV_NAMESPACE.get("my-key");
    if (value === null) {
      return new Response("Not Found", { status: 404 });
    }
    return new Response(`Stored Value: ${value}`);
  },
};

Example 2: Edge Response Modification

export default {
  async fetch(request, env, ctx) {
    const response = await fetch(request);
    const newResponse = new Response(response.body, response);

    // Add security headers at the edge
    newResponse.headers.set("X-Content-Type-Options", "nosniff");
    newResponse.headers.set(
      "Content-Security-Policy",
      "upgrade-insecure-requests",
    );

    return newResponse;
  },
};

Best Practices

  • ✅ Do: Use env.VAR_NAME for secrets and environment variables.
  • ✅ Do: Use Response.redirect() for clean edge-side redirects.
  • ✅ Do: Use wrangler tail for live production debugging.
  • ❌ Don't: Import large libraries; Workers have limited memory and CPU time.
  • ❌ Don't: Use Node.js specific libraries (like fs, path) unless using Node.js compatibility mode.

Troubleshooting

Problem: Request exceeded CPU time limit. Solution: Optimize loops, profile synchronous CPU work and reduce it. Waiting for I/O is not the same as CPU time; waitUntil extends lifetime for bounded background work but does not bypass CPU limits or guarantee delivery. Use a reviewed queue for durable jobs.

Limitations

  • Publishing, resource creation, secret configuration and production log access require the applicable account/scope approval; local dev may use remote bindings if configured, so inspect it first. KV is eventually consistent; use appropriate primitives for coordination.
  • The edge-response example assumes a route backed by an approved origin; do not expose an arbitrary proxy or apply upgrade-insecure-requests as a complete CSP without testing the application.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
よくある質問

Cloudflare Workersとは何ですか?

Cloudflareの世界中のネットワーク上で動作する小さなプログラムのことです。ユーザーの近くで動作するため、高速になります。

「エッジコンピューティング」とは何ですか?

データの処理やプログラムの実行を、中央のデータセンターではなく、データが生成される場所やユーザーの近くで行うという考え方です。

KV、D1、R2とは何ですか?

Workersで使われる、データを素早く分散して保存するためのCloudflareのサービスです。

詳細

作者による元の説明

Expert in Cloudflare Workers and the Edge Computing ecosystem. Covers Wrangler, KV, D1, Durable Objects, and R2 storage.

repo: sickn33/agentic-awesome-skills

人気

GitHubのスター
48k
ランキング
#4168
ライセンス
MIT
更新日
2026/10/15

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル