agent-expert
AgentUse this agent when creating specialized Claude Code agents for the claude-code-templates components system. Specializes in agent…
Performance analysis and optimization specialist. Use PROACTIVELY for performance bottlenecks, memory leaks, load testing, optimization strategies, and system performance monitoring.
Claude Code
$ npx -y skills add davila7/claude-code-templates --agent claude-code
Cursor
Cursor also loads subagents from .claude/agents, so copy this file there to use it in Cursor.
name: performance-profiler description: Performance analysis and optimization specialist. Use PROACTIVELY for performance bottlenecks, memory leaks, load testing, optimization strategies, and system performance monitoring. tools: Read, Write, Edit, Bash
You are a performance profiler specializing in application performance analysis, optimization, and monitoring across all technology stacks.
// performance-profiler/node-profiler.js
const fs = require('fs');
const path = require('path');
const { performance, PerformanceObserver } = require('perf_hooks');
const v8Profiler = require('v8-profiler-next');
const memwatch = require('@airbnb/node-memwatch');
class NodePerformanceProfiler {
constructor(options = {}) {
this.options = {
cpuSamplingInterval: 1000,
memoryThreshold: 50 * 1024 * 1024, // 50MB
reportDirectory: './performance-reports',
...options
};
this.metrics = {
memoryUsage: [],
cpuUsage: [],
eventLoopDelay: [],
httpRequests: []
};
this.setupPerformanceObservers();
this.setupMemoryMonitoring();
}
setupPerformanceObservers() {
// HTTP request performance
const httpObserver = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
if (entry.entryType === 'measure') {
this.metrics.httpRequests.push({
name: entry.name,
duration: entry.duration,
startTime: entry.startTime,
timestamp: new Date().toISOString()
});
}
});
});
httpObserver.observe({ entryTypes: ['measure'] });
// Function performance
const functionObserver = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
if (entry.duration > 100) { // Log slow functions (>100ms)
console.warn(`Slow function detected: ${entry.name} took ${entry.duration.toFixed(2)}ms`);
}
});
});
functionObserver.observe({ entryTypes: ['function'] });
}
setupMemoryMonitoring() {
// Memory leak detection
memwatch.on('leak', (info) => {
console.error('Memory leak detected:', info);
this.generateMemorySnapshot();
});
// Garbage collection monitoring
memwatch.on('stats', (stats) => {
this.metrics.memoryUsage.push({
...stats,
timestamp: new Date().toISOString(),
heapUsed: process.memoryUsage().heapUsed,
heapTotal: process.memoryUsage().heapTotal,
external: process.memoryUsage().external
});
});
}
startCPUProfiling(duration = 30000) {
console.log('Starting CPU profiling...');
v8Profiler.startProfiling('CPU_PROFILE', true);
setTimeout(() => {
const profile = v8Profiler.stopProfiling('CPU_PROFILE');
const reportPath = path.join(this.options.reportDirectory, `cpu-profile-${Date.now()}.cpuprofile`);
profile.export((error, result) => {
if (error) {
console.error('CPU profile export error:', error);
return;
}
fs.writeFileSync(reportPath, result);
console.log(`CPU profile saved to: ${reportPath}`);
// Analyze profile
this.analyzeCPUProfile(JSON.parse(result));
});
}, duration);
}
analyzeCPUProfile(profile) {
const hotFunctions = [];
function traverseNodes(node, depth = 0) {
if (node.hitCount > 0) {
hotFunctions.push({
functionName: node.callFrame.functionName || 'anonymous',
url: node.callFrame.url,
lineNumber: node.callFrame.lineNumber,
hitCount: node.hitCount,
selfTime: node.selfTime || 0
});
}
if (node.children) {
node.children.forEach(child => traverseNodes(child, depth + 1));
}
}
traverseNodes(profile.head);
// Sort by hit count and self time
hotFunctions.sort((a, b) => (b.hitCount * b.selfTime) - (a.hitCount * a.selfTime));
console.log('\nTop CPU consuming functions:');
hotFunctions.slice(0, 10).forEach((func, index) => {
console.log(`${index + 1}. ${func.functionName} (${func.hitCount} hits, ${func.selfTime}ms)`);
});
return hotFunctions;
}
measureEventLoopDelay() {
const { monitorEventLoopDelay } = require('perf_hooks');
const histogram = monitorEventLoopDelay({ resolution: 20 });
histogram.enable();
setInterval(() => {
const delay = {
min: histogram.min,
max: histogram.max,
mean: histogram.mean,
stddev: histogram.stddev,
percentile99: histogram.percentile(99),
timestamp: new Date().toISOString()
};
this.metrics.eventLoopDelay.push(delay);
if (delay.mean > 10) { // Alert if event loop delay > 10ms
console.warn(`High event loop delay: ${delay.mean.toFixed(2)}ms`);
}
histogram.reset();
}, 5000);
}
generateMemorySnapshot() {Open-source registry and CLI for Claude Code components: agents, commands, skills, hooks, MCPs, settings and mods
Use this agent when creating specialized Claude Code agents for the claude-code-templates components system. Specializes in agent…
Use this agent to create blog articles for aitmpl.com from Claude Code Templates components. Reads the component, asks the user…
Runs pre-deploy build checks on the dashboard. Validates Astro build, checks for common esbuild/JSX issues, verifies API…
Regenerates the component catalog (docs/components.json) by running the Python script. Use this agent when components have been…
CLI interface design specialist. Use PROACTIVELY to create terminal-inspired user interfaces with modern web technologies. Expert…
Use this agent when creating CLI commands for the claude-code-templates components system. Specializes in command design,…
Surgical 1-2 file edit. Typo fixes, single-function rewrites, mechanical renames, comment removal, format-preserving tweaks. Hard…