webperf-snippets
CLAUDE.md1.5k starsChanged 8 months agoMITView on GitHub
WebPerf Snippets is a curated collection of web performance measurement JavaScript snippets for the browser console and Chrome DevTools. The repository is a documentation site (Next.js + Nextra) plus the tooling that packages the same snippets as Agent Skills, a CLI and llms.txt files. The snippet source files in snippets/ are the single source of truth. Documentation pages, skills, the CLI and llms-full.txt are all derived from them.
We split this CLAUDE.md into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 81
Every snippet is an IIFE that returns a structured object with script, status (ok, tracking, error, unsupported) and the metric data.
- Very specific: line 85
After changing a snippet: npm run generate-skills and node scripts/generate-llms.js, and commit the regenerated files.
- Very specific: line 92
Create content/<Category>/<Name>.mdx (kebab-case or the existing naming of the category) and import the snippet with import snippet from …
- Very specific: line 95
If a page is renamed, add a redirect in next.config.mjs.
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project overview
WebPerf Snippets is a curated collection of web performance measurement JavaScript snippets for the browser console and Chrome DevTools. The repository is a documentation site (Next.js + Nextra) plus the tooling that packages the same snippets as Agent Skills, a CLI and llms.txt files.
The snippet source files in snippets/ are the single source of truth. Documentation pages, skills, the CLI and llms-full.txt are all derived from them.
Technology stack
- Site: Next.js 16 App Router with Nextra 4 (
nextra-theme-docs) and React 19, deployed on Vercel. Search is Pagefind, built afternext build - Media: Cloudinary URLs (
res.cloudinary.com/nucliweb), with no SDK - Analytics: Google Analytics
- CLI (
cli/, npm workspacewebperf-snippets): Playwright runner for the snippets, tested with Vitest
Repository layout
content/ MDX pages, file-system routing, one _meta.js per directory
app/ Root layout, the [[...mdxPath]] page that renders the MDX, sitemap and robots
mdx-components.js MDX components of the theme, with the external link label
CoreWebVitals/ Loading/ Interaction/ Media/ Resources/ DevTools-Overrides/
index.mdx, which-snippet.mdx, CLI.mdx, visualizer.mdx
snippets/ The snippet sources (*.js), same categories as content/
SCHEMA.md Return-value contract every snippet must follow
_shared/ Helpers marked with `// @shared`
_view/ The view of a result (labels, formats, order) for the extension, the CLI and the site
components/ Snippet (code block), Callout, Icon, Demo, SnippetVisualizer, diagrams/
components/diagrams/ Own SVG diagrams (Flow, Sequence, custom), styled with --dg-* tokens
lib/ remark/rehype plugins: browser support, icons, emoji stripping
styles/globals.css Global styles, including the --dg-* tokens and .wp-support*
public/demos/ Interactive HTML demos; see public/demos/README.md for the contract
skills/, dist/, .claude/skills/ Generated Agent Skills (do not edit by hand)
public/llms.txt, public/llms-full.txt Generated
public/<page>.md Markdown version of each page, generated before the build and not committed (lib/page-markdown.mjs)
cli/ Playwright CLI, workflows, e2e tests and fixtures
extension/ Chrome DevTools panel that runs the snippets (MV3, loaded unpacked)
.claude-plugin/ Marketplace of Claude Code, with the plugins of plugins/
plugins/webperf/ Claude Code plugin with the MCP server of the CLI (npx -y webperf-snippets@1 mcp)
scripts/ Generators, checks and their tests
workspace/ Local notes, ignored by gitCommands
npm run dev # development server (port 3000)
npm run build # production build (regenerates llms files first)
npm run lint # eslint
npm run generate-skills # regenerate skills/, dist/, .claude/skills/ from snippets/
npm run generate-skills:check # CI check: generation leaves no diff
npm run test:skills # every skill script keeps the result objects of its snippet
node scripts/generate-llms.js # regenerate public/llms*.txt
npm run check:consistency # shared helpers must carry the `// @shared` marker
npm run check:emoji # no emoji left in rendered text where an icon exists
npm run test:demos # demo contract
npm run test:site # sitemap routes, _meta reader, built snippets check
npm run check:built-snippets # after `npm run build`: every page shows its snippets as in the source
npm run test:icons # emoji to icon plugins
npm run test:support # browser support plugin
npm run test:prompt # agent prompt of each snippet (lib/snippet-prompt.mjs)
npm run extension:build # extension/snippets.json, then load extension/ unpacked in chrome://extensions
npm run test:view # view of the results (snippets/_view/), on the fixtures of every snippet
npm run view:fixtures # regenerate scripts/fixtures/results/ after changing what a snippet returns
npm run test:extension # DevTools extension: runner, result rendering, catalog
npm run test:extension:e2e # every snippet through the real panel, on the seeded page of the CLI tests
npm run eval:prompts # an agent runs the prompts on local pages, graded from its transcript (eval-prompts.yml: on demand and on PRs that change the prompt)
npm run test:unit --prefix cli
npm run smoke:cli-package # before a CLI release: the packed CLI installed in an empty folder, npm audit of that tree and its MCP server
npm run test:e2e --prefix cli # Playwright against local fixtures (cli/tests/fixtures)CI (.github/workflows/ci.yml) runs lint, build, all the checks above except eval:prompts, generate-skills:check and the CLI unit and e2e tests. The pre-commit hook (.githooks/pre-commit) runs check:consistency, check:emoji and lint.
Snippets
- Every snippet is an IIFE that returns a structured object with
script,status(ok,tracking,error,unsupported) and the metric data. The contract is insnippets/SCHEMA.mdand is enforced bycli/tests/e2e/snippet-contract.test.js. - A snippet that needs a
PerformanceObserverentry type checksPerformanceObserver.supportedEntryTypesfirst and returnsstatus: "unsupported"when it is missing. - Chrome exposes some entry types only through observers (
largest-contentful-paint,layout-shift,longtask,event,first-input), so they are read with a buffered observer, notgetEntriesByType. - Helpers duplicated across snippets (
formatBytes,getRootDomain) carry a// @sharedmarker and stay identical. - After changing a snippet:
npm run generate-skillsandnode scripts/generate-llms.js, and commit the regenerated files. - Tests come first and use the e2e harness in
cli/tests/helpers/contract.jsand the fixtures incli/tests/fixtures/.
Documentation pages
CONTRIBUTING.md describes the page template step by step. In short:
- Create
content/<Category>/<Name>.mdx(kebab-case or the existing naming of the category) and import the snippet withimport snippet from '../../snippets/<Category>/<Name>.js?raw', rendered with<Snippet code={snippet} />. - Register it in the
_meta.jsof the category (export default { ... }with a literal object, whichscripts/read-meta.jsreads). - Add the
browserSupportfrontmatter and a### Browser supportsection before "Further reading". The badge and tables are generated from MDN browser-compat-data bylib/remark-browser-support.js, and the build fails if a key does not exist or the title is missing.browserSupportlists what the snippet needs to run; the optionalbrowserSupportReportedlists what it only audits. - If a page is renamed, add a redirect in
next.config.mjs.
Emojis in MDX are replaced by icons at render time (rehype plugin); the MDX source keeps the emoji.
Writing rules for pages are in "Writing documentation pages" of CONTRIBUTING.md: page template, sentence-case headings, no bold as headers, link format, callouts, timeless language.
Diagrams and demos
- Diagrams are SVG components in
components/diagrams, not Mermaid. UseFloworSequence, or a custom component, and the--dg-*tokens fromstyles/globals.css. - Demos are standalone HTML files in
public/demos, embedded with<Demo>. They share a style, an icon block (.ic) and a contract documented inpublic/demos/README.md, checked bynpm run test:demos.
Notes
devandbuildrun with--webpack: the plugins oflib/are functions, and Nextra 4 does not load them under Turbopack (its loader cannot resolve plugins given as strings). The?rawimport of the snippets is a webpack rule innext.config.mjs; Next 16 keeps its SWC rule outsideoneOf, so the rule excludessnippets/from every SWC rule, or the code reaches the page rewritten.npm run check:built-snippetsfails after a build when a page shows different code from the source.package.jsonpinszodto 4.3.6 fornextraandnextra-theme-docsonly, with nestedoverrides: Nextra 4.6.1 fails in<Layout>with 4.4.3 or later (Invalid input: expected nonoptional, checked again with 4.6.7):<Layout>validates its props withoutchildrenagainst a schema that requires it, shuding/nextra#5036. The rest of the tree, such as the MCP SDK of the CLI, gets the latestzod, which fixes GHSA-mrhx-c7xc-m3w5; Nextra only validates its own configuration with it, at build time. Review it when Nextra is upgraded.agentRules: falseinnext.config.mjsstopsnext devfrom writing a Next.js block intoCLAUDE.mdandAGENTS.md.- The code block and the demo are components of this repository, and
Calloutwraps the one of the theme (components/); their styles usewp-*classes and--wp-*tokens instyles/globals.css, never the utility classes of the theme. - The dev server does not pick up changes in
lib/; restart it after editing a plugin. - Images in MDX are Cloudinary URLs in a plain
<img>with asrcSetof transformations (content/CLI.mdx); videos usecomponents/LazyVideoPlayer.js, a native<video>that loads on click.
Trending
More talk lately.about the whole repository
Who's talking about nucliweb/webperf-snippets
- A Hacker News story“Web Performance Snippets”Hacker News · May 27, 2023 · 3 points
- @nucliweb.net“📣 New webperf-snippet to measure the click interactions on the page. …”Bluesky · May 26, 2023 · 3 likes
- A Hacker News story“Web Performance Snippets”Hacker News · May 28, 2023 · 2 points
- @nucliweb.net“📣 New webperf-snippet "Largest Contentful Paint Sub-Parts" …”Bluesky · May 24, 2023 · 1 likes
- @nucliweb.net“Get your <head> in order, a new web perf snipped, by Rick Viscomi, to use in the Chrome Dev Tools How you …”Bluesky · May 22, 2023 · 1 likes
The biggest 5 of 24 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 24
Talked about on GitHub, Bluesky and Hacker News (24 times).
On GitHub · 19
- Oct 30, 2026claude-code-marketplaces.github.nucliweb.webperf-snippets: 2.4.1 → 2.4.2 — sudosubin/agents.nix0 reactions
- Oct 30, 2026agent-skills.github.nucliweb.webperf-snippets: 2.4.0 → 2.4.1 — sudosubin/agents.nix0 reactions
- Oct 29, 2026claude-code-plugins.github.nucliweb.webperf-snippets: 2.4.0 → 2.4.1 — sudosubin/agents.nix0 reactions
- Oct 29, 2026claude-code-marketplaces.github.nucliweb.webperf-snippets: 2.4.0 → 2.4.1 — sudosubin/agents.nix0 reactions
- Oct 29, 2026claude-code-plugins.github.nucliweb.webperf-snippets: 2.3.0 → 2.4.0 — sudosubin/agents.nix0 reactions
14 more on GitHub
- Oct 29, 2026claude-code-marketplaces.github.nucliweb.webperf-snippets: 2.3.0 → 2.4.0 — sudosubin/agents.nix0 reactions
- Oct 29, 2026agent-skills.github.nucliweb.webperf-snippets: 2.3.0 → 2.4.0 — sudosubin/agents.nix0 reactions
- Oct 28, 2026claude-code-plugins.github.nucliweb.webperf-snippets: init at 2.3.0 — sudosubin/agents.nix0 reactions
- Oct 28, 2026claude-code-marketplaces.github.nucliweb.webperf-snippets: init at 2.3.0 — sudosubin/agents.nix0 reactions
- Oct 27, 2026agent-skills.github.nucliweb.webperf-snippets: 2.1.0 → 2.3.0 — sudosubin/agents.nix0 reactions
- Oct 25, 2026agent-skills.github.nucliweb.webperf-snippets: 2.0.1 → 2.1.0 — sudosubin/agents.nix0 reactions
- Oct 20, 2026[Candidate] nucliweb/webperf-snippets/skills/webperf - webperf — ProSkillsMD/proskills0 reactions · 1 comment
- Oct 20, 2026[Candidate] nucliweb/webperf-snippets/.claude/skills/webperf-core-web-vitals - webperf-core-web-vitals — ProSkillsMD/proskills0 reactions · 1 comment
- Oct 20, 2026[Candidate] nucliweb/webperf-snippets/.claude/skills/webperf - webperf — ProSkillsMD/proskills0 reactions · 1 comment
- Oct 16, 2026agent-skills.github.nucliweb.webperf-snippets: 1.3.0 → 2.0.1 — sudosubin/agents.nix0 reactions
- Oct 3, 2026agent-skills.github.nucliweb.webperf-snippets: 1.2.0 → 1.3.0 — sudosubin/agents.nix0 reactions
- Sep 30, 2026agent-skills.github.nucliweb.webperf-snippets: init at 1.2.0 — sudosubin/agents.nix0 reactions
- Apr 12, 2024Improve TTFB snippet — corewebvitals/pagespeed0 reactions
- Dec 7, 2022feat: add other author snippets — push-based/awesome-web-performance-snippets0 reactions
On Bluesky · 3
- May 26, 2023📣 New webperf-snippet to measure the click interactions on the page. https://github.com/nucliweb/webperf-snippets#interactions Thank you… — @nucliweb.net3 likes and reposts
- May 24, 2023📣 New webperf-snippet "Largest Contentful Paint Sub-Parts" https://github.com/nucliweb/webperf-snippets#largest-contentful-paint-sub-parts-… — @nucliweb.net1 likes and repost
- May 22, 2023Get your <head> in order, a new web perf snipped, by Rick Viscomi, to use in the Chrome Dev Tools How you order elements can have an effect… — @nucliweb.net1 likes and repost
On Hacker News · 2
- May 27, 2023Web Performance Snippets3 points
- May 28, 2023Web Performance Snippets2 points
In this repository14 other files it gives its agents.
- public/llms-full.txtllms.txt
- public/llms.txtllms.txt
- webperf-core-web-vitalsSkill
- webperf-interactionSkill
- webperf-loadingSkill
- webperf-mediaSkill
- webperf-resourcesSkill
- webperfSkill
- webperf-core-web-vitalsSkill
- webperf-interactionSkill
- webperf-loadingSkill
- webperf-mediaSkill
- webperf-resourcesSkill
- webperfSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

