agentleFS
LeonxLJXLeonxLJX/web-engineer-skills/skills/performance-budget/SKILL.md

performance-budget

Skill0 starsChanged 2 months agoMITView on GitHub

Set and enforce Core Web Vitals budgets, then hit them — LCP/CLS/INP diagnosis, bundle dieting, image strategy, and the profiling workflow that finds the real bottleneck. Use when a page is slow, before a release, or when adding any dependency.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write the numbers into CI.

    line 10
  2. Distinctive:

    If LCP data comes from an API, stream the shell and suspend only below the fold.

    line 31
  3. Very specific:

    No content injected above existing content (banners, cookie bars animate in transform, never push).

    line 36
  4. Distinctive:

    Every new dependency must state: size gzipped, what it replaces, why built-in/one-liner isn't enough.

    line 55

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Performance budgets that mean something

Budget first, build second

Write the numbers into CI; a budget that isn't enforced is a wish:

MetricBudgetWhy
LCP≤ 2.5s (p75)users judge speed by it
CLS≤ 0.1layout shift = rage clicks
INP≤ 200msresponsiveness
JS (initial route)≤ 170KB gzip~3G mid-tier phone parse time

bundlesize/size-limit in CI fails the PR, not the quarter.

Diagnose before optimizing

  1. Lab: Lighthouse on throttled "Slow 4G / mid-tier mobile" — not your dev machine.
  2. Field: real-user data (web-vitals lib → your analytics) — lab lies, p75 users don't.
  3. Trace the specific slow metric (Performance panel), don't shotgun "optimizations".

LCP

  • The LCP element is usually the hero image or headline. Server-render it; fetchpriority="high" / priority on the image.
  • Kill render-blocking chains: critical CSS inline, defer the rest; no sync third-party scripts in <head>.
  • If LCP data comes from an API, stream the shell and suspend only below the fold.

CLS

  • Reserve space: explicit width/height (or aspect-ratio) on images/iframes/embeds.
  • No content injected above existing content (banners, cookie bars animate in transform, never push).
  • Web fonts: font-display: swap with metric-matched fallbacks (size-adjust) to avoid swap shift.

INP

  • Long tasks > 50ms: split with scheduler.yield() / setTimeout; move heavy work to a Worker.
  • Event handlers do the minimum and update UI optimistically; heavy validation debounced.
  • Hydration giants (big trees going interactive) are an INP factory — shrink the client island instead.

Bundle diet (the repeatable one)

  1. Analyze: webpack-bundle-analyzer / rollup-plugin-visualizer.
  2. Duplicates: npm ls for doubled deps; dedupe lockfile.
  3. Date (dayjs/date-fns over moment), icons (per-icon ESM), lodash (named imports).
  4. Dynamic-import the heavy tail: editors, charts, maps, xlsx.
  5. Tree-shake blockers: side-effectful barrel files — import from module paths.

Dependency rule

Every new dependency must state: size gzipped, what it replaces, why built-in/one-liner isn't enough. A 2KB problem doesn't deserve a 40KB solution.

Definition of done (agent checklist)

  • CI budget check green on changed routes
  • LCP element identified and optimized (priority/fetchpriority)
  • All media has reserved space (CLS)
  • No sync third-party in head
  • New deps justified with size + replacement note

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.