- Add a new snippet
- Improve an existing snippet or its documentation
- Fix a bug
- Improve workflows and decision trees for Agent Skills
git clone https://github.com/nucliweb/webperf-snippets.git
cd webperf-snippets
npm install
npx next devAdd the snippet to the appropriate category under snippets/:
snippets/
βββ CoreWebVitals/ # LCP, CLS, INP metrics
βββ Loading/ # TTFB, FCP, scripts, fonts, images, hints
βββ Interaction/ # Long tasks, animation frames, scroll
βββ Media/ # Images, videos, SVGs
βββ Resources/ # Network bandwidth, connection quality
Use kebab-case for the filename (e.g., My-New-Snippet.js).
Each snippet must return a structured object so Agent Skills can consume its output:
// ... snippet logic ...
return {
script: "My-New-Snippet",
status: "ok", // "ok" | "error"
count: results.length,
details: { /* structured data */ },
items: results,
};Add a corresponding .mdx file in pages/<Category>/My-New-Snippet.mdx:
import snippet from '../../snippets/<Category>/My-New-Snippet.js?raw'
import { Snippet } from '../../components/Snippet'
# My New Snippet
Brief description of what it measures and why it matters.
<Snippet snippet={snippet} />
## Results
Explain what the output means.
## Further reading
- [Relevant web.dev article](https://web.dev/...)Use the copy prop in code blocks to enable easy copying to DevTools:
```js copy
// example usage
```Add an entry to pages/<Category>/_meta.json:
{
"My-New-Snippet": {
"title": "My New Snippet"
}
}Preserve the existing order and group related snippets together.
npm run generate-skillsThis reads all snippets and their MDX documentation and rebuilds the skills in /skills/ and /.claude/skills/.
Never edit generated files directly. Always modify source files in
/snippets/and regenerate.
npm run lint
npm run buildSkills include intelligent workflows that chain snippets automatically. To add or improve them, edit the WORKFLOWS.md file in the relevant category:
snippets/Loading/WORKFLOWS.md
snippets/CoreWebVitals/WORKFLOWS.md
snippets/Interaction/WORKFLOWS.md
Structure:
## Common Workflows
### Workflow Name
When the user asks about [scenario]:
1. **Snippet1.js** - Brief description
2. **Snippet2.js** - Brief description
## Decision Tree
### After Snippet1.js
- **If metric > threshold** β Run **Snippet2.js**
- **If metric is good** β Run **Snippet3.js**See snippets/Loading/WORKFLOWS.md for a complete reference.
- Snippet file added under
snippets/<Category>/ - MDX documentation page created under
pages/<Category>/ - Entry added to
pages/<Category>/_meta.json -
npm run generate-skillsrun and output committed -
npm run lintpasses with no errors -
npm run buildsucceeds
- File names: kebab-case (
My-New-Snippet.js) - English for all code, variable names, and comments
- No external dependencies in snippets β they run in browser consoles
console.logis fine; snippets are diagnostic tools