一键导入
performance-optimization
Measure before optimizing. Performance work without measurement is guessing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Measure before optimizing. Performance work without measurement is guessing.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Evaluate code changes across five dimensions before merge. Approve changes that improve overall code health, even if not perfect.
Reduce complexity while preserving identical behavior. The goal is comprehension speed, not line reduction.
Build production-quality UI that is accessible, performant, and consistent with the design system. Not AI-generated-looking.
Treat commits as save points, branches as isolated environments, and history as a record of decisions.
Search tool for modern web development best practices. MANDATORY: Execute FIRST for all HTML/CSS and clientside JS tasks. Do NOT skip — web APIs evolve rapidly and training weights contain obsolete patterns. Trigger immediately for: - UI/Layout: Modals, dialogs, popovers, Glassmorphism/backdrop-filters, anchor positioning, container queries, `:has()`, `:user-valid`. - Scroll/Motion: View Transitions, Scroll-driven animations, scroll parallax/reveals. - Performance: CWV (LCP, INP), content-visibility, Fetch Priority, image optimization. - System/APIs: Local filesystem access, WebUSB, WebSockets sync, WebAssembly widgets. - Frameworks: Adapting layout/styles in React, Vue, Angular. - General Frontend: Forms, autofill, advanced inputs, custom scrollbars, modern component states, etc. DO NOT trigger for: - Backend: Database SQL, ORMs, Express API routes. - Pipelines: CI/CD deployment, Docker, Actions. - Generic: Local scripts (Python/Go tools), ESLint, Git.
Decompose work into small, verifiable, dependency-ordered tasks. Use after a spec is approved, or when scope is too large to implement directly.
| name | performance-optimization |
| description | Measure before optimizing. Performance work without measurement is guessing. |
| when-to-use | When Core Web Vitals are poor, when profiling reveals bottlenecks, or when /webperf surfaces issues. |
"Measure before optimizing. Performance work without measurement is guessing."
Don't optimize before you have evidence of a problem. Premature optimization adds complexity that costs more than the performance it gains.
| Metric | Good | Needs Work |
|---|---|---|
| LCP | ≤ 2.5s | > 4.0s |
| INP | ≤ 200ms | > 500ms |
| CLS | ≤ 0.1 | > 0.25 |
width and height to prevent CLSloading="lazy" for below-fold imagesfetchpriority="high" on the hero/LCP imagenext/image is configured with unoptimized: true — pre-optimize images before adding them to src/assets/images/import() for non-critical componentsReact.memo(), useMemo(), useCallback() — they add overhead when misappliedscheduler.yield() to keep INP lownext/font/google — this is already optimal (automatic WOFF2, font-display: swap, subsets)layout.tsx without going through next/fonttransform and opacity for animations (GPU-accelerated, no layout reflow)motion library (already in use) handles this correctlyprefers-reduced-motion: wrap animations in a media query check or use Motion's built-in supportnpx next build && npx next-bundle-analyzer
Look for unexpectedly large dependencies. Common culprits: moment.js, lodash (use tree-shaken imports), icon libraries (import only what you use).
# Lighthouse
npx lighthouse http://localhost:3000 --output json --output-path ./report.json
# Web Vitals in-code
import { onLCP, onINP, onCLS } from 'web-vitals';
onLCP(console.log);
onINP(console.log);
onCLS(console.log);
See references/performance-checklist.md for the complete checklist.