optimize

A performance-review command for websites and web applications. It measures loading, responsiveness, layout movement, code size, images, fonts, and third-party scripts against stated limits.

In plain words
What is it for?
Use it to review Core Web Vitals—standard measures of loading speed, interaction delay, and visual stability—then find opportunities to reduce JavaScript, CSS, image, font, and script costs.
Why use it?
It replaces guesses about slowness with measurements and points to common sources of slow loads, delayed interactions, and shifting page layouts.

Command

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/dragoon0x/canon/optimize
Clone the repo
git clone --depth 1 https://github.com/Dragoon0x/canon
Per session 22 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 523 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.00022 $0.00523
Opus 5 $0.00011 $0.00262
Sonnet 5 $0.00004 $0.00105
Haiku 4.5 $0.00002 $0.00052

Measured 2d ago against content hash 4b229f2830a5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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 2d ago.

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.

source/commands/optimize.md · 45 lines

What it actually says

/optimize

Measure, then cut. Not vibes-based "it feels slow" — concrete targets from canon-performance.

Targets (Core Web Vitals, "Good" thresholds)

  • LCP: ≤ 2.5s
  • INP: ≤ 200ms
  • CLS: ≤ 0.1
  • TTFB: ≤ 800ms

Budgets

  • Initial JS (parsed+compiled): ≤ 200KB gzipped for most apps, ≤ 350KB for complex.
  • CSS: ≤ 60KB gzipped.
  • Hero/LCP image: ≤ 200KB, served at correct dimensions, fetchpriority="high", no lazy.
  • Total page weight (first load): ≤ 1.5MB.

Checklist

  1. LCP image: identified, preloaded, fetchpriority="high", not loading="lazy", served at rendered size.
  2. Fonts: font-display: swap, 1–2 families max, subset if possible, preload the critical weight.
  3. CLS: width and height attributes on every <img>, reserved space for ads and embeds, no layout-shifting web fonts without proper fallbacks.
  4. JS: code-split by route, lazy-load below-the-fold interactive components, tree-shake dead imports, replace heavy libs (moment → date-fns, lodash-full → per-function).
  5. Third parties: audit. Every third-party script pays rent or leaves.
  6. Images: modern formats (AVIF with WebP fallback), srcset for responsive, no raw PNG/JPG where a vector works.
  7. Caching: long cache for hashed assets, short/no cache for HTML, service worker only if you own the consequences.
  8. INP: keep long tasks ≤ 50ms, debounce input handlers, defer non-critical work with requestIdleCallback or scheduler.postTask.

Output

  • Current vs target table for each metric.
  • Top 5 interventions ranked by impact.
  • Before/after bundle report if applicable.
  • Specific code changes, not "consider optimizing".

Success criteria

Hits all four CWV "Good" thresholds on a median mobile device over 4G. Bundle under budget. No single task over 50ms on the critical path.

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. 2d ago First seen · 45 lines · 22 tokens per session scan A 4b229f2830a5

Subscribe to this mod's changes

optimize is a command published in the GitHub repository Dragoon0x/canon (5 stars, last pushed 4mo ago), licensed MIT. It adds 22 tokens to every session and 523 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-08-31.