From cortexloop
Optimizes code by establishing baselines, analyzing algorithmic complexity, and applying targeted fixes with before/after proof. Use for latency, N+1 queries, and React re-render performance reviews.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cortexloop:performance-optimizationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Methodology adapted from [performance-deity](https://github.com/v0idOS/performance-deity) (MIT). Every optimization must be proven with real numbers.
Methodology adapted from performance-deity (MIT). Every optimization must be proven with real numbers.
Optimize code by measuring first, analyzing bottlenecks, applying targeted fixes, and proving improvement with before/after benchmarks. Never guess at performance — measure, fix, verify.
/cortexloop performance passWhen NOT to use:
Execute all four phases in order. Do not skip any phase when applying fixes in Direct mode.
time / built-in profilers if the script fails due to missing deps.State explicitly:
user_id"Apply fixes in priority order (highest impact first):
| Category | Patterns to fix | Typical fix |
|---|---|---|
| Database | N+1, missing indexes, SELECT * | JOIN/batch load, EXPLAIN ANALYZE, add index |
| Algorithm | O(n²) lookups, repeated scans | Hash map/set, sort + binary search |
| Memory | Unbounded arrays, leak refs | Pagination, streaming, weak refs / cleanup |
| Async | Sync I/O on hot path | async/await, parallel with limits |
| Network | Over-fetching, no cache | GraphQL field selection, ETag, compression |
| Frontend | Re-renders, large bundles | memo, virtualization, code splitting |
| Build | Slow CI, cold builds | Cache layers, incremental builds |
After each change in Direct mode:
Present a Performance Report table for every applied optimization:
| Metric | Baseline | Optimized | Δ |
|---|---|---|---|
| Average | Xms | Yms | -Z% |
| P95 | Xms | Yms | -Z% |
Follow with a one-paragraph explanation grounded in CPU/memory/I/O theory.
In Report mode (no changes applied), use this table with projected improvements and mark as estimated until verified.
- [ ] Run EXPLAIN ANALYZE on slow queries
- [ ] Check for N+1 (ORM eager vs lazy loading)
- [ ] Verify indexes on WHERE/JOIN/ORDER BY columns
- [ ] Pagination on list endpoints (limit + cursor/offset)
- [ ] Avoid SELECT * — fetch only needed columns
- [ ] Profile with React DevTools — identify avoidable re-renders
- [ ] memo/useMemo/useCallback only where profiling shows benefit
- [ ] Virtualize long lists (react-window, tanstack-virtual)
- [ ] Dynamic import for heavy components
- [ ] Check bundle size impact (next/bundle-analyzer or equivalent)
- [ ] No sync fs/crypto on request path
- [ ] Connection pooling for DB/Redis
- [ ] Rate-limit expensive endpoints
- [ ] Cache pure/read-heavy responses with TTL
- [ ] Profile with cProfile/py-spy before optimizing
- [ ] Vectorize with numpy/pandas where appropriate
- [ ] Use generators for large datasets
- [ ] Avoid repeated regex compilation in loops
| Severity | Criteria |
|---|---|
| Critical | O(n²) or worse on user-facing path; unbounded memory; blocks event loop |
| High | N+1 queries; missing pagination; measurable P95 > 500ms on core flow |
| Medium | Avoidable re-renders; missing cache; suboptimal but acceptable |
| Low | Micro-optimization; premature unless hot path |
## Performance Findings
### [SEVERITY] [Title]
- **Location:** path:line
- **Bottleneck:** [precise description]
- **Current complexity:** O(?)
- **Baseline:** Avg Xms, P95 Yms (or "not measured — static analysis only")
- **Recommendation:** [specific fix]
- **Projected improvement:** [estimate or measured Δ]
npx claudepluginhub whitequeen306/code-cortex-loop --plugin cortexloopOptimizes code for performance, readability, or efficiency: measures baselines, profiles bottlenecks, fixes frontend (React re-renders, bundles), backend, database issues. Use for slowdowns or high usage.
Measures and fixes performance bottlenecks in code, databases, and APIs using profiling, query analysis, and caching. Applies when users mention slowness or high response times.
Analyzes and optimizes performance across frontend, backend, and database layers: CPU, memory, I/O, bundle size, queries, images, and rendering.