Performance optimization

From JeremyDev87/codingbuddy · View interactive version

Performance optimization is an AI agent skill from the GitHub repository JeremyDev87/codingbuddy. Use when optimizing code performance, addressing slowness complaints, or measuring application speed improvements

How to use this skill

Skill file

Performance Optimization

Iron Law: NO OPTIMIZATION WITHOUT PROFILING FIRST

No exceptions - not for "obvious" bottlenecks, "quick wins", or "best practices".

Use for: Slow APIs, UI lag, high memory, slow builds, database queries, any "make it faster" request.

Five Phases

| Phase | Activity | Output |

|-------|----------|--------|

| 1. Profile | Find hot paths with profiler | Bottlenecks with % of time |

| 2. Benchmark | 5 warm-up + 10 measured runs | Baseline with mean, std, p95 |

| 3. Prioritize | Apply Amdahl's Law | ROI-ranked list |

| 4. Optimize | ONE change, verify | Measured improvement |

| 5. Prevent | CI gates, monitoring | Regression detection |

Phase 1: Profile

  1. Clarify metrics ("It's slow" → p50? p95?)
  2. Select profiler:
  1. Profile cold AND warm cache
  2. Flame graphs: Wider bars = more time
  3. Time-box: Max 2 hours → Escalate if unclear

Phase 3: Prioritize (Amdahl's Law)

Formula: Speedup = 1 / ((1 - P) + P/S)

| Bottleneck % | Max Speedup | Action |

|--------------|-------------|--------|

| < 5% | < 1.05x | Skip |

| 5-20% | 1.05-1.25x | Low priority |

| 20-50% | 1.25-2x | Medium |

| > 50% | > 2x | High priority |

Multiple similar %? Optimize easiest first. Re-profile after each.

Phase 4: Optimize

  1. Write benchmark test first
  2. ONE change at a time
  3. Compare statistically
  4. Rollback: Separate commit, feature flags

Phase 5: Prevent

Add CI gate: PERF_BUDGET_MS: 150 → fail build if exceeded

Red Flags - STOP

Rationalizations

| Excuse | Reality |

|--------|---------|

| "I know the bottleneck" | Profiling surprises 90% of time |

| "Micro-optimizations add up" | Amdahl's Law: 5% code = 95% time |

See documentation-template.md for before/after template.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.