/profile-skills:perf-measurefrom Profile Skills
Gather performance evidence without changing the code - profile to find where time or memory goes (Python, Node, Bun, browser, Bash), benchmark and compare two versions/branches/runtimes with interleaved runs and a confidence-interval verdict, verify someone's claimed speedup by independent re-measurement, or review a diff/PR for performance regressions with measured confirmation. Use this skill whenever the user asks to profile, find a bottleneck or hotspot, "why is this slow", "where is the time going", "what's using the memory", wants a flame graph, asks to benchmark or compare implementations, "is this faster", "did this regress", "is this speedup real", "will this PR be slow", "check this for perf issues", or hands you a .prof, .cpuprofile, speedscope, trace.json or benchmark JSON. To change code to make it faster use perf-optimize; to add CI gates use perf-ci.
Ships in Profile Skills. 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; scripts run unread.
This skill answers performance questions with evidence, and does not edit the code under study. It has four modes. Pick the one that matches the question:
| Mode | Question | Output |
|---|---|---|
| profile | Where does the time or memory go? | Hotspot table with shares and Amdahl ceilings, and why each is expensive |
| bench | Is B faster than A? By how much? Does it scale? | Verdict with ratio, 95% CI, n, environment |
| verify | Is this claimed speedup real? | Independent re-measurement and whether it reproduces the claim |
| review | Will this diff regress performance? | Findings ranked by severity, blockers confirmed by measurement |
The engine is perfkit (stdlib Python 3.9+): PK=${CLAUDE_SKILL_DIR}/scripts/perfkit.py.
The command reference is in references/perfkit.md.
One decision rule (ADR-0005). "Faster" or "slower" is decided only by perfkit compare.
test-policy.toml (ADR-0004): 20 per arm at R4, 30 at R5.equivalent, below-threshold or inconclusive. Report it as such;
never round noise into a result.Best-of-breed tools collect; perfkit decides (ADR-0006). The tools are py-spy,
Scalene, pyperf, memray, node --cpu-prof, mitata, @platformatic/flame and hyperfine.
Install them on demand:
uv tool install py-spy, uv run --with scalene …,
npm i -D mitata @platformatic/flame in a scratch dir;brew install hyperfine).Their own statistics are reported alongside, but they never decide.
Execute scripts; don't replay them. In Claude Code's interactive zsh, grep and find
are shell functions backed by bundled ugrep/bfs. Time shell code by running the script
(bash ./x.sh), never by pasting its commands into your shell.
Artefacts go in .perf/<concern>/ (ADR-0007): profiles, traces, heap snapshots, flame
graphs, raw JSON.
.perf/ is git-ignored.Run python3 $PK doctor first. It lists installed tools, counter support, and noise
warnings (load, battery, CI runner, bash version). Carry its warnings into the report.
Name the question and reproduce the complaint. Use the user's slow input, at a realistic size, through the real entry point, running ≥1–2 s or ≥2,000 samples. Profile the application, not the test runner, unless the suite itself is what's slow.
Choose the profiler from the question:
| Runtime | CPU / wall (find hotspots) | Line level / memory | Notes |
|---|---|---|---|
| Python | py-spy record -f speedscope (--idle for wall, --subprocesses) | Scalene (--cpu-only 1.02× overhead; memory, copy volume); memray for allocations/leaks | macOS: py-spy needs root. If sudo -n true fails, ask the user to run the exact command with ! sudo …; otherwise fall back to Scalene or pyinstrument and say so. cProfile for exact call counts. 3.15+: python -m profiling.sampling |
| Node | node --cpu-prof --cpu-prof-dir=.perf/<c> | --heap-prof, heap snapshots + memlab | @platformatic/flame for flame graphs. File written only on normal exit |
| Bun | bun --cpu-prof-md / --cpu-prof for localisation only | --heap-prof-md | Measured overhead 27–74%, and idle time is counted as JS self time (Bun #44077). Never take timings from a Bun profile; if the code also runs on Node, cross-check there |
| Browser | scripts/browser_trace.mjs (Playwright, CPU/network throttle, --interact) | heap snapshots, memlab | Production build; median of ≥3 runs |
| Bash / zsh | scripts/xtrace.sh (bash 5 EPOCHREALTIME; zsh native; bash 3.2 fallback flagged as inflated) | /usr/bin/time -l (macOS) / time -v | Count forks and execs: shell cost is usually process creation |
| Native / any binary | samply record --save-only | Instruments, heaptrack | references/native.md |
Flags and gotchas: references/profile-python.md, profile-javascript.md (Node and
Bun), profile-browser.md, profile-bash.md, memory.md, services.md (HTTP, DB,
N+1).
Normalize:
python3 $PK hotspots .perf/<c>/<profile> --project-root . --json .perf/<c>/hotspots.json.
This reads pstats, .cpuprofile, Chrome traces, speedscope, folded stacks and xtrace logs.
Read it correctly:
max× is the Amdahl ceiling: a 5% frame can never give more than ×1.05.Report:
max×, calls), with file:line and why each is
expensive;Define the claim before measuring:
Collect samples with the right harness:
| Thing measured | Harness → perfkit |
|---|---|
| command, script, CLI, build (≥10 ms) | perfkit abtest (interleaved, output-checked, instruction counts recorded), or --engine hyperfine for hyperfine bursts per block |
| Python function/snippet | pyperf (-o a.json / -o b.json, or pyperf command) → perfkit compare a.json b.json |
| JS/TS function (Node, Bun) | mitata run({ format: 'json' }) → perfkit compare; or a per-arm driver process under abtest for decisions |
| HTTP service | k6 open-loop (constant-arrival-rate) / oha; alternate A/B runs (references/bench-cli-and-load.md) |
| page | browser_trace.mjs medians, A/B alternated |
| scaling | perfkit scaling --cmd '… {n}' --sizes … (tail exponent; ≥8× size span) |
Two versions of the same repo: put each in a git worktree under .perf/wt-*, build both,
then measure the built artefacts.
Prove both arms did the same work. Use --require-same-output, or assert inside the
benchmark. Consume results so JIT and optimizers can't delete the work.
Decide: run perfkit compare (references/stats.md). Before reporting, go through
the benchmarking-crimes checklist (references/crimes.md).
Report one line a reader can trust, then the details. For example: "B is 1.8× faster (ratio 0.55, 95% CI 0.53–0.57, paired n=20 interleaved, outputs identical, M4 on AC, load 3.1)".
The claim is a hypothesis, not a fact. Agents' speedups often don't reproduce: many published agent speedups failed on other machines, and in one field study only 45.7% of agent performance PRs included any validation at all.
Get git diff <base>...<head> and the PR text. Note every performance claim; each one
gets verify mode.
For each changed function, establish execution frequency × size: per request, per row or per keystroke vs once at startup, and the realistic n. No blocker or major finding without this argument.
Scan with the catalogs: references/antipatterns-python.md, -js.md, -browser.md,
-bash.md, -data.md (N+1, I/O, caching). ruff check --select PERF,… hints are hints
only.
Confirm blockers and majors by measurement:
Unmeasurable findings are labelled suspected.
Check the measuring stick. Is the PR editing benchmarks, fixtures, thresholds or
perf-policy.toml alongside the code they judge? Are new caches bounded and safe? Are
concurrency changes covered (see hand-offs)?
Write it up with references/review-template.md: verdict, findings with evidence, claims
table, "checked and fine". Behaviour changes found along the way are correctness
findings, and they outrank performance.
quest task create … --actor … --actor-kind delegated-agent --accountable-human ….Perf report: <concern>), linked from the task with quest task edit <id> --doc …..perf/ is disposable once summaries are recorded. Repos using
housekeeping add ".perf" to .housekeeping.toml [junk] patterns, so tidy trashes it
when the task is done.references/perfkit.md: every perfkit command, input formats, output JSON.references/stats.md: the decision rule, pairing, noise, MDE and runs needed, multiple comparisons.references/crimes.md: benchmarking-crimes checklist.references/profile-python.md, profile-javascript.md, profile-browser.md, profile-bash.md, memory.md, services.md, native.md.references/bench-python.md, bench-javascript.md, bench-cli-and-load.md.references/antipatterns-*.md, references/review-template.md.scripts/perfkit.py, scripts/browser_trace.mjs, scripts/xtrace.sh.references/antipatterns-bash.md (opens in a new tab)references/antipatterns-browser.md (opens in a new tab)references/antipatterns-data.md (opens in a new tab)references/antipatterns-js.md (opens in a new tab)references/antipatterns-python.md (opens in a new tab)references/bench-cli-and-load.md (opens in a new tab)references/bench-javascript.md (opens in a new tab)references/bench-python.md (opens in a new tab)references/crimes.md (opens in a new tab)references/memory.md (opens in a new tab)references/native.md (opens in a new tab)references/perfkit.md (opens in a new tab)references/profile-bash.md (opens in a new tab)references/profile-browser.md (opens in a new tab)references/profile-javascript.md (opens in a new tab)references/profile-python.md (opens in a new tab)references/review-template.md (opens in a new tab)references/services.md (opens in a new tab)references/stats.md (opens in a new tab)scripts/browser_trace.mjs (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
Generated from the plugin's indexed repository (opum-ai/profile-skills) — no native marketplace selected
npx claudepluginhub p/opum-ai-profile-skills3 skills in this plugin
/perf-ciKeep performance from regressing as agents ship changes - adopt perf-policy.toml (benchmarks, noise-calibrated tolerances, budgets for latency, startup, memory, bundle size, query/exec counts and Core Web Vitals) on top of test-skills' R1-R5 rigor tiers, and wire a CI gate that builds base and head on the same runner, compares them interleaved and paired with a confidence-interval rule (perfkit suite + gate), reads its policy from the base branch so a PR can't loosen it, and is proven to fail on an injected regression and pass a clean change; CodSpeed, Bencher, github-action-benchmark, Lighthouse CI and size-limit where they fit. Use this skill whenever the user asks to add performance or benchmark checks to CI, catch perf regressions in PRs, set performance budgets or SLOs, track benchmarks over time, fix flaky perf tests, gate bundle size or Lighthouse scores, or add performance rules for agents to a repo. For one-off measurement use perf-measure; for optimizing use perf-optimize./perf-optimizeMake code measurably faster or leaner without breaking it - the recursive loop of baseline → profile → one hypothesis → one change → re-measure with statistics → keep only if significant AND tests stay green, otherwise revert and record why, repeat until a stop rule fires - for Python, JavaScript/TypeScript on Node and Bun, browser pages and Bash. Pins behaviour first (tests and coverage of the changed path, kill matrix at higher rigor), records every experiment (kept or rejected) in Quest and lore, hands concurrency and algorithm-equivalence questions to proof-skills, and scales evidence with the R1-R5 rigor profiles. Use this skill whenever the user asks to speed something up, optimize, reduce latency/memory/startup/build time/bundle size/page load, says something is "slow", "takes forever", "times out" or "uses too much memory", wants a performance pass, or asks to iteratively/recursively improve performance - even if they never say "profile". For measuring or reviewing without changing code use perf-measure; for CI gates use perf-ci.