jpeetz/agent-skills

performance-optimization

Use this skill when optimizing application performance across frontend (Core Web Vitals, bundles), backend (N+1 queries, connection pools, caching), and database (indexes, query plans).

Ver código fuente

Cómo usar

  1. Copia el comando y revisa el paquete antes de instalarlo en tu entorno de agente.
  2. Consulta las herramientas, credenciales y entornos necesarios en el documento original.
  3. Describe las entradas y el resultado deseado; contrasta la salida con las fuentes.
npx skills add https://github.com/jpeetz/agent-skills --skill performance-optimization

Antes de empezar

  • La instalación no incluye suscripción al modelo, cuota API ni permisos sobre tus archivos.
  • Las estrellas e instalaciones reflejan actividad, no una prueba independiente de calidad o seguridad.
Documento original del Skill

Contenido del repositorio de origen con títulos, ejemplos, código, tablas, enlaces e imágenes preservados.

Performance Optimization

Measure before optimizing. Performance work without measurement is guessing — and guessing leads to premature optimization that adds complexity without improving what matters. Profile first, identify the actual bottleneck, fix it, measure again. Optimize only what measurements prove matters.

When to Use This Skill

Use this skill when:

  • Performance requirements exist in the spec (load time budgets, response time SLAs, LCP/INP/CLS targets)
  • Users or monitoring report slow behavior (high latency, sluggish interactions, jank)
  • Core Web Vitals scores are below 'Good' thresholds
  • You suspect a recent change introduced a performance regression
  • Building features that handle large datasets or high traffic volumes
  • Profiling or tracing reveals a bottleneck that needs addressing
  • An N+1 query pattern is discovered in data-fetching code
  • Bundle size analysis shows large, unnecessary dependencies

When NOT to use: Do not optimize before you have empirical evidence of a problem. Premature optimization is a known source of bugs, complexity, and wasted effort. If you're guessing at what's slow, measure first.

Core Web Vitals Targets

MetricGoodNeeds ImprovementPoor
LCP (Largest Contentful Paint)≤ 2.5 s≤ 4.0 s> 4.0 s
INP (Interaction to Next Paint)≤ 200 ms≤ 500 ms> 500 ms
CLS (Cumulative Layout Shift)≤ 0.1≤ 0.25> 0.25
FCP (First Contentful Paint)≤ 1.8 s≤ 3.0 s> 3.0 s
TTFB (Time to First Byte)≤ 800 ms≤ 1.8 s> 1.8 s

The Optimization Workflow

 1. MEASURE   → Establish a baseline with real data (Lighthouse, RUM, EXPLAIN ANALYZE)
 2. IDENTIFY  → Find the actual bottleneck — not the assumed one
 3. FIX       → Address the specific bottleneck with a targeted change
 4. VERIFY    → Re-measure using the same method as the baseline
 5. GUARD     → Add monitoring, budgets, or regression tests

Step 1: MEASURE — Establish Baseline

Use synthetic tools for repeatable, controlled measurements:

  • Lighthouse / PageSpeed Insights — lab-based scoring for Core Web Vitals
  • Chrome DevTools Performance tab — flame graphs, network waterfall, bundle analysis
  • WebPageTest — multi-location RUM-like testing with filmstrips
  • `EXPLAIN ANALYZE` — for database query performance baselines
  • `profile` / `perf` / `py-spy` — for backend process profiling

Complement with Real User Monitoring (RUM) to capture real-world conditions:

  • web-vitals library — JavaScript library reporting live LCP, INP, CLS
  • CrUX (Chrome User Experience Report) — aggregated field data from real Chrome users
  • APM tools (Datadog, New Relic, Sentry) — backend latency distributions

Record the baseline numbers. Without a specific before-value, you cannot know if an optimization worked.

Step 2: IDENTIFY — Find the Actual Bottleneck

Diagnose by symptom:

SymptomCommon CausesDiagnostic Tool
Slow LCPLarge images, render-blocking resources, slow server responseLighthouse, network waterfall
High CLSMissing image dimensions, late-loading ads/fonts, dynamic embedsLighthouse CLS diagnostic, layout shift tracker
Poor INPLong tasks (heavy JS), large DOM, slow event handlersPerformance tab, Long Tasks API
Large bundle sizeUnused dependencies, no code splitting, duplicated modulesvite-bundle-analyzer, webpack-bundle-analyzer
N+1 queriesORM lazy loading in loopsEXPLAIN ANALYZE, Rails/ActiveRecord logs, Django Debug Toolbar
Slow API responsesMissing indexes, inefficient joins, connection pool exhaustionEXPLAIN ANALYZE, connection pool metrics
High memoryUnbounded caches, memory leaks, large datasets in memoryHeap snapshots, malloc profiling

Step 3: FIX — Address Anti-Patterns

Apply targeted fixes based on the identified bottleneck. Each fix must be justified by data from Step 2, not by intuition.

Frontend

Anti-PatternRecommended Fix
Images too large for display sizeUse <picture> / srcset with responsive breakpoints; serve WebP/AVIF
Render-blocking CSS/JSInline critical CSS; defer non-critical JS with type="module" or defer
Missing image dimensionsAlways set width and height attributes to reserve layout space
Heavy client-side JSCode-split by route with dynamic import(); tree-shake unused exports
Unnecessary re-renders (React)React.memo, useMemo, useCallback; stable references for props
Font loading causes CLSUse font-display: swap or font-display: optional with size-adjust
Large third-party scriptsLoad async; defer if not critical; evaluate removal

Backend

Anti-PatternRecommended Fix
N+1 queriesUse eager loading (joins, includes); batch in a single query
Unbounded data fetchingPaginate with cursor-based or offset-based limits
Missing database indexesAdd composite indexes matching query patterns; verify with EXPLAIN
Connection pool exhaustionTune pool size (max_connections); add PgBouncer or proxy multiplexing
No cachingAdd HTTP caching headers; application-level cache for expensive + cold data
Serializing large responsesProject only needed fields; use pagination + streaming

Database

Anti-PatternRecommended Fix
Table scan on large tableAdd index; rewrite query to use index; partition table
Inefficient JOIN orderRestructure query to filter most selective conditions first
Over-fetching columnsSELECT * → SELECT needed_columns
No query plan check before indexAlways run EXPLAIN (ANALYZE, BUFFERS) before and after adding an index

Step 4: VERIFY — Re-measure the Same Way

  1. Run the exact same measurement (same tool, same page, same location)
  2. Compare numbers against the baseline
  3. If the change did NOT improve the metric → revert it
  4. If the change improved one metric but regressed another → decide by SLA priority

Step 5: GUARD — Prevent Regression

  • Performance budgets — set thresholds in Lighthouse CI (e.g. "LCP must stay under 2.5s")
  • Lighthouse CI — fail PR builds that exceed budgets
  • Bundle size checks — compare PR bundle diffs with tools like bundlewatch
  • Custom RUM dashboards — monitor P75, P95, and P99 of key metrics
  • Database migration guard — run EXPLAIN ANALYZE on slow queries before deployment

Common Rationalizations

RationalizationReality
"We'll optimize later"Performance debt compounds. Fix obvious anti-patterns now.
"It's fast on my machine"Profile on representative hardware + throttled network. Dev machines are not production.
"This optimization is obvious"If you didn't measure, you don't know. Assumptions are wrong >50% of the time.
"The query is slow, add an index"Read the query plan first. The index may already be unusable, or the issue may be different.
"Just cache it"Cache only what is expensive to compute AND re-read far more often than written. A cache that never hits is dead weight.
"A CDN will fix the speed"CDNs improve TTFB for global users but don't fix bloated bundles, N+1 queries, or layout shifts.
"We'll lazy-load everything"Over-lazy-loading delays interactivity. Critical above-fold content should load eagerly.
"Let's rewrite in [framework]"Framework rewrites are the most expensive performance "fix." Profile first; a targeted change is cheaper by orders of magnitude.
"It passed Lighthouse, we're good"Lighthouse is a synthetic lab test. Real-user conditions (2G, older devices, ad blockers) will differ. Always validate with RUM.

Red Flags

  • Optimization work performed without profiling data
  • N+1 query patterns in any new or changed data-fetching code
  • An index added without reviewing the query plan before and after
  • A cache implementation with no stated staleness window or eviction policy
  • List endpoints without pagination or with unbounded LIMIT
  • Images rendered without explicit width and height dimensions
  • Optimizations kept in production without re-measurement confirming improvement
  • Performance improvements claimed based on a single measurement (variance is real — average 3+ runs)
  • A framework migration proposed as a performance fix without profiling evidence

Verification

  • [ ] Before and after measurements exist with specific numbers (not "felt faster")
  • [ ] The result was re-measured using the same tool/method as the baseline
  • [ ] Changes that didn't meaningfully beat baseline variance were reverted
  • [ ] Core Web Vitals are within 'Good' thresholds on the optimized page(s)
  • [ ] No N+1 queries exist in new or modified data-fetching code
  • [ ] Every new index is justified by a query plan (EXPLAIN ANALYZE before + after)
  • [ ] Cache implementations document: what is cached, TTL/staleness, max size, eviction policy
  • [ ] All paginated endpoints have bounded limits and cursor/offset documentation
  • [ ] Images have explicit width/height attributes and format for responsive delivery
  • [ ] Bundle size is verified — no unexpected growth vs. baseline
  • [ ] Existing functional tests still pass after optimization changes
  • [ ] RUM data confirms lab improvements hold under real-world conditions

References

  • references/browser-performance-metrics.md — detailed Core Web Vitals diagnostics and tooling
  • references/query-optimization.md — database query profiling and index design guidelines
  • references/image-optimization-guidelines.md — responsive images, format selection, lazy loading
del mismo repositorio

Más Skills

Todos los Skills
jpeetz
Comunidad

accessibility-compliance-audit

Comprehensive web accessibility (a11y) audit and compliance skill. Audits HTML, React, Vue, and Angular codebases against WCAG 2.2 AA standards. Activates when users ask for "accessibility audit", "a11y check", "WCAG compliance", "ADA compliance", "screen reader testing", "keyboard navigation audit", "color contrast check", "accessibility fix", or "make this accessible". Detects violations, explains impact, and generates fix-ready code. Covers semantic HTML, ARIA authoring, focus management, col

instalaciones
1
GitHub Stars
14
Actualizado
21 oct
jpeetz
Comunidad

agent-n-video-pipeline

Use this skill when producing a fully-local "Agent N presents a message" video on the 16GB Apple-Silicon M5 executor: Kokoro mature TTS → LTX-2.3 MLX A2V talking render with native lip sync → karaoke captions → trim → QA → X caption. Replaces the old cloud Herald pipeline (grok-imagine + volcengine) with zero cloud cost. Activates for Herald release videos, Agent N announcements, and newsletter video messages.

instalaciones
1
GitHub Stars
14
Actualizado
21 oct
jpeetz
Comunidad

anti-over-engineering

Use when AI agents over-engineer code beyond user requests.

instalaciones
1
GitHub Stars
14
Actualizado
21 oct
jpeetz
Comunidad

api-and-interface-design

Use this skill when designing APIs, module boundaries, or any public interface. Create stable, well-documented interfaces that are hard to misuse — REST endpoints, GraphQL schemas, module contracts, component props. Covers contract-first design, error semantics, validation boundaries, idempotency, and consistent naming.

instalaciones
1
GitHub Stars
14
Actualizado
21 oct