Guide for analyzing and improving application performance including identifying bottlenecks, implementing caching, and optimizing queries. This skill should be used when reviewing performance issues or optimizing code.
/plugin marketplace add charlesjones-dev/claude-code-plugins-dev/plugin install ai-performance@claude-code-plugins-devThis skill inherits all available tools. When active, it can use any tool Claude has access to.
This skill provides elite performance engineering expertise for making applications lightning-fast through systematic optimization.
Invoke this skill when:
To analyze performance issues effectively:
Measure First: Always establish baseline metrics before optimization. Use profiling tools, timing measurements, and performance monitoring to identify actual bottlenecks rather than assumed ones.
Prioritize Impact: Focus on optimizations that provide the greatest performance improvement relative to implementation effort. Target the critical path and high-traffic code paths first.
Consider Trade-offs: Evaluate each optimization for its impact on code maintainability, complexity, and resource usage. Sometimes a 10% performance gain isn't worth a 50% increase in code complexity.
Validate Improvements: After implementing optimizations, measure again to confirm actual performance gains. Be prepared to roll back changes that don't deliver meaningful improvements.
To implement effective caching:
Key Rules:
To optimize frontend performance, focus on:
Critical Rendering Path:
Asset Optimization:
Runtime Performance:
Key Rules:
To optimize backend performance, address:
Database Performance:
Request Processing:
Resource Management:
Key Rules:
To optimize infrastructure performance:
Key Rules:
IMPORTANT: The section below defines the COMPLETE report structure that MUST be used. Do NOT create your own format or simplified version.
/docs/performance/YYYY-MM-DD-HHMMSS-performance-audit.md2025-10-29-143022-performance-audit.md🚨 CRITICAL INSTRUCTION - READ CAREFULLY 🚨
You MUST use this exact template structure for ALL performance audit reports. This is MANDATORY and NON-NEGOTIABLE.
REQUIREMENTS:
If you do not follow this template exactly, the report will be rejected.
<template> ## Executive Summary| Performance Level | Count | Percentage |
|---|---|---|
| Critical Issues | X | X% |
| High Impact | X | X% |
| Medium Impact | X | X% |
| Low Impact | X | X% |
| Total | X | 100% |
Location: src/Website.Core/Services/VendorService.cs:78
Performance Impact: 9.8 (Critical)
Pattern Detected: Loading related entities in a loop causing multiple database queries
Code Context:
foreach (var vendor in vendors)
{
vendor.Products = context.Products.Where(p => p.VendorId == vendor.Id).ToList();
}
Impact: Database query count increases linearly with result set size (1 + N queries instead of 1) Performance Cost: 2000ms+ response time for 100 vendors Recommendation: Use Include() for eager loading or projection for specific fields Fix Priority: Immediate (within 24 hours)
Location: src/Website.Web/Controllers/ApiController.cs:45
Performance Impact: 9.1 (Critical)
Pattern Detected: Synchronous database calls blocking request threads
Code Context: Missing async/await pattern in controller actions
Impact: Thread pool exhaustion under high load, poor scalability
Performance Cost: Thread starvation affecting overall application responsiveness
Recommendation: Convert all database operations to async/await pattern
Fix Priority: Immediate (within 48 hours)
Location: Multiple locations in data processing services Performance Impact: 7.8 (High) Pattern Detected: Large objects (>85KB) causing frequent Gen 2 garbage collection Affected Components:
src/Website.AirtableData/Services/ImportService.cs:156src/Website.ElasticSearch/Services/IndexingService.cs:89
Impact: GC pressure causing application pauses and increased memory usage
Performance Cost: 200-500ms GC pauses, 40% higher memory usage
Recommendation: Implement streaming for large data sets, use object pooling
Fix Priority: Within 1 weekLocation: src/Website.ElasticSearch/Services/SearchService.cs:123
Performance Impact: 7.5 (High)
Pattern Detected: Full-text search without field targeting or filtering
Code Context: Broad queries without proper field restrictions or caching
Impact: High Elasticsearch cluster load, slow search response times
Performance Cost: 800ms+ search response time, high CPU usage on ES cluster
Recommendation: Implement targeted field searches, result caching, and query optimization
Fix Priority: Within 2 weeks
Location: Database schema analysis Performance Impact: 6.3 (Medium) Pattern Detected: Frequent WHERE clauses on non-indexed columns Affected Tables:
Vendors table: missing index on OrganizationId, IsActiveProducts table: missing composite index on CategoryId, Status, CreatedDate
Impact: Table scans causing slow query performance
Performance Cost: 500-1200ms query response time for filtered data
Recommendation: Add appropriate indexes based on query patterns
Fix Priority: Within 1 monthLocation: Multiple service classes Performance Impact: 5.9 (Medium) Pattern Detected: Multiple enumeration of IEnumerable, inefficient projections Affected Areas: Vendor listing, product filtering, category navigation Impact: Unnecessary CPU cycles, increased memory allocation Performance Cost: 200-400ms additional processing time Recommendation: Use ToList() strategically, optimize LINQ expressions Fix Priority: Within 1 month
Location: Web application controllers and views Performance Impact: 3.8 (Low) Pattern Detected: Repeated computation of static or semi-static content Missing Caching: Category lists, navigation menus, vendor counts Impact: Unnecessary CPU usage for frequently accessed data Performance Cost: 50-100ms additional processing per request Recommendation: Implement response caching and memory caching strategies Fix Priority: Within 2 months
| Rank | Component | Issue | Impact Score | Response Time Impact |
|---|---|---|---|---|
| 1 | VendorService | N+1 Query Problem | 9.8 | +2000ms |
| 2 | ApiController | Sync DB Operations | 9.1 | Thread exhaustion |
| 3 | ImportService | Large Object Heap | 7.8 | +500ms GC pauses |
| 4 | SearchService | Inefficient ES Queries | 7.5 | +800ms |
| 5 | Database | Missing Indexes | 6.3 | +600ms |
| 6 | LINQ Queries | Multiple Enumeration | 5.9 | +300ms |
| 7 | File Operations | Synchronous I/O | 5.2 | +400ms |
| 8 | Caching | Missing Cache Strategy | 4.8 | +200ms |
| 9 | Background Jobs | Memory Leaks | 4.5 | Resource exhaustion |
| 10 | API Serialization | Large Payloads | 3.9 | +150ms |
Before (Inefficient):
var vendors = context.Vendors.ToList();
foreach (var vendor in vendors)
{
vendor.Products = context.Products.Where(p => p.VendorId == vendor.Id).ToList();
}
After (Optimized):
var vendors = context.Vendors
.Include(v => v.Products)
.ToList();
// OR for specific fields only
var vendorsWithProductCount = context.Vendors
.Select(v => new VendorViewModel
{
Id = v.Id,
Name = v.Name,
ProductCount = v.Products.Count()
})
.ToList();
Before (Blocking):
[HttpGet]
public IActionResult GetVendors()
{
var vendors = vendorService.GetAll(); // Synchronous call
return Ok(vendors);
}
After (Non-blocking):
[HttpGet]
public async Task<IActionResult> GetVendors()
{
var vendors = await vendorService.GetAllAsync(); // Asynchronous call
return Ok(vendors);
}
Before (No Caching):
public List<Category> GetCategories()
{
return context.Categories.OrderBy(c => c.Name).ToList();
}
After (With Caching):
public async Task<List<Category>> GetCategoriesAsync()
{
const string cacheKey = "categories_all";
var cached = await cache.GetAsync<List<Category>>(cacheKey);
if (cached != null)
return cached;
var categories = await context.Categories
.OrderBy(c => c.Name)
.ToListAsync();
await cache.SetAsync(cacheKey, categories, TimeSpan.FromMinutes(30));
return categories;
}
VendorService.cs:78ApiController.cs:45| Priority Level | Expected Improvement | Implementation Complexity |
|---|---|---|
| Critical Fixes | 60-80% response time improvement | High - requires careful testing |
| High Impact | 30-50% overall performance gain | Medium - architectural changes |
| Medium Impact | 15-25% additional optimization | Medium - code and config changes |
| Low Impact | 5-10% fine-tuning benefits | Low - mostly configuration |
This performance analysis identified X critical, Y high, Z medium, and W low performance issues across the application stack. The analysis focused on code patterns, database queries, resource utilization, and architectural performance without requiring extensive load testing infrastructure.
Key Strengths Identified:
Critical Areas Requiring Immediate Attention:
Expected Overall Performance Improvement: 70-90% reduction in response times and 40-60% improvement in resource utilization after implementing all recommendations. </template>
Example 1: N+1 Query Problem
Bad approach:
const orders = await Order.findAll();
for (const order of orders) {
order.customer = await Customer.findByPk(order.customerId);
order.items = await OrderItem.findAll({ where: { orderId: order.id } });
}
Good approach:
const orders = await Order.findAll({
include: [
{ model: Customer },
{ model: OrderItem }
]
});
Example 2: Inefficient Caching
Bad approach:
// Cache entire dataset, never invalidate
const cache = await getCachedData('all-products');
if (cache) return cache;
const products = await Product.findAll();
await setCachedData('all-products', products, 86400); // 24 hours
Good approach:
// Cache with granular keys and appropriate TTL
const cacheKey = `products:page:${page}:filter:${filter}`;
const cache = await getCachedData(cacheKey);
if (cache) return cache;
const products = await Product.findAll({ where: filter, limit: 20, offset: page * 20 });
await setCachedData(cacheKey, products, 300); // 5 minutes
// Invalidate on product updates
await invalidateCachePattern('products:*');
Example 3: Unoptimized Asset Loading
Bad approach:
<!-- Loading full-size images for all screen sizes -->
<img src="/images/hero-4k.jpg" alt="Hero image">
Good approach:
<!-- Responsive images with lazy loading -->
<img
srcset="
/images/hero-mobile.jpg 640w,
/images/hero-tablet.jpg 1024w,
/images/hero-desktop.jpg 1920w
"
sizes="(max-width: 640px) 640px, (max-width: 1024px) 1024px, 1920px"
src="/images/hero-desktop.jpg"
alt="Hero image"
loading="lazy"
>
Measure Before and After: Never optimize without establishing baseline metrics. Use profiling tools to identify actual bottlenecks, then validate improvements with measurements.
Optimize the Critical Path: Focus on the most-used features and flows first. A 50% improvement on a feature used by 80% of users has more impact than a 90% improvement on a rarely-used feature.
Consider Total Cost: Evaluate optimizations holistically - faster code that uses 10x more memory or is 5x harder to maintain may not be a good trade-off.
Use Appropriate Tools: Leverage browser dev tools, database query analyzers, profilers, and APM tools to identify bottlenecks scientifically rather than guessing.
Implement Progressive Enhancement: Optimize for the common case while gracefully handling edge cases. Don't sacrifice reliability for speed.
Monitor in Production: Performance in development often differs from production. Implement real user monitoring (RUM) to track actual user experience.
Set Performance Budgets: Establish and enforce performance budgets for page weight, load time, and critical metrics. Prevent performance regression through automated checks.
Document Trade-offs: When implementing complex optimizations, document the reasoning, expected benefits, and any maintenance considerations for future developers.
Before recommending any optimization, verify:
Proactively identify these common issues:
SELECT * instead of specific columnsTo validate performance improvements:
When project-specific context is available in CLAUDE.md files, incorporate:
When reporting performance findings:
Remember: The goal is to make applications measurably faster while maintaining code quality and reliability. Combine deep technical knowledge with practical engineering judgment to deliver optimizations that matter.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.