diagnose-slow
Skill2 starsChanged 10 days agoMITView on GitHub
Find out what is actually slow before changing any code. Use when a page, endpoint, query, build, test suite or device feels slow, when someone proposes a cache, an index, an async rewrite or a faster library without a measurement, or when a performance problem keeps coming back after a previous "fix".
In this repository8 other files it gives its agents.
- api-contractSkill
- bilingual-docsSkill
- debug-connectivitySkill
- plan-migrationSkill
- release-verifySkill
- review-diffSkill
- write-a-skillSkill
- write-postmortemSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Before deliberately trading correctness or complexity for speed.
- Very specific: line 19
Not for: a hang that never completes (see debug-connectivity), or an outage.
- Distinctive: line 28
Amdahl's law is not optional: If one step is 60 % of the time, halving everything else caps you at a 20 % improvement.
- Distinctive: line 39
Time the phases: Put a stopwatch around each boundary you can see: request → handler → query → serialise → render.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.
Files
Diagnose slow before optimising
"Slow" is not a diagnosis. A number is. Until you know whether the time is spent in the database, the
network, the renderer, or a sleep, every optimisation is a guess with a maintenance cost attached.
When to use
- "The app is slow", "this endpoint is slow", "the build takes forever".
- A performance change is proposed without a profile, a timing breakdown, or a baseline number.
- A previous optimisation did not help — which usually means it targeted the wrong layer.
- Before deliberately trading correctness or complexity for speed.
Not for: a hang that never completes (see debug-connectivity), or an outage.
Ground rules
- Measure the whole path first, then narrow. A stopwatch around the outer call is enough to start; a profile is what you need second.
- One number, one environment, one workload. "Faster" without a repeatable input is an opinion.
- Record the baseline before touching anything — in the report, with the command that produced it.
- Optimise the biggest term, not the easiest one. A 90 % win on 5 % of the time is noise.
- Amdahl's law is not optional. If one step is 60 % of the time, halving everything else caps you at a 20 % improvement.
- Distinguish latency from throughput. A single slow request and a saturated service have different causes and different fixes.
Procedure
- Write the user-visible claim with a number. "The list page takes 4.2 s to first row on a laptop with a warm cache" — not "it is slow". If nobody can state the symptom numerically, that is the first task.
- Time the phases. Put a stopwatch around each boundary you can see: request → handler → query → serialise → render. Even coarse instrumenting (six timestamps in a log line) turns "everything is slow" into "one step is 80 %".
- Reproduce with a fixed workload. Same input size, same machine, same cache state, same concurrency. Record the exact command. A measurement you cannot repeat is a rumour.
- Profile the dominant phase. CPU profile for CPU-bound work, a query log /
EXPLAIN (ANALYZE)for databases, a network waterfall for HTTP, a trace for UI. The tool depends on the phase; do not profile everything. - Look for the usual suspects before the exotic ones — N+1 queries, a missing index, a synchronous call in a loop, serialisation of a large object graph, a layout thrash in a list, an unbounded cache, a cold start that re-does work on every request.
- Change one thing, re-measure with the same command, and report the delta. If the delta is inside the noise of your measurement, you have not learned anything — measure better or accept the result.
- Decide when to stop. State the target ("p95 under 300 ms for 1 000 rows"), and whether it was met. Shipping 20 % and pretending it is done is how a slow feature becomes folklore.
Anti-patterns
| Tempting move | Why it is wrong |
| Adding a cache first | It hides the cost and adds a correctness problem (invalidation) you will debug for months |
| Rewriting in a "faster" language or library | The bottleneck is usually I/O or an algorithm, both of which follow you |
| Parallelism as the first fix | If the work is 90 % serial, threads add load and change nothing |
| Optimising the build while the app is slow | Two different problems; pick the one the user feels |
| Micro-benchmarks of a function that runs once | Measure the system, not the snippet |
| Quoting a single run | One sample is not a measurement; run it three times and report the spread |
Definition of done
- A baseline number exists, with the exact command and environment that produced it.
- The dominant phase is named, with evidence (profile, query plan, trace, timing breakdown).
- The change addresses that phase; the delta is measured with the same command.
- Correctness is unchanged, or the trade-off is stated explicitly.
- A regression guard exists if practical: a benchmark, a query-count assertion, a budget in CI.
- What remains slow, and why it was left alone, is written down.
Report format
Claim: <user-visible symptom with a number>
Baseline: <command> → <p50 / p95 / total>, <environment>, <input size>
Dominant: <phase> — <% of total>, evidence: <profile/plan/trace>
Change: <one sentence>
After: <same command> → <new number>, <delta %>, <spread over runs>
Trade-off: <what got worse, if anything>
Left alone: <what is still slow and why>See references/measurement.md for the tooling table per layer, plus the statistics that stop a measurement from lying to you.
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
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.

