performance-optimization
Skill5 starsChanged 4 months agoMITView on GitHub
Fix a performance problem by profiling first, making one targeted change, and verifying both the speedup and that correctness held. Use when a feature is measurably slow, a page or API exceeds its budget, or a query takes too long. Do not use to pre-optimize code that has not been measured.
We split this skill into the rules it gives an agent
9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 102 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Run the scenario and record the baseline:
- Distinctive: line 40
Read the profiler output - do not guess from the source.
- Distinctive: line 66
Add caching everywhere in case something else is also slow
- Distinctive: line 73
Run the same scenario under the same conditions as the baseline:
- Distinctive: line 79
If the improvement is less than 20% or does not meet the target, re-profile - you may have fixed a symptom, or the bottleneck may have …
- Distinctive: line 93
Do not add caching without a cache invalidation strategy.
- Distinctive: line 94
Do not replace a correct algorithm with a faster but subtly incorrect one and call it "good enough."
- Distinctive: line 95
Do not optimize code that is called rarely - focus on hot paths only.
- Distinctive: line 96
Do not report the optimization as complete before running both the performance measurement and the correctness check.
“Common” is measured: kept by at least 6 in 10 of the 102 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.
Files
Profile first. Every performance intuition is wrong until the profiler confirms it. The code that looks slow is rarely the bottleneck; the bottleneck is almost always somewhere the code looks unremarkable. An optimization without a measurement is a guess. A guess that happens to speed things up does not mean you found the right thing.
The one rule
No change before you have a baseline measurement and a profiled bottleneck. If you cannot name the specific file, function, and line where the most time or memory is spent - with numbers - you are still in the investigation phase.
Step 1: Establish the baseline
Define what "slow" means in terms the problem must satisfy:
- What is the current measured value? (response time, frame rate, memory usage, query duration, build time)
- What is the target? (a budget from a spec, a regression from a previous version, a user-reported threshold)
- Can the scenario be reproduced reliably? If not, instrument first and gather data before optimizing.
Run the scenario and record the baseline:
# For Node.js / server-side
node --prof app.js # then: node --prof-process isolate-*.log
# or: clinic flame -- node app.js
# For queries
EXPLAIN ANALYZE SELECT ... # PostgreSQL
# or the equivalent for your database
# For browser / frontend
# Use the browser devtools Performance panel; record the scenario end-to-end
# Look at the flame chart, not just the summarySave the baseline number. The optimization is only valid if the after-measurement is better than this.
Step 2: Find the bottleneck
Read the profiler output - do not guess from the source. Identify:
- The hot function: the one frame where the most CPU time is spent (not called the most - spent the most)
- The call chain: how does execution reach the hot function? What is the logical operation that triggers it?
- The bottleneck class: is this CPU-bound (computation), memory-bound (allocation/GC pressure), I/O-bound (disk or network latency), lock-bound (contention), or rendering-bound (layout/paint)?
Common bottlenecks that do not look like bottlenecks:
- N+1 queries: a loop that runs one query per item instead of one query for all items
- Serialization on the hot path:
JSON.parse/JSON.stringifyinside a tight loop - Synchronous I/O blocking an event loop
- Repeated computation of a value that never changes within the call
- An O(n^2) algorithm that looks like two nested loops over a "small" list that grew
- Memory allocation creating GC pressure (allocating objects in tight loops, large closures held alive)
Step 3: Form a hypothesis
State it exactly: "The bottleneck is X at file:line because Y, which will be fixed by Z."
Be specific enough to be falsifiable. "The code is slow because it does too much" is not a hypothesis. "The getUser function issues one SQL query per item in the results array at src/db/users.ts:44, so a page with 50 results makes 50 database round trips; replacing this with a single WHERE id IN (...) query should reduce the query time from ~500ms to ~10ms" is a hypothesis.
Step 4: Make one change
Address only the identified bottleneck. Do not:
- Refactor surrounding code while fixing performance
- Add caching everywhere in case something else is also slow
- Change the algorithm and the data structure at the same time
The change should be the minimum needed to fix the specific bottleneck. Multiple simultaneous changes make the measurement impossible to attribute.
Step 5: Measure and compare
Run the same scenario under the same conditions as the baseline:
- Record the after measurement using the same tool and methodology
- Calculate the delta: how much faster, how many fewer allocations, what query time
- State whether the target is now met
If the improvement is less than 20% or does not meet the target, re-profile - you may have fixed a symptom, or the bottleneck may have shifted to a new location now that the first one is gone.
Step 6: Verify correctness
An optimization that breaks behavior is not an optimization - it is a bug. Run the full test suite. If there are no tests covering the modified path, write one before treating the optimization as done.
Check specifically:
- Does the output still match the baseline for all inputs, including edge cases?
- Are any caches invalidated correctly? Does a cache hit return the same result as a cache miss?
- Does the optimized code handle concurrent access correctly if the original did?
What not to do
- Do not add caching without a cache invalidation strategy.
- Do not replace a correct algorithm with a faster but subtly incorrect one and call it "good enough."
- Do not optimize code that is called rarely - focus on hot paths only.
- Do not report the optimization as complete before running both the performance measurement and the correctness check.
Other versions117 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 117
- addyosmani/agent-skills★ 112ksame name
- sanity-io/sanity★ 6.4ksame name
- gamedev-skills/awesome-gamedev-agent-skills★ 6.4ksame name
- compozy/compozy★ 2.8ksame name
- ollaya-dev/ollaya★ 1.4ksame name
- buddy-compiler/buddy-mlir★ 772same name
- ThibautBaissac/rails_ai_agents★ 665same name
- rizqinrr/viserys-agent★ 560same name
- derHaken/SuperAntigravity★ 439same name
- ukanwat/aaabench★ 399same name
107 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 constraint-driven-development, using-agent-skills 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.
MrCipherSmithSkillconstraint-driven-development
Use when a project needs a persistent, measurable quality bar — starting a project without documented standards, 'set up constraints', or when coverage/perf/a11y thresholds get re-debated per-PR. Produces CONSTRAINTS.md with enforceable numbers, ratchets, and a guard against silent weakening. NOT for throwaway prototypes or a one-off CI setup.
Also in 16 projects that use this
LLl0k0laDSkillusing-agent-skills
Use when starting a session or when you need to discover which skill applies to the current task. This is the meta-skill that governs how all other skills are discovered and invoked.
Also in 34 projects that use this
LLl0k0laDSkillgit-workflow-and-versioning
Use when making any code change. Use when committing, branching, resolving conflicts, or when you need to organize work across multiple parallel streams.
Also in 41 projects that use this
HK-hubSkilldeprecation-and-migration
Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when deciding whether to maintain or sunset existing code.
Also in 38 projects that use this
ukanwatSkillinput-systems
Architect game input — action mapping (abstracting keys into named actions), rebinding with conflict detection and persistence, multi-device support (keyboard, gamepad, touch), analog deadzones, and feel features like input buffering and coyote time, plus accessibility. Engine-neutral. Use when the user mentions input mapping, rebind controls, gamepad support, deadzone, input buffering, coyote time, or accessible controls.
Also in 4 projects that use this
HK-hubSkillobservability-and-instrumentation
Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.
Also in 30 projects that use this
- +6 more from LLl0k0laD
In this repository89 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- site/llms-full.txtllms.txt
- site/llms.txtllms.txt
- improveSkill
- academic-writingSkill
- benchmark-reportingSkill
- bibtex-managerSkill
- citation-graphSkill
- citation-verifierSkill
- design-science-methodologySkill
- docx-thesisSkill
- experiment-reproducibilitySkill
- latex-toolkitSkill
- literature-searchSkill
- lit-review-synthesisSkill
- paper-readerSkill
- proofread-academicSkill
- research-figuresSkill
- research-methodologySkill
- research-questionSkill
- statistics-advisorSkill
- supervisor-updateSkill
- systematic-reviewSkill
- thesis-proposalSkill
- coolify-image-appSkill
- coolify-vps-baselineSkill
- deploy-verificationSkill
- express-prisma-coolify-imageSkill
- ghcr-coolify-pipelineSkill
- live-domain-cutoverSkill
- nextjs-coolify-imageSkill
- proxy-client-addressSkill
- vps-ops-toolkitSkill
- adr-writingSkill
- openapi-specSkill
- readme-writingSkill
- technical-writingSkill
- adversarial-reviewerSkill
- api-design-reviewSkill
- code-review-responseSkill
- create-agentSkill
- create-commandSkill
- create-hookSkill
- create-skillSkill
- db-migration-safetySkill
- dependency-upgradeSkill
- dockerfile-best-practicesSkill
- error-handling-patternsSkill
- executing-plansSkill
- explain-codebaseSkill
- fix-ciSkill
- github-actions-pipelineSkill
- grill-with-docsSkill
- incident-postmortemSkill
- logging-and-observabilitySkill
- parallel-agentsSkill
- refactoring-recipesSkill
- solid-principlesSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- The first 60 shown.
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
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.

