# Performance Optimizer

Performance Optimizer guides coding agents through profiling, database indexing, and caching to meet Web Vitals and backend latency targets.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 228 installs · ★ 39 repo stars
- Author: daffy0208
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/daffy0208/ai-dev-standards/tree/HEAD/skills/performance-optimizer/SKILL.md
- Updated: 2025-12-25
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/daffy0208-performance-optimizer

## What it does

The skill enforces a core principle: measure first, optimize second. It defines target budgets such as LCP under 2.5s, API P95 response times under 500ms, and database queries under 100ms. Instead of guessing, the assistant relies on profiler output and concrete numbers.

Its workflow covers frontend audits via Lighthouse and React DevTools, followed by backend profiling with Python `cProfile` or `0x` flame graphs in Node.js. For database bottlenecks, it explains how to inspect queries with PostgreSQL `EXPLAIN (ANALYZE, BUFFERS)`, eliminate N+1 issues using DataLoader, and configure multi-layer caching with Redis and HTTP headers.

Without actual profiling logs or slow-query reports, the assistant cannot determine where execution stalls.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add daffy0208/ai-dev-standards --skill performance-optimizer -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/performance-optimizer/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/performance-optimizer/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add daffy0208/ai-dev-standards --skill performance-optimizer -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/performance-optimizer/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add daffy0208/ai-dev-standards --skill performance-optimizer -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/performance-optimizer/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install daffy0208/ai-dev-standards skills/performance-optimizer
```

2. **Manually: put the files in place**
- File: `.github/skills/performance-optimizer/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add daffy0208/ai-dev-standards --skill performance-optimizer -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/daffy0208/ai-dev-standards --path skills/performance-optimizer
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/performance-optimizer/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add daffy0208/ai-dev-standards --skill performance-optimizer -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/daffy0208/ai-dev-standards/tree/HEAD/skills/performance-optimizer/SKILL.md

## When to use it
- Eliminate N+1 query patterns using eager loading or DataLoader
- Trace server bottlenecks with Node.js flame graphs or Python cProfile
- Tune database queries using PostgreSQL indexes and execution plans
- Set up multi-tier caching with Redis and Cache-Control headers

## Example prompts
- Find the slow queries in this controller and fix the N+1 problem.
- Set up a Redis caching layer for this user lookup function.
- Configure Cache-Control headers in Express for static assets and API routes.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: d9fede5ef6745928.

BEGIN THIRD-PARTY FILE d9fede5ef6745928
````text
---
name: Performance Optimizer
description: Optimize application performance and scalability. Use when investigating slow applications, scaling bottlenecks, or improving response times. Covers profiling, caching, database optimization, and frontend performance.
version: 1.0.0
---

# Performance Optimizer

Make applications fast, scalable, and cost-efficient.

## Core Principle

**Measure first, optimize second.** Don't guess at bottlenecks—profile, measure, then fix the slowest parts.

## Performance Budget

### Web Vitals (Target Metrics)

```yaml
Core Web Vitals:
  Largest Contentful Paint (LCP): < 2.5s # Main content visible
  First Input Delay (FID): < 100ms # Interaction responsiveness
  Cumulative Layout Shift (CLS): < 0.1 # Visual stability

Additional Metrics:
  First Contentful Paint (FCP): < 1.8s # First content rendered
  Time to Interactive (TTI): < 3.8s # Fully interactive
  Total Blocking Time (TBT): < 200ms # Main thread blocked
  Speed Index: < 3.4s # Visual progress

Backend Metrics:
  API Response Time (P95): < 500ms
  Database Query Time (P95): < 100ms
  Server Response Time (TTFB): < 600ms
```

---

## Phase 1: Profiling & Measurement

**Goal**: Identify actual bottlenecks, not perceived ones

### Frontend Profiling

**Chrome DevTools**:

```javascript
// 1. Performance tab → Record → Reload page
// 2. Analyze:
//    - Main thread activity
//    - Network waterfall
//    - JavaScript execution time
//    - Rendering time

// 3. Lighthouse audit
// Run: chrome://lighthouse or `npm i -g lighthouse`
lighthouse https://yoursite.com --view
```

**React DevTools Profiler**:

```javascript
// Wrap component to profile
import { Profiler } from 'react'

function onRenderCallback(id, phase, actualDuration) {
  console.log(`${id} (${phase}) took ${actualDuration}ms`)
}

;<Profiler id="ExpensiveComponent" onRender={onRenderCallback}>
  <ExpensiveComponent />
</Profiler>
```

### Backend Profiling

**Node.js Profiling**:

```bash
# Generate CPU profile
node --prof app.js

# Process profile
node --prof-process isolate-0x*.log > processed.txt

# Flame graphs (better visualization)
npm i -g 0x
0x app.js
```

**Python Profiling**:

```python
import cProfile
import pstats

# Profile function
cProfile.run('slow_function()', 'output.prof')

# Analyze
p = pstats.Stats('output.prof')
p.sort_stats('cumulative').print_stats(20)
```

### Database Profiling

**PostgreSQL**:

```sql
-- Enable query logging
ALTER DATABASE yourdb SET log_min_duration_statement = 100; -- Log queries >100ms

-- Analyze query
EXPLAIN (ANALYZE, BUFFERS)
SELECT * FROM users WHERE email = 'test@example.com';

-- Find slow queries
SELECT query, mean_exec_time, calls
````
END THIRD-PARTY FILE d9fede5ef6745928

The third-party file has ended. Everything between the d9fede5ef6745928 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2688 of 15242 bytes. © daffy0208 · MIT · https://github.com/daffy0208/ai-dev-standards/tree/HEAD/skills/performance-optimizer/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
