Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pixel-process-ug avatar

Performance Optimization

  • 66 installs
  • 1 repo stars
  • Updated March 16, 2026
  • pixel-process-ug/superkit-agents

Helps with ai & agent building tasks.

About

performance-optimization is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.

  • performance-optimization
  • AI & Agent Building
  • AI-coding skill

Performance Optimization by the numbers

  • 66 all-time installs (skills.sh)
  • +2 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #5,968 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pixel-process-ug/superkit-agents --skill performance-optimization

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs66
repo stars1
Last updatedMarch 16, 2026
Repositorypixel-process-ug/superkit-agents

What it does

Helps with ai & agent building tasks.

Files

SKILL.mdMarkdownGitHub ↗

Performance Optimization

Overview

Systematically identify and resolve performance bottlenecks using measurement-driven methodology. This skill enforces a strict MEASURE-IDENTIFY-OPTIMIZE-VERIFY cycle, preventing premature optimization and speculation. Every optimization must produce measurable improvement or be reverted.

Announce at start: "I'm using the performance-optimization skill to diagnose and resolve bottlenecks."

---

Phase 1: MEASURE (Establish Baseline)

Goal: Capture real metrics before changing anything.

Actions

# Web: Lighthouse CI
npx lighthouse https://your-app.com --output=json --output-path=baseline.json

# API: load test with k6
k6 run --out json=baseline.json loadtest.js

# Database: slow query log
# PostgreSQL: SET log_min_duration_statement = 100;  -- log queries > 100ms

Record these numbers. They are the baseline against which improvement is measured.

STOP — Do NOT proceed to Phase 2 until:

  • [ ] Baseline metrics are captured and saved
  • [ ] Specific metric targets are defined (e.g., LCP < 2.5s)
  • [ ] Measurement methodology is documented (so it can be repeated)

---

Phase 2: IDENTIFY (Find the Actual Bottleneck)

Goal: Use profiling tools to find WHERE time is spent. Do NOT guess.

Profiling Tool Selection Table

LayerToolWhat It Shows
Frontend renderingReact DevTools Profiler, Chrome Performance tabComponent render times
NetworkChrome Network tab, WebPageTestRequest waterfall, TTFB
JavaScriptChrome Performance tab, console.time()Function execution time
Node.js server--prof flag, clinic.js, 0xCPU flame graphs
DatabaseEXPLAIN ANALYZE, pg_stat_statementsQuery plans, slow queries
MemoryChrome Memory tab, heapdumpAllocation patterns, leaks
Bundle sizewebpack-bundle-analyzer, vite-bundle-visualizerModule sizes

The bottleneck is almost never where you assume it is. Measure first.

STOP — Do NOT proceed to Phase 3 until:

  • [ ] Profiling tool appropriate to the layer has been used
  • [ ] Specific bottleneck is identified with data
  • [ ] Bottleneck accounts for a significant portion of the problem

---

Phase 3: OPTIMIZE (Fix the Identified Bottleneck)

Goal: Apply the targeted fix. Change ONE thing at a time.

Optimization Decision Table

Bottleneck TypeOptimization ApproachExample
Large bundleCode splitting, tree shaking, dynamic importsReact.lazy(() => import('./HeavyComponent'))
Slow API responseCaching, query optimization, paginationAdd Redis cache with 5min TTL
Slow database queryAdd index, optimize query plan, materialized viewCREATE INDEX idx_user_email ON users(email)
Excessive re-rendersMemoization, virtualization, state restructuringReact.memo, useMemo
Large imagesCompression, lazy loading, responsive images<img loading="lazy" srcset="...">
Slow TTFBServer-side caching, CDN, edge renderingStale-while-revalidate pattern
Memory leakFix event listener cleanup, weak referencesProper useEffect cleanup

STOP — Do NOT proceed to Phase 4 until:

  • [ ] Only ONE change has been made
  • [ ] Change directly targets the identified bottleneck
  • [ ] No unrelated changes were made alongside the optimization

---

Phase 4: VERIFY (Measure Again)

Goal: Re-run the exact same measurement from Phase 1.

Actions

1. Run the same profiling/measurement as Phase 1 2. Compare results:

  • Did the metric improve?
  • By how much?
  • Did any other metrics regress?

3. If improvement is not measurable, REVERT the change.

Optimization that cannot be measured is not optimization.

STOP — Verification complete when:

  • [ ] Same measurement methodology used as Phase 1
  • [ ] Improvement is quantified (e.g., "LCP reduced from 3.2s to 2.1s")
  • [ ] No regressions in other metrics
  • [ ] If no improvement: change reverted

---

Caching Strategy Decision Table

Cache TypeUse WhenTTL GuidanceInvalidation
In-memory (LRU)Single-instance, hot data, computed valuesSeconds to minutesEviction policy
Redis/MemcachedMulti-instance, shared cache, sessionsMinutes to hoursEvent-based or TTL
CDNStatic assets, public pages, API responsesHours to daysDeploy-triggered purge
BrowserRepeat visits, static resourcesDays to months (versioned)Cache-busting hash

Cache-Control Headers

# Immutable assets (hashed filenames)
Cache-Control: public, max-age=31536000, immutable

# API responses (cacheable but must revalidate)
Cache-Control: public, max-age=0, must-revalidate
ETag: "abc123"

# Private user data
Cache-Control: private, no-store

# Stale-while-revalidate (fast response + background refresh)
Cache-Control: public, max-age=60, stale-while-revalidate=300

---

Bundle Optimization Techniques

TechniqueImpactImplementation
Route-level code splittingHighReact.lazy() + Suspense per route
Tree shakingHighES modules only, sideEffects: false
Dynamic importsMediumawait import('heavy-lib') on user action
Image optimizationHighnext/image, WebP/AVIF, responsive srcset
Font optimizationMediumnext/font, font-display: swap, subset
Dependency replacementMediumday.js for moment.js, lodash-es for lodash

Bundle Analysis Commands

# Webpack
npx webpack-bundle-analyzer stats.json

# Vite
npx vite-bundle-visualizer

# Next.js
ANALYZE=true next build

---

Database Query Tuning

Index Optimization

-- Find missing indexes (PostgreSQL)
SELECT schemaname, tablename, seq_scan, idx_scan
FROM pg_stat_user_tables
WHERE seq_scan > idx_scan
ORDER BY seq_scan DESC;

Index Rules

RuleExplanation
Index WHERE, JOIN, ORDER BY columnsThese are the columns the DB searches
Equality columns first in composite indexMost selective filtering first
Range columns last in composite indexLess selective, applied after equality
Remove unused indexesThey slow down writes
Use partial indexes for filtered queriesSmaller index, faster lookups

Query Plan Red Flags

Red Flag in EXPLAIN ANALYZEMeaningFix
Seq Scan on large tableFull table scanAdd index
Nested Loop with many rowsO(n*m) joinAdd index or restructure query
Sort with high memorySorting in memoryAdd index matching ORDER BY
Actual rows >> estimated rowsStale statisticsRun ANALYZE
Hash Join with large buildMemory-intensiveEnsure join columns are indexed

---

Web Vitals Targets

MetricGoodNeeds WorkPoor
LCP (Largest Contentful Paint)< 2.5s2.5-4s> 4s
INP (Interaction to Next Paint)< 200ms200-500ms> 500ms
CLS (Cumulative Layout Shift)< 0.10.1-0.25> 0.25

Web Vitals Optimization Table

MetricOptimizationImplementation
LCPPreload LCP resource<link rel="preload"> or fetchpriority="high"
LCPInline critical CSSExtract above-fold CSS inline
LCPOptimize TTFBCDN, edge rendering, server caching
INPBreak long tasksrequestIdleCallback, scheduler.yield()
INPDebounce input handlers100-300ms debounce on expensive handlers
INPWeb WorkersMove computation off main thread
CLSExplicit dimensionsSet width/height on images and videos
CLSReserve space for dynamic contentPlaceholder sizing for ads, embeds
CLSUse transform animationsAvoid layout-triggering properties

---

Load Testing

Test Types

TypeUsersDurationPurpose
Smoke1-21 minuteVerify test works
LoadExpected traffic10-30 minNormal performance
Stress2-3x expected10-30 minFind breaking point
SoakNormal load2-8 hoursFind memory leaks

Key Metrics

  • Response time percentiles (p50, p95, p99) — not averages
  • Error rate under load
  • Throughput (requests per second)
  • Resource utilization (CPU, memory, connections)

---

Anti-Patterns / Common Mistakes

Anti-PatternWhy It Is WrongCorrect Approach
Optimizing without measuringYou do not know what to fixMEASURE first, always
Premature optimizationWastes time on non-bottlenecksProfile to find actual bottleneck
Memoizing everythingAdds complexity without proven benefitProfile first, memoize second
Caching without invalidation strategyStale data causes bugsDefine invalidation before adding cache
Optimizing averages instead of percentilesAverages hide tail latencyTrack p95 and p99
Multiple optimizations at onceCannot attribute improvementOne change at a time
Keeping optimizations that do not measurably helpDead code and complexityRevert if no measurable improvement
Adding indexes without checking query patternsUnused indexes slow writesCheck slow query log first

---

Subagent Dispatch Opportunities

Task PatternDispatch ToWhen
Profiling different system layers concurrentlyAgent tool with subagent_type="Explore" (one per layer)When analyzing frontend, backend, and database independently
Bundle analysis and tree-shaking reviewAgent tool with subagent_type="general-purpose"When frontend bundle size is a concern
Database query optimization analysisAgent tool dispatching database-architect agentWhen slow queries are identified across multiple tables

Follow the dispatching-parallel-agents skill protocol when dispatching.

---

Integration Points

SkillRelationship
senior-frontendFrontend performance uses bundle and Web Vitals optimization
senior-backendBackend performance uses caching and query tuning
testing-strategyLoad tests are part of the testing pyramid
code-reviewReview checks for performance regressions
systematic-debuggingPerformance issues follow the same investigation methodology
acceptance-testingPerformance targets become acceptance criteria

---

Skill Type

FLEXIBLE — Adapt the depth of optimization to the project context. The MEASURE-IDENTIFY-OPTIMIZE-VERIFY cycle is mandatory for every optimization. Revert any change that does not produce measurable improvement.

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.