performance-optimization
Skill1 starsChanged 9 months agoApache-2.0View on GitHub
Web and backend performance optimization including Core Web Vitals (LCP, FID, INP, CLS), bundle analysis with webpack-bundle-analyzer, code splitting, lazy loading, image optimization (WebP, AVIF, responsive srcset), caching strategies (HTTP Cache-Control, CDN, Redis, application-level), database query optimization (indexing, EXPLAIN ANALYZE, N+1), memory leak detection with Chrome DevTools and Node --inspect, connection pooling, and async processing patterns. Use when diagnosing slow pages, reducing bundle size, optimizing API response times, or fixing memory leaks.
83 other projects use a version of this.
Adopted by
Most recently taken up by
- Lukk17/agent-standardstheir own version, first seen Oct 5, 2026
- GuillemRoca/agent-skills-androidtheir own version, first seen Oct 3, 2026
- addyosmani/agent-skillstheir own version, first seen Oct 3, 2026
- weisser-dev/agentic-skillstheir own version, first seen Oct 3, 2026
- Rvey/agent-engineering-kittheir own version, first seen Oct 1, 2026
- JPeetz/agent-skillstheir own version, first seen Sep 29, 2026
Used with
Projects with it also use constraint-driven-development, using-agent-skills and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
vinvcnSkillconstraint-driven-development
把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。
Also in 4 projects that use this
LLl0k0laDSkillusing-agent-skills
Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.
Also in 21 projects that use this
LLl0k0laDSkillgit-workflow-and-versioning
Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.
Also in 23 projects that use this
borhen68Skillobservability-and-instrumentation
Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.
Also in 12 projects that use this
az9713Skilldeprecation-and-migration
Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.
Also in 21 projects that use this
az9713Skillcode-simplification
Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.
Also in 29 projects that use this
- +6 more from LLl0k0laD
Other versions83 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 83
- addyosmani/agent-skills★ 101ksame name
- rohitg00/awesome-claude-code-toolkit★ 2.7ksame name
- gamedev-skills/awesome-gamedev-agent-skills★ 1.3ksame name
- ukanwat/overtime★ 387same name
- Mindrally/skills★ 266same name
- shashankswe2020-ux/whoop-mcp★ 165same name
- magnus919/agent-skills★ 109same name
- thiientv/godmode★ 96same name
- dylantarre/animation-principles★ 94same name
- DevelopersGlobal/ai-agent-skills★ 69same name
73 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository73 other files it gives its agents.
- accessibility-wcagSkill
- api-designSkill
- api-testingSkill
- asset-optimizationSkill
- audio-systemsSkill
- aws-essentialsSkill
- ci-cd-pipelinesSkill
- codebase-analysisSkill
- code-reviewerSkill
- container-securitySkill
- cost-optimizationSkill
- database-designSkill
- data-visualizationSkill
- doc-generationSkill
- docker-kubernetesSkill
- docxSkill
- email-notificationsSkill
- env-configSkill
- flutter-mobileSkill
- framer-motionSkill
- frontend-code-reviewSkill
- frontend-designSkill
- fullstack-developerSkill
- game-enginesSkill
- gameplay-designSkill
- game-programming-languagesSkill
- game-serversSkill
- git-workflowSkill
- godot-4Skill
- golang-proSkill
- go-linter-configurationSkill
- graphics-renderingSkill
- i18n-localizationSkill
- incident-responseSkill
- level-designSkill
- llm-integrationSkill
- local-securitySkill
- memory-managementSkill
- monetization-systemsSkill
- monitoring-observabilitySkill
- multiplayer-netcodeSkill
- nextjs-16Skill
- notebooklm-researchSkill
- npm-packageSkill
- oauth-authSkill
- particle-systemsSkill
- playwright-testingSkill
- postgres-advancedSkill
- programming-architectureSkill
- project-migrationSkill
- publishing-platformsSkill
- python-best-practicesSkill
- react-nativeSkill
- redis-patternsSkill
- refactoring-patternsSkill
- remotion-best-practicesSkill
- rust-best-practicesSkill
- scraping-automationSkill
- security-reviewSkill
- seo-metaSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. 0 are common, 3 are distinctive, and 13 are very specific to this project.
0
Common
Most of the 72 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
Use 103 Early Hints to let the browser start fetching before HTML arrives.
- Distinctive: line 52
Avoid layout thrashing: batch DOM reads, then batch DOM writes.
- Very specific: line 53
Use content-visibility: auto on offscreen sections.
- Very specific: line 71
Always set explicit width and height on images and videos (browser calculates aspect ratio).
- Distinctive: line 73
Never inject content above existing content unless triggered by user interaction.
- Very specific: line 74
Use font-display: optional or preload fonts to prevent FOIT/FOUT shifts.
- Very specific: line 75
Use CSS aspect-ratio for responsive embeds: aspect-ratio: 16 / 9.
- Very specific: line 92
Look for: duplicate dependencies, moment.js (replace with dayjs), lodash (use lodash-es or per-function imports), large polyfills.
- Very specific: line 126
Use ESM (import/export), not CJS (require).
- Very specific: line 128
Avoid barrel files (index.ts re-exporting everything) — they defeat tree shaking.
- Very specific: line 227
Run EXPLAIN ANALYZE on every slow query.
- Very specific: line 276
Event listeners: never removed. Use AbortController to clean up.
- Very specific: line 279
Unreferenced timers: Always clearInterval/clearTimeout on shutdown.
- Very specific: line 296
Look for Detached HTMLDivElement — DOM nodes removed from tree but still referenced in JS.
- Distinctive: line 326
When an API handler does work that isn't needed for the response, move it out of the request path.
- Very specific: line 346
Use BullMQ (Node.js), Celery (Python), or a message broker (RabbitMQ, SQS) for production queues.
“Common” is measured: kept by at least 6 in 10 of the 72 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Senior performance engineer who identifies bottlenecks and applies targeted optimizations with measurable impact.
Use this skill when
- Diagnosing or improving Core Web Vitals (LCP, INP, CLS)
- Reducing JavaScript bundle size or optimizing code splitting
- Implementing caching at any layer (HTTP, CDN, Redis, application)
- Optimizing database queries or fixing N+1 problems
- Debugging memory leaks in Node.js or browser
- Designing async processing pipelines for throughput
Core Web Vitals
LCP (Largest Contentful Paint) — Target: < 2.5s
LCP measures when the largest visible element finishes rendering. Usually a hero image, video, or large text block.
Common fixes:
- Preload the LCP resource:
<link rel="preload" as="image" href="/hero.webp"> - Inline critical CSS, defer the rest. Use
crittersfor automated critical CSS extraction. - Set
fetchpriority="high"on the LCP image. Removeloading="lazy"from above-the-fold images. - Serve from CDN. Eliminate redirect chains.
- Use
103 Early Hintsto let the browser start fetching before HTML arrives.
<!-- Optimal LCP image -->
<img
src="/hero.webp"
srcset="/hero-480.webp 480w, /hero-800.webp 800w, /hero-1200.webp 1200w"
sizes="(max-width: 600px) 480px, (max-width: 1024px) 800px, 1200px"
width="1200"
height="630"
alt="Hero image"
fetchpriority="high"
decoding="async"
/>INP (Interaction to Next Paint) — Target: < 200ms
INP replaced FID in March 2024. It measures the worst-case delay between user input and visual update across the entire page lifecycle.
Common fixes:
- Break long tasks (>50ms) with
scheduler.yield()orsetTimeout(0). - Move heavy computation to Web Workers.
- Debounce rapid-fire events (scroll, resize, input) — 100-150ms debounce.
- Avoid layout thrashing: batch DOM reads, then batch DOM writes.
- Use
content-visibility: autoon offscreen sections.
// Break a long task into yielding chunks
async function processItems(items: Item[]) {
for (let i = 0; i < items.length; i++) {
processItem(items[i]);
if (i % 50 === 0) {
// Yield to main thread every 50 items
await new Promise((resolve) => setTimeout(resolve, 0));
}
}
}CLS (Cumulative Layout Shift) — Target: < 0.1
Common fixes:
- Always set explicit
widthandheighton images and videos (browser calculates aspect ratio). - Reserve space for dynamic content:
min-heighton containers that load async. - Never inject content above existing content unless triggered by user interaction.
- Use
font-display: optionalor preload fonts to prevent FOIT/FOUT shifts. - Use CSS
aspect-ratiofor responsive embeds:aspect-ratio: 16 / 9.
Bundle Analysis and Code Splitting
Analyze First
# Next.js — built-in analyzer
ANALYZE=true next build
# Webpack
npx webpack-bundle-analyzer dist/stats.json
# Vite
npx vite-bundle-visualizerLook for: duplicate dependencies, moment.js (replace with dayjs), lodash (use lodash-es or per-function imports), large polyfills.
Code Splitting Patterns
// Route-based splitting (React)
const Dashboard = lazy(() => import("./pages/Dashboard"));
const Settings = lazy(() => import("./pages/Settings"));
// Component-level splitting for heavy UI
const HeavyChart = lazy(() => import("./components/HeavyChart"));
function App() {
return (
<Suspense fallback={<Skeleton />}>
<Routes>
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/settings" element={<Settings />} />
</Routes>
</Suspense>
);
}
// Prefetch on hover for perceived instant loading
function NavLink({ to, children }: { to: string; children: React.ReactNode }) {
const prefetch = () => {
if (to === "/dashboard") import("./pages/Dashboard");
};
return <Link to={to} onMouseEnter={prefetch}>{children}</Link>;
}Tree Shaking Essentials
- Use ESM (
import/export), not CJS (require). CJS is not tree-shakeable. - Set
"sideEffects": falsein package.json (or list files with side effects). - Avoid barrel files (
index.tsre-exporting everything) — they defeat tree shaking.
Image Optimization
Format Selection
| Format | Use for | Browser support |
| AVIF | Photos, complex images. 50% smaller than JPEG. | Chrome, Firefox, Safari 16.4+ |
| WebP | Universal fallback. 30% smaller than JPEG. | All modern browsers |
| SVG | Icons, logos, simple graphics. Infinite scale. | Universal |
| PNG | Screenshots with text, transparency needed. | Universal |
Next.js Image Component
import Image from "next/image";
// Automatically serves AVIF > WebP > JPEG, responsive sizes, lazy loaded
<Image
src="/product.jpg"
width={800}
height={600}
alt="Product photo"
sizes="(max-width: 768px) 100vw, 50vw"
priority={isAboveFold} // Sets fetchpriority="high", disables lazy load
/>Sharp for Server-Side Processing
import sharp from "sharp";
await sharp(inputBuffer)
.resize(1200, 630, { fit: "cover", position: "attention" }) // Smart crop
.avif({ quality: 50 }) // AVIF at quality 50 ≈ JPEG at quality 80
.toFile("output.avif");Caching Strategies
HTTP Cache-Control Headers
# Static assets (hashed filenames): cache forever
Cache-Control: public, max-age=31536000, immutable
# API responses: revalidate after 60s, serve stale while revalidating
Cache-Control: public, max-age=60, stale-while-revalidate=300
# User-specific data: no shared cache
Cache-Control: private, max-age=0, must-revalidate
# Never cache
Cache-Control: no-storeRedis Caching Patterns
async function getCachedOrFetch<T>(
key: string,
fetcher: () => Promise<T>,
ttlSeconds: number
): Promise<T> {
const cached = await redis.get(key);
if (cached) return JSON.parse(cached) as T;
const data = await fetcher();
// SET with EX (expire) and NX (only if not exists) to prevent thundering herd
await redis.set(key, JSON.stringify(data), "EX", ttlSeconds);
return data;
}
// Cache-aside with stale-while-revalidate pattern
async function getWithSWR<T>(key: string, fetcher: () => Promise<T>, ttl: number): Promise<T> {
const cached = await redis.get(key);
if (cached) {
const parsed = JSON.parse(cached) as { data: T; fetchedAt: number };
const age = Date.now() - parsed.fetchedAt;
if (age > ttl * 500) {
// Over 50% of TTL — revalidate in background
fetcher().then((fresh) =>
redis.set(key, JSON.stringify({ data: fresh, fetchedAt: Date.now() }), "EX", ttl)
);
}
return parsed.data;
}
const data = await fetcher();
await redis.set(key, JSON.stringify({ data, fetchedAt: Date.now() }), "EX", ttl);
return data;
}Database Query Optimization
Index Strategy
- Run
EXPLAIN ANALYZEon every slow query. Look forSeq Scanon large tables. - Index columns used in
WHERE,JOIN,ORDER BY. Composite indexes: leftmost prefix matters. - Covering indexes: include all
SELECTcolumns so the DB reads only the index, not the table.
-- Composite index: supports WHERE user_id = ? AND created_at > ?
CREATE INDEX idx_orders_user_created ON orders (user_id, created_at DESC);
-- Covering index: query satisfied entirely from index
CREATE INDEX idx_orders_covering ON orders (user_id, created_at DESC)
INCLUDE (total_amount, status);
-- Partial index: only index rows that matter
CREATE INDEX idx_orders_pending ON orders (created_at)
WHERE status = 'pending';N+1 Detection and Fix
// BAD: N+1 — 1 query for users + N queries for orders
const users = await db.query("SELECT * FROM users LIMIT 100");
for (const user of users) {
user.orders = await db.query("SELECT * FROM orders WHERE user_id = $1", [user.id]);
}
// GOOD: 2 queries total with a join or IN clause
const users = await db.query("SELECT * FROM users LIMIT 100");
const userIds = users.map((u) => u.id);
const orders = await db.query("SELECT * FROM orders WHERE user_id = ANY($1)", [userIds]);
const ordersByUser = Map.groupBy(orders, (o) => o.user_id);
for (const user of users) {
user.orders = ordersByUser.get(user.id) ?? [];
}Memory Leak Detection
Node.js
# Start with inspector
node --inspect dist/server.js
# Generate heap snapshot programmatically
kill -USR2 <pid> # Node writes .heapsnapshot to cwdCommon Node.js leak sources:
- Event listeners never removed. Use
AbortControllerto clean up. - Closures capturing large objects. Null out references after use.
- Global caches without eviction. Use
lru-cachewithmaxandttl. - Unreferenced timers. Always
clearInterval/clearTimeouton shutdown.
import { LRUCache } from "lru-cache";
// Bounded cache: max 1000 entries, 5-minute TTL
const cache = new LRUCache<string, object>({
max: 1000,
ttl: 1000 * 60 * 5,
});Browser (Chrome DevTools)
- Open Memory tab. Take a heap snapshot (Snapshot 1).
- Perform the suspected leaking action (navigate, open modal, etc.).
- Take Snapshot 2. Use "Comparison" view to see allocated-but-not-freed objects.
- Look for
Detached HTMLDivElement— DOM nodes removed from tree but still referenced in JS. - Filter by "Objects allocated between Snapshot 1 and 2" to find the leak source.
Connection Pooling
// Go database/sql — pool is built in
db, err := sql.Open("postgres", connStr)
db.SetMaxOpenConns(25) // Match your DB's max_connections / number_of_instances
db.SetMaxIdleConns(10) // Keep idle connections warm
db.SetConnMaxLifetime(5 * time.Minute) // Rotate connections to rebalance after DB failover
db.SetConnMaxIdleTime(1 * time.Minute) // Close idle connections to free DB resources// Node.js with pg pool
import { Pool } from "pg";
const pool = new Pool({
max: 20, // Max connections in pool
idleTimeoutMillis: 30000, // Close idle connections after 30s
connectionTimeoutMillis: 5000, // Fail fast if no connection available
});
// Always release connections — use pool.query() for auto-release
const result = await pool.query("SELECT * FROM users WHERE id = $1", [userId]);Async Processing Patterns
When an API handler does work that isn't needed for the response, move it out of the request path.
// BAD: user waits for email sending + analytics
app.post("/signup", async (req, res) => {
const user = await createUser(req.body);
await sendWelcomeEmail(user); // 500ms
await trackSignupEvent(user); // 200ms
res.json(user); // Total: 700ms+ for user
});
// GOOD: respond immediately, process async via queue
app.post("/signup", async (req, res) => {
const user = await createUser(req.body);
await queue.add("send-welcome-email", { userId: user.id });
await queue.add("track-signup", { userId: user.id });
res.json(user); // Total: ~50ms for user
});Use BullMQ (Node.js), Celery (Python), or a message broker (RabbitMQ, SQS) for production queues. Always make queue consumers idempotent — jobs may be retried.
Game Performance
Frame Budgets
| Target FPS | Frame Time | Platform |
| 30 FPS | 33.3 ms | Console (heavy games) |
| 60 FPS | 16.6 ms | PC, Console, Mobile |
| 90 FPS | 11.1 ms | VR (minimum) |
| 120 FPS | 8.3 ms | Competitive games |
| 144+ FPS | 6.9 ms | High-end PC |
At 60 FPS (16.6ms), budget roughly 8ms CPU (game logic, physics, animation, audio) and 8ms GPU (geometry, lighting, post-process, UI).
CPU Optimization
- Algorithmic: Spatial hashing for neighbor queries, early-out conditions, reduce O(n^2) to O(n log n).
- Cache-friendly data: Data-oriented design (Struct of Arrays over Array of Structs), process data linearly, minimize cache misses.
- Allocation: Object pooling, pre-allocate collections, avoid GC in hot paths.
- Threading: Offload to job systems, async loading, parallel processing.
GPU Optimization
- Draw calls: Static/dynamic batching, GPU instancing, merge meshes. Target <2000 on PC, <200 on mobile.
- Overdraw: Front-to-back rendering, occlusion culling, reduce transparency.
- Shaders: Reduce instruction count, use half precision, minimize texture samples.
- Geometry: LOD systems, mesh simplification, frustum culling.
Platform Targets
Mobile constraints:
- Thermal throttling and battery drain are primary limits
- Memory: 500MB-2GB. Draw calls: 100-200. Triangles: 100K-500K/frame. Texture memory: 200-500MB.
- Target 30-60 FPS stable.
VR requirements:
- Maintain 90 FPS constantly (dropped frames cause nausea).
- Single-pass stereo rendering, fixed foveated rendering, aggressive LOD, minimal post-processing.
Frame Rate Troubleshooting
- Frame drops: Profile CPU vs GPU bound. Check for GC spikes. Move logic to FixedUpdate or coroutines. Add object pooling and LOD.
- Long loads: Async loading with progress bar. Stream assets in background. Compress aggressively. Pre-warm caches.
- Inconsistent pacing: Enable VSync. Use fixed timestep for physics. Spread heavy work across frames.
Profiling Tools
| Engine | CPU Profiler | GPU Profiler | Memory |
| Unity | Profiler | Frame Debugger | Memory Profiler |
| Unreal | Insights | RenderDoc | Memreport |
| Godot | Profiler | GPU Debugger | Built-in |
| Any | Platform tools | RenderDoc/PIX | Valgrind/Instruments |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

