Skip to content
Development
Skill

/optimizing-performance

Measure-first performance optimization that balances gains against complexity. Use when addressing slow code, profiling issues, or evaluating optimization trade-offs.

BOOST
From plugin
claude-essentials
13017 skills4 agents3 commands
Install
$ npx -y skills add rileyhilliard/claude-essentials --skill optimizing-performance --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/optimizing-performance

Context preview

The summary Claude sees to decide when to auto-load this skill.

Measure-first performance optimization that balances gains against complexity. Use when addressing slow code, profiling issues, or evaluating optimization trade-offs.

SKILL.md

optimizing-performance.SKILL.md
name: optimizing-performance
description: Measure-first performance optimization that balances gains against complexity. Use when addressing slow code, profiling issues, or evaluating optimization trade-offs.

Optimizing Performance

**Core principle:** Readable code that's "fast enough" beats complex code that's "optimal". Measure first.

**Focus area:** Use an explicitly named target if one was given. Otherwise, run `git diff` and focus on unstaged changes. If no unstaged changes exist, ask the user what to optimize.

The Golden Rule

IF optimization reduces complexity AND improves performance → ALWAYS DO IT
IF optimization increases complexity → Only if 10x faster OR fixes critical UX (>16ms UI, >100ms input)

Win-Win Optimizations (Always Do)

**Multiple loops → Single loop:**

// ❌ Three passes
const ids = users.map(u => u.id);
const active = users.filter(u => u.active);

// ✅ One pass
const { ids, active } = users.reduce((acc, u) => {
  acc.ids.push(u.id);
  if (u.active) acc.active.push(u);
  return acc;
}, { ids: [], active: [] });

**Nested loops → Hash map (O(n²) → O(n)):**

// ❌ O(n²)
const matched = orders.filter(o => users.some(u => u.id === o.userId));

// ✅ O(n)
const userIds = new Set(users.map(u => u.id));
const matched = orders.filter(o => userIds.has(o.userId));

High-Value Optimizations

| Pattern | When | Fix | |---------|------|-----| | Virtualization | Lists >1000 items | react-window, tanstack-virtual | | Memoization | >5ms calc OR unnecessary re-renders | `useMemo`, `React.memo` | | Batching | Multiple state updates | Single setState, bulk INSERT | | Lazy loading | Large dependencies | `import('./heavy-lib')` |

Red Flags

  • Optimizing without benchmark data
  • Micro-optimizing <16ms code
  • Adding complexity for minimal gain
  • Optimizing infrequently-run code
Read more
Ships withclaude-essentials

A unified development plugin for Claude Code with essential skills and specialized agents, all accessible under the ce namespace.

Get the whole plugin

Other skills on claude-essentials.