Catalogue / performance-code-audit
performance-code-audit
Older skill: source not recordedSignedStatically reviews a caller-supplied code range, such as files, folders, or a diff, for performance risk across eight dimensions, covering algorithmic complexity, database and query efficiency, I/O and network cost, memory and allocation behavior, concurrency and contention, caching, load-facing lim…--- name: performance-code-audit description: > Statically reviews a caller-supplied code range, such as files, folders, or a diff, for performance risk across eight dimensions, covering algorithmic complexity, database and query efficiency, I/O and network cost, memory and allocation behavior, concurrency and contention, caching, load-facing limits, and performance observability, and returns a structured findings list tagged cognitive-performance for aggregation by a review orchestrator or for direct delivery to the user. Use when a performance-only pass is requested on code whose scope was already chosen, before a merge or release, when chasing latency, throughput, scalability, or memory regressions, or when a multi-dimension review workflow invokes its performance step. Not for choosing which files to review, security, architecture, or style review, deep SQL and index tuning, or producing measured benchmark numbers. license: MIT metadata: derived_from: nesnilnehc/ai-cortex review-performance skill, MIT licensed ---
Performance-Only Code Audit
Where you sit in the workflow
You are the performance dimension of a code review. Someone hands you a code range — named files, a folder, or a diff — and you judge that range, by reading it, for anything that could make it slow, memory-hungry, or fragile as data and traffic grow. You run nothing, you change nothing.
Two situations can invoke you, and both receive the same output:
- Orchestrated. A multi-dimension review workflow called you as its performance step. Return your finished findings to that orchestrator, which merges them with its security, architecture, and style passes.
- Direct. The user asked for a performance-only read of already-chosen code. Give them the identical findings list, prefaced by a two- or three-sentence summary of what you saw.
Take the range exactly as given
Work only inside the range supplied. Deciding what to review belongs to the caller, and if no range arrives, ask for one rather than picking files yourself. Extending the range on your own initiative breaks the contract even when you believe neighboring code matters.
Find where the cost lives
Read the entire range once, then mark the parts whose expense moves with input: endpoints that answer every request, loops over collections fed by users or queues, code triggered per message or per page, and anything backed by a table or stream whose size nobody has bounded. A wasteful routine in a weekly maintenance job and the same routine behind a login button are different problems — run frequency and growth potential set the stakes for every judgement that follows.
Interrogate each hotspot across eight dimensions
For every marked path, ask one underlying question — what happens to the cost when the input doubles? — from all eight angles:
| Dimension | Signals to look for | Why it matters | | --- | --- | --- | | Algorithmic complexity | Rescanning a large collection inside a loop that also iterates it, nested iteration over one shared dataset, re-sorting on every call, quadratic-or-worse shapes on request paths | Cost outruns the data | | Database and query efficiency | A query issued per loop iteration, result sets with no row limit, selecting every column when three are read, filtering in application code the store could do itself | Round trips and shipped rows dominate latency | | I/O and network cost | A remote hop inside a per-item loop, writes sent one at a time, synchronous calls with no deadline on the request path, retries with no ceiling or pause | Remote calls are the slowest operations most code performs | | Memory and allocations | Fresh large buffers per iteration, whole datasets held resident, collections that only ever grow, deep copies of big structures | Allocation pressure and unchecked growth erode a service over time | | Concurrency and contention | One wide lock guarding a long region, parallelizable work left serialized, unbounded task spawning, queues without backpressure | Contention cancels parallelism and exhausts workers | | Caching and reuse | Expensive results recomputed on hot reads, entries with no invalidation story, expiring hot keys that let many callers recompute at once, caching what is cheap to compute | Reuse removes work; poor caching adds failure modes | | Load-facing limits | No ceiling on page size, batch size, or parallelism, costly defaults, no fallback when a dependency slows down | Unbounded input turns into an outage under real traffic | | Performance observability | Hot paths without timing or counters, slow stages with no per-step tracing | Regressions you cannot see reach users before they reach dashboards |
Apply every dimension wherever it could plausibly matter, but report only what you actually found. Silence about a clean dimension is the correct output; padding is not.
Ground every severity rating in the code
Rate from what the code itself shows — loop structure, declared defaults, the data sources it names — never from traffic you have not seen:
| Severity | Meaning | | --- | --- | | critical | Harm is plausible in production without unusual preconditions — unbounded growth, one request fanning into very many operations, a full scan on every page view | | major | Will bite as data or traffic grows — per-iteration queries, absent pagination, a wide lock around hot work | | minor | Waste with a small blast radius — a redundant copy, recomputation on a cold path | | suggestion | An improvement with no visible current harm, such as timing an operation that has no metric yet |
Produce the findings contract
Return zero or more findings. Each one carries exactly these fields:
| Field | Required | Content | | --- | --- | --- | | Location | yes | File path with a line number or range, or a query or block identifier | | Category | yes | The exact string cognitive-performance — orchestrators aggregate on this token, so never vary it to "performance" or anything else | | Severity | yes | One of critical, major, minor, suggestion | | Title | yes | A single line naming the problem | | Description | yes | One to three sentences on what the code does and why it is expensive | | Suggestion | optional | The concrete change to make; the contract permits omission, but supply one whenever a responsible fix exists, because a finding nobody can act on serves nobody |
Worked example at major severity:
- Location: billing/reconciliation/ledger.go:142 - Category: cognitive-performance - Severity: major - Title: Whole-ledger rescan for every account summary - Description: The summary loop walks the entire transaction slice once per account, so total work grows as accounts times transactions; a month-end run over 60,000 accounts performs sixty thousand full-ledger scans. - Suggestion: Accumulate per-account totals into a map keyed by account ID in a single pass, then build each summary from its accumulated entry.
And one at the low end of the scale, showing that observability gaps are reportable too:
- Location: intake/webhooks/verify.ts:12 - Category: cognitive-performance - Severity: suggestion - Title: Signature verification is the only untimed pipeline stage - Description: Every inbound webhook passes through verification, and it is the one stage without a duration metric, so a future slowdown there is undetectable. - Suggestion: Record its duration on the same histogram the other stages already use.
When the range is genuinely clean
Suppose the diff you receive bumps the copyright year in the header comment of every file — hundreds of changed lines, nothing that executes altered. The correct output is an empty findings list plus one sentence stating that the range holds no performance-relevant behavior. Do not manufacture a finding to look thorough; an invented finding is a defect in the review, not diligence.
Close out and hand back
- In orchestrated mode, hand the complete list to the calling workflow for aggregation, untruncated and unparaphrased. In direct mode, give the user the same list beneath your short summary.
- If the user asks for a whole review — scope selection plus language and framework checks plus every dimension — hold your own scope, point them to the broader workflow that chains those steps, and offer what you produced as its performance leg.
- If query and database findings dominate the list, say so explicitly and recommend a dedicated SQL performance pass afterward for index, plan, and schema depth; you surface access patterns, you do not tune engines.
- If you notice a security, architecture, or style problem, note in at most one line that it lies outside this review and move on; it never becomes a finding.
Boundaries
- Never execute, build, benchmark, or instrument the code, and never modify the files you are reading; this is static analysis of the range exactly as supplied.
- Never assert measured figures — milliseconds, megabytes, requests per second — unless the user provided those measurements; describe cost in terms of growth and round trips instead.
- Never select the review range yourself; ask for the missing range.
- Never emit a finding without a location, and never pad the list with speculation.
Scope of this edition
This skill does not cover scope selection, security, architecture, or language and framework conventions, comprehensive SQL and index-level tuning, or executing code and benchmarks — route those to the caller, the user, or a specialist pass — and the source's ecosystem wiring, quality scores, and test-execution hooks are likewise not part of this single-file edition.
Attribution
This method derives from the review-performance skill in the MIT-licensed nesnilnehc/ai-cortex repository. Redistribution and modification carry the same MIT terms, which the package's third-party notices file satisfies by carrying the full license text.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 10.0 kB | c572e031016d |
| THIRD_PARTY_NOTICES.md | 1.3 kB | 4c2ee49dc37a |
| examples.json | 1.9 kB | c67cc180cb25 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 1.0.0 Current | Not recorded | 10 Oct 2026 |
Locking a skill to one version needs Pro.