Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Applies measure-first performance optimization: profiles to find hot spots, applies algorithm and data-structure improvements before micro-optimizations, and validates each change prevents regression. For single-process code tuning; not for correctness bugs (use cc-debugging) or concurrency, distributed, and real-time tuning (explicitly out of scope).
.claude/skills/ryanthedev-performance-optimization/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 56% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 48% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 37% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 24% | 0% |
| case-22 | ✗→✓ | ▲ Improved | 1% | 0% |
Profile before optimizing — intuition about hot spots is measurably wrong more often than right:
Optimization proceeds only from a measurement — unmeasured "optimizations" are edits with a coin-flip chance of helping.
This skill covers single-threaded, single-process code tuning for general-purpose computing.
Not covered (need specialized guidance):
Simpler code usually runs faster. Fewer special cases = less code to check; deep modules = more work per call with fewer layer crossings; complicated code does extraneous or redundant work.
Each step is a gate — skipping one forfeits the evidence the next step depends on.
1. Is the program correct and complete?
NO -> Make it correct first. STOP optimization.
YES -> Continue
2. Have you measured to find the actual bottleneck?
NO -> Profile/measure first. Do NOT guess.
YES -> Continue
3. Can requirements be relaxed?
YES -> Relax requirements. Done.
NO -> Continue
4. Can design/architecture solve it? (Stage 2: Fundamental Fixes)
YES -> Fix design. Done.
NO -> Continue
5. Can algorithm/data structure solve it?
YES -> Change algorithm. Done.
NO -> Continue
6. Can compiler flags help? (40-59% improvement possible)
YES -> Enable optimizations. Measure.
NO -> Continue
7. Is it in the <4% that causes >50% of runtime?
NO -> Do NOT optimize this code. Find actual hot spot.
YES -> PROCEED with code tuning (see below)What counts as valid measurement:
Identify WHICH dimension: throughput, latency, memory, or CPU. Different problems need different solutions.
Before code-level changes, check for architectural fixes:
If a fundamental fix exists, implement it with standard design techniques. If not, continue down the tree.
When no fundamental fix is available, redesign the critical path:
Consolidation techniques:
| Technique | Example | |-----------|---------| | Encode multiple conditions in single value | Variable that is 0 when any special case applies | | Single test for multiple cases | Replace 6 individual checks with 1 combined check | | Combine layers into single method | Critical path handled in one method, not three | | Merge variables | Combine multiple values into single structure |
Only reached after completing the 7-step decision tree.
1. Save working version (cannot revert without backup)
2. Make ONE change (multiple changes = unmeasurable)
3. Measure improvement (same workload, before/after)
4. Keep if faster, revert if not (no "close enough")
5. RepeatLogic:
Loops:
Data:
Expressions:
Checklist and code examples: Read(${CLAUDE_SKILL_DIR}/checklists.md)
Re-measure before keeping any change. Keep only if: significant speedup (with data), OR simpler AND at least as fast. Otherwise back it out.
| Red Flag | Symptom | |----------|---------| | Premature Optimization | Optimizing without measurement | | Death by Thousand Cuts | Many small inefficiencies, no single fix helps (5-10x slower) | | Pass-Through Methods | Identical signature to caller, unnecessary layer crossing | | Shallow Layers | Multiple layers providing same abstraction | | Repeated Special Cases | Same conditions checked multiple times | | Trading maintainability for <10% gain | Complex optimization for minor speedup |
| Threshold/Rule | Value | Source | |----------------|-------|--------| | Hot spot concentration | <4% causes >50% runtime | Knuth 1971 | | Failed optimization rate | >50% negligible or negative | CC p.607 | | Compiler optimization gains | 40-59% improvement possible | CC p.596 | | I/O vs memory | ~1000x difference | CC p.591 |
Checklist: Read(${CLAUDE_SKILL_DIR}/checklists.md)
Output Format: | Item | Status | Evidence | Location | |------|--------|----------|----------| | Measured before tuning? | VIOLATION | No profiler/measurement found | N/A | | Loop unswitching opportunity | WARNING | Invariant if (debug) inside loop | app.py:142 |
Severity: VIOLATION (clear anti-pattern), WARNING (needs measurement), PASS (no issues)
| After | Next | |-------|------| | Optimization complete | Verify design not degraded | | Structure degraded | cc-refactoring-guidance |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 13,602 | 17,063 | +25% | 1 | 1 | 0% | 2,234 | 4,312 | +93% | 0 | 0 | — |
case-02 | fail→pass | 19,263 | 21,133 | +10% | 1 | 1 | 0% | 3,346 | 5,211 | +56% | 0 | 0 | — |
case-03 | fail→pass | 18,959 | 17,457 | -8% | 1 | 1 | 0% | 3,118 | 4,623 | +48% | 0 | 0 | — |
case-04 | fail→pass | 22,364 | 17,677 | -21% | 1 | 1 | 0% | 3,511 | 4,816 | +37% | 0 | 0 | — |
case-05 | pass→pass | 17,922 | 12,748 | -29% | 1 | 1 | 0% | 2,980 | 3,909 | +31% | 0 | 0 | — |
case-06 | pass→pass | 18,945 | 12,210 | -36% | 1 | 1 | 0% | 3,036 | 3,635 | +20% | 0 | 0 | — |
case-07 | pass→pass | 15,358 | 13,019 | -15% | 1 | 1 | 0% | 2,509 | 3,526 | +41% | 0 | 0 | — |
case-08 | pass→pass | 18,972 | 11,005 | -42% | 1 | 1 | 0% | 2,938 | 3,484 | +19% | 0 | 0 | — |
case-09 | pass→pass | 16,092 | 10,836 | -33% | 1 | 1 | 0% | 2,846 | 3,413 | +20% | 0 | 0 | — |
case-10 | pass→pass | 17,605 | 9,073 | -48% | 1 | 1 | 0% | 2,534 | 3,165 | +25% | 0 | 0 | — |
case-11 | pass→pass | 12,454 | 11,633 | -7% | 1 | 1 | 0% | 2,041 | 3,299 | +62% | 0 | 0 | — |
case-12 | fail→fail | 9,883 | 9,094 | -8% | 1 | 1 | 0% | 1,558 | 1,819 | +17% | 0 | 0 | — |
case-13 | fail→pass | 17,007 | 10,000 | -41% | 1 | 1 | 0% | 2,664 | 3,295 | +24% | 0 | 0 | — |
case-14 | pass→pass | 12,087 | 12,525 | +4% | 1 | 1 | 0% | 1,979 | 3,092 | +56% | 0 | 0 | — |
case-15 | pass→pass | 8,981 | 7,205 | -20% | 1 | 1 | 0% | 1,520 | 2,759 | +82% | 0 | 0 | — |
case-16 | pass→pass | 17,012 | 8,660 | -49% | 1 | 1 | 0% | 2,510 | 2,950 | +18% | 0 | 0 | — |
case-17 | pass→pass | 11,858 | 6,591 | -44% | 1 | 1 | 0% | 1,713 | 2,773 | +62% | 0 | 0 | — |
case-18 | pass→pass | 13,405 | 7,046 | -47% | 1 | 1 | 0% | 2,082 | 2,680 | +29% | 0 | 0 | — |
case-19 | pass→pass | 7,724 | 6,793 | -12% | 1 | 1 | 0% | 1,304 | 2,660 | +104% | 0 | 0 | — |
case-20 | pass→pass | 6,287 | 5,143 | -18% | 1 | 1 | 0% | 919 | 2,290 | +149% | 0 | 0 | — |
case-21 | pass→pass | 7,701 | 5,388 | -30% | 1 | 1 | 0% | 1,195 | 2,517 | +111% | 0 | 0 | — |
case-22 | fail→pass | 25,533 | 4,560 | -82% | 1 | 1 | 0% | 2,358 | 2,392 | +1% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +23 percentage points is the difference between those two pass rates over the 21 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.