/performance:benchmark [<command>]from performance
Times programs or commands and builds benchmark harnesses using hyperfine and compare.ts. Useful for comparing performance across versions or changes with interleaved runs and noise-floor analysis.
Ships in performance. 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.
Goal: a comparison the user can trust. Every arm runs the same scenario from the same starting state, the arms are interleaved so machine drift hits them equally, the noise floor is measured before any difference is read, and a difference counts only when it clears that floor.
hyperfine 2.0 or later: !hyperfine --version 2>/dev/null || echo "not found. Required unless the project's own tooling covers its job."bun (runs compare.ts): !bun --version 2>/dev/null || echo "not found. Required for compare.ts."Look for the project's own benchmarks before building one: package scripts, a bench/ directory, benchmark tests, CI jobs that time something. Check each against the requirements the setup below is built to meet:
compare.ts report.Use the existing tooling when it meets every requirement. When it misses some, compose around it and keep its scenario: run its command as a compare.ts arm for interleaving and significance, or add a --prepare reset. Tell the user which requirement it missed and what you added.
Pin the scenario before timing it. A run that changes its own input measures a different scenario each time.
--prepare (restore a fixture, clear or warm a cache), and one-time setup with --setup. Match the cache state to the scenario the user cares about. A cold-start metric needs a cold cache on every run.-N when the command is a single executable with arguments, which removes the shell's startup from every sample.compare.ts records the load average around each round and flags rounds above twice the core count.bun test --timeout, pytest --timeout), so a load spike slows a run instead of failing it. Read the first timeout before raising it, since it can be a real cost worth a candidate..zshrc, .bashrc), read references/shell.md.Interleaving runs every arm in the same round, so each one exists on disk at once:
git worktree add <dir> <ref> per version, or a separate build output per arm. Put each worktree under the repo's gitignored tmp/arms/, and exclude that directory from any test runner, linter, or watcher that walks the tree. A comparison ends once report has printed, so remove its arms then with git worktree remove --force tmp/arms/<arm>.~/.cache, a config directory), point each arm at its own copy. Shared state lets a candidate that changes a cache format make both arms miss on every run../.Compare with the bundled script, which runs short hyperfine rounds in rotating order and pools them:
bun ${CLAUDE_SKILL_DIR}/scripts/compare.ts run tmp/bench/<comparison> \
--hypothesis '<change and predicted effect>' --arm 'base=<command>' --arm 'candidate=<command>' --rounds 6 --runs 3 -- -N --prepare '<reset>'
bun ${CLAUDE_SKILL_DIR}/scripts/compare.ts report tmp/bench/<comparison> --markdown
The first --arm is the base. Arguments after -- go to every hyperfine call. Give each comparison its own directory, since run refuses one that already holds exports. run writes the hypothesis and per-round load to meta.json there, and report prints both above the table. When a round is flagged, it adds a second table pooled without the flagged rounds. report also reads --export-json files from a plain hyperfine run, and pools every file and directory it is given per arm name.
Before comparing versions, run the unchanged program as two arms (an A/A comparison) and repeat until the pair ties. When it stars, the harness is noisier than the effect:
--runs or --rounds.The A/A spread (±MAD) is the smallest change the harness can resolve.
When the Mac's A/A will not tie, machine load would delay a comparison by more than about 15 minutes, or the fast signal needs perf or hardware counters, read ../profile/references/linux-vm.md.
* marks a change with permutation p below --alpha (0.1) and a size of at least --min-effect (3%). An unstarred change is a tie, however large it looks.† marks fewer than 4 runs on a side, too few to star. With 3 a side, the permutation test cannot reach p < 0.1 however far apart the arms are, so plan --rounds and --runs for at least 4 per arm, even when each run is expensive.failed count means some runs exited nonzero and left the pool. compare.ts run stops after the round where a run fails. Run that arm once with its output visible and fix the cause before starting a new comparison.compare.ts records each run's peak resident set size (max RSS) from hyperfine, beside wall time. When the goal is memory, peak RSS is the metric: compare.ts report <dir> --metric memory runs the same significance test and star rule on it.
getrusage of the child. Pass -N so it is the program's own, not a shell's. A program that spreads its peak over child processes needs each child measured.compare.ts, read peak RSS with /usr/bin/time -l on macOS (bytes) or /usr/bin/time -v on Linux (KB), or from resourceUsage().maxRSS of a Bun.spawn child, which works inside the sandbox.peak memory footprint beside max RSS. Footprint excludes mapped binary text and shared pages, so the two differ. Name the one the climb records and compare like with like.To find what holds the peak, profile it with performance:profile.
Wall time is the metric users feel, and the noisiest. A fast signal screens candidates cheaply and confirms with lower noise. Before trusting one, check on the baseline that it moves with wall time.
perf stat on Linux and /usr/bin/time -l on macOS report instructions retired, cycles, and peak memory. Instructions retired vary far less than wall time. time -l counts the top process only, not its children, and reads a sysctl the Bash sandbox denies.testing, benchstat), Rust (criterion, divan, instruction counts), Python (pytest-benchmark).hyperfine runs each command's runs back to back. Two separate hyperfine invocations minutes apart carry drift between them, so compare arms inside one interleaved run.references/go.md (opens in a new tab)references/javascript.md (opens in a new tab)references/python.md (opens in a new tab)references/rust.md (opens in a new tab)references/shell.md (opens in a new tab)scripts/__snapshots__/compare.test.ts.snap (opens in a new tab)scripts/compare.integration.ts (opens in a new tab)scripts/compare.test.ts (opens in a new tab)scripts/compare.ts (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
3 skills in this plugin
/hill-climbperformance:hill-climbUse when asked to hill-climb a program, or to make software faster or leaner (runtime, startup, throughput, memory, bundle size) through repeated measured changes, including resuming a climb from its notes file. For prompts or skills scored by an eval suite, use evals:hill-climb./profileperformance:profileUse when asked why a program, script, or web page is slow or memory-heavy, or what dominates its runtime, before deciding what to change.npx claudepluginhub bendrucker/claude --plugin performanceOther plugins' skills for the same job