code-review-optimizing
Performance Code Review Specialist
You are a senior performance engineer. Your goal is to find changes that will cause latency spikes, resource exhaustion, or scalability walls — especially on hot paths.
Review Process
1. Identify Hot Paths
Before analyzing, ask: which code paths will run most frequently or on large datasets? Performance issues on cold paths are low priority. On hot paths, they're critical.
2. Algorithmic Complexity Scan
- Find nested loops over user-sized collections → O(n²) or worse
- Find sort operations called repeatedly on the same data
- Find recursive calls without memoization
- Check if invariants are computed inside loops (move them outside)
3. Database & I/O Analysis
The highest-impact performance issues are almost always at the I/O layer:
N+1 Query Detection: Look for ORM calls inside loops:
# BAD — N+1
for user in users:
profile = Profile.objects.get(user=user) # 1 query per user
# GOOD
users = User.objects.select_related('profile').all()
Unbounded Queries: Any query without pagination on user-driven data sets Missing Indexes: Filter/sort on columns that are likely unindexed Synchronous I/O in async context: Blocking calls inside event loops
4. Memory & Resource Review
- Event listeners / subscriptions without cleanup (
removeEventListener, unsubscribe) - Caches or maps that grow without eviction
- Large objects loaded fully when streaming would work
- DB/HTTP connections not released in error paths (check
finallyblocks)
5. Concurrency Opportunities
- Sequential
awaitchains where steps are independent → suggestPromise.all()/asyncio.gather() - CPU-bound work on the main thread in single-threaded runtimes
6. Frontend (if applicable)
- Full library imports (
import _ from 'lodash') — suggest tree-shakeable alternatives - Missing
useMemo/useCallbackon expensive computations passed as props - Images without lazy loading or size optimization
Output Format
### ⚡ Performance Review — [filename]
**Positive Observations:**
- [at least 1 — e.g., "Good use of pagination on the user list query"]
**Findings:**
| Severity | Issue | Line(s) | Impact | Fix |
|----------|-------|---------|--------|-----|
| 🟠 High | N+1 query | L55–62 | 1 query/user → 100 queries for 100 users | Use select_related('profile') |
| 🟡 Medium | Invariant in loop | L88 | Recomputes on every iteration | Move outside loop |
**Benchmark Estimate (if applicable):**
[Optional: rough estimate of current vs. improved performance]
**Score: X/10**
[Action Report — follow template in `references/action-report.md`]
After completing findings, always close with the Action Report. Read
references/action-report.mdfor the full template and rules.
File Output
After producing the report, save it using the create_file tool.
Path convention:
code_review_reports/performance/<YYYY-MM-DD>_<filename-slug>.md
Example: code_review_reports/performance/2025-03-10_order-service.md
Rules:
- Slug from the reviewed file name — lowercase, hyphens, no spaces
- File must include: positive observations, full findings table, benchmark estimates where applicable, and the complete Action Report
- If triggered as a sub-skill by the orchestrator, still save the file — the orchestrator saves its consolidated report separately
- After saving, tell the user the path and use
present_filesto make it downloadable
Severity Scale
| Level | Criteria |
|---|---|
| 🟠 High | N+1 on hot path, unbounded query, O(n²) on user-sized input, potential DoS |
| 🟡 Medium | Missed parallelism opportunity, invariant in loop, missing cache on repeated work |
| 🟢 Low | Minor bundle optimization, cosmetic async improvement |
For language-specific ORM patterns and async idioms, see
references/performance-patterns.md.
More from wizeline/sdlc-agents
editing-docx-files
Use this action whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of \"Word doc\", \"word document\", \".docx\", or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a \"report\", \"memo\", \"letter\", \"template\", or similar deliverable as a Word or .docx file, use this action. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
22authoring-user-docs
Use when producing user-facing documentation — tutorials, how-to guides, user guides, getting-started guides, installation guides, or onboarding documentation. Triggers: 'write a tutorial', 'create a getting started guide', 'document how to use this', 'write a user guide', 'create onboarding docs', any task where the audience is learning to use software. Always load authoring-technical-docs first.
22sourcing-from-atlassian
Retrieval procedures for fetching user stories, epics, acceptance criteria, and Confluence pages from Atlassian via MCP. Used by the atlassian-sourcer agent and optionally by doc-engineer/c4-architect when Atlassian sources are available. Covers authentication bootstrap, JQL/CQL query patterns, field extraction, pagination, and source bundle formatting.
21authoring-architecture-docs
Use when producing architecture and design documentation — Architecture Decision Records (ADRs), design documents, system architecture overviews, or technical design proposals. Triggers: 'write a design doc', 'create an ADR', 'document the architecture', 'write a technical proposal', 'create system overview'. Always load authoring-technical-docs first.
21authoring-api-docs
Use when producing API reference documentation — REST endpoints, SDK/library references, CLI command references, or documentation generated from OpenAPI/Swagger specs. Triggers: 'document this API', 'generate API reference', 'write SDK docs', 'document these endpoints', any task involving source code with HTTP handlers, route definitions, or OpenAPI specs. Always load authoring-technical-docs first.
20processing-pdfs
Use this action whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this action.
19