secondsky avatar

Cloudflare Workers Performance

This covers the core performance bottlenecks you'll hit with Cloudflare Workers: CPU limits, cold starts, memory pressure, and caching. It's packed with before/after code showing what actually slows things down (unnecessary cloning, buffering entire responses, missing cache layers) and how to fix it. The profiling middleware is genuinely useful for finding hot paths, and the multi-layer caching strategy (memory, Cache API, KV) is solid. Best part is the table mapping errors to fixes, because "CPU limit exceeded" is useless without knowing whether to stream, batch, or optimize your JSON parsing. Aimed at people already hitting performance walls rather than premature optimization.

skills.sh installs
329
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill cloudflare-workers-performance --agent claude-code

Installs into .claude/skills of the current project.

Files

Cloudflare Workers Performance Optimization

Techniques for maximizing Worker performance and minimizing latency.

Quick Wins

// 1. Avoid unnecessary cloning
// ❌ Bad: Clones entire request
const body = await request.clone().json();

// ✅ Good: Parse directly when not re-using body
const body = await request.json();

// 2. Use streaming instead of buffering
// ❌ Bad: Buffers entire response
const text = await response.text();
return new Response(transform(text));

// ✅ Good: Stream transformation
return new Response(response.body.pipeThrough(new TransformStream({
  transform(chunk, controller) {
    controller.enqueue(process(chunk));
  }
})));

// 3. Cache expensive operations
const cache = caches.default;
const cached = await cache.match(request);
if (cached) return cached;

Critical Rules

  1. Stay under CPU limits - 10ms (free), 30ms (paid), 50ms (unbound)
  2. Minimize cold starts - Keep bundles < 1MB, avoid dynamic imports
  3. Use Cache API - Cache responses at the edge
  4. Stream large payloads - Don't buffer entire responses
  5. Batch operations - Combine multiple KV/D1 calls

Top 10 Performance Errors

Sponsors

Details

Repository
github.com/secondsky/claude-skills
Categories
Debugging, Cloud & Infrastructure
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146

Recommended

More Debugging
1tirth8205 avatarDebug Issuetirth8205/code-review-graphSystematically debug issues using graph-powered code navigation302skills.sh installs
2lllllllama avatarsafe-debuglllllllama/ai-paper-reproduction-skillsafe debug226skills.sh installs
3charleswiltgen avataraxiom-swiftui-performancecharleswiltgen/axiomUse when UI is slow, scrolling lags, animations stutter, or when asking 'why is my SwiftUI view slow', 'how do I optimize List performance', 'my app drops frame215skills.sh installs
4charleswiltgen avataraxiom-swiftui-debuggingcharleswiltgen/axiomUse when debugging SwiftUI view updates, preview crashes, or layout issues - diagnostic decision trees to identify root causes quickly and avoid misdiagnosis un204skills.sh installs
5matlab avatarmatlab-performance-optimizermatlab/skillsmatlab performance optimizer200skills.sh installs
6sickn33 avatarincident-response-smart-fixsickn33/antigravity-awesome-skillsincident response smart fix197skills.sh installs