cloudflare-workers:optimize

cloudflare-workers:optimize is a command for coding agents from secondsky/claude-skills. It costs 29 tokens per session (2,793 once invoked), scanned A, original, MIT.

A performance analysis command for Cloudflare Workers, which are server-side programs running on Cloudflare’s network. It examines bundle size, caching, memory use, CPU time, and dependencies.

In plain words
What is it for?
Use it to review large dependencies, caching strategies, memory leaks, CPU-heavy code, and bundle size, then receive prioritized recommendations.
Why use it?
It helps identify what is making a Worker slow, resource-heavy, or close to its deployment limits before applying changes.

Command

Part of the cloudflare-workers plugin — 10 skills, 5 commands, 3 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/secondsky/claude-skills/workers-optimize
Clone the repo
git clone --depth 1 https://github.com/secondsky/claude-skills

Or install cloudflare-workers, the plugin that ships this one along with the rest of its 10 skills, 5 commands, 3 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cloudflare-workers:optimize

README.md
[![agentmods](https://agentmods.dev/badge/commands/secondsky/claude-skills/workers-optimize.svg)](https://agentmods.dev/commands/secondsky/claude-skills/workers-optimize)
Your own site
<a href="https://agentmods.dev/commands/secondsky/claude-skills/workers-optimize"><img src="https://agentmods.dev/badge/commands/secondsky/claude-skills/workers-optimize.svg" alt="Measured on agentmods" height="20"></a>
Per session 29 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,793 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00029 $0.02793
Opus 5 $0.00015 $0.01396
Sonnet 5 $0.00006 $0.00559
Haiku 4.5 $0.00003 $0.00279

Measured yesterday against content hash c317b3cba1f5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

cloudflare-workers:optimize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/cloudflare-workers/commands/workers-optimize.md · 455 lines

How it starts

The opening of the file, as written. The whole thing — 455 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Workers Optimize Command

Comprehensive performance analysis and optimization for Cloudflare Workers.

Execution Workflow

Phase 1: Analysis Scope Determination

If --target argument provided:

  • Focus analysis on specified area (bundle, memory, or cache)
  • Skip other analyses for faster results

If no --target argument:

  • Run complete performance audit
  • Analyze all optimization areas

Phase 2: Bundle Size Analysis

Analyze Worker bundle size and identify bloat:

  1. Build Worker and check output size:
bunx wrangler deploy --dry-run --outdir=.wrangler-output
du -h .wrangler-output/
  1. Parse bundle size:

    • Extract total bundle size in KB
    • Compare against limits:
      • Free tier: 1MB limit
      • Paid tier: 10MB limit
    • Flag if >50% of limit used
  2. Identify large dependencies:

# Analyze package.json dependencies
grep -A 100 '"dependencies"' package.json

Common bloat sources:

  • moment.js (large, use date-fns instead)
  • lodash (use lodash-es for tree-shaking)
  • axios (use native fetch)
  • Large UI libraries in backend code
  1. Check for unnecessary imports:
    • Grep for wildcard imports: import * as
    • Check for unused imports in main worker file
    • Look for dev dependencies in production bundle

Findings:

### Bundle Size Analysis

**Current Size**: X KB / Y MB limit (Z% used)

**Large Dependencies**:
1. [package-name]: X KB
2. [package-name]: X KB

**Recommendations**:
- Remove [package] (unused in production)
- Replace [package] with [lighter alternative]
- Use dynamic imports for [feature]

Phase 3: Caching Analysis

Analyze Cache API usage and opportunities:

  1. Check for Cache API usage:
grep -r "caches.open" src/
grep -r "cache.match" src/
grep -r "cache.put" src/
  1. Identify cacheable endpoints:

    • Look for GET routes
    • Check for static responses
    • Find repeated external API calls
  2. Check cache headers:

grep -r "Cache-Control" src/
grep -r "max-age" src/

Read the full file on GitHub · 455 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 455 lines · 29 tokens per session scan A c317b3cba1f5

Subscribe to this mod's changes

cloudflare-workers:optimize is a command published in the GitHub repository secondsky/claude-skills (214 stars, last pushed yesterday), licensed MIT. It adds 29 tokens to every session and 2,793 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.