Profiling-driven performance optimization covering caching, query tuning, N+1 fixes, memory analysis, and load testing. Use to diagnose bottlenecks or set performance budgets.
Ships in knowledge-virtuoso. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Performance work follows one rule: measure before you change anything. Intuition about bottlenecks is wrong more often than right. Every optimization starts with profiling, forms a hypothesis, applies a targeted fix, and ends with another measurement.
| Principle | Meaning |
|---|---|
| Measure first | Never optimize without profiling data. Gut feelings about bottlenecks are unreliable |
| Optimize the critical path | Focus on the code that runs most often or blocks user-visible latency |
| Set budgets | Define acceptable latency, throughput, and resource usage before you start |
| Avoid premature optimization | Write readable, correct code first. Optimize only when measurements show a real problem |
| Know the tradeoffs | Every optimization costs something (memory for speed, complexity for throughput, freshness for latency) |
Profiling shows where time and resources go. Without it you are guessing.
| Type | What it reveals | When to use |
|---|---|---|
| CPU profiling | Hot functions, call frequency, execution time distribution | Slow request handling, high CPU usage |
| Memory profiling | Allocation rates, heap size, object retention, leaks | Growing memory usage, OOM errors, GC pressure |
| I/O profiling | Disk reads/writes, network calls, blocking waits | Slow file operations, external service latency |
| Database profiling | Query execution time, query count per request, slow queries | High DB load, N+1 patterns, missing indexes |
Define limits that trigger action when exceeded:
See Profiling Patterns Reference for profiling workflows, bottleneck signatures, and load testing strategies.
Caching removes redundant computation and data fetching by storing results closer to where they are needed.
| Layer | Location | Latency | Use case |
|---|---|---|---|
| L1 - In-process | Application memory (object cache, memoization) | Nanoseconds | Hot data accessed many times per request |
| L2 - Distributed | Redis, Memcached, shared cache | Sub-millisecond to low milliseconds | Data shared across application instances |
| HTTP cache | Browser, reverse proxy (Varnish, Nginx) | Zero network round-trip for client cache | Static assets, cacheable API responses |
| CDN | Edge servers worldwide | Low latency from geographic proximity | Static files, pre-rendered pages, media |
| Database cache | Query result cache, buffer pool | Varies | Repeated identical queries |
| Strategy | How it works | Best for |
|---|---|---|
| TTL-based | Cache entries expire after a fixed duration | Data that tolerates bounded staleness |
| Event-based | Cache is cleared when the source data changes | Data that must stay fresh after writes |
| Write-through | Writes update both the cache and the backing store at the same time | Read-heavy workloads needing strong consistency |
| Write-behind | Writes update the cache immediately; backing store is updated asynchronously | High write throughput where eventual consistency is acceptable |
When a popular cache key expires, many concurrent requests may all try to regenerate it at once and overwhelm the backend. Three approaches prevent this:
See Caching Strategies Reference for implementation patterns with multi-language examples.
Database queries are the most common performance bottleneck in web applications.
The N+1 problem occurs when code fetches a list of N records and then runs one more query per record to load related data. Instead of 1 query, it runs N+1.
Detection signals:
Prevention strategies:
Opening a database connection is expensive (TCP handshake, authentication, TLS negotiation). A connection pool keeps a set of reusable connections:
See Database Optimization Reference for query patterns, explain plan analysis, and multi-language examples.
| Pattern | Description |
|---|---|
| Object pooling | Reuse expensive objects instead of allocating and discarding them |
| Streaming | Process large datasets as streams instead of loading everything into memory |
| Lazy initialization | Defer creation of expensive objects until they are needed |
| Weak references | Hold references that do not prevent garbage collection |
| Buffer reuse | Allocate buffers once and reuse them across operations |
Lazy loading defers work until the result is needed. It reduces startup time and memory use, but adds complexity and can cause surprise latency later.
Where lazy loading helps:
Where lazy loading hurts:
Replace individual operations with batch alternatives where possible:
| Symptom | Likely cause | First investigation step |
|---|---|---|
| Slow response times, low CPU | I/O waits (database, network, disk) | Profile I/O and check query logs |
| High CPU, normal response times | Inefficient algorithms or excessive computation | CPU profile to find hot functions |
| Growing memory over time | Memory leak (unreleased references, unbounded caches) | Heap dump comparison over time |
| Intermittent slowness under load | Resource contention (locks, connection pool exhaustion) | Check pool sizes and lock wait times |
| Fast locally, slow in production | Network latency, missing caches, different data volumes | Compare profiling data between environments |
| Reference | Contents |
|---|---|
| Caching Strategies | Cache layers, invalidation patterns, stampede prevention, with multi-language examples |
| Database Optimization | Query optimization, N+1 prevention, connection pooling, batch operations, with multi-language examples |
| Profiling Patterns | Profiling workflows, bottleneck signatures, performance budgets, load testing strategies |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
profiling, caching, query-tuning, load-testing, bottleneck-analysis
/knowledge-virtuoso:performancefrom knowledge-virtuoso
npx claudepluginhub krzysztofsurdy/code-virtuoso --plugin knowledge-virtuoso6 skills in this plugin
/accessibilityWeb accessibility patterns and WCAG 2.1/2.2 compliance. Use to build accessible components, audit a UI for a11y issues, fix screen reader or keyboard problems, check contrast, or add ARIA./context-engineeringHow to budget and structure what a coding agent sees. Use when asked to trim, split or write AGENTS.md, CLAUDE.md, rules files or skill descriptions (for example 'CLAUDE.md is too long'), when an agent ignores instructions, forgets rules or drifts in long sessions, and when planning compaction or progress notes./debuggingSystematic debugging by root cause analysis. Use when facing a bug, test failure, flaky behavior, production error, or integration failure. Covers reproduce, hypothesize, fix, prevent, and post-mortems./docs-lookupLooks up current, version-correct docs before answering a library question from memory. Use when asked for an exact method signature, argument order, config key, CLI flag, or the call for 'our version' or a named version (for example 'in 7.2'). Check the docs or lockfile first even when sure, because APIs change between versions./securityApplication security principles and OWASP Top 10. Use to review code for vulnerabilities, implement authentication or authorization, handle secrets, configure security headers, prevent injection (SQL, XSS, CSRF), or prepare for an audit.Other plugins' skills for the same job