Skip to content
Join 7,000+ leaders following Alastair's work on LinkedIn.

Skill

Performance Pass

It finds the one place your code is slow, lands the small change that fixes it, and proves the results didn't change.

  • Works in
  • Claude Code

Download the skill or copy it below

---name: performance-passdescription: Finds and lands 80:20 performance wins - big speed-ups from small changes - and proves them safe. Use when anything is slow, times out or "takes ages"; when a request, query, import, sync or page feels sluggish; when the user says "speed this up", "why is this slow", "performance", "profile it" or "latency"; when finishing a feature on an interactive path; and for a periodic performance check on an active service. Carries the measure, profile, fix and prove loop, the equivalence proof that makes an optimisation safe, and the baseline record that makes the next pass cheap.license: "CC BY 4.0. Credit: Performance Pass, a free skill from HumanSpark.ai (https://humanspark.ai/performance-pass/)"---# Performance Pass**Slow code is rarely slow everywhere.** It is slow in one place you have not measured yet.A typical case: a search call took 92 seconds cold. Moving its index from a spinning disk to an SSD brought it toabout 7 seconds, and two small code changes then brought it to a third of a second, with identical results. Eachtime, profiling found nearly all the cost in one place: 5.9 of 6.6 seconds in one function, and 33 of 34 seconds ofan import in one lookup with no index.## When the win is worth having

When to use it

A page, query or import takes ages.

why is this slow?

A request times out and someone is waiting on it.

speed this up

You're finishing a feature someone will use interactively.

profile it

It's time for a regular check that nothing has slowed down.

run a performance pass

New to skills? A skill is a saved set of instructions your AI assistant reads whenever the job comes up, so you set it up once and it works the same way every time. AI Skills for Teams explains how they work.

More than a timeout fix

Slow code is rarely slow everywhere. It's slow in one place you haven't measured yet. Performance Pass finds and lands the 80:20 wins - big speed-ups from small changes - and proves they're safe to ship.

What it does

It runs a measure-profile-fix-prove loop. You measure the real path on real data, cold and warm. That's the only way to find where the actual time goes. Then you profile to find the line holding most of it. Guessing the hot spot is the mistake this step prevents.

Once you know what's slow, you rank fixes by win per line changed. Usually it's a missing index, a loop making one query per item instead of one batch, work repeated per item that can move out of the loop, or storage - the same work on a fast local disk instead of a slow one.

Then you measure the neighbours. A fix that speeds one path can slow another. You run both on the same data and compare. Finally you prove the output is identical - "64 of 64 queries identical" or one fingerprint over the whole result. A speed-up that changes results is a behaviour change and it gets reviewed as one.

What it won't do

It won't optimise background jobs nobody's waiting on unless they're missing a window or costing real money. It also won't chase a 40% win on something that's already fast enough.

And it's not for guessing. The whole point is measuring first, so you fix the right thing instead of the thing that feels slow.

More free skills

Once you've optimised a path, Comparison Integrity helps you choose between competing approaches if there are several. For anything involving data or dependencies, Safe Defaults Review checks that your defaults fail loudly rather than silently. The full set is on the skills page.

How to install it

It's one file with no code in it, so read it first: you'll see exactly what it tells your assistant to do.

Claude Code

  1. Download the skill and unzip it.
  2. Put the folder in ~/.claude/skills/ to use it in every project, or in .claude/skills/ inside one project.
  3. Start a new session. It loads by itself when the job comes up.

Commit a project's .claude/skills/ folder and your whole team gets the skill.

The skill

Download the zip and upload it wherever your assistant takes skills. Or copy the whole block below into any AI assistant: the first lines ask it to save the rest as a skill, so you only do this once.

The skill
Please install the skill below for me.

Save everything between the BEGIN SKILL and END SKILL lines as a new skill called "performance-pass", exactly as written. If you can't create skills, save it as custom instructions or as a project instead. When it's saved, tell me in one line how to use it.

===== BEGIN SKILL =====
---
name: performance-pass
description: Finds and lands 80:20 performance wins - big speed-ups from small changes - and proves them safe. Use when anything is slow, times out or "takes ages"; when a request, query, import, sync or page feels sluggish; when the user says "speed this up", "why is this slow", "performance", "profile it" or "latency"; when finishing a feature on an interactive path; and for a periodic performance check on an active service. Carries the measure, profile, fix and prove loop, the equivalence proof that makes an optimisation safe, and the baseline record that makes the next pass cheap.
license: "CC BY 4.0. Credit: Performance Pass, a free skill from HumanSpark.ai (https://humanspark.ai/performance-pass/)"
---

# Performance Pass

**Slow code is rarely slow everywhere.** It is slow in one place you have not measured yet.

A typical case: a search call took 92 seconds cold. Moving its index from a spinning disk to an SSD brought it to
about 7 seconds, and two small code changes then brought it to a third of a second, with identical results. Each
time, profiling found nearly all the cost in one place: 5.9 of 6.6 seconds in one function, and 33 of 34 seconds of
an import in one lookup with no index.

## When the win is worth having

State the impact in the same units as the cost. The question that matters is **who is waiting**:

- **An interactive path** (a person or an agent is blocked on it): a timeout or a wait of several seconds is a
  defect. Pursue it.
- **A background job** nobody waits on: only if it misses its window, costs real money, or holds a lock something
  interactive needs.
- **Already fast enough:** stop. A 40% win on 50 milliseconds nobody notices costs more than it buys.

## The loop

1. **Measure the real path, cold and warm, on real data.** Use a COPY of the live data, never a toy fixture: many
   slow paths only show up at real size. Name the number the user feels ("6.6 s cold, and the gateway times out at
   30 s"), not a proxy.
2. **Profile before choosing a fix.** For example `python -m cProfile -s cumtime`, `py-spy record` for a running
   process, or `EXPLAIN QUERY PLAN` for SQLite. Find the line that holds most of the time. Guessing the hot spot
   is the mistake this step prevents.
3. **Rank fixes by win per line changed.** The usual 80:20 shapes:
   - a missing index, or a side table that lets a query skip reading full rows
   - a loop that makes one query per item, which becomes one query or one batch
   - work repeated per item that can be moved out of the loop or cached
   - reading whole rows or files to learn one field
   - storage: the same work on a fast local disk instead of a slow disk or network mount
4. **Measure the neighbours.** A fix that speeds up one path can slow another. Check the other main paths on the
   same copy before you keep it.
5. **Prove the output is identical.** This is what makes an optimisation safe to ship. Run the old and new code
   side by side on the same fresh copy and compare the results exactly, for example "64 of 64 queries identical",
   or one fingerprint over the whole result. A speed-up that changes results is a behaviour change, and it gets
   reviewed as one.
6. **Guard it with a structural test, not a timing assertion.** Timings in a test suite are noisy and fail for
   reasons unrelated to the change. Test the property instead: the query plan uses the index, the side table
   matches a full scan, no code path does the forbidden full-table lookup.
7. **Deploy, then measure live.** Committed is not deployed, and deployed is not running: a service may need a
   restart before it serves the new code. Report the live cold number, including the first call after a restart.
8. **Record the baseline and what would reopen it.** Write down the number, the conditions, and the trigger for
   another look ("cold latency doubles", "a timeout comes back", "the data grows enough to change the profile").
   Without it, the next pass has to measure from scratch to learn anything.

The commit message carries the before and after numbers and the equivalence proof.

## The periodic pass

For each active service with a recorded baseline:

1. Re-run the recorded measurement under the recorded conditions.
2. Compare it with the baseline. **More than twice as slow, or past a timeout or budget, is a finding.** Anything
   else is a line in the record, not a project.
3. With no baseline yet, take one. That is the deliverable. Profile only if a number is already bad.
4. Report a table - service, path, baseline, now, verdict - plus at most three fix candidates, each with its
   estimated size. Let whoever runs the service choose; do not start on a finding without a go-ahead.

A monthly check per active service is a sensible rhythm, plus whenever someone reports a timeout or "this is slow".

## A slow test suite

The same loop applies, and the first 80:20 check is free: **is the suite using the cores it has?** One suite of
about 1,400 tests took 817 seconds on one core while a parallel test runner sat installed on a 12-core machine.
Running it across 8 workers, grouped by file, took under 210 seconds, with no test changed.

1. **Time it from a run you needed anyway** (for pytest, `--durations=60`). Never run a suite just to time it.
2. **Run in parallel before optimising tests.** Grouping by file keeps expensive per-file setup, like servers or
   browsers, to one start per file. After that, the slowest single file sets the floor, so look at that next.
3. **Parallel runs expose shared-state bugs. Fix them; never go back to one core to hide them.** The classic one:
   a test picks a free port, closes it, and starts a server on it, and another worker grabs the port in the gap.
   Keep the socket open and hand it to the server.
4. **Per-test setup multiplies.** Build one template database per worker and copy the file for each test (one
   suite went from 84 ms to 3 ms per test this way). Every test still gets its own file.
5. **Give development its own fast tier:** everything that needs no browser, run in parallel, plus the tests for the
   area being changed. The full suite stays the release check.

## Traps

- **Don't double the quiet flag in pytest.** `addopts = "-q"` in the config plus `-q` on the command line becomes
  `-qq`, which drops the "N passed, M skipped" summary, so a log can no longer report its own counts.
- **A fresh copy is not the live system.** Copy and live can differ by 2x or more, so prove equivalence on a copy
  but quote latency from live.
- **The first call after a restart is not representative,** and neither is a warm repeat. Report both cold and warm.
- **Don't trust a profile of the wrong process.** Profiling a command-line wrapper shows you the wrapper.
===== END SKILL =====

Let's explore what AI can do for you and your team

  • Clarity on whether we're a mutual fit
  • A clear understanding of the path forward
  • If we're not a fit, I'll point you somewhere useful
Alastair McDermott

25 mins · Free · No obligation

Book a Focus Call