Agent Skillstheopenco/llmgateway › core-web-vitals

core-web-vitals

GitHub

针对 Next.js App Router 前端,诊断并优化 LCP、INP 和 CLS 等 Core Web Vitals 指标。通过测量基线、分析性能瓶颈(如资源加载、交互延迟、布局偏移),提供基于证据的具体修复建议,提升页面加载速度与用户体验。

.agents/skills/core-web-vitals/SKILL.md theopenco/llmgateway

Trigger Scenarios

审计 Core Web Vitals 性能 调查 LCP、INP 或 CLS 回归问题 优化前端加载、响应速度、图片、字体或布局行为

Install

npx skills add theopenco/llmgateway --skill core-web-vitals -g -y
More Options

Non-standard path

npx skills add https://github.com/theopenco/llmgateway/tree/main/.agents/skills/core-web-vitals -g -y

Use without installing

npx skills use theopenco/llmgateway@core-web-vitals

指定 Agent (Claude Code)

npx skills add theopenco/llmgateway --skill core-web-vitals -a claude-code -g -y

安装 repo 全部 skill

npx skills add theopenco/llmgateway --all -g -y

预览 repo 内 skill

npx skills add theopenco/llmgateway --list

SKILL.md

Frontmatter
{
    "name": "core-web-vitals",
    "description": "Diagnose and improve Largest Contentful Paint, Interaction to Next Paint, and Cumulative Layout Shift in this repository's Next.js App Router frontends. Use when auditing Core Web Vitals, investigating LCP, INP, or CLS regressions, or changing frontend loading, responsiveness, image, font, or layout behavior for performance."
}

Core Web Vitals

Measure the affected route before changing it. Do not apply generic performance advice without identifying the actual LCP element, slow interaction, or layout shift.

Targets and evidence

Use Google's current thresholds at the 75th percentile:

Metric Good Poor
LCP ≤ 2.5 s > 4 s
INP ≤ 200 ms > 500 ms
CLS ≤ 0.1 > 0.25

Field data and lab data answer different questions. Check CrUX or PageSpeed Insights for user impact, then reproduce locally with Chrome DevTools or a repeatable browser trace. Lighthouse reports LCP and CLS, but cannot measure INP without real interaction; use its Total Blocking Time only as a lab proxy.

Official references:

Diagnose

  1. Identify the affected app and route. Read its page, layout, loading boundary, client components, data queries, images, fonts, and third-party scripts.
  2. Record a baseline on a production build with the same viewport, throttling, cache state, and interaction sequence used for the final comparison.
  3. Use the trace to identify the cause:
    • LCP: server delay, resource discovery, resource load, or render delay.
    • INP: input delay, event-handler work, or presentation delay.
    • CLS: the shifting element and the element that changed its geometry.
  4. Change the smallest cause supported by the trace.

Repository-specific fixes

These apps use Next.js 16 App Router. Prefer Server Components and existing TanStack Query patterns over client-side useEffect fetching.

For LCP:

  • Keep above-the-fold content in the initial server-rendered response when possible. Use a nearby loading boundary only when streaming improves the observed route.
  • Use next/image with correct width and height, or fill with a sized parent and an accurate sizes value.
  • Next.js 16 deprecates the Image priority prop; use preload only for the measured LCP image. Do not preload multiple competing images.
  • Remove request waterfalls and late client-only discovery shown in the trace.

For INP:

  • Trace the exact slow click, keypress, or tap. Reduce synchronous work in that path and avoid rerendering unrelated subtrees.
  • Provide immediate visual feedback, then defer only work that is not required for the next paint.
  • Virtualize or paginate large rendered collections when the trace shows DOM or reconciliation cost. Do not add memoization without a measured benefit.

For CLS:

  • Reserve dimensions for images, video, embeds, skeletons, banners, and async content before they load.
  • Keep loading and loaded states geometrically compatible.
  • Animate transform and opacity when possible instead of layout dimensions.
  • Inspect font fallback metrics before changing font-display; a blanket value is not a CLS fix.

Verify

Build the affected app through Turbo, run the same trace again, and compare the before/after measurements. Test relevant responsive breakpoints and both themes when layout or assets differ.

Run pnpm format and the full pnpm build before handoff. Report the measured baseline, the measured result, the route and conditions, and any field-data gap that cannot be validated locally.

Version History

  • 8fdff5b Current 2026-08-16 07:59

    重构为结构化工作流:明确目标与证据标准,细化诊断步骤(识别路由、记录基线、追踪原因),新增针对 Next.js 16 App Router 的特定修复指南(Server Components、TanStack Query、Image 组件最佳实践)。

  • 8c03315 2026-07-24 16:53

Same Skill Collection

.agents/skills/add-model/SKILL.md
.agents/skills/blog/SKILL.md
.agents/skills/changelog/SKILL.md
.agents/skills/knowledge-base/SKILL.md
.agents/skills/migrations/SKILL.md
.agents/skills/pull-request/SKILL.md
.agents/skills/skill-authoring/SKILL.md
.agents/skills/verify/SKILL.md
.claude/skills/verify/SKILL.md

Metadata

Files
0
Version
8fdff5b
Hash
9c69c238
Indexed
2026-07-24 16:53

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 19:44
浙ICP备14020137号-1 $mapa de visitantes$