Performance review
Reviews code for performance problems such as N+1 queries, work inside hot loops, unbounded memory growth, missing indexes, blocking I/O on the request path and chatty network calls. Use when the user asks why code is slow or to review a change for performance.
performance-reviewInstall
Run one command — it saves SKILL.md into your agent's skills folder. Restart the agent and the skill is picked up automatically.
mkdir -p ~/.claude/skills/performance-review && curl -fsSL https://anymodel.org/en/skills/code-review/performance-review/SKILL.md -o ~/.claude/skills/performance-review/SKILL.md
mkdir -p ~/.agents/skills/performance-review && curl -fsSL https://anymodel.org/en/skills/code-review/performance-review/SKILL.md -o ~/.agents/skills/performance-review/SKILL.md
New-Item -ItemType Directory -Force "$HOME\.claude\skills\performance-review" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/code-review/performance-review/SKILL.md -UseBasicParsing -OutFile "$HOME\.claude\skills\performance-review\SKILL.md"
New-Item -ItemType Directory -Force "$HOME\.agents\skills\performance-review" | Out-Null; Invoke-WebRequest https://anymodel.org/en/skills/code-review/performance-review/SKILL.md -UseBasicParsing -OutFile "$HOME\.agents\skills\performance-review\SKILL.md"
Any other agent: save the file into its skills folder, or give it the link to the file: https://anymodel.org/en/skills/code-review/performance-review/SKILL.md
SKILL.md
Performance Review
Find the performance problems that matter at realistic scale and ask for measurements before recommending micro-optimizations.
1. Establish the context
Before reading code, find out:
- What is slow or at risk: latency of one request, throughput, memory, startup, a batch job, a UI frame?
- What scale is realistic: rows in tables, requests per second, size of inputs, number of users?
- Is there a measurement already (profiler output, slow query log, APM trace, benchmark)? If yes, start from it.
If there is no number and the user claims "it is slow", ask for a reproduction or add a cheap measurement first (timing log around the suspect, EXPLAIN, a profiler run). Do not guess.
2. Look for the usual big wins
Work from the largest cost down. These beat any micro-optimization:
- N+1 queries: a query inside a loop over results of another query, or lazy-loaded relations accessed per item. Fix with a join,
IN (...)batch, or eager loading. - Missing indexes: columns used in
WHERE,JOIN,ORDER BYwithout an index; functions applied to indexed columns; leading wildcardLIKE '%x'. Verify with the database's explain tool. - Fetching too much:
SELECT *, loading whole tables to filter in memory, no pagination or limit, returning huge payloads. - Work inside hot loops: regex compilation, JSON parsing, config reads, object construction or sorting repeated per iteration instead of once outside.
- Quadratic behavior: nested loops over collections,
list.containsor arrayincludesinside a loop (use a set or map), string concatenation in a loop on large data. - Unbounded memory: collections, caches or queues that only grow; reading a whole file or response into memory instead of streaming; listeners or timers never removed.
- Blocking I/O on the request path: synchronous file, network or CPU-heavy work in an event loop or request handler; calls that should be queued or moved to a background job.
- Chatty network: many small sequential calls where one batch call works; independent calls that could run in parallel; no timeouts or connection reuse.
- Missing caching of stable, expensive results, or caching without invalidation or a size bound.
- Frontend: re-rendering large lists without keys or virtualization, large bundles loaded eagerly, layout thrash.
3. Verify, do not assume
For each suspect, state the cost model: "this runs once per row, rows are about 10k, each call is about 2 ms, so about 20 s." If you cannot estimate, mark the finding as unverified and propose the exact measurement.
# examples of cheap measurements
time ./run-job.sh
python -X importtime app.py 2> imports.log
node --cpu-prof script.js
psql -c "EXPLAIN (ANALYZE, BUFFERS) SELECT ..."
Run measurements only on the user's dev data and never against production without asking.
4. Output format
Summary: <what was reviewed, the one biggest risk>
[high] path/to/file.js:57 - N+1 query in order listing
Cost: <estimate: calls x time at realistic size>
Evidence: <measured / read from code / unverified>
Fix: <specific change, with the expected effect>
[medium] ...
[low] ...
Measurements to take: <what to run to confirm or rule out unverified findings>
Leave alone: <things that look slow but are not on a hot path>
Pitfalls
- Do not micro-optimize (loop style,
forvsmap, small allocations) without a profile showing it matters. - Do not trade readability for a speedup nobody can measure.
- Do not add caching as a first answer; remove the redundant work first.
- Do not change query semantics (ordering, null handling) while rewriting for speed; check results are identical.
- Do not forget the write side: new indexes slow inserts and take disk; say so.
- Before and after numbers belong in the report if you changed anything; if you did not measure, say that explicitly.
Source: AnyModel skills catalog · License: CC BY 4.0
Connect through AnyModel API
This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.
AnyModel