agentleFS
Mingz6Mingz6/copilot-dev-os/skills/performance-optimization/SKILL.md

performance-optimization

Skill1 starsChanged 35 days agoMITView on GitHub

Cross-stack performance optimization best practices covering frontend, backend, and database. Includes checklists, anti-patterns, profiling guidance, and practical examples for .NET, React, Node.js, Python, and SQL. Use when: "why is this slow", "optimize this", "profile this function", "this query is taking too long", "reduce memory usage", "lazy loading", "benchmark this".

156 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use accessibility-engineering, 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.
  • steven123397Skill

    accessibility-engineering

    Audits existing interfaces for WCAG 2.2 AA conformance and remediates the violations found. Use when auditing a page or component for accessibility, running axe-core or pa11y, triaging a11y violations, or checking screen reader and contrast issues before shipping.

    Also in 4 projects that use this

  • LLl0k0laDSkill

    using-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 40 projects that use this

  • MrCipherSmithSkill

    constraint-driven-development

    Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.

    Also in 20 projects that use this

  • LLl0k0laDSkill

    idea-refine

    Refine ideas through structured divergent and convergent thinking. Use "idea-refine" or "ideate" to trigger.

    Also in 45 projects that use this

  • jaydubya818Skill

    deprecation-and-migration

    Retire APIs or migrate consumers and persistent data across releases.

    Also in 46 projects that use this

  • jaydubya818Skill

    observability-and-instrumentation

    Add or review logs, metrics, traces, and actionable alerts.

    Also in 36 projects that use this

  • +5 more from LLl0k0laD

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. 0 are common, 15 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 138 edited versions we read keep these.

  • 15

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Avoid Premature Optimization: Write clear code first; optimize when needed.

    line 14
  2. Very specific:

    Use React.memo, useMemo, useCallback to prevent unnecessary re-renders.

    line 24
  3. Distinctive:

    Use stable keys in lists (not array indices).

    line 25
  4. Distinctive:

    Prefer CSS transitions/animations over JavaScript for GPU-accelerated effects.

    line 26
  5. Very specific:

    Use CDNs, Service Workers, <link rel="preload">.

    line 37
  6. Very specific:

    Use defer/async for non-critical scripts.

    line 38
  7. Distinctive:

    Don't block the main thread — use Web Workers for heavy computation.

    line 41
  8. Distinctive:

    Use Maps/Sets for lookups, TypedArrays for numeric data.

    line 44
  9. Distinctive:

    Avoid anonymous functions in render.

    line 50
  10. Distinctive:

    Avoid O(n²) or worse — profile nested loops.

    line 65
  11. Distinctive:

    Use async/await for I/O-bound work.

    line 69
  12. Distinctive:

    Use TTL-based, event-based, or manual invalidation.

    line 76
  13. Distinctive:

    Always paginate large result sets.

    line 81
  14. Very specific:

    Never block the event loop (fs.readFileSync in production).

    line 94
  15. Distinctive:

    Avoid N+1 queries — use JOINs or batch queries.

    line 118
  16. Distinctive:

    Use the most efficient data types.

    line 123
  17. Distinctive:

    Keep transactions short to reduce lock contention.

    line 127
  18. Distinctive:

    Use the lowest isolation level that meets consistency needs.

    line 128
  19. Distinctive:

    Read replicas for scaling reads.

    line 131

“Common” is measured: kept by at least 6 in 10 of the 138 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Performance Optimization Best Practices

Your goal is to help me optimize code for performance across any layer of the stack.

General Principles

  • Measure First, Optimize Second: Profile and benchmark before optimizing. Use tools like Chrome DevTools, Lighthouse, Py-Spy, dotTrace, or language-specific profilers.
  • Optimize for the Common Case: Focus on frequently executed code paths.
  • Avoid Premature Optimization: Write clear code first; optimize when needed.
  • Minimize Resource Usage: CPU, memory, network, disk — always ask "can this be done with less?"
  • Set Performance Budgets: Define limits for load time, memory, API latency. Enforce with automated checks.

Frontend Performance

Rendering and DOM

  • Minimize DOM manipulations — batch updates, use document fragments.
  • Use React.memo, useMemo, useCallback to prevent unnecessary re-renders.
  • Use stable keys in lists (not array indices).
  • Prefer CSS transitions/animations over JavaScript for GPU-accelerated effects.
  • Defer non-critical rendering with requestIdleCallback.

Asset Optimization

  • Compress images (WebP, AVIF). Use loading="lazy" for images.
  • Minify and bundle JS/CSS (esbuild, Webpack, Rollup). Enable tree-shaking.
  • Subset fonts, use font-display: swap.
  • Set long-lived cache headers with cache busting.

Network

  • Reduce HTTP requests. Enable HTTP/2 or HTTP/3.
  • Use CDNs, Service Workers, <link rel="preload">.
  • Use defer/async for non-critical scripts.

JavaScript

  • Don't block the main thread — use Web Workers for heavy computation.
  • Debounce/throttle scroll, resize, input events.
  • Clean up event listeners, intervals, DOM references to prevent memory leaks.
  • Use Maps/Sets for lookups, TypedArrays for numeric data.

Framework-Specific

React

  • React.memo, useMemo, useCallback to avoid re-renders.
  • Code-split with React.lazy + Suspense.
  • Avoid anonymous functions in render.
  • Profile with React DevTools Profiler.

Angular

  • OnPush change detection. trackBy in ngFor. Lazy load modules.

Vue

  • Computed properties over methods in templates. v-show vs v-if. Lazy load routes.

Backend Performance

Algorithms and Data Structures

  • Choose the right data structure: arrays for sequential, hash maps for lookups, trees for hierarchy.
  • Avoid O(n²) or worse — profile nested loops.
  • Batch processing and streaming for large datasets.

Concurrency

  • Use async/await for I/O-bound work.
  • Thread/worker pools to manage concurrency.
  • Batch network/database calls to reduce round trips.
  • Implement backpressure in queues and pipelines.

Caching

  • Cache expensive computations (Redis, Memcached).
  • Use TTL-based, event-based, or manual invalidation. Stale cache is worse than no cache.
  • Cache stampede protection with locks or request coalescing.

API and Network

  • Minimize payloads. Compress responses (gzip, Brotli).
  • Always paginate large result sets. Use cursors for real-time data.
  • Connection pooling for databases and external services.
  • Rate limiting to protect APIs.

Language-Specific

.NET

  • async/await for I/O. Span<T>, Memory<T> for efficient memory.
  • IAsyncEnumerable<T> for streaming.
  • Profile with dotTrace, PerfView.
  • Pool objects and connections.

Node.js

  • Never block the event loop (fs.readFileSync in production).
  • Clustering or worker threads for CPU-bound tasks.
  • Streams for large data processing.
  • Profile with clinic.js or node --inspect.

Python

  • Built-in dict, set, deque for speed. lru_cache for memoization.
  • multiprocessing or asyncio for parallelism.
  • Profile with cProfile, line_profiler, Py-Spy.

Java

  • Efficient collections. Thread pools (Executors).
  • Tune JVM: -Xmx, -Xms, -XX:+UseG1GC.
  • Profile with VisualVM, JProfiler.

Database Performance

Query Optimization

  • Index columns used in WHERE, JOIN, ORDER BY. Drop unused indexes.
  • Never SELECT *. Select only needed columns.
  • Parameterized queries for safety and plan caching.
  • Analyze query plans with EXPLAIN.
  • Avoid N+1 queries — use JOINs or batch queries.
  • Paginate with LIMIT/OFFSET or cursors.

Schema Design

  • Normalize to reduce redundancy; denormalize for read-heavy workloads.
  • Use the most efficient data types.
  • Partition large tables. Archive old data.

Transactions

  • Keep transactions short to reduce lock contention.
  • Use the lowest isolation level that meets consistency needs.

Caching and Replication

  • Read replicas for scaling reads. Monitor replication lag.
  • Cache query results in Redis/Memcached.
  • Sharding for horizontal scalability.

Code Review Checklist

  • Any O(n²) or worse algorithmic inefficiencies?
  • Data structures appropriate for their use?
  • Unnecessary computations or repeated work?
  • Caching used where appropriate? Invalidation handled?
  • Database queries optimized, indexed, free of N+1?
  • Large payloads paginated, streamed, or chunked?
  • Memory leaks or unbounded resource usage?
  • Network requests minimized, batched, retried?
  • Assets optimized, compressed, served efficiently?
  • Blocking operations in hot paths?
  • Performance-critical paths documented and tested?

Profiling and Benchmarking

  • Profilers: Chrome DevTools, Py-Spy, VisualVM, dotTrace, PerfView
  • Microbenchmarks: benchmark.js, pytest-benchmark, JMH
  • Load testing: k6, Gatling, Locust
  • A/B testing for real-world impact measurement
  • Distributed tracing: OpenTelemetry, Jaeger, Zipkin

Scalability

  • Horizontal scaling: stateless services, sharding, load balancers
  • Auto-scaling with sensible thresholds
  • Idempotent operations, retries, circuit breakers

Cloud and Serverless

  • Minimize cold starts: keep dependencies lean, functions warm
  • Tune memory/CPU allocation
  • Monitor cloud cost as a performance metric

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.