Performance engineering
Use Addy Osmani’s skills to investigate a slow page
Turn an agent’s performance advice into a testable patch: establish a baseline, inspect traces, isolate one bottleneck, and verify the work with a reproducible browser lab.

A coding agent can inspect a slow page and produce a convincing list: memoize components, split the bundle, compress the hero, add caching. The hard part is finding which change removes the work that is delaying your users. That requires a measurement contract, a trace, and a patch small enough to explain.
Addy Osmani’s agent-skills repository includes a performance-optimization skill and a web-performance-auditor persona. Used together, they give the assistant a procedure for gathering evidence and deciding whether an optimization should survive review. This guide puts that procedure around a deliberately small browser experiment, then shows how to apply it to a real product.Addy Osmani ↗Addy Osmani ↗
Load the skill and check what actually arrived
The optimization skill supplies a measure, diagnose, change, verify sequence. The auditor adds an important boundary: a source review can identify risks, but numeric results need actual measurement artifacts. Its Quick mode leaves the scorecard unmeasured; Deep mode uses reports or traces. An agent’s confident reading of a component is still a source review.Addy Osmani ↗Addy Osmani ↗
npx skills add addyosmani/agent-skills --skill performance-optimizationInspect the installed SKILL.md and its relative references before starting. The repository documents a portability gap: installing one skill may omit shared checklists outside that skill’s directory. A whole-repository integration keeps that material available. The repository’s /webperf command also depends on the host’s command integration; installing a Markdown skill alone does not guarantee that slash command exists.Addy Osmani ↗
For repeatable work, record the source revision and the local skill file hash with the experiment. A later update can change instructions, tools, or review behavior. Those changes belong in the experiment log alongside the model, prompt, application revision, and browser version.
Write the measurement contract before the patch
Specify a route, action, dataset, cache state, and observable failure. “The dashboard is slow” leaves the assistant free to optimize whatever is easiest to change. “Refreshing the 900-row fixture spends time in repeated layout during one click” narrows the claim to something a trace and an assertion can inspect.
Investigate [ROUTE AND USER ACTION] using the performance-optimization skill.
Before editing:
1. Record the app revision, browser version, viewport, CPU/network settings, dataset, and cache state.
2. Reproduce the symptom. Save the exact command and raw measurement artifacts.
3. Name one primary metric, its measurement window, and a correctness assertion. Mark other metrics as unmeasured.
4. Explain one bottleneck supported by the trace, with the source location that produces it.
Then propose the smallest patch that changes that mechanism. Preserve the same output and user behavior. Re-run the same protocol, include every sample, and inspect the trace again. State what the result demonstrates and what remains untested. Do not infer field Core Web Vitals from a lab interaction or attribute a manually authored patch to an agent benchmark.A useful correctness assertion captures the work the product owes the user. For a filtered list, check the matching records, order, and count. For a chart, check the rendered values. For an API, check authorization and result semantics. Otherwise an agent can win a timing measurement by quietly removing required work.
Follow the delay to the appropriate evidence
| Observed symptom | First artifact to inspect | Question to resolve |
|---|---|---|
| The main content appears late | Network waterfall and LCP attribution | Is the resource discovered late, slow to transfer, or ready but waiting to render? |
| A click stalls the page | Performance recording of that interaction | Was time spent before the handler, inside JavaScript, or producing the next frame? |
| A React view repeatedly updates | React Performance tracks and browser timeline | Which update triggers the work, and is rendering actually the expensive part? |
| The server takes too long to respond | Request trace, query timings, and query plan | Is it executing work, waiting for a connection, or waiting on another service? |
LCP has distinct waiting and rendering components. A smaller image can leave the final paint unchanged if another dependency still blocks it. For interaction latency, distinguish input delay, processing, and presentation rather than treating every stall as a slow event handler.web.dev ↗web.dev ↗
React’s performance tracks can align component work with scheduling and browser activity. Use the correct build: tracks are available in development and profiling configurations, with different coverage and instrumentation overhead. Validate the final patch in the production configuration you intend to ship.React ↗
A small case: repeated layout during a refresh
The downloadable page contains 900 equal-width rows, each holding a bar. Refreshing computes each bar’s width from a fixed ratio. The baseline reads a row’s current width, writes its child’s width, then reads the next row. A layout-affecting write can make the browser resolve layout again before the following geometry read.
for (const row of document.querySelectorAll('.row')) {
const width = row.clientWidth;
row.firstElementChild.style.width =
`${width * Number(row.dataset.ratio)}px`;
}The candidate uses a property of this fixture: every row has the same width. It measures that shared width once and then performs the writes. A real layout with heterogeneous rows needs a separate pass that reads every required width before a second pass writes anything. Reusing the first row’s width there would change the output.web.dev ↗
const rows = [...document.querySelectorAll('.row')];
const width = rows[0].clientWidth; // Equal-width fixture only.
for (const row of rows) {
row.firstElementChild.style.width =
`${width * Number(row.dataset.ratio)}px`;
}The trace is the bridge between these few lines and the timing result. Open each included trace in the DevTools Performance panel, locate the refresh-work User Timing measure, and inspect the layout events around it. The runner also reads Chrome’s layout counters across the click and two animation frames, so deferred layout after the handler remains visible in a separate measurement window.
Measure the same work under the same conditions
npm init -y
npm install playwright@1.62.1
npx playwright install chromium
node benchmark.mjsThe recorded run used 151.0.7922.34, Playwright 1.62.1, Node v24.14.0, and Apple M1 Pro on darwin/arm64. The viewport was 1280 × 900 at device scale factor 1, with a 4× CPU slowdown and no network throttling. All resources are local and inline. CPU throttling supplies a controlled slowdown; it does not reproduce an actual phone.
After one discarded warm-up for each variant, the runner measured 12 pairs. It alternated baseline/candidate and candidate/baseline order, using a fresh browser context for every run. Two further runs captured traces and were excluded from the statistics because tracing adds overhead. Every measured run checked all 900 resulting bar widths against the expected values.
| Local synthetic measurement | Interleaved baseline | Batched candidate |
|---|---|---|
| Median synchronous refresh work | 719.9 ms | 3.3 ms |
| Observed refresh-work range | 706.5–768.6 ms | 1.5–4.0 ms |
| Median layout count in click/frame window | 902 | 3 |
| Median layout time in click/frame window | 696.7 ms | 4.1 ms |
| Output assertions per run | 900 correct bar widths | 900 correct bar widths |
| Field INP, LCP, CLS, and conversion | Not measured | Not measured |

The candidate’s shorter handler can defer some rendering until after JavaScript returns. That is why the secondary layout counter and layout duration matter: they check the mechanism across a wider window. The experiment supports the narrower conclusion that batching removed repeated layout work while preserving the fixture’s output. A user-visible interaction claim still needs an appropriate interaction measurement.
Keep the measurement’s name attached to the number
refresh-work is a User Timing measure around one function. It is not INP. It excludes time waiting before the handler and does not finish at the presentation of the next frame. Calling it INP because it came from a click would turn a valid measurement into an unsupported claim.
Google’s Core Web Vitals guidance evaluates real visits at the 75th percentile, segmented by device class. A Lighthouse report, local trace, and field distribution answer different questions. Use the lab to reproduce a mechanism and detect regressions; use attributed real-user measurements to find out whether the fix helped the affected visitors.web.dev ↗web.dev ↗
Preserve raw observations before aggregating them. Twelve local pairs are a diagnostic sample, not a population study. A tiny change inside overlapping run-to-run variation needs more investigation. Run order, CPU temperature, browser version, cache behavior, and instrumentation can all move the result. An impressive percentage does not remove those uncertainties.
Review the patch and the claim together
Ask the agent to explain the exact work that disappeared. “Fewer layouts because geometry reads no longer follow each width write” is an inspectable claim. “Optimized rendering” leaves too much room for hand-waving. The explanation should match both the source diff and the trace.
Review this performance change using the baseline, candidate, raw samples, traces, and correctness checks provided.
Report:
- The measured metric and the boundaries of its timing window.
- The changed mechanism and its source location.
- The distribution of all runs under matching conditions.
- Whether work was removed, moved, deferred, cached, or skipped.
- Which behavior assertions still hold.
- Any added memory, stale-data, or maintenance cost.
- Whether the claim exceeds the evidence.
Recommend keep, investigate further, or revert. Explain uncertainty. Do not fill missing measurements with estimates.Keep an experiment ledger that includes rejected attempts. Record the hypothesis, application revision, run command, evidence path, result, and decision. This prevents the next agent from proposing the same failed memoization or caching change simply because the abandoned patch disappeared from Git history.
Turn the result into a regression guard
The fixture already supplies one guard: all rows must receive the correct width. For timing, start by running the same harness on a stable CI worker and collecting its normal variation. Set a project-specific budget that catches meaningful regressions without failing on ordinary noise. An absolute threshold copied from this laptop would be an unreliable CI policy.
For a real page, pair that synthetic guard with field attribution for the affected route and interaction. Preserve the ability to roll back. Review the resulting performance distribution after enough relevant visits arrive, and check that the change has not increased failures or moved the cost elsewhere.
The useful output of a performance skill is an evidence package: a reproduced symptom, a bounded hypothesis, a small change, preserved behavior, and a measurement another person can repeat. Once those pieces exist, you can judge the assistant’s work with much more precision than a list of optimization suggestions.
Sources & further reading
Checked November 7, 2026. Definitions and guidance come from the references below; prompts and concepts are original sinabuilds work.
- Agent Skills installation and integration notes Addy Osmani
Pinned source for individual skill installation, shared-reference limitations, and host-specific command integrations.
- performance-optimization skill Addy Osmani
Pinned source for measurement-led optimization, verification, and regression guards. The lab is an original application of the procedure.
- Web performance auditor Addy Osmani
Pinned persona definition distinguishing source-level findings from measurements and field data from lab artifacts.
- Avoid large, complex layouts and layout thrashing web.dev
Browser layout behavior and the effect of alternating geometry reads with style writes.
- Optimize Largest Contentful Paint web.dev
LCP decomposition and the difference between lab diagnosis and actual visitor experience.
- Optimize Interaction to Next Paint web.dev
Input, processing, and presentation delays, plus field measurement guidance.
- Web Vitals web.dev
Core Web Vitals and percentile-based evaluation of field data.
- React Performance tracks React
Track availability, build-specific limitations, and profiling overhead.
- Chrome DevTools for agents Chrome Developers
Current browser inspection and verification tooling for coding agents.