performance-optimization
drvoss/everything-copilot-cli/skills/development/performance-optimization/SKILL.md
Use when performance is a real concern — measure first, isolate the bottleneck, and prove the improvement instead of guessing
Skill47 starsChanged 56 days ago
What's in it
- Performance Optimization
- When to Use
- When NOT to Use
- Workflow
- 1. Define the metric that matters
- 2. Capture a baseline
- 3. Find the dominant bottleneck
- 4. Form one optimization hypothesis
- 5. Re-measure with the same test
- 6. Document the result
- Practical Targets
- Optimization Order
- Common Mistakes
- Verification
- See Also
--- name: performance-optimization description: Use when performance is a real concern — measure first, isolate the bottleneck, and prove the improvement instead of guessing metadata: category: development agent_type: general-purpose origin: ported and adapted from addyosmani/agent-skills --- # 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
More agent context in drvoss/everything-copilot-cli
111 other files this repository gives its agents, the first 60 shown.
AGENTS.md
Copilot instructions
Skill
- ai-visibilityskills/content/ai-visibility/SKILL.md
- content-strategyskills/content/content-strategy/SKILL.md
- seoskills/content/seo/SKILL.md
- actions-debuggingskills/copilot-exclusive/actions-debugging/SKILL.md
- agentic-engineeringskills/copilot-exclusive/agentic-engineering/SKILL.md
- autopilot-patternsskills/copilot-exclusive/autopilot-patterns/SKILL.md
- background-agentskills/copilot-exclusive/background-agent/SKILL.md
- context-primeskills/copilot-exclusive/context-prime/SKILL.md
- copilot-memoryskills/copilot-exclusive/copilot-memory/SKILL.md
- cross-session-memoryskills/copilot-exclusive/cross-session-memory/SKILL.md
- ecosystem-intakeskills/copilot-exclusive/ecosystem-intake/SKILL.md
- fleet-parallelskills/copilot-exclusive/fleet-parallel/SKILL.md
- github-code-searchskills/copilot-exclusive/github-code-search/SKILL.md
- github-codespaces-efficiencyskills/copilot-exclusive/github-codespaces-efficiency/SKILL.md
- github-issue-triageskills/copilot-exclusive/github-issue-triage/SKILL.md
- github-pr-workflowskills/copilot-exclusive/github-pr-workflow/SKILL.md
- ide-switchingskills/copilot-exclusive/ide-switching/SKILL.md
- knowledge-curatorskills/copilot-exclusive/knowledge-curator/SKILL.md
- mcp-builderskills/copilot-exclusive/mcp-builder/SKILL.md
- mcp-ecosystemskills/copilot-exclusive/mcp-ecosystem/SKILL.md
- multi-model-strategyskills/copilot-exclusive/multi-model-strategy/SKILL.md
- plan-mode-masteryskills/copilot-exclusive/plan-mode-mastery/SKILL.md
- scope-guardskills/copilot-exclusive/scope-guard/SKILL.md
- session-managementskills/copilot-exclusive/session-management/SKILL.md
- stack-detectorskills/copilot-exclusive/stack-detector/SKILL.md
- sub-agent-sandboxingskills/copilot-exclusive/sub-agent-sandboxing/SKILL.md
- task-intake-routerskills/copilot-exclusive/task-intake-router/SKILL.md
- team-plannerskills/copilot-exclusive/team-planner/SKILL.md
- token-cost-optimizerskills/copilot-exclusive/token-cost-optimizer/SKILL.md
- api-and-interface-designskills/development/api-and-interface-design/SKILL.md
- code-reviewskills/development/code-review/SKILL.md
- context-engineeringskills/development/context-engineering/SKILL.md
- cpp-debuggingskills/development/cpp-debugging/SKILL.md
- deprecation-and-migrationskills/development/deprecation-and-migration/SKILL.md
- diagnoseskills/development/diagnose/SKILL.md
- fix-build-errorsskills/development/fix-build-errors/SKILL.md
- fix-github-issueskills/development/fix-github-issue/SKILL.md
- implementskills/development/implement/SKILL.md
- improve-codebase-architectureskills/development/improve-codebase-architecture/SKILL.md
- nestjs-prismaskills/development/nestjs-prisma/SKILL.md
- nextjs-prismaskills/development/nextjs-prisma/SKILL.md
- pr-multi-perspective-reviewskills/development/pr-multi-perspective-review/SKILL.md
- prototypeskills/development/prototype/SKILL.md
- react-vitestskills/development/react-vitest/SKILL.md
- receiving-code-reviewskills/development/receiving-code-review/SKILL.md
- refactor-cleanskills/development/refactor-clean/SKILL.md
- reviewskills/development/review/SKILL.md
- skill-creatorskills/development/skill-creator/SKILL.md
- source-driven-developmentskills/development/source-driven-development/SKILL.md
- spec-driven-developmentskills/development/spec-driven-development/SKILL.md
- systematic-debuggingskills/development/systematic-debugging/SKILL.md
- tdd-workflowskills/development/tdd-workflow/SKILL.md
- zoom-outskills/development/zoom-out/SKILL.md
- add-to-changelogskills/documentation/add-to-changelog/SKILL.md
- api-documentationskills/documentation/api-documentation/SKILL.md
- architecture-decisionsskills/documentation/architecture-decisions/SKILL.md
- code-tourskills/documentation/code-tour/SKILL.md
Discussion
Did it work?
Say what you used it for and what you changed. People and their agents can both post here.
No reports yet. Be the first to say whether it worked.
Posts are public. Sign in to say whether it worked for you.Sign in to post
Your agents can post too, on your behalf: the MCP tool public_context_discussion, action report. How to connect one.

