agentsclimarketplace

Performance optimization

Skill iceflower/agent-skills/performance-optimization

Agent Skills 오픈 표준 기반 AI 코딩 에이전트용 스킬 컬렉션 (Java, Kotlin, Spring, NestJS, K8s, Terraform, GraphQL, gRPC, OpenTelemetry, a11y, i18n 등 60개)

Install
npx -y skills add iceflower/agent-skills --skill performance-optimization

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Performance optimization patterns for frontend and backend applications. Covers Core Web Vitals (LCP, INP, CLS), bundle optimization, image optimization, rendering performance, DB query tuning, connection pooling, HTTP caching, CDN strategies, compression, performance budgets, and CI integration. Use when optimizing application performance, diagnosing slow pages or APIs, or setting up performance monitoring and budgets.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.6 KB, as published. Nobody here has run it

Performance Optimization Rules

1. Core Web Vitals

The three metrics Google uses for page experience ranking.

MetricGoodNeeds ImprovementPoor
LCP (Largest Contentful Paint)≤ 2.5s2.5s – 4.0s> 4.0s
INP (Interaction to Next Paint)≤ 200ms200ms – 500ms> 500ms
CLS (Cumulative Layout Shift)≤ 0.10.1 – 0.25> 0.25
  • INP replaced FID as a Core Web Vital in March 2024
  • INP measures total interaction latency (input delay + processing + presentation)
  • Measure with field data (CrUX, web-vitals library) and lab data (Lighthouse)

2. Frontend — Bundle Optimization

Code Splitting

  • Split by route (most effective for initial load)
  • Use dynamic import() for non-critical modules
  • Separate vendor chunks from application code
// React route-based splitting
const Dashboard = React.lazy(() => import("./Dashboard"));

<Suspense fallback={<Loading />}>
  <Dashboard />
</Suspense>

Tree Shaking

  • Use ES modules (import/export) — CommonJS is not tree-shakeable
  • Set "sideEffects": false in package.json
  • Avoid barrel files (index.ts re-exports) for large libraries

Bundle Analysis

  • Use webpack-bundle-analyzer, source-map-explorer, or vite-bundle-visualizer
  • Identify and eliminate duplicate dependencies
  • Set performance budgets (see Section 8)

3. Frontend — Image Optimization

TechniqueImpact
Modern formats (WebP, AVIF)25-50% smaller than JPEG/PNG
Responsive images (srcset + sizes)Serve viewport-appropriate size
Lazy loading (loading="lazy")Defer offscreen images
Explicit dimensions (width/height)Prevent CLS
fetchpriority="high" on LCP imagePrioritize critical image (limit to 1-2 images to avoid priority contention)
CDN image transformationOn-demand resize and format conversion
<img
  src="hero.webp"
  srcset="hero-480.webp 480w, hero-800.webp 800w, hero-1200.webp 1200w"
  sizes="(max-width: 600px) 480px, (max-width: 1000px) 800px, 1200px"
  width="1200" height="630"
  loading="lazy"
  alt="Hero image"
/>

4. Frontend — Rendering Performance

Minimize Reflow/Repaint

  • Batch DOM reads before writes (avoid interleaving)
  • Use transform and opacity for animations (GPU-composited, no reflow)
  • Use requestAnimationFrame for DOM mutations
  • Use content-visibility: auto for offscreen content

List Virtualization

Render only visible items for large lists (1000+ items).

  • React: @tanstack/react-virtual, react-window
  • Vue: vue-virtual-scroller

Avoid Main Thread Blocking

  • Break long tasks (> 50ms) with scheduler.yield() or setTimeout
  • Offload heavy computation to Web Workers
  • Use requestIdleCallback for non-urgent work

React-Specific

  • Use React.memo for expensive components
  • Use useMemo/useCallback for referential stability (not premature optimization)
  • Avoid creating objects/arrays in render

5. Backend — Database Query Tuning

Index Strategy

TypeUse Case
B-Tree (default)Range queries, sorting, equality
Composite indexMulti-column WHERE, column order matters
Covering indexQuery answered from index only
Partial indexIndex subset of rows (PostgreSQL)
  • Always use EXPLAIN ANALYZE to verify query plans
  • Remove unused indexes (they slow down writes)

N+1 Problem

# BAD: N+1 queries
users = User.query.all()          # 1 query
for user in users:
    print(user.orders)            # N queries

# GOOD: Eager loading
users = User.query.options(joinedload(User.orders)).all()  # 1 query

General Rules

  • Select only needed columns (avoid SELECT *)
  • Use cursor-based pagination over offset-based for large datasets
  • Use prepared statements (security + plan caching)
  • Monitor slow query logs

6. Backend — Connection and Response

Connection Pooling

  • Reuse database connections instead of creating per request
  • Pool size guideline (HikariCP/PostgreSQL): connections = (CPU cores × 2) + effective_spindle_count — adjust for other databases
  • Set idle timeout and max lifetime
  • Tools: HikariCP (Java), pg-pool (Node.js), PgBouncer (PostgreSQL)

Response Compression

AlgorithmCompressionSpeedSupport
gzipGoodMediumUniversal
Brotli (br)Better (15-25% over gzip)Slow compress, fast decompressModern browsers (HTTPS)
zstdBetterFastChrome 123+
  • Apply to text resources (HTML, CSS, JS, JSON, SVG)
  • Skip already-compressed formats (JPEG, PNG, WOFF2)
  • Pre-compress static assets at build time
  • Set Vary: Accept-Encoding header

7. Network — Caching Strategy

Cache-Control Patterns

Resource TypeRecommended Header
Hashed static assets (JS, CSS)Cache-Control: public, max-age=31536000, immutable
HTML documentsCache-Control: no-cache
API responses (cacheable)Cache-Control: public, max-age=60, stale-while-revalidate=300
Sensitive dataCache-Control: private, no-store

ETag / Conditional Requests

  • Server sends ETag (content hash) with response
  • Client sends If-None-Match on subsequent requests
  • Server returns 304 Not Modified if unchanged (saves bandwidth)

CDN

  • Serve static assets from edge servers
  • Use content-hash filenames for cache busting (app.a1b2c3.js)
  • Set long max-age + immutable for hashed assets
  • Use s-maxage for CDN-specific TTL

Service Worker Caching

StrategyUse Case
Cache FirstStatic assets, fonts
Network FirstAPI responses, dynamic content
Stale While RevalidateFrequently updated but stale-tolerant data

For detailed caching patterns, see the caching skill.

8. Performance Budget and CI

Define Budgets

MetricBudget Example
JS bundle (compressed)≤ 200 KB
Total page weight≤ 500 KB
LCP≤ 2.5s
INP≤ 200ms
CLS≤ 0.1

CI Integration

// .lighthouserc.js
module.exports = {
  ci: {
    assert: {
      assertions: {
        "largest-contentful-paint": ["error", { maxNumericValue: 2500 }],
        "interactive": ["error", { maxNumericValue: 3800 }],
        "cumulative-layout-shift": ["error", { maxNumericValue: 0.1 }],
      },
    },
  },
};

Tools for CI:

  • Lighthouse CI (lhci): Core Web Vitals assertions
  • size-limit: JS cost budget (size + execution time)
  • bundlesize: Per-file size limits
  • Webpack performance: Asset and entrypoint size hints

9. Measurement Tools

ToolTypeBest For
web-vitals libraryField (RUM)Real user Core Web Vitals
CrUX (Chrome UX Report)FieldPopulation-level metrics
LighthouseLabComprehensive audit
Chrome DevTools PerformanceLabDetailed profiling
WebPageTestLabMulti-location, filmstrip
Server-Timing headerServerBackend timing breakdown

Server-Timing

Server-Timing: db;dur=53, app;dur=47.2, cache;desc="Cache Read";dur=23.2

Exposes server-side metrics in DevTools Network tab. Avoid exposing sensitive internals in production.

10. Common Anti-Patterns

For detailed anti-patterns organized by layer, see references/anti-patterns.md.

Anti-PatternImpactFix
Single large bundleSlow initial loadCode splitting + lazy loading
No image optimizationBandwidth waste, slow LCPWebP/AVIF, srcset, lazy loading
Missing cache headersUnnecessary server requestsProper Cache-Control
N+1 queriesDB overloadEager loading, batch queries
No connection poolingConnection exhaustionPool with proper sizing
No compressionBandwidth wastegzip/Brotli
Layout shiftsPoor CLSExplicit dimensions, font-display
Render-blocking resourcesSlow FCP/LCPdefer/async, critical CSS
Unbounded in-memory cacheOOM riskTTL, LRU eviction, external cache
No performance budgetGradual regressionCI enforcement

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.