Performance profiling, optimization techniques, and benchmarking methodology. Use when profiling code, optimizing bottlenecks, benchmarking implementations, analyzing memory usage, improving latency, or when performance, profiling, benchmarking, optimization, memory-leak, or --perf are mentioned.
/plugin marketplace add outfitter-dev/agents/plugin install baselayer@outfitterThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/benchmarking.mdEvidence-based performance optimization → measure → profile → optimize → validate.
<when_to_use>
NOT for: premature optimization, optimization without measurement, guessing at bottlenecks </when_to_use>
<iron_law> NO OPTIMIZATION WITHOUT MEASUREMENT
Required workflow:
Optimizing unmeasured code wastes time and introduces bugs. </iron_law>
<phases> Use TodoWrite to track optimization process:Phase 1: Establishing baseline
Phase 2: Profiling bottlenecks
Phase 3: Analyzing root cause
Phase 4: Implementing optimization
Phase 5: Validating improvement
Latency (response time):
Throughput:
Memory:
CPU:
Always measure:
<profiling_tools>
Built-in timing:
console.time('operation')
// ... code to measure
console.timeEnd('operation')
// High precision
const start = Bun.nanoseconds()
// ... code to measure
const elapsed = Bun.nanoseconds() - start
console.log(`Took ${elapsed / 1_000_000}ms`)
Performance API:
const mark1 = performance.mark('start')
// ... code to measure
const mark2 = performance.mark('end')
performance.measure('operation', 'start', 'end')
const measure = performance.getEntriesByName('operation')[0]
console.log(`Duration: ${measure.duration}ms`)
Memory profiling:
--inspect flag + Chrome DevToolsprocess.memoryUsage() for RSS/heap trackingCPU profiling:
--prof flag + node --prof-processBenchmarking:
#[cfg(test)]
mod benches {
use criterion::{black_box, criterion_group, criterion_main, Criterion};
fn benchmark_function(c: &mut Criterion) {
c.bench_function("my_function", |b| {
b.iter(|| my_function(black_box(42)))
});
}
criterion_group!(benches, benchmark_function);
criterion_main!(benches);
}
Profiling:
cargo bench — criterion benchmarksperf record + perf report — Linux profilingcargo flamegraph — visual flamegraphscargo bloat — binary size analysisvalgrind --tool=callgrind — detailed profilingheaptrack — memory profilingInstrumentation:
use std::time::Instant;
let start = Instant::now();
// ... code to measure
let duration = start.elapsed();
println!("Took: {:?}", duration);
</profiling_tools>
<optimization_patterns>
Time complexity:
Space-time tradeoffs:
Reduce allocations:
// Bad: creates new array each iteration
for (const item of items) {
const results = []
results.push(process(item))
}
// Good: reuse array
const results = []
for (const item of items) {
results.push(process(item))
}
// Bad: allocates String every time
fn format_user(name: &str) -> String {
format!("User: {}", name)
}
// Good: reuses buffer
fn format_user(name: &str, buf: &mut String) {
buf.clear();
buf.push_str("User: ");
buf.push_str(name);
}
Memory pooling:
Lazy evaluation:
Batching:
Caching:
Async I/O:
Query optimization:
Schema design:
Connection management:
At each step:
Check gains:
Check regressions:
Check documentation:
NEVER:
Related skills:
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.