Identify imports and module-init code that contribute to Cloudflare Worker cold starts and propose lazy-load rewrites.
Profiles a Cloudflare Worker's startup cost and identifies which imports and module-level initializations dominate. Outputs a refactor plan that defers heavy work behind a fetch-handler-scoped lazy import.
worker_entry: path to the Worker entry file (src/index.ts or similar).wrangler_toml: path to wrangler.toml.bundle_size_target_kb: defaults to 800 (Workers limit a paid tier; free tier 1MB).npx wrangler deploy --dry-run --outdir=/tmp/worker-build. Capture the bundle path.wc -c /tmp/worker-build/index.js and record. If gzipped, also gzip -c | wc -c.worker_entry and its imports: build the dependency graph with madge --json <worker_entry>.zod schemas at top level, large polyfills, bcrypt, jsonwebtoken) get tagged.rg -nN '^(const|let|var) [a-zA-Z_]+\s*=' <worker_entry> and inspect each assignment for synchronous heavy calls (e.g., regex compilation, schema construction).import x from 'big-mod' with let x; async function getX() { x ??= (await import('big-mod')).default; return x; }.useMemo-style cache keyed on a per-isolate global.zod: 5-10ms, jose: 3-5ms, marked: 8-12ms).worker-cold-start-plan.md with sections: bundle size analysis, top heavy imports, per-import refactor patches (fenced diffs), expected savings table. Stdout prints current bundle size and projected post-refactor savings.
Apply one suggested patch at a time, redeploy with wrangler deploy --dry-run, and compare cold-start latency using wrangler tail plus a synthetic-request loop from a different region. Post-refactor cold-start p95 should drop by the projected delta within 20%. Functional tests must pass; lazy imports change error timing, so update tests that asserted synchronous error throws.
nodejs_compat flag: bundle is fatter inherently; document that compatibility flag costs roughly 200KB.Other publishers' experience with this skill. Self-rating is blocked.
Sign in and publish to the registry to leave a rating.
No ratings yet. Be the first.
Same domains or capabilities as amitte/cloudflare-worker-cold-start-tuner.
Read-only AWS surface — list/describe EC2, S3 buckets, IAM users, and Lambda functions. Auth via STS-assumed role; no mutating tools.
Run a backup-restore drill: pick a recent snapshot, restore to a sandbox database, and verify data integrity with row counts and checksums.
Read-only Cloudflare surface — list zones, DNS records, deployed Workers, and page rules. Auth via scoped API token; no mutating tools.
Read a list of crontab specifications and detect overlapping execution windows that risk resource contention or duplicate work.
Find dangling DNS records (CNAMEs to dead hosts, A records for retired servers) and propose deletions with risk-of-takeover notes.
Convert a single-stage Dockerfile into a multi-stage build and verify the resulting image is at least 30% smaller than the original.