agentleFS
SWEStashSWEStash/swe-workflow-skills/skills/performance-optimization/SKILL.md

performance-optimization

Skill1 starsChanged 4 days agoMITView on GitHub

Identify and resolve performance bottlenecks via static analysis — N+1 queries, algorithmic complexity, query optimization, caching, memory leaks, bundle size, connection management. Triggers: this is slow, optimize, performance, N+1, query optimization, caching, bundle size, memory leak, latency, response time, scale, bottleneck.

125 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use constraint-driven-development, git-workflow-and-versioning 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.
  • 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 15 projects that use this

  • LLl0k0laDSkill

    git-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 42 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 33 projects that use this

  • HK-hubSkill

    deprecation-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 39 projects that use this

  • ukanwatSkill

    input-systems

    Architect game input — action mapping (abstracting keys into named actions), rebinding with conflict detection and persistence, multi-device support (keyboard, gamepad, touch), analog deadzones, and feel features like input buffering and coyote time, plus accessibility. Engine-neutral. Use when the user mentions input mapping, rebind controls, gamepad support, deadzone, input buffering, coyote time, or accessible controls.

    Also in 4 projects that use this

  • HK-hubSkill

    observability-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 31 projects that use this

  • +6 more from LLl0k0laD

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 8 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 110 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before touching code, establish baselines:

    line 18
  2. Distinctive:

    If the user doesn't have measurements, help them instrument first (see Step 2).

    line 26
  3. Distinctive:

    Write or confirm a performance test exists (even a simple timing assertion)

    line 57
  4. Distinctive:

    Check for regressions (functional tests still pass, other paths not degraded)

    line 60
  5. Distinctive:

    Document what was changed and why (this prevents someone from "cleaning up" the optimization later)

    line 66
  6. Distinctive:

    Premature optimization: Don't optimize code that runs once at startup or handles 10 requests/day

    line 71
  7. Distinctive:

    Micro-optimization: Don't optimize individual array operations when the real bottleneck is a database query taking 2 seconds

    line 72
  8. Distinctive:

    Sacrificing readability: If the optimization makes the code unmaintainable, it's a bad trade unless the performance gain is critical

    line 75

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

Identify and resolve performance bottlenecks through static analysis and design review. Good performance optimization is measurement-driven — identify the bottleneck first, optimize second.

Core Rule

Never optimize without understanding the bottleneck. Random optimization wastes time and often makes things worse. The workflow is always: measure → identify → optimize → verify.

Workflow

Step 1: Understand the Problem

Before touching code, establish baselines:

  • What is slow? Specific endpoint, page load, batch job, query?
  • How slow? Current latency/throughput numbers (or perceived slowness)
  • What's acceptable? Target latency, throughput, or response time
  • When did it start? Was it always slow, or is this a regression?
  • Under what conditions? Load-dependent, data-size-dependent, time-dependent?

If the user doesn't have measurements, help them instrument first (see Step 2). Optimization without measurement is guessing.

Step 2: Identify the Bottleneck

The bottleneck is almost always in one of these areas. Check in this order (most common first):

  1. Database queries — N+1 problems, missing indexes, full table scans, unoptimized joins
  2. External API calls — Sequential calls that could be parallel, no caching of responses
  3. Algorithmic complexity — O(n²) or worse hiding in loops, nested iterations over large datasets
  4. Memory usage — Leaks, loading entire datasets into memory, unbounded caches
  5. Network/I/O — Large payloads, no compression, chatty protocols, missing CDN
  6. Serialization — Expensive JSON parsing/generation, unnecessary data transformation
  7. Concurrency issues — Race conditions, lock contention, thread pool exhaustion, async bottlenecks. See references/concurrency.md for patterns and common bugs.

See references/bottleneck-patterns.md for the detailed detection guide.

Step 3: Analyze and Recommend

For each identified bottleneck:

  1. Explain what the problem is and why it causes slowness
  2. Quantify the impact (e.g., "This makes 50 DB queries per page load instead of 2")
  3. Propose a specific fix with expected improvement
  4. Assess the complexity and risk of the fix

Order recommendations by impact-to-effort ratio. The best optimizations are high impact and low effort.

Step 4: Implement the Fix

Apply one optimization at a time. For each:

  1. Write or confirm a performance test exists (even a simple timing assertion)
  2. Apply the change
  3. Verify the improvement
  4. Check for regressions (functional tests still pass, other paths not degraded)

Step 5: Verify and Document

After optimization:

  • Compare before/after metrics
  • Document what was changed and why (this prevents someone from "cleaning up" the optimization later)
  • Set up monitoring to alert if performance regresses

Anti-patterns

  • Premature optimization: Don't optimize code that runs once at startup or handles 10 requests/day
  • Micro-optimization: Don't optimize individual array operations when the real bottleneck is a database query taking 2 seconds
  • Caching everything: Caches add complexity and staleness bugs. Cache only what's measured as slow and frequently accessed
  • Optimizing the wrong layer: Frontend optimization won't fix a slow API. Database optimization won't fix a slow algorithm
  • Sacrificing readability: If the optimization makes the code unmaintainable, it's a bad trade unless the performance gain is critical

Principles Applied

  • KISS: The simplest optimization that meets the target wins. Don't build a distributed cache when a database index will do.
  • YAGNI: Optimize for current scale, not hypothetical future scale. Document triggers for when to revisit.
  • DRY: Centralize caching logic, query optimization, and connection management — don't optimize the same pattern in 10 places.

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.