/qa-load-testing:lighthouse-perffrom qa-load-testing
Sets up Lighthouse CI to enforce Core Web Vitals (LCP, INP, CLS) on every PR with Google's 75th percentile thresholds, per-route budgets, and PR comments.
Ships in qa-load-testing. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The Core Web Vitals are Google's three canonical user-experience metrics (web-vitals):
| Metric | Measures | "Good" threshold |
|---|---|---|
| LCP (Largest Contentful Paint) | Loading performance | ≤ 2.5 seconds |
| INP (Interaction to Next Paint) | Interactivity | ≤ 200 milliseconds |
| CLS (Cumulative Layout Shift) | Visual stability | ≤ 0.1 |
INP became a stable Core Web Vital in 2024, replacing FID (web-vitals). The canonical measurement standard is the 75th percentile of page loads, segmented across mobile and desktop (web-vitals).
INP needs a real user interaction, so a Lighthouse navigation run (what
lhci autorun does) cannot report it: the interaction-to-next-paint
audit only runs in timespan mode (lh-inp). In the lab, gate on
Total Blocking Time (TBT), which web.dev calls "a reasonable proxy metric
for INP, but it's not a substitute for INP" (inp), and track INP
itself from field data (see "Lab vs field" below).
This skill covers Lighthouse CI (@lhci/cli) - the official
Google Chrome team tool for running Lighthouse on every PR and
asserting against budgets (lhci).
non-functional-requirement-extractor)
and needs CI enforcement.If the project is a backend API or a CLI tool, this skill doesn't
apply - use k6-load-testing or a
sibling load runner for backend perf.
npm install --save-dev @lhci/cli
(Per lhci; the docs reference @lhci/[email protected] as the
current major.) Pin to a specific minor in CI for determinism.
Create .lighthouserc.js (or .lighthouserc.json) at the project
root. The canonical shape per lhci:
module.exports = {
ci: {
collect: {
// What to audit
url: [
'http://localhost:3000/',
'http://localhost:3000/dashboard',
'http://localhost:3000/pricing',
],
// How many runs per URL - median report wins; 3 is canonical for stability
numberOfRuns: 3,
// Lighthouse settings
settings: {
preset: 'desktop', // desktop apps only; omit it for the default mobile run (there is no 'mobile' preset)
chromeFlags: '--no-sandbox', // CI-runner-friendly
},
// Use a static-server when running headless in CI
startServerCommand: 'npm run start',
startServerReadyPattern: 'ready on',
},
assert: {
// Canonical Web Vitals budgets per web.dev/articles/vitals
assertions: {
'largest-contentful-paint': ['error', { maxNumericValue: 2500 }], // 2.5s
// INP is timespan-only in Lighthouse; TBT is its lab proxy.
// 200 ms = Lighthouse's mobile "fast" band; use 150 with preset: 'desktop'.
'total-blocking-time': ['error', { maxNumericValue: 200 }],
'cumulative-layout-shift': ['error', { maxNumericValue: 0.1 }], // 0.1
// Lighthouse category scores (0-1)
'categories:performance': ['warn', { minScore: 0.9 }],
'categories:accessibility': ['error', { minScore: 0.95 }],
'categories:best-practices': ['warn', { minScore: 0.9 }],
},
},
upload: {
// Where to upload the .json reports for trend analysis
target: 'temporary-public-storage', // or 'lhci' for self-hosted server
},
},
};
Assertion levels per lhci:
'error' - fails the CI run (exits non-zero).'warn' - surfaces in the report but doesn't fail.'off' - disabled (useful for opt-out per-page).The canonical invocation per lhci:
lhci autorun
autorun runs three phases in sequence:
startServerCommand set), run
Lighthouse N times per URL.error-level failures.For finer control, the phases can run independently: lhci collect,
lhci assert, lhci upload.
For a single PR-relevant audit:
lhci collect --url=http://localhost:3000/dashboard --numberOfRuns=3
lhci assert
lhci autorun only runs navigations, and the interaction-to-next-paint
audit has supportedModes: ['timespan'] (lh-inp), so an INP
assertion in lighthouserc never measures anything. To check an
interaction in CI, script it with the Lighthouse user-flow API
(lh-flows): a timespan "analyzes an arbitrary period of time,
typically containing user interactions", but it "Does not provide an
overall performance score" and has no LCP.
// perf/inp-flow.mjs - node perf/inp-flow.mjs (needs lighthouse + puppeteer)
import puppeteer from 'puppeteer';
import { startFlow } from 'lighthouse';
const BUDGET_MS = 200;
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://localhost:3000/search');
const flow = await startFlow(page);
await flow.startTimespan();
await page.type('#query', 'running shoes'); // the interaction under test
await page.waitForSelector('#results li');
await flow.endTimespan();
const { steps } = await flow.createFlowResult();
const audit = steps.at(-1).lhr.audits['interaction-to-next-paint'];
await browser.close();
if (audit.numericValue === undefined) throw new Error('no interaction was recorded');
console.log(`INP ${Math.round(audit.numericValue)} ms (budget ${BUDGET_MS})`);
if (audit.numericValue > BUDGET_MS) process.exit(1);
Keep total-blocking-time in lighthouserc as the navigation-mode
proxy (TBT is "a reasonable proxy metric for INP, but it's not a
substitute for INP", inp). The timespan covers only the scripted
interaction on one machine; the INP target itself is the 75th
percentile of real users (CrUX or your RUM, see "Lab vs field").
Score swings of 20-30 points on one commit usually come from the config and the machine, not the code:
formFactor "doesn't control emulation"; it
only sets scoring and which mobile-only audits run. So
formFactor: 'desktop' alone leaves the mobile screen emulation in
place, a mismatch Lighthouse rejects ("Screen emulation mobile setting
(true) does not match formFactor setting (desktop)"). The CLI help says
"For desktop, use --preset=desktop instead" (lh-readme);
in LHCI that is collect.settings.preset: 'desktop', which sets
formFactor, screen emulation, user agent and desktop throttling
together.throttlingMethod: 'devtools' adds the runner's noise to
every metric.numberOfRuns: 5.benchmarkIndex ("CPU/Memory
Power"). Mobile runs apply a constant 4x CPU slowdown; when the
runner's benchmarkIndex is outside the expected range, calibrate
throttling.cpuSlowdownMultiplier (lh-thr). Better still,
run on dedicated hardware: the docs recommend at least 2 dedicated
cores and say to avoid "burstable" or "shared-core" instances.largest-contentful-paint, total-blocking-time and
cumulative-layout-shift; the category score mixes them.# .github/workflows/lighthouse.yml
name: lighthouse
on:
pull_request:
paths:
- 'src/**'
- 'package.json'
- 'package-lock.json'
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- name: Build
run: npm run build
- name: Lighthouse CI
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} # optional, for PR comments
run: npx lhci autorun
- name: Upload Lighthouse reports
if: always()
uses: actions/upload-artifact@v4
with:
name: lighthouse-reports
path: .lighthouseci/
retention-days: 14
The optional LHCI_GITHUB_APP_TOKEN (set up via the Lighthouse CI
GitHub App) enables PR comments showing the per-metric delta vs. the
main branch's last green run.
Budget authoring is part of Lighthouse CI configuration: picking per-route
LCP / INP / CLS thresholds by traffic class, resource-size caps in
budget.json, the assertMatrix config shape, and how to validate a new
budget against production before committing it, are all in
references/budgets.md. Start there when the project
has no budgets yet or the existing ones need a redesign.
LCP / INP thresholds are the same across mobile and desktop, but mobile is consistently slower in practice - the same JS bundle runs on a less-powerful CPU over a less-stable network.
Common pattern: separate .lighthouserc.mobile.js and
.lighthouserc.desktop.js, run both in CI. The mobile run leaves
preset unset: Lighthouse's defaults already emulate a mobile device
with CPU and network throttling. The desktop run sets
preset: 'desktop' (the CLI's presets are perf, experimental and
desktop, per lh-readme).
# Run both
LHCI_BUILD_CONTEXT__GITHUB_BASE_URL=https://github.com/... \
npx lhci autorun --config=.lighthouserc.mobile.js
npx lhci autorun --config=.lighthouserc.desktop.js
| Anti-pattern | Why it fails | Fix |
|---|---|---|
numberOfRuns: 1 | Single-run measurements are noisy; flaky alerts. | Use 3 (canonical) or 5 for high-stakes pages; LHCI uses the median. |
Asserting on first-input-delay (FID) | FID was retired in 2024 (web-vitals). | Gate on total-blocking-time in the lab and track INP in field data. |
Asserting on interaction-to-next-paint in lhci autorun | The INP audit runs only in timespan mode (lh-inp), so a navigation run has no INP to check. | Gate on total-blocking-time (lab proxy, inp); script the interaction as a user-flow timespan; track INP with the web-vitals library in production. |
formFactor: 'desktop' without the desktop preset | Mobile screen emulation stays on (a mismatch Lighthouse rejects); desktop pages are not tested as desktop. | preset: 'desktop' (Stable numbers section). |
throttlingMethod: 'devtools' on shared CI runners | Devtools throttling cannot mitigate host hardware variance. | Default simulated throttling, 5 runs, dedicated runner. |
| Hard error on every metric out of the box | Existing pages may not meet thresholds; team learns to ignore the gate. | Start with warn for everything; promote to error once green for 2 weeks. |
| Auditing only the homepage | The homepage is usually the most-optimized page; misses regressions on long-tail routes. | Audit a representative URL set: home + 1 logged-in dashboard + 1 long-form content + 1 form-heavy. |
| Lighthouse score as the sole metric | Lighthouse score conflates multiple subscores; doesn't isolate which Web Vital regressed. | Assert on the individual metrics (largest-contentful-paint, total-blocking-time as the INP proxy, cumulative-layout-shift); category score is supplementary. |
| Running against production | Lighthouse fires real network requests and triggers analytics; pollutes prod metrics. | Always against staging or a local build. |
Lighthouse CI measures lab data (synthetic; deterministic runner). Field data (real-user metrics, RUM) is measured by Web Vitals JS in production. Both matter:
| Source | Tool | Use for |
|---|---|---|
| Lab (synthetic) | Lighthouse CI | Per-PR regression gate. |
| Field (RUM) | web-vitals library + analytics | Real-user 75th-percentile tracking. |
Lighthouse CI catches per-PR regressions; field data tracks the 75th-percentile threshold per web-vitals. Don't substitute one for the other.
interaction-to-next-paint audit
source (supportedModes: ['timespan']).startFlow, startTimespan / endTimespan; timespans have no score or LCP.benchmarkIndex, 4x default CPU slowdown,
cpuSlowdownMultiplier calibration.formFactor does not control emulation; the
desktop preset replaces it.--preset choices, "For desktop, use
--preset=desktop instead".lhci autorun,
configuration shape, assertion levels.budget.json resource-size caps at design time.perf-budget-gate - downstream
unified gate aggregating Lighthouse + load-runner verdicts.non-functional-requirement-extractor - upstream skill that surfaces Web Vitals NFRs from PRDs.evals/cutting-the-rum-vendor-because-ci-reports-the-same-three/criteria.json (opens in a new tab)evals/cutting-the-rum-vendor-because-ci-reports-the-same-three/task.md (opens in a new tab)evals/first-gate-on-an-app-that-misses-every-target/criteria.json (opens in a new tab)evals/first-gate-on-an-app-that-misses-every-target/task.md (opens in a new tab)evals/green-gate-while-the-reports-page-takes-nine-seconds/criteria.json (opens in a new tab)evals/green-gate-while-the-reports-page-takes-nine-seconds/task.md (opens in a new tab)evals/interactivity-assertion-that-has-never-fired/criteria.json (opens in a new tab)evals/interactivity-assertion-that-has-never-fired/task.md (opens in a new tab)evals/lhci-assert-upload/criteria.json (opens in a new tab)evals/lhci-assert-upload/task.md (opens in a new tab)evals/lhci-budgets/criteria.json (opens in a new tab)evals/lhci-budgets/task.md (opens in a new tab)evals/lhci-desktop-noisy-runner/criteria.json (opens in a new tab)evals/lhci-desktop-noisy-runner/task.md (opens in a new tab)evals/lhci-inp-navigation/criteria.json (opens in a new tab)evals/lhci-inp-navigation/task.md (opens in a new tab)evals/lhci-login-pages/criteria.json (opens in a new tab)evals/lhci-login-pages/task.md (opens in a new tab)evals/nightly-audit-firing-at-the-live-storefront/criteria.json (opens in a new tab)evals/nightly-audit-firing-at-the-live-storefront/task.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
9 skills in this plugin
/db-query-plan-analyzerUse for any question or task about a slow SQL query or a database bottleneck, including how to read EXPLAIN or EXPLAIN ANALYZE output and database CPU that saturates under load. Reads plans from PostgreSQL, MySQL or SQLite, finds the main cost (sequential scans, nested loops, sort spills, missing or unusable indexes) and proposes the index or query rewrite./flame-graph-analyzerUse for any question or task about reading a flame graph or CPU profile, including finding the hot path after a slow release or a regression traced to one commit. Reads flame graphs and profiles from py-spy, async-profiler, Go pprof or clinic.js, finds the hottest frames, tells CPU-bound from lock contention or allocation pressure and suggests the next step./npx claudepluginhub testland/qa --plugin qa-load-testingOther plugins' skills for the same job