Use when you have a written implementation plan to execute in a separate session with review checkpoints
npx skills add ramidamolis-alt/agent-skills-workflows --skill "performance-optimizer"
Install specific skill from multi-skill repository
# Description
Expert performance optimizer using ALL MCP servers. Uses MongoDB for metrics, UltraThink for analysis, Memory for benchmarks, and search MCPs for optimization techniques.
# SKILL.md
name: performance-optimizer
description: Expert performance optimizer using ALL MCP servers. Uses MongoDB for metrics, UltraThink for analysis, Memory for benchmarks, and search MCPs for optimization techniques.
⚡ Performance Optimizer Skill (Full MCP Integration)
Master performance optimizer using ALL 11 MCP servers.
MCP Performance Arsenal
| MCP Server | Performance Role |
|---|---|
| MongoDB | Metrics storage, query analysis |
| UltraThink | Bottleneck analysis |
| Memory | Baseline benchmarks, patterns |
| Context7 | Framework optimization docs |
| Filesystem | Profiling files, configs |
| Brave/Tavily | Modern optimization techniques |
| NotebookLM | Deep performance research |
Advanced Performance Patterns
1. Bottleneck Analysis with UltraThink
await mcp_UltraThink_ultrathink({
thought: `
# Performance Bottleneck Analysis
## Current Metrics
- Response time: ${avgResponseTime}ms (p95: ${p95}ms)
- Throughput: ${requestsPerSec} req/s
- Error rate: ${errorRate}%
- CPU: ${cpuUsage}%
- Memory: ${memoryUsage}%
## Bottleneck Identification
### Hypothesis 1: Database
- Evidence: Query time ${queryTime}ms
- Analysis: ...
- Confidence: 0.8
### Hypothesis 2: Network
- Evidence: External API calls ${externalTime}ms
- Analysis: ...
- Confidence: 0.5
### Hypothesis 3: CPU-bound
- Evidence: CPU at ${cpuUsage}%
- Analysis: ...
- Confidence: 0.3
## Primary Bottleneck: Database
## Optimization Strategy: ...
`,
total_thoughts: 25,
confidence: 0.8
});
2. Query Optimization Pipeline (MongoDB)
// Get slow queries
const slowQueries = await mcp_MongoDB_aggregate(
"performance", "query_logs",
[
{ $match: { duration: { $gte: 100 } } },
{ $group: {
_id: "$query_fingerprint",
avgDuration: { $avg: "$duration" },
count: { $sum: 1 },
examples: { $push: "$query" }
}},
{ $sort: { avgDuration: -1 } },
{ $limit: 10 }
]
);
// Analyze and optimize each
for (const query of slowQueries) {
const explain = await mcp_MongoDB_explain(
database, collection,
["find", { filter: query.examples[0] }],
"executionStats"
);
await mcp_UltraThink_ultrathink({
thought: `
# Query Optimization: ${query._id}
## Current Performance
- Avg duration: ${query.avgDuration}ms
- Executions: ${query.count}
- Total time impact: ${query.avgDuration * query.count}ms
## Explain Analysis
- Stage: ${explain.stage}
- Docs examined: ${explain.docsExamined}
- Index used: ${explain.indexUsed || "NONE"}
## Optimization
- Add index: ${suggestedIndex}
- Rewrite query: ${rewrittenQuery}
- Expected improvement: ${improvement}%
`,
total_thoughts: 15
});
}
3. Baseline & Benchmark Tracking (Memory)
// Store baseline
await mcp_Memory_create_entities([{
name: `Baseline_${component}_${date}`,
entityType: "Baseline",
observations: [
`Response time p50: ${p50}ms`,
`Response time p95: ${p95}ms`,
`Response time p99: ${p99}ms`,
`Throughput: ${rps} req/s`,
`Memory: ${memory}MB`,
`CPU: ${cpu}%`
]
}]);
// Compare with previous
const previousBaseline = await mcp_Memory_search_nodes(
`Baseline ${component}`
);
await mcp_UltraThink_ultrathink({
thought: `
# Performance Comparison
## Current vs Previous
| Metric | Current | Previous | Change |
|--------|---------|----------|--------|
| p50 | ${current.p50} | ${prev.p50} | ${diff}% |
| p95 | ${current.p95} | ${prev.p95} | ${diff}% |
| RPS | ${current.rps} | ${prev.rps} | ${diff}% |
## Analysis
${analysis}
## Recommendation
${recommendation}
`,
total_thoughts: 15
});
4. Framework Optimization Research
// Get framework-specific optimizations
const [docs, web] = await Promise.all([
mcp_Context7_query-docs(
frameworkLibraryId,
"performance optimization caching"
),
mcp_Brave_brave_web_search(
`${framework} performance optimization 2026`
)
]);
// Synthesize
await mcp_UltraThink_ultrathink({
thought: `
# ${framework} Performance Optimizations
## Official Documentation
${docs.recommendations}
## Community Best Practices (2026)
${web.techniques}
## Applicable to Our Project
1. ...
2. ...
## Priority Ranking
1. Highest impact, lowest effort: ...
2. ...
`,
total_thoughts: 20
});
5. Memory Profiling Pipeline
// Read heap dump/profile
const profileData = await mcp_Filesystem_read_file(
heapDumpPath
);
await mcp_UltraThink_ultrathink({
thought: `
# Memory Profile Analysis
## Heap Summary
- Total size: ${heapSize}MB
- Used: ${usedSize}MB
- Objects: ${objectCount}
## Top Memory Consumers
${topConsumers.map(c => `- ${c.type}: ${c.size}MB (${c.count} instances)`)}
## Memory Leak Suspects
${leakSuspects.map(s => `- ${s.description}: Growing ${s.rate}MB/hour`)}
## Optimization Actions
1. ...
`,
total_thoughts: 20
});
Secret Performance Techniques
1. Performance Knowledge Graph
// Store optimization patterns
await mcp_Memory_create_entities([{
name: `Optimization_${technique}`,
entityType: "Optimization",
observations: [
`Context: ${whenToUse}`,
`Before: ${beforeMetrics}`,
`After: ${afterMetrics}`,
`Improvement: ${improvement}%`,
`Implementation: ${implementation}`,
`Gotchas: ${gotchas}`
]
}]);
// Link to components
await mcp_Memory_create_relations([
{ from: "Optimization_Caching", to: "Component_UserService", relationType: "applied_to" }
]);
2. Automated Regression Detection
// Compare with baseline
const baseline = await mcp_Memory_search_nodes(
`Baseline ${component}`
).sort((a, b) => b.timestamp - a.timestamp)[0];
const current = await collectMetrics();
if (current.p95 > baseline.p95 * 1.2) {
// 20% regression
await mcp_UltraThink_ultrathink({
thought: `
# Performance Regression Detected!
## Metrics
- Baseline p95: ${baseline.p95}ms
- Current p95: ${current.p95}ms
- Regression: ${regression}%
## Recent Changes
${recentChanges}
## Likely Cause
${likelyCause}
## Recommended Fix
${fix}
`,
total_thoughts: 15
});
}
3. Multi-Dimensional Optimization
await mcp_UltraThink_ultrathink({
thought: `
# Multi-Dimensional Optimization
## Trade-off Analysis
| Dimension | Current | Target | Cost |
|-----------|---------|--------|------|
| Latency | ${latency}ms | ${targetLatency}ms | ${cost1} |
| Throughput | ${rps} | ${targetRps} | ${cost2} |
| Cost | $${cost}/mo | $${targetCost}/mo | - |
## Pareto Optimal Solutions
1. Solution A: -20% latency, +10% cost
2. Solution B: +50% throughput, +20% cost
3. Solution C: -30% cost, +10% latency
## Recommendation
Given priorities: ${priorities}
Choose: Solution ${chosen}
`,
total_thoughts: 25
});
4. Real-time Metrics Pipeline
// Insert metrics to MongoDB
await mcp_MongoDB_insert-many(
"performance", "metrics",
metricsBuffer // Collected over interval
);
// Aggregate for dashboards
const realtime = await mcp_MongoDB_aggregate(
"performance", "metrics",
[
{ $match: { timestamp: { $gte: fiveMinutesAgo } } },
{ $group: {
_id: {
minute: { $dateToString: { format: "%Y-%m-%d %H:%M", date: "$timestamp" } }
},
avgLatency: { $avg: "$latency" },
p95Latency: { $percentile: { input: "$latency", p: [0.95] } },
errorRate: { $avg: { $cond: ["$error", 1, 0] } }
}},
{ $sort: { "_id.minute": -1 } }
]
);
5. Optimization Playbook Generator
// Create reusable optimization playbook
const optimizations = await mcp_Memory_search_nodes("Optimization");
await mcp_Notion_API-post-page({
parent: { database_id: playbooksDbId },
properties: {
title: [{ text: { content: "Performance Optimization Playbook" } }]
},
children: optimizations.map(opt => ({
type: "toggle",
toggle: {
rich_text: [{ text: { content: opt.name } }],
children: opt.observations.map(o => ({
type: "bulleted_list_item",
bulleted_list_item: { rich_text: [{ text: { content: o } }] }
}))
}
}))
});
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.