feat: add webperf-core-web-vitals skill#1198
feat: add webperf-core-web-vitals skill#1198nucliweb wants to merge 10 commits intoChromeDevTools:mainfrom
Conversation
Design decision: agent-first scriptsThe scripts have been rewritten to be agent-first: all This reduced the total script code from ~1481 lines to ~623 lines. What was kept: element highlighting via Open question for reviewers: is the visual highlighting worth keeping, or should the scripts be pure data with zero side effects? Arguments either way:
|
Runs the skill in an isolated subagent so the main context only sees the final analysis result, not the intermediate script execution calls.
|
Added Tip via @lydiahallie. |
Scripts: - fix(LCP-Video-Candidate): apply activationStart correction to LCP value (bfcache navigations returned inflated values without this) - fix(LCP): use getComputedStyle for background image detection (inline style check missed CSS-driven backgrounds) - fix(CLS): add message field to synchronous return so agent knows to call getCLS() - fix(INP): remove misleading rating:"good" from no-interactions error case; preserve getDataFn so agent can retry after user interacts - feat(LCP, LCP-Sub-Parts, LCP-Trail): add window.__cwvHighlight flag to allow disabling visual element outlines without changing scripts Documentation: - docs(schema): document getINPDetails() with return schema and example - docs(schema): add INP error case (no interactions) to schema examples - docs(SKILL): add Error Recovery section with per-script guidance - docs(SKILL): add cross-skill fork note — cross-skill triggers are recommendations to report, not direct calls from the forked subagent - docs(SKILL): add Visual Highlighting section documenting __cwvHighlight - docs(SKILL): prefix cross-skill script references with skill name - docs(SKILL): document getINPDetails() step in INP debugging workflow
Review fixes — based on Anthropic skill-creator recommendationsThis commit applies improvements recommended by Anthropic's skill-creator after a full review of the skill scripts and documentation. Bug fixes
New feature:
|
Motivation
Addresses the non-deterministic performance measurement problem raised in #1114. Instead of letting the LLM generate measurement code on the fly, this skill uses curated, deterministic JavaScript snippets from nucliweb/webperf-snippets executed via
evaluate_script.Benefits:
What's included
SKILL.mdDescribes the complete skill with:
webperf-loading,webperf-interaction,webperf-mediaScripts (7 total)
Core CWV metrics:
LCP.js— Measures LCP, highlights element, returns structured JSON synchronouslyCLS.js— Measures CLS from buffered entries, exposesgetCLS()for ongoing trackingINP.js— Tracking script; returns{ status: "tracking" }, thengetINP()after user interactionLCP diagnostics:
LCP-Sub-Parts.js— Breaks down LCP into TTFB / Resource Load Delay / Resource Load Time / Element Render DelayLCP-Trail.js— Tracks all LCP candidate elements during load with color-coded outlinesLCP-Image-Entropy.js— Detects low-entropy images ineligible for LCP (Chrome 112+)LCP-Video-Candidate.js— Audits video LCP: poster presence, preload,fetchpriority, formatReferences
references/snippets.md— Human-readable descriptions and thresholds for each scriptreferences/schema.md— Structured JSON return schema for agent consumptionScript source and minification
Scripts are sourced from
nucliweb/webperf-snippets— specifically from the/snippets/CoreWebVitals/directory, which is the readable source.The
skills/directory in that repo contains Terser-minified build output (generated viascripts/generate-skills.js). The upstream rationale for minification is token optimization: smaller scripts mean fewer tokens consumed when the skill is loaded into context.For this MCP integration, we're using the unminified source for maintainability and reviewability. If token optimization becomes a concern, minification can be added as a build step later.
INP interaction workflow
INP requires real user interactions to measure. When
INP.jsreturns{ status: "tracking" }, the skill instructs the agent to:getINP()to collect resultsThe agent cannot simulate interactions on behalf of the user for this metric.
Relationship to existing
debug-optimize-lcpskillThe existing skill is a workflow guide that orchestrates MCP tools (trace recording, performance insights). This skill is script-based — it executes curated snippets and returns structured JSON. They are complementary: use
debug-optimize-lcpfor trace-based LCP analysis,webperf-core-web-vitalsfor script-based CWV measurement.Decision: no
!command`` injection in SKILL.mdClaude Code supports embedding shell commands in
SKILL.mdusing the!command`` syntax — the output is injected inline when the skill loads, so the agent receives the content without needing aReadtool call (reference).This was considered for injecting script contents directly into the prompt (e.g.
!`cat scripts/LCP.js`), which would eliminate the file-read step during execution. However, this feature is Claude Code-specific: other agents (Cursor, Windsurf, generic MCP clients) would receive the literal command string instead of its output, breaking the skill entirely.Since these skills target any MCP-compatible agent, we keep scripts as separate files read on demand. Cross-agent compatibility takes priority over saving a tool call.
Next skills
This is the first in the webperf skills series. Planned follow-ups (tracked in issue #1114):
webperf-loading(28 scripts: TTFB, FCP, render-blocking, fonts, resource hints…)webperf-interaction(8 scripts: INP deep-dive, Long Animation Frames, scroll jank…)webperf-media(3 scripts: image audit, video audit, SVG bitmap detection)webperf-resources(1 script: network bandwidth / connection quality)webperf(meta-skill)