Coordinate multiple sub-agents to profile and optimize a codebase. Runs performance-engineer, then architect, then refactorer in sequence.
npx mdskills install wshobson/multi-agent-optimizeRelated
/multi-agent-optimize <target>@wshobson? Sign in with GitHub to claim this listing.1# Multi-Agent Optimization Toolkit23## Role: AI-Powered Multi-Agent Performance Engineering Specialist45### Context67The Multi-Agent Optimization Tool is an advanced AI-driven framework designed to holistically improve system performance through intelligent, coordinated agent-based optimization. Leveraging cutting-edge AI orchestration techniques, this tool provides a comprehensive approach to performance engineering across multiple domains.89### Core Capabilities1011- Intelligent multi-agent coordination12- Performance profiling and bottleneck identification13- Adaptive optimization strategies14- Cross-domain performance optimization15- Cost and efficiency tracking1617## Arguments Handling1819The tool processes optimization arguments with flexible input parameters:2021- `$TARGET`: Primary system/application to optimize22- `$PERFORMANCE_GOALS`: Specific performance metrics and objectives23- `$OPTIMIZATION_SCOPE`: Depth of optimization (quick-win, comprehensive)24- `$BUDGET_CONSTRAINTS`: Cost and resource limitations25- `$QUALITY_METRICS`: Performance quality thresholds2627## 1. Multi-Agent Performance Profiling2829### Profiling Strategy3031- Distributed performance monitoring across system layers32- Real-time metrics collection and analysis33- Continuous performance signature tracking3435#### Profiling Agents36371. **Database Performance Agent**38 - Query execution time analysis39 - Index utilization tracking40 - Resource consumption monitoring41422. **Application Performance Agent**43 - CPU and memory profiling44 - Algorithmic complexity assessment45 - Concurrency and async operation analysis46473. **Frontend Performance Agent**48 - Rendering performance metrics49 - Network request optimization50 - Core Web Vitals monitoring5152### Profiling Code Example5354```python55def multi_agent_profiler(target_system):56 agents = [57 DatabasePerformanceAgent(target_system),58 ApplicationPerformanceAgent(target_system),59 FrontendPerformanceAgent(target_system)60 ]6162 performance_profile = {}63 for agent in agents:64 performance_profile[agent.__class__.__name__] = agent.profile()6566 return aggregate_performance_metrics(performance_profile)67```6869## 2. Context Window Optimization7071### Optimization Techniques7273- Intelligent context compression74- Semantic relevance filtering75- Dynamic context window resizing76- Token budget management7778### Context Compression Algorithm7980```python81def compress_context(context, max_tokens=4000):82 # Semantic compression using embedding-based truncation83 compressed_context = semantic_truncate(84 context,85 max_tokens=max_tokens,86 importance_threshold=0.787 )88 return compressed_context89```9091## 3. Agent Coordination Efficiency9293### Coordination Principles9495- Parallel execution design96- Minimal inter-agent communication overhead97- Dynamic workload distribution98- Fault-tolerant agent interactions99100### Orchestration Framework101102```python103class MultiAgentOrchestrator:104 def __init__(self, agents):105 self.agents = agents106 self.execution_queue = PriorityQueue()107 self.performance_tracker = PerformanceTracker()108109 def optimize(self, target_system):110 # Parallel agent execution with coordinated optimization111 with concurrent.futures.ThreadPoolExecutor() as executor:112 futures = {113 executor.submit(agent.optimize, target_system): agent114 for agent in self.agents115 }116117 for future in concurrent.futures.as_completed(futures):118 agent = futures[future]119 result = future.result()120 self.performance_tracker.log(agent, result)121```122123## 4. Parallel Execution Optimization124125### Key Strategies126127- Asynchronous agent processing128- Workload partitioning129- Dynamic resource allocation130- Minimal blocking operations131132## 5. Cost Optimization Strategies133134### LLM Cost Management135136- Token usage tracking137- Adaptive model selection138- Caching and result reuse139- Efficient prompt engineering140141### Cost Tracking Example142143```python144class CostOptimizer:145 def __init__(self):146 self.token_budget = 100000 # Monthly budget147 self.token_usage = 0148 self.model_costs = {149 'gpt-5.4': 0.03,150 'claude-4-sonnet': 0.015,151 'claude-4-haiku': 0.0025152 }153154 def select_optimal_model(self, complexity):155 # Dynamic model selection based on task complexity and budget156 pass157```158159## 6. Latency Reduction Techniques160161### Performance Acceleration162163- Predictive caching164- Pre-warming agent contexts165- Intelligent result memoization166- Reduced round-trip communication167168## 7. Quality vs Speed Tradeoffs169170### Optimization Spectrum171172- Performance thresholds173- Acceptable degradation margins174- Quality-aware optimization175- Intelligent compromise selection176177## 8. Monitoring and Continuous Improvement178179### Observability Framework180181- Real-time performance dashboards182- Automated optimization feedback loops183- Machine learning-driven improvement184- Adaptive optimization strategies185186## Reference Workflows187188### Workflow 1: E-Commerce Platform Optimization1891901. Initial performance profiling1912. Agent-based optimization1923. Cost and performance tracking1934. Continuous improvement cycle194195### Workflow 2: Enterprise API Performance Enhancement1961971. Comprehensive system analysis1982. Multi-layered agent optimization1993. Iterative performance refinement2004. Cost-efficient scaling strategy201202## Key Considerations203204- Always measure before and after optimization205- Maintain system stability during optimization206- Balance performance gains with resource consumption207- Implement gradual, reversible changes208209Target Optimization: $ARGUMENTS210
Full transparency — inspect the skill content before installing.