Skip to content
Back to skills

Perf Diagnosis

ASecurity

Diagnoses an app's performance by measuring before changing anything. Finds the bottleneck (a process's CPU, the database, the event loop, the pool, an upstream), says how it was checked (path:line + measurement) and, when the measurement is missing, says what to measure and how locally (k6, think time, p95/p99, CPU per process) before proposing a cache, another runtime, scaling or load balancing. Reports and stops. Use it for "my app is slow", "why is this endpoint slow?", "how many users ca...

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 17, 2026
developmentgosqlnodedockerdebuggingapidatabaseci/cdsecurityperformance

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned November 17, 2026

npx -y skills add OmarAlex24/audit-skills --skill perf-diagnosis --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Perf Diagnosis?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Perf Diagnosis
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/omaralex24-perf-diagnosis/badge)](https://www.skillsdirectory.com/skills/omaralex24-perf-diagnosis)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: perf-diagnosis
description: Diagnoses an app's performance by measuring before changing anything. Finds the bottleneck (a process's CPU, the database, the event loop, the pool, an upstream), says how it was checked (path:line + measurement) and, when the measurement is missing, says what to measure and how locally (k6, think time, p95/p99, CPU per process) before proposing a cache, another runtime, scaling or load balancing. Reports and stops. Use it for "my app is slow", "why is this endpoint slow?", "how many users can my server handle", "find the bottleneck", "load test this", "is it the database or the CPU?", "p99 is spiking", "should I add caching", "should I switch to Bun?", "hot partition", "add a cache node", even without the word "performance". Other topics go to architecture-review, infra-review, code-structure, data-consistency, api-security-review, correctness-review. Also triggers on Spanish requests such as "la app va lenta", "¿cuántos usuarios aguanta mi servidor?", "encuentra el cuello de botella" or "¿pongo Redis?".
---

# Performance diagnosis

Answers two questions about a user's app: **where the time goes** and **how much load it takes before it breaks its own criteria**. Every answer carries its evidence. A `path:line` says where the problem could be; saying it *is* the bottleneck takes a measurement. If that measurement does not exist, the deliverable is the plan to take it, not a fix.

The method comes from one concrete experiment: a $12 VPS (1 shared vCPU, 2 GB) running Nginx → Node → Postgres. Users who browse at their own pace were modeled, load went up until p95/p99/errors broke, and what ran out was the box's CPU, shared by Node, Postgres and Nginx, not RAM, disk or locks. Then repeated work was removed with a cache before buying hardware ([sources](references/sources.md)). The numbers from that video and others are in [references/benchmarks.md](references/benchmarks.md) **as reference, not as truth**. Always measure again in the user's app.

Write the report in the user's language.

## Non-negotiable rules

- **Report first.** Phases 0 to 5 do not modify the repo, install dependencies, apply migrations or commit. Some measurement steps change state on the machine without touching the code: starting containers, seeding a database, running a build, installing k6 or adding a temporary log. Those steps go in the plan marked with ✋ and run only with the user's OK.
- **Nothing against shared systems.** No load test, `EXPLAIN ANALYZE`, query or write against production, staging or any shared environment without the user's explicit confirmation. Before touching a database, print what it points to (`host:port/db`, where the value came from) and wait for confirmation if it is not local.
- **Outbound dependencies count.** A local test can also hit other people's systems: a remote DB in `.env`, payment APIs, LLM providers, email or webhooks. Before any load, list those targets and print them. Each one gets a stub or the user's confirmation.
- **Video numbers do not replace a measurement.** If you cite one, it goes with its conditions (hardware, load, version) and with the instruction to measure in the user's app.
- **Hypothesis and finding do not mix.** Every candidate in the report carries its confidence (**Confirmed**, **Likely** or **Smell**) and its method (**reading**, **measurement** or **both**). Only a candidate with method measurement or both is reported as a bottleneck; without a measurement it is Likely at most, and the unverified step is the measurement.

## Phase 0: scope and environment

1. Fix the scope: which app, which endpoints or flows, which symptom (high latency, timeouts, CPU, the bill). In a monorepo with no hint, ask.
2. Read the project's rules (AGENTS.md, CLAUDE.md, CONTRIBUTING.md, architecture docs).
3. Draw the path of a request: client → proxy/CDN → app process(es) → DB, cache and external dependencies. Note runtime and version, framework, how many processes or workers, the connection pool and where each piece runs (same machine, another VM, managed service).
4. **Print the targets**: the DB that `.env`/config points to in each environment and every outbound dependency on the hot path. Without this step there is no phase 3.
5. Detect what is available to measure without installing anything: `command -v k6 oha autocannon wrk hey`, `docker`, `psql`/`sqlite3`, the operating system (`uname`). macOS has no `steal`, `pidstat` or `mpstat`. The table per platform is in [references/measurement.md](references/measurement.md#tools-by-platform).
6. If it is a managed platform (Cloudflare Workers, Lambda, Vercel, Fly Machines), follow the branch in [references/measurement.md](references/measurement.md#managed-platforms). There is no box CPU to look at there: the time goes into round trips, cold starts and upstreams.

## Phase 1: are there measurements already?

Look for evidence that already exists before producing new evidence: metrics or APM, logs with duration per request or per dependency, `pg_stat_statements`, the slow query log, results of earlier load tests or benchmarks in the repo. An existing number counts if it states its conditions: environment, load and date. Note it with its source.

## Phase 2: candidates in the code (static)

Read [references/signals.md](references/signals.md) and walk the hot path from phase 0. For each candidate note:

- `path:line` and what it does there (for example, "query per post in the feed").
- **Hypothesis** (Likely or Smell while there is no measurement): which resource it would consume (process CPU, DB, connections, network, upstream). If you give an order of magnitude (rows read per request, for example), mark it as **estimate, not measurement**.
- **How to confirm it**: the exact measurement, what to look at and **which result rules it out**.

Rule out false positives with reasons: code that is not on the hot path, small tables that fit in memory, a job that runs at night. There is no need to measure what the code already rules out.

## Phase 3: local measurement plan (if the measurement is missing)

This is the central phase when there is no data. Follow [references/measurement.md](references/measurement.md) and deliver commands ready to run:

0. **Cheapest first.** If the local database is already up and its target is local, the volume (`count(*)`, sizes) and the plans (`EXPLAIN (ANALYZE, BUFFERS)` of the candidate `SELECT` queries) in a read-only session (`PGOPTIONS='-c default_transaction_read_only=on'`) often turn a hypothesis into data without starting or installing anything. Pass the parameters as literals, the same way the app passes them; a subselect can give a different plan. Check that the service is up with a filter (`docker ps --filter name=…`, `lsof -iTCP:<port>`), not with a truncated listing.
1. **Isolated local environment** with data seeded at a realistic volume and external dependencies stubbed.
2. **The question.** Pick one:
   - where the time goes (profiling and query count per request);
   - how much it takes with more users (load ladder);
   - how much it takes with more data (volume ladder; this is the one that matters in internal apps with few users);
   - before and after a change.
3. **User model**: virtual users that follow a real flow with think time, not N requests at once. If the client polls or auto-refreshes, every open tab is a user that requests every N seconds. Compute its req/s per user. Each virtual user with its own account or token. Measure the same request the client makes (headers, cookies) against a production build, not dev mode.
4. **Success criteria fixed before running**: p95, p99 and error rate. The user picks the values.
5. **Ladder**: go up in stages until a criterion breaks, narrow down the limit and confirm it with 3 runs.
6. **Ceiling per endpoint**: the same endpoint with no think time, to know how much headroom is left.
7. **Monitor during the run**: total CPU and **per process** (app, DB, proxy), RAM and swap, active and waiting queries in the DB, cache hit, event loop lag and the load generator's CPU.

Say what a local run answers and what it does not. It answers which resource runs out first, the time split per stage and the before-and-after comparison on the same machine. **It does not give production capacity**, because the generator competes with the app for CPU and the hardware is different.

If the user approves running the plan and every target is local, run it and go to phase 4 with data.

## Phase 4: locate the bottleneck with the data

Read the results with the table in [references/measurement.md](references/measurement.md#how-to-read-the-results). The readings that come up most:

- The tail (p95/p99) breaks before the median. When the median also jumps to seconds, arrivals exceed service capacity and the queue grows without end.
- App and DB on the same machine with total CPU near 100%: the exhausted resource is the box's CPU. The report gives the split per process (in the video, Node 53%, Postgres 38%, Nginx 8%). Removing work from any of them helps; the video's cache won precisely because it skipped Postgres. A DB with 0 waiting queries rules out locks and contention, not its CPU cost.
- One process near 100% of **one core** on a multi-core machine: the bottleneck is that process's CPU. A single Node process at 100% shows as 25% of the total on 4 cores.
- Low CPU with high latency: something is being waited on (pool, locks, upstream, disk), or synchronous work is blocking the event loop.
- The DB with waiting queries, locks, sequential scans or a low cache hit: the bottleneck is the database.
- CPU with headroom and failures as open connections approach tens of thousands: look at kernel limits (conntrack, file descriptors) before the code. In one of the video challenges, CPU was at 52% when the connection table hit 65,536.
- The generator near its CPU limit: the result is a floor, not a ceiling.

The verdict says which resource, at which `path:line` and with which measurement. If two candidates remain that you could not separate, say so and propose the measurement that separates them.

## Phase 5: report and stop

Use [references/report-template.md](references/report-template.md). It goes in the chat, in the user's language, and is saved to a file only if they ask. The fixes from [references/fixes.md](references/fixes.md) are ordered **from lightest to heaviest**: remove repeated work before changing framework or runtime (and, on a small box, check how much CPU the proxy takes), and change runtime before buying hardware or splitting the system. Each one is **conditional on the measurement** that justifies it and carries its cost: stale data, harder debugging, operations. End by asking what to apply and **stop**.

## Phase 6: apply (only what the user picked)

- Before touching anything, a test or a reproducible benchmark that captures the current behavior and the baseline number.
- One change at a time, measured with the same load and the same criterion as the baseline. If it does not improve the metric that motivated the change, revert it or report it as such.
- Run the project's checks (lint, typecheck, tests). No commits or PRs unless asked.

## Out of scope: which skill to point to

- Monolith versus microservices as a decision, choosing a database and designing a partition key → `architecture-review`. Only the **measured cost** belongs here (network hops, CPU per request, hot partition as a symptom).
- Observability and alarms, containers, K8s, platform limits and the rest of the infrastructure (IaC, environments, Docker and compose, K8s, CI/CD, deploy, config and secrets management, backups and restore, monitoring and alarms, platform limits, infrastructure SPOFs, pinned versions and infra cost) → `infra-review`. Only what costs time or CPU, measured, belongs here.
- Module or layer boundaries that are not respected, dependency cycles, the same problem solved several ways, god-modules, unused code or packages and docs or ADRs that contradict the code → `code-structure`.
- Retries, queues, idempotency and consistency between a cache and its source → `data-consistency`. Only load amplification belongs here.
- Rate limiting and throttling as a defense → `api-security-review`.
- State and transitions spread across the code → `implicit-state-machines`.
- A calculation that gives a wrong result (formula, ms versus s units, bounds, rounding) → `correctness-review`. Only what costs time or CPU belongs here.
- Code that calls an LLM: timeouts that do not cancel the call, retries that get billed, tool loops or `max_tokens` with no cap, provider failures that pass as valid answers → `llm-app-review`. Only the measured latency of the call and the load belong here.

## Swarm mode

It turns on when the invocation brings a swarm brief (between `[swarm brief]` and `[end of brief]`), with `contract:`, `map:`, `structure:`, `output:` and `data:`. Used on its own, the skill follows the procedure above unchanged, report included. In this mode:

- **Phases:** follow phases 0 to 4. From phase 3 run only step 0 (volume and `EXPLAIN` of `SELECT`), and only with the `data:` command; the rest of the plan goes to `requested_measurements` and the ✋ steps never run. The brief's map replaces reading the rules, the request path and the deployment in phase 0, but read what the map points to and whatever it is missing.
- **No questions and no waiting:** what you would ask the user goes to the `questions` field; you do not stop to wait for an answer.
- **No subagents or reviewers:** the swarm does the independent verification. This overrides any review with subagents. Make the pass that tries to rule out each finding yourself, prioritize by the map's hot paths and declare in `not_covered` what you did not cover.
- **Data:** only the `data:` command. You never open connections, tunnels or scripts of your own, and you do not read `.env` looking for credentials. If `data:` is "none", what you would have measured goes to `requested_measurements`. It is the only target: you do not print or test other targets from `.env`, and outbound dependencies are only listed.
- **Slice:** if the brief brings `slice:`, you only report findings whose main location (`locations[0]`) is in that slice; the membership rule is in the brief and other auditors of this same skill have the other slices. You may open files outside it only to follow a sequence that starts in your slice, and each one goes to `outside_slice` with the reason. A defect that starts outside is not yours: at most, one line in `not_covered` with its path:line. The slice section (`slice map:`) completes the global map. What the brief marks in `exclude:` belongs to no slice: you do not audit it, do not cite it as evidence and do not report anything whose main location falls there; you may open it only to understand a call that leaves the scope, and then it goes to `outside_slice` with the reason.
- **Limits:** you do not modify the audited repo and you do not read other audit runs or other auditors' folders, except what the brief gives you: contract, map, `structure:` and your folder.
- **Metric:** fill `metric` in each finding per `before-after.md` (next to the contract the brief gives), with this skill's row of its "Guide per skill" as the hint: the same measurement with N runs: median and p95 latency, queries per request, ms per iteration, CPU or memory, with at least 5 runs per side for what varies. A metric is a command that is run again, never a count of findings, and you do not invent its result: `{not_measurable: "<why>"}` is valid.
- **Output:** a single file, `findings.json`, in the folder the brief gives (`your folder:`), with the contract's object, and that same object as your answer. In swarm mode you write no readable report and no other file: the report template is for normal mode and the swarm's plan comes from the `findings.json` files. Use the contract's vocabulary: confidence, method, severity, effort and action.

Files in this skill

  • SKILL.md15.7 KB
  • references/benchmarks.md22.3 KB
  • references/fixes.md14.7 KB
  • references/measurement.md19.9 KB
  • references/report-template.md3.3 KB
  • references/signals.md16.9 KB
  • references/sources.md13.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.