Performance Way¶
Source: hooks/ways/softwaredev/code/performance/performance.md
Frontmatter
| Field | Value |
|---|---|
description |
performance optimization, profiling, benchmarking, latency |
vocabulary |
optimize profile benchmark latency throughput memory cache bottleneck flamegraph allocation heap speed slow performance |
pattern |
slow|optimi|latency|cpu.?profil|flamegraph|speed.?up|benchmark|bottleneck|throughput|memory.?leak |
refire |
0.2 |
scope |
agent, subagent |
pattern_keep |
slow |
What Claude Should Do¶
When asked about performance, start with static analysis — don't just say "profile it":
- Scan for algorithmic issues: nested loops over collections (O(n^2)), repeated database/API calls inside loops (N+1), string concatenation in tight loops
- Identify the pattern, show the fix:
- N+1 queries → batched query or join (show the rewrite)
- Repeated computation → memoize or cache (show before/after)
- Unnecessary allocation → pre-allocate or reuse (show the change)
- Suggest profiling tools for the detected language:
- Python:
cProfile,py-spy,memory_profiler - Node.js:
--prof,clinic.js,0x - Rust:
cargo flamegraph,criterionfor benchmarks - Go:
pprof,benchstat
Generate Measurements¶
When the user wants to benchmark, produce before/after measurement code — don't just suggest "measure it".
Avoid¶
- Suggesting "just profile it" without analyzing the code first
- Micro-optimizations that hurt readability
- Caching without specifying an invalidation strategy