agentleFS
POSTTTTPOSTTTT/SKILLs/.claude/skills/optimize/SKILL.md

optimize

Skill1 starsChanged 5 months agoMITView on GitHub

Analyze a codebase for performance and produce an optimization report — where the program is slow, how to make it faster, and the expected speed impact, effort, and risk of each change. Use when the user asks to "optimize the program", "make it faster", "improve performance", "find bottlenecks", "why is this slow", or "reduce latency/memory". Reads and understands the code first, reasons from profiling and algorithmic complexity (not guesses), and reports recommendations ranked by impact — without rewriting hot code until asked.

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 71 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Look for existing benchmarks/profiles.

    line 20
  2. Distinctive:

    Prefer contiguous data (arrays over linked lists / pointer-chasing object graphs), sequential access (prefetcher-friendly), and packing hot …

    line 52
  3. Distinctive:

    Don't pay for abstractions you don't need in hot loops (excess indirection, virtual dispatch, deep call chains, needless copies).

    line 60
  4. Distinctive:

    Use cores (threads/async), overlap I/O with compute instead of blocking, parallelize independent work.

    line 64

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

Performance Optimization Report

Guiding idea: the fastest program is the one that does the least work on the most cache-friendly data — everything else is detail. Your job is to find where the program does too much work or touches memory badly, and write a clear report on how to fix it and what speedup to expect. Report first; don't rewrite hot code until the user approves — performance changes can alter behavior and hurt readability.

Step 0 — Measure, don't guess (most important rule)

Optimization without measurement is superstition. The bottleneck is rarely where intuition says. Per Amdahl's Law, optimizing code that's 1% of runtime yields at most 1% — effort must go to the actual hot path.

  • Look for existing benchmarks/profiles. If none, recommend how to profile this stack (e.g. cProfile/py-spy for Python, perf/flamegraph for native, Chrome DevTools/--prof for JS, pprof for Go, JMH for Java) and what workload to measure under.
  • Be explicit about confidence: mark each finding as measured (backed by a profile/benchmark) vs suspected (inferred from reading the code). Never present a guess as a proven hotspot.

Step 1 — Understand the codebase

  • Map the architecture, entry points, and the hot paths users actually wait on (request handlers, render loops, batch jobs, tight inner loops).
  • Identify the language/runtime — it changes what matters (GC pressure in managed langs, cache layout in native, event-loop blocking in JS, the GIL in Python, allocations everywhere).
  • Note the data: sizes, shapes, access patterns, and where data crosses boundaries (DB, network, disk, serialization).

Step 2 — Analyze against the five principles

For each, find concrete issues and cite file:line.

1. Do less work — algorithmic complexity (biggest wins)

  • Better algorithms/data structures beat micro-tweaks. O(n²)→O(n log n) dwarfs any constant-factor gain. Look for: nested loops over the same data, linear scans that should be hash/index lookups, repeated sorting, quadratic string building.
  • Eliminate redundant computation: hoist invariants out of loops, memoize/cache pure results, avoid recomputing what hasn't changed.
  • Watch for hidden O(n) per call (e.g. list.contains in a loop) and N+1 queries.

2. Respect the memory hierarchy — data locality

  • CPUs are starved by memory, not compute; a cache miss costs ~100× an arithmetic op.
  • Prefer contiguous data (arrays over linked lists / pointer-chasing object graphs), sequential access (prefetcher-friendly), and packing hot fields tightly so the working set fits in cache. Flag structure-of-arrays vs array-of-structures opportunities for hot loops (data-oriented design).

3. Reduce overhead

  • Cut allocations and GC pressure (reuse buffers, pool objects, avoid boxing).
  • Batch I/O and system calls (one bulk DB query/write, not per-row); buffer.
  • Don't pay for abstractions you don't need in hot loops (excess indirection, virtual dispatch, deep call chains, needless copies).

4. Exploit parallelism

  • Use cores (threads/async), overlap I/O with compute instead of blocking, parallelize independent work. Note SIMD/vectorization chances in numeric loops.
  • Reduce dependency chains and unpredictable branches that stall the pipeline.
  • Be honest about cost: concurrency adds bugs/locks — recommend only where the win is real and the work is actually independent.

5. Right-size everything else

  • Connection pooling, lazy vs eager loading, compression trade-offs, caching layers, appropriate data types and indexes.

Step 3 — Write the report

Rank findings by impact, not by how easy they are to spot. For each:

  • Location — file:line and the hot path it's on.
  • Principle — which of the five.
  • Problem — what work/memory cost is being paid, with complexity (e.g. "O(n²) over users, n≈10k").
  • Fix — concrete change, with a corrected snippet where useful.
  • Expected effect — speed/memory impact, framed honestly: a rough magnitude ("~n× fewer comparisons", "removes ~1 DB round-trip per row") and a note that Amdahl's Law caps the gain by this path's share of total runtime — so tie it to how hot the path actually is.
  • Effort & risk — small/medium/large; does it change behavior or readability?
  • Confidence — measured vs suspected.

Suggested layout:

# Optimization Report — <scope> — <date>

## How this was assessed
<profiled? or read-only inference? what workload>

## Top opportunities (ranked by impact)
### 1. [HIGH] N+1 queries in order listing — Principle 1 (do less work)
- Location: src/api/orders.js:48 (per-request hot path)
- Problem: 1 query + N per-row queries; O(n) round-trips, n = #orders.
- Fix: single JOIN / batched `WHERE id IN (...)`.
- Expected effect: ~N fewer DB round-trips; if this path is ~60% of request time,
  expect a large latency drop. Confirm with a before/after benchmark.
- Effort: small · Risk: low · Confidence: suspected (profile to confirm)

## Lower-priority / micro-optimizations
## Not worth it / premature
<things that look slow but are cold paths — Amdahl says skip>

End with: "Want me to implement any of these? Tell me which and I'll apply it and re-measure."

Rules

  • Measure before claiming. Distinguish measured hotspots from suspected ones; recommend profiling when there's no data. Don't dress up guesses as facts.
  • Impact-ranked, Amdahl-aware. Push algorithmic/hot-path wins first; call out premature/cold-path optimizations as not worth it.
  • Report, don't rewrite hot code until approved. Note when a speedup costs readability or changes behavior — that's a trade-off the user should choose.
  • Correctness first. A faster wrong answer is worthless; preserve behavior and recommend re-running tests/benchmarks after any change.

Download now (ZIP)

  • Other versions73 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 73

    1. Z3Prover/z3★ 13ksame name
    2. highcharts/highcharts★ 13ksame name
    3. whitecircle/halo★ 825same name
    4. hacan359/tonkatsu_box★ 597same name
    5. talesofai/cohub★ 583same name
    6. kovrichard/catalyst★ 469same name
    7. nexmoe/DayBee★ 424same name
    8. nexmoe/eve★ 424same name
    9. Southclaws/storyden★ 346same name
    10. 10xChengTu/Mux0★ 337same name

    63 more not listed

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Used alongsideProjects with it also use arrange, teach-impeccable and 10 more.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • HK-hubSkill

      arrange

      Improve layout, spacing, and visual rhythm. Fixes monotonous grids, inconsistent spacing, and weak visual hierarchy. Use when the user mentions layout feeling off, spacing issues, visual hierarchy, crowded UI, alignment problems, or wanting better composition.

      Also in 13 projects that use this

    • HK-hubSkill

      teach-impeccable

      One-time setup that gathers design context for your project and saves it to your AI config file. Run once to establish persistent design guidelines.

      Also in 16 projects that use this

    • zwy123zwySkill

      normalize

      将用户随意输入的提示词规范化为结构清晰、便于大模型执行的标准化提示词。适用于需要整理、统一提示词格式时调用。

      Also in 18 projects that use this

    • open-coder-aiSkill

      policy-init

      Create conformant Chock policy from request. args(request, target_path,

      Also in 3 projects that use this

    • owshq-mecSkill

      layout

      Improve layout, spacing, and visual rhythm. Fixes monotonous grids, inconsistent spacing, and weak visual hierarchy. Use when the user mentions layout feeling off, spacing issues, visual hierarchy, crowded UI, alignment problems, or wanting better composition.

      Also in 7 projects that use this

    • +7 more from HK-hub
  • In this repository6 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.