
How to Use
About
Profile and optimize application performance with Chrome DevTools, flame graphs, and APM tools.
name: perf-ops description: "Performance profiling and optimization orchestrator - diagnoses symptoms, dispatches profiling to language experts, manages before/after comparisons. Triggers on: performance, profiling, flamegraph, pprof, py-spy, clinic.js, memray, heaptrack, bundle size, webpack analyzer, load testing, k6, artillery, vegeta, locust, benchmark, hyperfine, criterion, slow query, EXPLAIN ANALYZE, N+1, caching, optimization, latency, throughput, p99, memory leak, CPU spike, bottleneck." license: MIT allowed-tools: "Read Edit Write Bash Glob Grep Agent TaskCreate TaskUpdate" metadata: author: claude-mods related-skills: debug-ops, monitoring-ops, testing-ops, code-stats, postgres-ops
Performance Operations
Orchestrator for cross-language performance profiling and optimization. Classifies symptoms inline, dispatches profiling to language expert agents (background), and manages optimization with confirmation.
Architecture
User describes performance issue or requests profiling
|
+---> T1: Diagnose (inline, fast)
| +---> Classify symptom (decision tree)
| +---> Detect language/runtime from project
| +---> Check installed profiling tools
| +---> Determine production vs development
| +---> Gather system baseline (CPU/mem/disk)
| +---> Present: diagnosis + recommended profiling approach
|
+---> T2: Profile (dispatch to language expert, background)
| +---> Select expert agent from routing table
| +---> Build perf-focused dispatch prompt
| +---> Expert runs profiler, collects data, interprets results
| | +---> Fallback: general-purpose with tool commands inlined
| +---> Returns: findings + bottleneck identification + suggestions
| |
| +---> [Optional parallel dispatch]:
| +---> CPU profiling agent ---+
| +---> Memory profiling agent --+--> Consolidate findings
| +---> Baseline benchmark ------+
|
+---> T3: Optimize (dispatch to expert, foreground + confirm)
+---> Expert proposes specific code changes
+---> Preflight: what changes, expected impact, risks
+---> User confirms
+---> Apply changes
+---> Re-benchmark for before/after delta
Safety Tiers
T1: Diagnose - Run Inline
No agent needed. Execute directly via Bash for instant results.
| Operation | Command / Method |
|-----------|-----------------|
| Detect Python profilers | which py-spy && which memray && which scalene |
| Detect Go profilers | which go && go tool pprof -h 2>/dev/null |
| Detect Rust profilers | which cargo-flamegraph && which samply |
| Detect Node profilers | which clinic && which 0x |
| Detect benchmarking tools | which hyperfine && which k6 && which vegeta |
| System CPU baseline | top -bn1 -o %CPU \| head -20 (Linux) or wmic cpu get loadpercentage (Win) |
| System memory baseline | free -h (Linux) or wmic OS get FreePhysicalMemory (Win) |
| Disk I/O check | iostat -x 1 3 (Linux) |
| Identify language | Check for package.json, go.mod, Cargo.toml, pyproject.toml, requirements.txt |
| Production vs dev | Ask user or detect from environment (NODE_ENV, FLASK_ENV, etc.) |
| Read existing profiles | Parse .prof, .svg, .bin files in project |
Production safety rule: In production environments, only recommend sampling profilers (py-spy, pprof HTTP endpoint, perf). Never suggest attaching debuggers, tracing profilers, or tools that require process restart.
T2: Profile - Dispatch to Expert Agent
Gather context from T1 diagnosis, then dispatch to the appropriate language expert.
Language Expert Routing:
| Detected Language | Expert Agent | Key Profiling Tools | |-------------------|-------------|---------------------| | Python (.py, pyproject.toml, requirements.txt) | python-expert | py-spy, memray, scalene, tracemalloc | | Go (go.mod, .go files) | go-expert | pprof (CPU/heap/goroutine/mutex), benchstat | | Rust (Cargo.toml, .rs files) | rust-expert | cargo-flamegraph, samply, DHAT, criterion | | TypeScript/JavaScript (backend, package.json + server) | javascript-expert | clinic flame/doctor/bubbleprof, 0x | | TypeScript/JavaScript (frontend, bundle issues) | typescript-expert | webpack-bundle-analyzer, Lighthouse, source-map-explorer | | SQL / PostgreSQL | postgres-expert | EXPLAIN ANALYZE, pg_stat_statements, pgbench | | General / unknown / CLI benchmarking | general-purpose | hyperfine, perf, strace |
Dispatch template (T2):
You are handling a performance profiling task dispatched by the perf-ops orchestrator.
## Diagnosis (from T1)
- Symptom: {classified symptom from decision tree}
- Language/Runtime: {detected language}
- Environment: {production | development}
- Installed tools: {list from tool detection}
- System baseline: {CPU/memory/disk metrics}
## Profiling Task
{spec
