agentleFS
yusixianyusixian/agent-skills/skills/page-performance-audit/SKILL.md

page-performance-audit

Skill2 starsChanged 3 months agoMITView on GitHub

Audit web-page loading, responsiveness, memory, images, network traffic, and runtime stability under normal, weak-network, weak-CPU, and combined mobile conditions. Use for local-versus-production comparisons, Android Chrome or CDP performance investigations, high-memory or slow-homepage diagnosis, cold-cache validation, scroll/GC retention tests, key-timeline screenshots, source attribution, and standalone evidence-backed HTML reports.

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. About 0 are common, 11 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read repository instructions before inspecting source.

    line 12
  2. Distinctive:

    Create a goal only when the user explicitly requests one.

    line 16
  3. Distinctive:

    Use at least two fresh baseline samples before treating a value as representative.

    line 27
  4. Very specific:

    Every collector invocation receives a collision-resistant sample ID, so repeated baseline, failure, screenshot, and memory artifacts remain …

    line 29
  5. Distinctive:

    Prefer Android Chrome over desktop emulation when an ADB device is available.

    line 33
  6. Very specific:

    Use Node.js 22 or newer; the collector relies on the built-in fetch and WebSocket implementations.

    line 35
  7. Very specific:

    Keep results outside tracked application source.

    line 56
  8. Very specific:

    If the repository's file-editing policy requires apply_patch, use it for authored files such as analysis.json.

    line 65
  9. Distinctive:

    Run one command per target and scenario:

    line 77
  10. Distinctive:

    When source attribution is in scope:

    line 135
  11. Very specific:

    Use CodeGraph first when .codegraph/ exists.

    line 137
  12. Distinctive:

    Read metrics.md before interpreting memory, TBT, images, constrained runs, or cache behavior.

    line 142
  13. Very specific:

    Create optional analysis.json in the artifact root after reviewing raw evidence:

    line 146
  14. Distinctive:

    Avoid generic advice. Every finding needs runtime evidence.

    line 172
  15. Very specific:

    Search the non-image HTML for undefined, NaN, ENOENT, or missing-file placeholders.

    line 190
  16. Distinctive:

    Search the report for private hostnames, identifiers, account UI, and local paths before sharing it.

    line 192
  17. Distinctive:

    Always reset or remove only state created for the audit:

    line 197
  18. Distinctive:

    Remove mappings only if this audit created them.

    line 204

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Page Performance Audit

Produce a reproducible diagnosis, not a single Lighthouse score. Prefer a real Android device, preserve failed samples, correlate metrics with screenshots, and finish with a standalone HTML report.

Establish scope

  1. Read repository instructions before inspecting source.
  2. Identify every target URL, especially local and production variants.
  3. Record authentication state, route, device, browser version, viewport, and whether production matches the current checkout.
  4. State the scenario matrix and cache policy before a long run. Wait only when the user explicitly asks to approve the plan first.
  5. Create a goal only when the user explicitly requests one.

Default matrix:

ScenarioNetworkCPU
baselineUnthrottled1×
weak-network300 ms RTT, 1.6 Mbps down, 750 Kbps up1×
weak-cpuUnthrottled4× slowdown
combinedWeak network4× slowdown

Use at least two fresh baseline samples before treating a value as representative. Run constrained scenarios as guarded time-series samples; a stalled page is evidence.

Every collector invocation receives a collision-resistant sample ID, so repeated baseline, failure, screenshot, and memory artifacts remain separate. Use --sample-id NAME only when a stable operator-chosen identifier is useful; it must be unique within the artifact directory.

Select the measurement surface

Prefer Android Chrome over desktop emulation when an ADB device is available. Use desktop Chrome CDP only as a clearly labeled fallback.

Use Node.js 22 or newer; the collector relies on the built-in fetch and WebSocket implementations. Android renderer PSS additionally requires adb and dumpsys meminfo. The bundled collector targets Chromium/CDP and has no equivalent iOS process-memory collector.

For Android Chrome:

AUDIT_CDP_PORT=9223
adb devices -l
adb forward "tcp:$AUDIT_CDP_PORT" localabstract:chrome_devtools_remote

For a local development port, add only the required reverse mapping:

AUDIT_APP_PORT=5173
adb reverse "tcp:$AUDIT_APP_PORT" "tcp:$AUDIT_APP_PORT"

Do not force-stop Chrome, clear global browser data, or close pre-existing tabs. The bundled collector creates and closes only its dedicated test target. Record the pre-existing target list with probe. Treat probe output as sensitive because it contains existing tab titles and URLs. Use --chrome-package or CHROME_PACKAGE when the device does not use com.android.chrome.

Prepare artifacts

Keep results outside tracked application source. Use a dated temporary or gitignored directory with raw/, screenshots/, optional analysis.json, and report.html.

AUDIT_SKILL_DIR="/path/to/installed/page-performance-audit"
AUDIT_OUTPUT_DIR="${TMPDIR:-/tmp}/page-performance-audit-$(date +%F)"
mkdir -p "$AUDIT_OUTPUT_DIR"
node "$AUDIT_SKILL_DIR/scripts/audit-page.mjs" probe --cdp http://127.0.0.1:9223

If the repository's file-editing policy requires apply_patch, use it for authored files such as analysis.json. Generated raw data, screenshots, and reports may be written by the bundled scripts.

Protect private evidence

The collector never writes token or cookie values, but raw artifacts can still contain full target and request URLs, query parameters, remote IPs, console errors, device model/build metadata, screenshots, and boolean authentication heuristics. Keep raw/ private unless it has been reviewed and redacted. Probe output can expose unrelated tabs and must not be published by default.

The HTML report hides full target URLs, device model/version, local artifact paths, and URLs embedded in errors by default. Add --include-target-urls or --include-device-details only when the report audience is authorized to see them. Screenshots and authored analysis.json remain the operator's responsibility to review.

Run cold-load scenarios

The collector always calls both Network.setCacheDisabled(true) and Network.setBypassServiceWorker(true). Treat these as controlled cold-load results, not repeat-navigation behavior.

Run one command per target and scenario:

node "$AUDIT_SKILL_DIR/scripts/audit-page.mjs" run \
  --url https://example.com/ \
  --label production \
  --scenario baseline \
  --out "$AUDIT_OUTPUT_DIR"

Repeat with weak-network, weak-cpu, and combined. For local development, use a separate label and URL. Useful overrides:

--duration-ms 60000
--threshold-mb 2200
--latency-ms 300
--download-kbps 1600
--upload-kbps 750
--cpu-rate 4
--cdp http://127.0.0.1:9223
--adb /absolute/path/to/adb
--chrome-package com.android.chrome
--require-auth --auth-selector '[data-testid="account-menu"]'
--sample-id production-baseline-02

The safety threshold stops a run after preserving the current memory sample. Do not raise it merely to force a page to finish.

Without --auth-selector, authentication is only a generic heuristic based on storage keys, sign-in controls, and account-avatar UI. Use a stable project-owned CSS selector when authenticated state matters to the validity of the sample; do not describe the fallback heuristic as proof of identity.

Run scroll and retention testing

Choose the target that best represents user behavior, usually production. Measure initial state, intermediate scroll depths, idle retention, and forced GC:

node "$AUDIT_SKILL_DIR/scripts/audit-page.mjs" memory \
  --url https://example.com/ \
  --label production \
  --out "$AUDIT_OUTPUT_DIR" \
  --load-wait-ms 30000 \
  --scrolls 10 \
  --idle-ms 30000

Compare renderer PSS, JS heap, DOM nodes, loaded images, decoded-image upper bound, and scroll depth. Do not equate a post-GC PSS drop with a fixed leak; distinguish reclaimable memory from retained DOM/media.

Diagnose before recommending

Rank hypotheses before deep source inspection. Test these common classes:

  1. Excess initial requests, preload closure, or eagerly mounted feature graphs.
  2. Oversized or over-eager media and decoded native memory.
  3. Hydration, long tasks, and main-thread blocking.
  4. Duplicate requests, polling, analytics, or subscriptions.
  5. Development-only overhead versus production behavior.

Aggregate network data by resource type, host, initiator, size, and time window. Compare screenshots at 0.5, 2, 5, and 10 seconds with FCP/LCP; a spinner is not meaningful content.

When source attribution is in scope:

  • Use CodeGraph first when .codegraph/ exists.
  • Trace heavy initial resources to route imports, mounted components, loaders, preload configuration, media components, virtualization, and third-party SDK initialization.
  • Reuse existing lazy boundaries, image-sizing utilities, and virtualization seams before proposing new abstractions.
  • Separate measured facts, source-confirmed causes, inferences, proposed budgets, and unverified deployment assumptions.

Read metrics.md before interpreting memory, TBT, images, constrained runs, or cache behavior.

Add analysis

Create optional analysis.json in the artifact root after reviewing raw evidence:

{
  "title": "Mobile homepage performance audit",
  "summary": "One-paragraph evidence-backed conclusion.",
  "findings": [
    {
      "priority": "P0",
      "title": "Initial script closure dominates startup",
      "evidence": "Measured request, transfer, timing, and source evidence."
    }
  ],
  "recommendations": [
    {
      "priority": "P0",
      "title": "Move the heavy feature behind an interaction boundary",
      "detail": "Expected impact and validation method."
    }
  ],
  "limitations": [
    "Production deploy SHA was unavailable."
  ]
}

Avoid generic advice. Every finding needs runtime evidence; every code-level cause needs a source path or call/import path. Label budgets as proposed targets unless they already exist in project policy.

Generate and verify the report

node "$AUDIT_SKILL_DIR/scripts/build-report.mjs" \
  --input "$AUDIT_OUTPUT_DIR" \
  --title "Page performance and memory audit"

The report embeds screenshots for offline viewing but intentionally summarizes raw JSON without embedding request URLs. Full target URLs and device details are opt-in. Treat raw/ as sensitive even when the report is safe to share.

The report is also the executable coverage gate. It is PASS only when every target has at least two baseline samples plus weak-network, weak-cpu, and combined, at least one memory-retention run exists, screenshots exist, and no failed or invalid-auth sample remains. The HTML is still written for incomplete audits, but the command reports INCOMPLETE, lists every missing obligation, and exits non-zero.

Verify before handoff:

  1. Parse every raw JSON file.
  2. Confirm the report exists, closes with </html>, and embeds the expected screenshot count.
  3. Search the non-image HTML for undefined, NaN, ENOENT, or missing-file placeholders.
  4. Render the report in Chrome and visually inspect at least the first viewport and one screenshot section.
  5. Search the report for private hostnames, identifiers, account UI, and local paths before sharing it.
  6. Report excluded, failed, aborted, and non-settled samples explicitly.

Clean up

Always reset or remove only state created for the audit:

adb reverse --remove "tcp:$AUDIT_APP_PORT"
adb forward --remove "tcp:$AUDIT_CDP_PORT"

Remove mappings only if this audit created them. Confirm unrelated tabs and workspace changes remain untouched. Do not delete the evidence directory unless the user asks.

Handoff

Lead with the HTML report link and the highest-impact diagnosis. Include:

  • device, browser, scenarios, cache policy, and target URLs;
  • representative baseline and worst observed values;
  • failure/stall evidence and interpretation limits;
  • ranked remediation with validation criteria;
  • links to the report, raw evidence, screenshots, and collector;
  • whether source files were changed.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.