agentleFS
DevelopersGlobalDevelopersGlobal/ai-agent-skills/skills/performance-optimization/SKILL.md

performance-optimization

Skill216 starsChanged 6 months agoMITView on GitHub

Measure first, optimize second. Data-driven performance improvements with before/after benchmarks and production validation.

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 102 edited versions we read keep these.

  • 7

    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:

    When performance issues are reported in production

    line 15
  2. Distinctive:

    Before optimizing any code (to ensure you're optimizing the right thing)

    line 16
  3. Distinctive:

    When reviewing changes that touch performance-sensitive paths

    line 17
  4. Distinctive:

    Write the performance test you'll use to validate improvement.

    line 26
  5. Distinctive:

    Use profiling tools: flame graphs, CPU profiles, memory profiles.

    line 32
  6. Distinctive:

    Run the same performance test from Step 1.

    line 51
  7. Distinctive:

    If improvement < 20%: the optimization may not be worth the complexity.

    line 53

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

Overview

Premature optimization is the root of all evil. But ignoring performance until it's a crisis is equally harmful. This skill enforces data-driven optimization: profile first, optimize the bottleneck, measure the improvement.

When to Use

  • When performance issues are reported in production
  • Before optimizing any code (to ensure you're optimizing the right thing)
  • When reviewing changes that touch performance-sensitive paths

Process

Step 1: Measure the Baseline

  1. Reproduce the performance issue reliably.
  2. Measure current performance: latency p50/p95/p99, throughput, memory, CPU.
  3. Profile to find the actual bottleneck — not where you think it is.
  4. Write the performance test you'll use to validate improvement.

Verify: You have concrete baseline numbers, not gut feelings.

Step 2: Identify the Real Bottleneck

  1. Use profiling tools: flame graphs, CPU profiles, memory profiles.
  2. Find the top 3 hotspots by actual execution time (not lines of code).
  3. The bottleneck is rarely where you expect it to be. Trust the data.

Verify: Bottleneck identified by profiling data, not assumption.

Step 3: Optimize Only the Bottleneck

  1. Fix only the profiled bottleneck — nothing else.
  2. Common optimizations by type:
    • CPU: Algorithmic improvement (O(n²) → O(n log n)), caching, batching
    • Memory: Streaming instead of buffering, object pooling, lazy loading
    • I/O: Connection pooling, N+1 query elimination, caching, async/parallel calls
    • AI: Prompt caching, batch inference, smaller models for simpler tasks

Verify: Change targets the profiled bottleneck, not speculative improvements.

Step 4: Measure the Improvement

  1. Run the same performance test from Step 1.
  2. Compare before vs. after metrics.
  3. If improvement < 20%: the optimization may not be worth the complexity.

Verify: Improvement measured with the same test harness as baseline.

Common Rationalizations (and Rebuttals)

ExcuseRebuttal
"I know where the bottleneck is"You're probably wrong. Profile first.
"This is clearly slow""Clearly slow" rarely matches profiler output. Measure.
"We'll optimize later"If it's slow enough to mention, it's slow enough to measure now.

Verification

  • Baseline metrics captured before any optimization
  • Bottleneck identified by profiler (not assumption)
  • Optimization targets only the profiled bottleneck
  • Improvement measured with same test harness
  • Before/after numbers documented

References

  • references/performance-checklist.md
  • observability skill

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.

Reviews can't be read right now.

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.