performance-optimization

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

1|Updated Mar 2, 2025
One-click install
npx skills add https://github.com/marjorg/setup --skill performance-optimization-marjorg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: performance-optimization
Source: https://github.com/marjorg/setup/tree/main/home/.agents/skills/performance-optimization
Command: npx skills add https://github.com/marjorg/setup --skill performance-optimization-marjorg

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Slow applications, regressions, and wasted optimization effort happen when teams guess at bottlenecks instead of measuring them. This Skill enforces a measure-identify-fix-verify-guard workflow so every performance change targets a proven bottleneck and is kept only if re-measurement confirms a real improvement. ## Core Features & Use Cases - Measurement-First Workflow: Establishes baselines with synthetic tools (Lighthouse, DevTools) and real-user monitoring (web-vitals, CrUX) before any change, then re-measures to keep or revert. - Anti-Pattern Fixes: Provides concrete before/after code for N+1 queries, unbounded fetching, connection pool exhaustion, missing image optimization, React re-renders, large bundles, and caching mistakes. - Database Query Analysis: Guides reading EXPLAIN ANALYZE output, designing composite indexes for the query shape, and recognizing when indexes will not help. - Use Case: A page's INP is 240ms. Profile the main thread, find long tasks from an unvirtualized list, apply virtualization, re-measure to 90ms, log the attempt, and add a CI bundle budget plus RUM alerting to guard against regression. ## Quick Start Ask the agent to profile your slow page or API endpoint and propose a measured performance fix following the optimization workflow.

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 a backend API?

Replace per-record lookups with a single query that joins or includes the related data, such as an ORM include clause. Confirm the fix by checking the query log before and after to verify the query count dropped to one.

How do I improve Core Web Vitals scores like LCP and INP?

Measure first with Lighthouse or the web-vitals library to find the actual bottleneck. For LCP, optimize hero images with responsive srcset and fetchpriority; for INP, profile long tasks on the main thread and reduce heavy JavaScript or re-renders.

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

Only after running EXPLAIN ANALYZE and reading the query plan. Index for the shape of the query with equality columns first, and skip indexes for low-selectivity filters, leading wildcards, or write-heavy tables where the write cost outweighs the read gain.

Why is my connection pool exhausted and should I increase its size?

Exhaustion usually means connections are held too long, not that the pool is too small. A larger pool just moves the queue to the database; instead find what holds connections, and for serverless use a proxy like pgbouncer or RDS Proxy.

When should I not add caching to an application?

Do not cache queries that are already fast, data whose staleness is a correctness bug like balances or permissions, or per-user data under a key that does not identify the user. Cache only what is expensive to produce and read far more often than it changes.

Should I keep an optimization that shows no measurable improvement?

No. A neutral result is a revert, because code you keep must be maintained forever without paying for itself. Log the attempt with baseline and result numbers so the same failed idea is not retried later.