Skip to content
Back to skills

Measure Before Optimizing

ASecurity

Use when asked to improve performance, or when about to optimize code believed to be slow

  • 2 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 6, 2026
ai-agentsgoperformance

Security analysis

A100/100

Scanned September 6, 2026

npx -y skills add yuchi-chang/no-cape --skill measure-before-optimizing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Measure Before Optimizing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Measure Before Optimizing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/yuchi-chang-measure-before-optimizing/badge)](https://www.skillsdirectory.com/skills/yuchi-chang-measure-before-optimizing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: measure-before-optimizing
description: Use when asked to improve performance, or when about to optimize code believed to be slow
---

# Measure Before Optimizing

No optimization without a measurement. Intuition about where time goes is wrong often enough that acting on it produces complexity without speed.

## The cycle

1. **Measure first.** Profile, time, or count queries on a realistic workload. Find the actual hotspot — not the code that "looks slow".
2. **State the baseline.** "X takes 2.3s, target is under 500ms." Without a number, nothing can be proven later.
3. **Fix the biggest cost first.** It is usually structural — N+1 queries, O(n²) loops, missing index, repeated work inside a loop, chatty I/O — not micro-level (string concatenation, function call overhead).
4. **Re-measure the same workload.** Report before/after numbers. Without them, the claim is just "I changed something".

## Heuristics

- Batching and killing N+1 patterns beat any micro-optimization by orders of magnitude.
- Cache only with an invalidation story — a stale cache trades a speed problem for a correctness bug.
- Don't trade readability for unmeasured gains; do trade it for a measured 10x.
- Parallelism added "for speed" without measurement usually adds race conditions, not speed.

## Red flags

"This should be faster", optimizing in the middle of an unrelated task, preemptive caching or parallelization. All of these mean: measure first, or leave it alone.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.