home / skills / greyhaven-ai / claude-code-config / performance-optimization

This skill analyzes bottlenecks and provides production-ready optimizations across algorithms, databases, frontend, and infrastructure to speed up applications.

npx playbooks add skill greyhaven-ai/claude-code-config --skill performance-optimization

Review the files below or copy the command above to add this skill to your agents.

Files (15)
SKILL.md
2.8 KB
---
name: grey-haven-performance-optimization
description: "Comprehensive performance analysis and optimization for algorithms (O(n²)→O(n)), databases (N+1 queries, indexes), React (memoization, virtual lists), bundles (code splitting), API caching, and memory leaks. 85%+ improvement rate. Use when application is slow, response times exceed SLA, high CPU/memory usage, performance budgets needed, or when user mentions 'performance', 'slow', 'optimization', 'bottleneck', 'speed up', 'latency', 'memory leak', or 'performance tuning'."
# v2.0.43: Skills to auto-load for performance work
skills:
  - grey-haven-code-style
  - grey-haven-observability-monitoring
# v2.0.74: Tools for performance optimization
allowed-tools:
  - Read
  - Write
  - MultiEdit
  - Bash
  - Grep
  - Glob
  - TodoWrite
---

# Performance Optimization Skill

Comprehensive performance analysis and optimization techniques for identifying bottlenecks and improving application speed.

## Description

This skill provides production-ready patterns, examples, and checklists for optimizing application performance across algorithms, databases, infrastructure, and code structure.

## What's Included

### Examples (`examples/`)
- **Algorithm optimization** - Improve time complexity (O(n²) → O(n))
- **Database optimization** - Eliminate N+1 queries, add indexes
- **Bundle size reduction** - Code splitting, tree shaking
- **React performance** - Memoization, virtual lists
- **API response time** - Caching strategies, async processing
- **Memory optimization** - Reduce allocations, fix leaks

### Reference Guides (`reference/`)
- Performance profiling tools and techniques
- Benchmarking best practices
- Optimization decision frameworks
- Performance budget guidelines
- Monitoring and alerting strategies

### Templates (`templates/`)
- Performance test templates (Lighthouse, Web Vitals)
- Benchmark comparison templates
- Optimization report structures
- Performance budget definitions

## Use This Skill When

- Application is slow or unresponsive
- Response times exceed SLA targets
- High CPU/memory usage detected
- Need to meet performance budgets
- Optimizing for production deployment

## Related Agents

- `performance-optimizer` - Automated performance analysis and optimization
- `memory-profiler` - Memory leak detection and profiling
- `observability-engineer` - Production monitoring setup

## Quick Start

```bash
# View optimization examples
ls examples/

# Check reference guides
ls reference/

# Use templates for benchmarking
ls templates/
```

## Metrics

- **Optimization Success Rate**: 85%+ performance improvement
- **Coverage**: Algorithm, database, infrastructure, code structure
- **Production-Ready**: All examples tested in real applications

---

**Skill Version**: 1.0
**Last Updated**: 2025-01-15

Overview

This skill delivers a practical, production-ready toolkit for diagnosing and fixing performance problems across algorithms, databases, frontend bundles, React apps, APIs, and memory usage. It combines concrete examples, reference guides, and templates to drive measurable speedups, with an 85%+ improvement track record. Use it as a checklist and hands-on playbook when speed, latency, or resource usage is a problem.

How this skill works

The skill inspects common performance domains: algorithmic complexity, database query patterns, frontend bundle size, React rendering, API response times, and memory allocation/leaks. It provides profiling techniques, concrete optimizations (for example converting O(n²) to O(n), adding indexes, eliminating N+1 queries, introducing memoization, virtual lists, and code splitting), and templates for benchmarking and reporting. You follow guided checks, run targeted profiles, apply recommended fixes, and validate improvements with provided test templates.

When to use it

  • Application feels slow or unresponsive
  • Response times exceed SLA or performance budgets
  • High CPU, memory, or error rates in production
  • You suspect N+1 queries, large bundles, or inefficient algorithms
  • Preparing for release and need to meet performance targets

Best practices

  • Start with profiling to find real bottlenecks before optimizing
  • Measure before and after using provided benchmarking templates
  • Fix root causes (algorithmic or query-level) before adding caching
  • Keep optimizations incremental and test for regressions under load
  • Document changes with the supplied optimization report template

Example use cases

  • Convert a quadratic loop to a linear algorithm to reduce runtime on large inputs
  • Eliminate N+1 database queries by batching and adding appropriate indexes
  • Reduce frontend bundle size via code splitting and tree shaking to cut initial load time
  • Optimize React app with useMemo, memo, and windowed lists to lower render cost
  • Introduce API caching and async processing to reduce response latency under load

FAQ

What kind of improvements can I expect?

Typical projects see 85%+ improvement for targeted problems; actual gains depend on workload and root cause complexity.

Do I need production access to use this skill?

You need profiling data and access to representative workloads; production access is recommended but local or staging traces can be sufficient for many fixes.

Which tools are recommended for profiling?

Use CPU and memory profilers for your stack (browser devtools, Lighthouse, Web Vitals, Python profilers, database EXPLAIN), plus the included benchmarking templates for repeatable measurements.