performance-optimization

Use when performance is a real concern — measure first, isolate the bottleneck, and prove the improvement instead of guessing

8 stars

Best use case

performance-optimization is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when performance is a real concern — measure first, isolate the bottleneck, and prove the improvement instead of guessing

Teams using performance-optimization should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/performance-optimization/SKILL.md --create-dirs "https://raw.githubusercontent.com/drvoss/everything-copilot-cli/main/skills/development/performance-optimization/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/performance-optimization/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How performance-optimization Compares

Feature / Agentperformance-optimizationStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when performance is a real concern — measure first, isolate the bottleneck, and prove the improvement instead of guessing

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Performance Optimization

Do not optimize by instinct. Start with measurement, change one thing at a time, and confirm the
result with the same metric you used at the beginning.

## When to Use

- A user or monitoring system reports a slow page, endpoint, query, or job
- A new feature needs a performance baseline before release
- You suspect a regression and need evidence before changing code
- A hot path is doing real work at scale and latency or throughput matters

## When NOT to Use

| Instead of performance-optimization | Use |
|------------------------------------|-----|
| Obvious correctness bug | `systematic-debugging` |
| General frontend inspection without a clear perf question | `browser-devtools` |
| Micro-tuning without user impact | leave it alone |
| "Feels slow" with no measurement plan | define a measurable target first |

## Workflow

### 1. Define the metric that matters

Pick the metric before touching code:

- **Web UI**: LCP, INP, CLS, bundle size, render time
- **API**: p50 / p95 / p99 latency, throughput, error rate
- **Database**: query duration, rows scanned, lock wait time
- **Background jobs**: wall-clock duration, queue time, memory growth

Write the target in one line:

```text
Goal: reduce p95 /search latency from 850ms to under 400ms.
```

### 2. Capture a baseline

Measure the current state using the closest native tool:

```powershell
# Node.js CPU profiling
node --prof server.js

# Frontend runtime inspection
# Use browser devtools / Lighthouse and record the before numbers

# Database query analysis
# EXPLAIN ANALYZE <query>
```

Keep the baseline numbers in the task notes, PR, or issue.

### 3. Find the dominant bottleneck

Look for the one thing consuming most of the time:

- Repeated expensive work
- N+1 queries or redundant network calls
- Heavy rendering or oversized bundles
- Serialization / parsing cost
- Synchronous work on the critical path

Use the 80/20 rule: fix the dominant bottleneck before touching minor inefficiencies.

### 4. Form one optimization hypothesis

```text
Hypothesis: caching the normalized search filters will reduce repeated query-building work and cut p95 latency by ~30%.
Test: add the cache, rerun the same benchmark, compare p95 latency.
Rollback: remove the cache if latency does not improve or invalidation gets messy.
```

One hypothesis, one change, one measurement.

### 5. Re-measure with the same test

After each change:

1. Re-run the same benchmark or profiling flow
2. Compare against the original baseline
3. Keep or revert based on evidence

If performance improves but correctness or maintainability regresses sharply, it is not a win.

### 6. Document the result

Record:

- Baseline metric
- Final metric
- What changed
- Why the change helped
- Any tradeoff introduced (memory, complexity, cache invalidation, eventual consistency)

## Practical Targets

| Area | Healthy target |
|------|----------------|
| LCP | <= 2.5s |
| INP | <= 200ms |
| CLS | <= 0.1 |
| API p95 latency | Fits product SLO; usually far below 1s for interactive endpoints |
| Slow DB query | Moves from table scan / many-row scan toward indexed, explainable execution |

## Optimization Order

1. Remove unnecessary work
2. Fix algorithmic complexity
3. Eliminate duplication or N+1 patterns
4. Parallelize or pipeline safe independent work
5. Cache with explicit invalidation rules
6. Leave micro-optimizations for last

## Common Mistakes

| Mistake | Fix |
|---------|-----|
| Optimizing before measuring | Record a baseline first |
| Changing five things at once | Make one testable change at a time |
| Chasing average latency only | Track tail latency (`p95` / `p99`) too |
| Adding a cache without invalidation strategy | Define freshness, eviction, and rollback before shipping |
| Keeping a "faster" change that hurts readability for no user-visible gain | Revert it |

## Verification

- [ ] Baseline metric was recorded before optimization
- [ ] The dominant bottleneck was identified with data, not intuition
- [ ] Each optimization had a written hypothesis
- [ ] Final measurement used the same method as the baseline
- [ ] Performance improved without breaking correctness

## See Also

- [`browser-devtools`](../../testing/browser-devtools/SKILL.md) — inspect runtime behavior in the browser
- [`systematic-debugging`](../systematic-debugging/SKILL.md) — root-cause workflow for non-performance bugs
- [`test-coverage`](../../testing/test-coverage/SKILL.md) — protect the optimized path with regression tests

Related Skills

verification-before-completion

8
from drvoss/everything-copilot-cli

Use before claiming any task is done — run the exact command that proves the fix works, read the output, and only then report success.

using-git-worktrees

8
from drvoss/everything-copilot-cli

Use when you need multiple branches checked out at once — create isolated working directories for parallel development without cloning the repository repeatedly

triage

8
from drvoss/everything-copilot-cli

Use when a single issue needs structured triage — classify it, reproduce if needed, request missing information, and leave a durable brief or close-out note in the tracker.

to-issues

8
from drvoss/everything-copilot-cli

Use when a plan, spec, or PRD must become an actionable backlog — break it into thin dependency-aware issues that each deliver a verifiable vertical slice

sprint-workflow

8
from drvoss/everything-copilot-cli

Use when starting a new feature, refactor, or multi-step dev task — runs the full sprint cycle (Think → Plan → Build → Review → Test → Ship → Monitor) using Copilot CLI's plan/autopilot modes.

sprint-retro

8
from drvoss/everything-copilot-cli

Use at the end of a sprint to run a data-driven retrospective — analyzes session history and git metrics to surface what shipped, what slowed you down, and concrete improvements.

security-audit

8
from drvoss/everything-copilot-cli

Use when a codebase needs a formal security audit beyond a quick scan — applies OWASP Top 10 and STRIDE threat modeling from a CSO perspective to surface systemic vulnerabilities.

release

8
from drvoss/everything-copilot-cli

Use when a sprint or feature is complete and ready to ship — tags the version, generates GitHub Release notes, runs rollout or smoke verification, and publishes to npm/PyPI/Docker registries.

prompt-optimizer

8
from drvoss/everything-copilot-cli

Use when a rough prompt, vague idea, or task description needs to become a finished copy-pasteable prompt for a chat-based LLM - rewrite it into one ready-to-send prompt with no blanks, no placeholders, and a clear output shape.

outside-voice

8
from drvoss/everything-copilot-cli

Use when you need an independent second opinion before, during, or after implementation — run challenge, consult, or review mode in a direct builder-to-builder voice

llm-wiki

8
from drvoss/everything-copilot-cli

Use when research or domain knowledge keeps getting rediscovered across sessions — build a supplementary markdown wiki that compounds synthesized knowledge without replacing GitHub or committed project guidance

interview-me

8
from drvoss/everything-copilot-cli

Use when a request is underspecified and you need to discover what the user actually wants before writing a plan, spec, or code - ask one question at a time, attach your current hypothesis, and stop only after the intent is explicitly confirmed.