performance-optimization
Audits and optimizes web application performance across frontend rendering, bundle sizing, network waterfall, database queries, and memory footprints. Use when investigating slow pages, high latency, or poor Web Vitals.
1How It Works & Mechanism
Full-stack performance profiling covering Core Web Vitals, memory leaks, and query latency.
Measure before optimizing. Performance work without measurement is guessing — and guessing leads to premature optimization that adds complexity without improving what matters. Profile first, identify the actual bottleneck, fix it, measure again.
Bundle analysis identifying tree-shaking failures, duplicate dependencies, and bloated modules.
- **Synthetic (Lighthouse, DevTools Performance tab):** Controlled conditions, reproducible. … - **RUM (web-vitals library, CrUX):** Real user data in real conditions.
Critical rendering path optimization (CSS containment, font loading, layout shift prevention).
What is slow? … First page load … Large bundle? --> Measure bundle size, check code splitting … Slow server response? --> Measure TTFB in DevTools Network waterfall
Database query plan audit detecting N+1 queries and missing composite indices.
- **N+1 queries.** One query per row is the most common backend bottleneck. Fetch the relation in the same query (join/include) instead of in the loop.
明确连接池耗尽排查原则与容量上限:单进程连接池须保证实例数乘最大连接数不超出数据库承载上限,禁止用无脑调大连接池掩盖连接泄漏。
- **Connection pool exhaustion.** Signature: *every* endpoint slows at once, time is spent waiting for a connection rather than executing, and the database shows mostly idle sessions.
构建严谨的缓存设计与防击穿防穿透纪律:要求显式指定失效策略、缓存键必须包含所有影响响应的输入(租户/语言/权限),并加设并发合并或陈旧响应守卫。
- **Missing caching.** Cache what is expensive to produce and read far more often than it changes … Every input that changes the response belongs in the key … Guard hot keys against the stampede
前端深度优化图片与资源加载:给所有图片显式标注宽高消除 CLS,LCP 图片配置高优先级加载与多分辨率响应式格式,非首屏图片懒加载。
- **Missing image optimization.** Every image declares `width` and `height` (CLS). The LCP image gets `fetchpriority="high"`, modern formats (AVIF, WebP) through `<picture>`
实行绝对严苛的验证裁决法则:复测必须采用与基线完全一致的环境与命令,收益在波动噪声内(中性结果)必须强制回滚,杜绝积累无效复杂度。
**"Neutral" is a revert, not a keep.** This is the step teams skip: the change is already written, throwing it away feels wasteful, so it lands unmeasured, and the codebase accretes complexity that never bought anything.
2Core Capabilities
4Recommended Governance & Evidence
5Second-Pass Verification
- [ok] 自身目录无自带可执行脚本与外发网络调用 — 经检查,skills/performance-optimization/ 下仅有 SKILL.md 与 references/optimization-patterns.md,全量扫描无网络请求、无凭证读取、无自带 .sh/.js 脚本。
- [ok] CI 命令仅为工程建议与示例,非 skill 自身打包执行 — 扫描命中的 npx bundlesize 与 npx --package=@lhci/cli lhci autorun 处于 Step 5 Enforce in CI 代码块中,属于推荐用户在工程 CI 流水线中集成的配置示例,skill 自身不带执行钩子。
- [ok] Core Web Vitals 规范阈值定义真实准确 — SKILL.md 中明确给出 LCP (≤2.5s)、INP (≤200ms)、CLS (≤0.1) 的 Good 级别标准,与 Google 官方 CWV 规范完全一致。
- [ok] optimization-patterns.md 完整涵盖声明的 6 种优化反模式 — references/optimization-patterns.md 包含 N+1 Queries、Unbounded Data Fetching、Queries That Ignore Their Index、Connection Pool Exhaustion、Missing Image Optimization、Unnecessary Re-renders、Large Bundle Size、Missing Caching 等全部对应模式与代码实现。
- [ok] 验证与回滚纪律(Keep or Revert 矩阵)有据可循 — SKILL.md Step 4 明确提供 Result vs. baseline 裁决矩阵以及 Neutral is a revert 原则,并要求建立实验台账。
6Verdict & Scenarios
Preview this skill in an interactive chat playground. Generic LLM evaluation trial.
💬 Open Chat Trial (Preview)