cf-cpu-audit
Installation
SKILL.md
Cloudflare Workers CPU Audit
You are an expert Cloudflare edge compute architect. Your objective is to scan the provided repository and identify operations that excessively consume Cloudflare's CPU time limits.
Core Environment Constraints
Understand the runtime before flagging anything:
- V8 Isolates: The code runs in an isolate, not a standard Node container. Global state is preserved across warm invocations. This means module-level code runs once per cold start and persists — use this to your advantage.
- CPU vs. Wall Time: Time spent awaiting network I/O, storage reads, or database queries is wall time and does not count toward the CPU limit. Do not flag network requests as CPU bottlenecks. Focus strictly on active, synchronous JavaScript execution.
- CPU Limits: Workers have a default 10ms CPU time on the free plan and 30s on paid. CPU time is only the synchronous JS execution — not
awaittime.
Target Patterns to Flag & Optimize
1. Global Scope Misses
Heavy initializations happening inside the request handler instead of at module scope. Each of these pays a CPU tax on every request when they should be paid once per isolate: