performance-optimization

Diagnose and fix frontend, backend, and database performance bottlenecks through measurement-driven optimization.

1|Updated Sep 4, 2026
One-click install
npx skills add https://github.com/SanHsien/agent-skills --skill performance-optimization-sanhsien
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: performance-optimization
Source: https://github.com/SanHsien/agent-skills/tree/main/skills/performance-optimization
Command: npx skills add https://github.com/SanHsien/agent-skills --skill performance-optimization-sanhsien

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Teams often optimize code based on guesses, adding complexity without improving what users actually experience. This Skill enforces a measure-first workflow: profile to find the real bottleneck, fix it, re-measure to verify, and guard against regression. ## Core Features & Use Cases - Structured Optimization Workflow: A five-step loop (Measure, Identify, Fix, Verify, Guard) with Core Web Vitals targets for LCP, INP, and CLS. - Anti-Pattern Fixes: Concrete before/after code for N+1 queries, unbounded fetching, connection pool exhaustion, unoptimized images, React re-renders, large bundles, and missing caching. - Verification Discipline: Rules for re-measuring against baselines, reverting neutral changes, and logging failed attempts so they are not retried. - Use Case: Your API endpoints are slow and you suspect database issues. Use this Skill to profile queries with EXPLAIN ANALYZE, identify a missing composite index, verify the improvement, and add a CI performance budget to prevent regression. ## Quick Start Ask the agent to profile the slow page load or API endpoint and apply the performance optimization workflow to find and fix the bottleneck.

Frequently Asked Questions about performance-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix N+1 queries in my backend API?

Replace per-record queries with a single query using a join or include clause, such as passing include: { owner: true } in an ORM call. Confirm the fix by checking the database query log before and after the change.

How to improve Core Web Vitals scores like LCP and INP?

Measure first with Lighthouse or the web-vitals library, then target the specific bottleneck: optimize hero images with responsive srcset for LCP, break up long main-thread tasks for INP, and set explicit image dimensions for CLS.

When should I add a database index for a slow query?

Run EXPLAIN ANALYZE first and read the query plan. Add a composite index matching the query shape only when you see sequential scans on large tables, and re-run the plan afterward to confirm the index is actually used.

Why is my connection pool exhausted and how do I fix it?

Pool exhaustion shows as all endpoints slowing at once while the database sits idle. Use one pool per process sized under the database connection limit, and for serverless workloads use a proxy like pgbouncer instead of raising the pool size.

When should I not optimize code performance?

Do not optimize without measurement evidence of a problem. Premature optimization adds complexity that costs more than the performance it gains, and changes that show no measurable improvement over the baseline should be reverted.