WebPerf Snippets Tested JavaScript snippets that measure and debug web performance. Your AI agent runs them for you, or you run them yourself in DevTools: the same code every time. AI agents are good at interpreting performance data and unreliable when they write measurement code on the fly. WebPerf Snippets keeps both apart: the measurement is fixed code, tested in CI, that returns structured data, and the agent…
Tested JavaScript snippets that measure and debug web performance. Your AI agent runs them for you, or you run them yourself in DevTools: the same code every time.
Tested JavaScript snippets that measure and debug web performance. Your AI agent runs them for you, or you run them yourself in DevTools: the same code every time.
AI agents are good at interpreting performance data and unreliable when they write measurement code on the fly. WebPerf Snippets keeps both apart: the measurement is fixed code, tested in CI, that returns structured data, and the agent reasons about the result. The same snippets run in the console, the CLI, the DevTools extension and the Agent Skills, and every one returns an object that follows a single contract (snippets/SCHEMA.md).
Snippet pages have a Copy prompt to measure button above the code. It copies a prompt that asks any AI agent with a terminal to run that snippet with the CLI on the URL you give it, and to report the value, the cause and the issues. The agent runs the published snippet instead of rewriting it or estimating the result.
MCP server
The CLI includes an MCP server: an agent in any MCP client (Claude Code, Cursor, VS Code, Gemini CLI) calls the snippets and the workflows as tools, on a headless Chromium, and reads the object each one returns. It is listed in the MCP Registry as io.github.nucliweb/webperf-snippets.
claude mcp add webperf -- npx -y webperf-snippets mcp
In Claude Code, the webperf plugin installs the same server:
See the MCP server documentation for other clients, the tools, the resources and prompts, and the CrUX key.
Agent skills
The snippets are packaged as Agent Skills for Claude Code, Cursor, OpenCode, Gemini CLI, VS Code extensions and other compatible agents. With Chrome DevTools MCP, the agent runs the snippets in your browser and reads the object they return.
npx skills add nucliweb/webperf-snippets
This installs the skills from the GitHub repository into ~/.claude/skills/. To install them from a clone instead:
git clone https://github.com/nucliweb/webperf-snippets.git
cd webperf-snippets
npm run install-skills # into .claude/skills/ of the current project
npm run install-global # into ~/.claude/skills/, for every project
The skills pass each script to Chrome DevTools MCP by path, and the server only reads files inside its workspace roots. For skills outside the project, such as in ~/.claude/skills/, add --workspace to the arguments of the server, with the real folder of the skills and not a symlink to it:
Without it the skills still work: the server answers Access denied and the agent sends the code of the script instead, at the cost of one failed call in each session.
Skill
Snippets
What it covers
webperf
57
Main entry point for all web performance analysis
webperf-core-web-vitals
7
LCP, CLS, INP measurements with detailed breakdowns
webperf-loading
35
TTFB, FCP, script and font analysis, resource hints, service workers
webperf-interaction
10
Long tasks, animation frames, scroll jank, INP debugging
webperf-media
4
Image and video audits, lazy loading validation, SVG analysis
The skills include workflows (predefined sequences, such as a complete loading audit or a font loading investigation) and decision trees that pick the next snippet from the result of the previous one: when TTFB is above 600 ms, the agent runs TTFB-Sub-Parts to find whether the time goes to DNS, the connection or the server.
User: "Analyze loading performance"
Agent:
1. Runs TTFB.js → 1.9 s (poor)
2. Follows the decision tree → runs TTFB-Sub-Parts.js
3. Finds that the server response takes most of the time
4. Runs Service-Worker-Analysis.js
5. Reports the findings with specific fixes
Skills activate when the request matches them:
Audit this page for Core Web Vitals
Debug slow LCP
Why is my TTFB so high?
Check for image optimization issues
See SKILLS.md for every skill, its workflows and its triggers.
The CLI runs the same snippets headlessly with Playwright. It diagnoses LCP regressions in CI, gates pull requests on performance budgets and automates the audits you run by hand. The --json output is what an agent or a script reads.
The core-web-vitals, audit, loading and interaction workflows chain several snippets in one run. A composite GitHub Action (nucliweb/webperf-snippets/.github/actions/webperf-snippets) wraps the CLI for CI, with budgets and a Markdown output ready to post as a pull request comment.
Every snippet also runs by hand in the DevTools console, with the same code the agents use. All snippets are tested in Google Chrome; most also work in other Chromium-based browsers and in Firefox, and Safari has limited Performance API support. Each snippet page shows the browser support of the APIs it needs.
Open DevTools (F12 or Cmd+Option+I / Ctrl+Shift+I)
Go to the Console tab
Paste and press Enter
Save as a DevTools snippet
Open DevTools → Sources tab → Snippets panel
Click + New snippet
Name it (e.g., “LCP”)
Paste the code
Right-click → Run (or Cmd+Enter / Ctrl+Enter)
DevTools extension (beta)
A DevTools panel runs the snippets on the inspected page without pasting them, shows their results, and audits the page with the checks of the CLI. It installs from the Chrome Web Store.
评论