cloudflare-workers-expert
它能做什么
这位专家可以帮你构建和优化运行在互联网“边缘”(Cloudflare Workers)上的程序。它懂得如何让这些程序更快、如何存储数据,以及如何与其他 Cloudflare 服务协同工作。
适用场景
- ✓当你构建的程序需要让全球各地的用户都能快速访问时。
- ✓当你希望把信息直接存储在 Cloudflare 的网络上时。
- ✓在请求到达主服务器之前,修改网站请求的进出方式。
技能链接
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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“创建一个 Worker,把网页的标题保存到 Cloudflare KV 存储中。”
每周 5 个新技能,1 分钟读完。
工作原理
它会使用 Wrangler 等工具来设置和测试你的 Workers。Workers 使用标准的 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
- Wrangler Ecosystem: Use the project’s wrangler.jsonc or wrangler.toml configuration and
npx wrangler devfor local testing. - Fetch API: Remember that Workers use the Web standard Fetch API, not Node.js globals.
- Bindings: Define all bindings (KV, D1, secrets) in
wrangler.tomland access them through theenvparameter in thefetchhandler. - 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.
- Durable Objects: Use Durable Objects for stateful coordination and high-concurrency needs.
- 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_NAMEfor secrets and environment variables. - ✅ Do: Use
Response.redirect()for clean edge-side redirects. - ✅ Do: Use
wrangler tailfor 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 是什么?
它们是 Cloudflare 提供的服务,用于快速、分布式地存储数据,Workers 会用到它们。
详情
作者的原始描述
Expert in Cloudflare Workers and the Edge Computing ecosystem. Covers Wrangler, KV, D1, Durable Objects, and R2 storage.
热度
- GitHub 星标
- 48k
- 排名
- #4168
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。