Performance Optimization logo

Performance Optimization

Community
UnpaidAttention
performance-optimization

Make code measurably faster or leaner without breaking it — define a target, measure a baseline, profile to find the ACTUAL bottleneck, apply optimizations in a fixed order of leverage, and re-verify correctness after each change. Trigger this when the user reports slowness, high latency, memory growth, or cost, sets a performance budget, or asks to "optimize" or "speed up" something. Do NOT trigger for functional bugs that happen to involve timing (use debugging-methodology) or for restructuring at equal performance (use safe-refactoring) — this skill exists to move a number.

Overview

PublisherUnpaidAttention
Repositoryfable5-methodology
Skill nameperformance-optimization
Stars
94
Forks
21
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by UnpaidAttention on GitHub. Read the source before you install it.

Installation

Install the Performance Optimization AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/UnpaidAttention/fable5-methodology/tree/main/skills/performance-optimization
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/UnpaidAttention/fable5-methodology.git /tmp/fable5-methodology
mkdir -p .claude/skills
cp -r /tmp/fable5-methodology/skills/performance-optimization .claude/skills/performance-optimization
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Performance Optimization in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Performance Optimization on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Performance Optimization is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Performance Optimization

Optimization without measurement is guessing with extra steps. Intuition about bottlenecks is wrong often enough that acting on it unmeasured wastes the time it was meant to save. The number rules everything: define it, baseline it, move it, prove it.

Step 1: Define the target and the workload

  1. Pin the metric AND the goal: "p95 of /search under 300 ms at 50 rps", "import of the 1M-row file under 2 min", "RSS under 512 MB". No target = no definition of done = optimization that never ends. If the user gave none, propose one and get a nod.
  2. Pin the workload: realistic data at realistic scale. A query fast on 100 dev rows and slow on 10M production rows is the NORMAL case, not an edge case — measuring on toy data measures nothing.

Step 2: Baseline before any change

Measure the current number, three runs (warm), record median and spread in your notes. Every later claim of improvement is relative to this recorded baseline — "feels faster" is not a result.

Step 3: Profile — find where the time actually goes

Use the stack's profiler, not code reading:

  • Rust: cargo flamegraph / perf; --release always — debug-build numbers are fiction.
  • Node/TS: node --prof or 0x/clinic flame; console.time brackets for coarse cuts.
  • Python: py-spy record (no code change) or cProfile + snakeviz.
  • SQL: EXPLAIN (ANALYZE, BUFFERS) on the real query with real data volume.
  • Anything network-y: count the requests first — chattiness dominates before CPU does.

Read the profile for the top consumer. Rule: no optimization is applied to code the profile didn't indict. If the profile surprises you (it usually does), that surprise just saved you a week of optimizing the wrong thing.

Step 4: Apply strategies in order of leverage

Try each level; only descend when the level above is exhausted for the indicted hotspot:

  1. Don't do the work: cache repeated computation, dedupe repeated calls, early-exit, skip unused fields, paginate instead of load-all.
  2. Do the work fewer times / in bulk: fix N+1 queries (join or batch), batch writes, buffer I/O, debounce, move loop-invariant work out of the loop.
  3. Do the work better: right algorithm/data structure — dict lookup over list scan, sort-then-merge over nested loops, the missing database index.
  4. Tune the machinery: connection pools, buffer sizes, compiler/runtime flags, --release.
  5. Parallelize: only now — parallel versions of wasteful work multiply the waste and add race conditions to it.
  6. Micro-optimize: last, rarely, and only with the profile still pointing there.

Step 5: One change, two measurements

For EACH optimization: apply it alone → re-run the metric → re-run the correctness suite. Keep a running table in your notes:

Changep95 beforep95 afterTests
Add index on orders(user_id, created_at)1400 ms310 msgreen
Batch the price lookups310 ms180 msgreen

A change that doesn't move the number gets REVERTED, even if it "should" help — dead optimizations are complexity with no dividend. A change that breaks a test is a bug, not a trade-off, unless the user explicitly accepts the trade.

Step 6: Stop at the target

When the target from Step 1 is met: stop. Further optimization is scope creep with a performance costume. Report the table, the final number vs. target, and any identified-but- unneeded next levers ("materialized view would take it to ~80 ms if ever needed").

Worked example

"The dashboard takes 8 s to load; get it under 2 s."

  • Target: p95 page-data endpoint < 2 s on the staging dataset (4M rows). Baseline: 8.1 s.
  • Profile (EXPLAIN + request log): intuition said "slow rendering"; reality: 41 sequential queries (N+1 on widgets) + one seq-scan aggregate. Rendering was 90 ms — untouched.
  • Level 2: batch widget query → 41 calls → 2. 8.1 s → 2.9 s. Suite green.
  • Level 3: index for the aggregate's filter → seq scan → index scan. 2.9 s → 1.3 s. Green.
  • Target met — STOP. Cache layer (level 1) noted as unneeded next lever, not built.
  • Report: table of both changes with numbers, final 1.3 s vs 2 s target, suite green.

Done when

The target metric from Step 1 is met and demonstrated by recorded before/after measurements on the realistic workload; every applied change is in the table with its own measured delta; the full correctness suite is green after the final state; ineffective changes were reverted; and no code the profiler didn't indict was "optimized".

Frequently asked questions

What does the Performance Optimization AI skill do?

Make code measurably faster or leaner without breaking it — define a target, measure a baseline, profile to find the ACTUAL bottleneck, apply optimizations in a fixed order of leverage, and re-verify correctness after each change. Trigger this when the user reports slowness, high latency, memory growth, or cost, sets a performance budget, or asks to "optimize" or "speed up" something. Do NOT trigger for functional bugs that happen to involve timing (use debugging-methodology) or for restructuring at equal performance (use safe-refactoring) — this skill exists to move a number.

Why use Performance Optimization on TypingMind?

Because you install it once and use it with any model. Performance Optimization is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Performance Optimization in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/UnpaidAttention/fable5-methodology/tree/main/skills/performance-optimization. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Performance Optimization?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Performance Optimization?

As many as you like. As long as a model supports skills, you can use Performance Optimization with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Performance Optimization AI skill free?

It is published on GitHub by UnpaidAttention. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇