performance-optimization
Skill1 starsChanged 56 days agoMITView on GitHub
Measure-first performance work for application code and data access, covering profiling, N+1 queries, fetch and index discipline, caching with an invalidation rule, streaming, and concurrent IO. Use when you say "this endpoint is slow", "the page takes four seconds to load", "profile this before I change anything", "did my change regress latency", or "this query runs inside a loop". Not for schema and index design on Postgres itself, use `postgres-patterns`, and not for Core Web Vitals in a Next.js app, use `nextjs-app-router-patterns`.
83 other projects use a version of this.
Adopted by
Most recently taken up by
- GuillemRoca/agent-skills-androidtheir own version, first seen Oct 3, 2026
- addyosmani/agent-skillstheir own version, first seen Oct 3, 2026
- weisser-dev/agentic-skillstheir own version, first seen Oct 3, 2026
- Rvey/agent-engineering-kittheir own version, first seen Oct 1, 2026
- JPeetz/agent-skillstheir own version, first seen Sep 29, 2026
- hemapriyan-rk/claude-rigor-skillstheir own version, first seen Sep 26, 2026
Used with
Projects 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.
vinvcnSkillconstraint-driven-development
把一个项目的质量线确立为书面契约,并阻止 agent 悄悄降低它。通过访谈确定用户在意哪些维度,当用户心里没有数字时提供合理的默认阈值,把一切记录进 CONSTRAINTS.md,并盯住 diff 中质量线被削弱的迹象——新增的 @ts-ignore 或 eslint-disable 抑制注释、被跳过或删除的测试、被剥掉的断言、未实现的 stub、被调低的阈值。当没有任何质量线被写下来时使用;当用户说 "set up constraints" 或 "define our standards" 时;当用户希望把他们在意的维度——无障碍性、Web 性能、覆盖率——设置成被强制执行的约束时;当 agent 为了变绿不断静默检查或跳过测试时;当你需要一个覆盖率或性能阈值却不知道该选什么数字时;或者当 agent 写下的代码超出任何人会读的体量时。
Also in 4 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 21 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 23 projects that use this
borhen68Skillobservability-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 12 projects that use this
az9713Skilldeprecation-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 21 projects that use this
az9713Skillcode-simplification
Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.
Also in 29 projects that use this
- +6 more from LLl0k0laD
Other versions83 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 83
- addyosmani/agent-skills★ 101ksame name
- rohitg00/awesome-claude-code-toolkit★ 2.7ksame name
- gamedev-skills/awesome-gamedev-agent-skills★ 1.3ksame name
- ukanwat/overtime★ 387same name
- Mindrally/skills★ 266same name
- shashankswe2020-ux/whoop-mcp★ 165same name
- magnus919/agent-skills★ 109same name
- thiientv/godmode★ 96same name
- dylantarre/animation-principles★ 94same name
- DevelopersGlobal/ai-agent-skills★ 69same name
73 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.
In this repository59 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/CLAUDE.mdCLAUDE.md
- agentic-engineeringSkill
- ai-regression-testingSkill
- angularSkill
- ansibleSkill
- api-designSkill
- architecture-decision-recordsSkill
- ascend-memorySkill
- ascend-web-hunterSkill
- audio-scribeSkill
- automation-inventorySkill
- backend-patternsSkill
- bashSkill
- build-dependency-managementSkill
- code-formatterSkill
- code-reviewerSkill
- coding-standardsSkill
- dart-flutter-patternsSkill
- database-migrationsSkill
- deployment-patternsSkill
- design-systemSkill
- docker-patternsSkill
- e2e-runbooksSkill
- e2e-testingSkill
- embedded-c-arduinoSkill
- frontend-designSkill
- g-code-3d-printingSkill
- github-opsSkill
- git-workflowSkill
- golang-patternsSkill
- hexagonal-architectureSkill
- home-assistantSkill
- java-coding-standardsSkill
- jetbrains-ide-opsSkill
- jira-integrationSkill
- keycloak-patternsSkill
- kicadSkill
- markdown-writerSkill
- mongodb-patternsSkill
- nextjs-app-router-patternsSkill
- node-backend-patternsSkill
- observability-and-loggingSkill
- obsidianSkill
- postgres-patternsSkill
- powershellSkill
- project-trackingSkill
- python-patternsSkill
- pytorch-patternsSkill
- react-patternsSkill
- researchSkill
- review-duplicationSkill
- security-reviewSkill
- seoSkill
- soap-webservicesSkill
- springboot-patternsSkill
- tdd-workflowSkill
- unitySkill
- web-accessibilitySkill
The file
Files
Performance Optimization
Make slow things fast without guessing, because performance work that is not driven by a measurement is decoration. The
cross-cutting principles hub is the coding-standards skill and this skill is the optimisation detail on top of it.
When to activate
- An application, endpoint, or job is slow, or a deployment regressed a latency or throughput metric.
- You need a baseline before optimising, or want to confirm an optimisation actually moved the metric.
- Reviewing a change for an obvious performance trap: a query inside a loop, an unbounded fetch, sequential awaits of unrelated calls.
When not to activate
- Designing a table, choosing a column type, or writing a migration. Use
postgres-patternsfor the schema anddatabase-migrationsfor the change. - Writing the tests that prove the fix holds. Use
tdd-workflow, or the language skill (python-patterns,golang-patterns,springboot-patterns). - Reducing container image size or build time. Use
docker-patterns. - Frontend rendering, bundle weight, and Core Web Vitals in a specific framework. Use
nextjs-app-router-patternsorangular. - A general code review that happens to mention speed. Use
code-reviewerand pull this skill in for the performance findings only.
Measure before you change anything
Profile, find the one real bottleneck, fix that one thing, then measure again. The bottleneck is almost never where intuition points, and a change that moves cost from one layer to another looks like a win in the code and like nothing in production.
Set a target before you start, a latency budget or a throughput number, so you know when to stop.
Fail: the diagnosis is a guess and the fix is unverifiable.
The list page feels slow, so I added a cache to the serializer.Pass: the diagnosis names a measured number, and the same measurement is repeated after.
p95 for GET /orders was 1.8s. A profile showed 1.6s in 340 individual customer lookups.
Target: p95 under 300ms. After batching the lookups, p95 measured 210ms.Avoid the N+1 query
One query per row in a loop is the most common cause of a slow endpoint. Batch the related lookups into a single query, or let the ORM fetch the relation eagerly.
Fail: one query for the list, then one more per row.
orders = order_repository.list_recent(limit=100)
for order in orders:
order.customer = customer_repository.get(order.customer_id)Pass: one query for the list, one for every customer it references.
orders = order_repository.list_recent(limit=100)
customers = customer_repository.get_many({order.customer_id for order in orders})
for order in orders:
order.customer = customers[order.customer_id]The same shape appears in every stack: JOIN FETCH or an entity graph in JPA, select_related / prefetch_related in
Django, a DataLoader in a GraphQL resolver. Confirm the fix by counting the queries the request issues, not by looking
at the code.
Fetch and index only what is needed
Select the columns the caller actually reads and page large result sets rather than loading the whole table. Add the indexes the real queries need, and confirm with the database's own query plan that they are used. An index nobody queries is write cost for no read benefit.
Fail: unbounded and over-wide.
SELECT * FROM events WHERE tenant_id = $1 ORDER BY created_at DESC;Pass: narrow, bounded, paged by cursor, and backed by an index on (tenant_id, created_at DESC, id DESC).
SELECT id, kind, created_at FROM events WHERE tenant_id = $1 AND (created_at, id) < ($2, $3) ORDER BY created_at DESC, id DESC LIMIT 50;Cache with a stated invalidation rule
Cache where reads dominate and the data tolerates slight staleness. Name the staleness you accept and the event that clears the entry, because a cache without an invalidation story is a correctness bug waiting to surface.
Fail: no expiry and no invalidation, so a rename never reaches readers.
_cache: dict[str, Product] = {}
def get_product(product_id: str) -> Product:
if product_id not in _cache:
_cache[product_id] = product_repository.get(product_id)
return _cache[product_id]Pass: bounded lifetime, and the write path clears the entry it invalidated.
def get_product(product_id: str) -> Product:
cached = cache.get(f"product:{product_id}")
if cached is not None:
return cached
product = product_repository.get(product_id)
cache.set(f"product:{product_id}", product, ttl_seconds=300)
return product
def rename_product(product_id: str, name: str) -> None:
product_repository.rename(product_id, name)
cache.delete(f"product:{product_id}")Keep memory bounded
Build a string from many pieces with a join or a buffer, never by repeated concatenation in a loop. Stream large data lazily instead of loading all of it, because a file or result set that fits today overflows tomorrow.
Fail: the whole export is materialised in memory before the first byte is sent.
rows = [format_row(row) for row in repository.fetch_all_orders()]
return Response("".join(rows), media_type="text/csv")Pass: the rows are produced and released one at a time.
def row_stream():
for row in repository.iter_orders(chunk_size=1000):
yield format_row(row)
return StreamingResponse(row_stream(), media_type="text/csv")Run independent IO concurrently
Sequential awaits of unrelated calls waste the whole duration of every call but the slowest. Start them together and join once.
Fail (TypeScript): three independent calls cost the sum of their latencies.
const profile = await api.getProfile(userId)
const orders = await api.getOrders(userId)
const preferences = await api.getPreferences(userId)Pass (TypeScript): they cost the slowest one.
const [profile, orders, preferences] = await Promise.all([
api.getProfile(userId),
api.getOrders(userId),
api.getPreferences(userId),
])Fail (Go): the same serial shape.
profile, err := client.Profile(ctx, userID)
if err != nil {
return err
}
orders, err := client.Orders(ctx, userID)
if err != nil {
return err
}Pass (Go): errgroup runs them together and returns the first error.
var profile Profile
var orders []Order
g, ctx := errgroup.WithContext(ctx)
g.Go(func() (err error) { profile, err = client.Profile(ctx, userID); return err })
g.Go(func() (err error) { orders, err = client.Orders(ctx, userID); return err })
if err := g.Wait(); err != nil {
return err
}Two rules survive the translation to any language: only parallelise calls with no data dependency between them, and cap the fan-out so a batch of 10,000 ids does not open 10,000 sockets.
Related skills
coding-standardsis the hub for the shared engineering floor this skill sits on.postgres-patternsowns schema, index, and query design in Postgres itself.database-migrationsowns applying an index or a schema change safely.observability-and-loggingowns the metrics and traces that give you the baseline to measure against.tdd-workflowowns the regression test that keeps the optimisation from silently reverting.code-revieweris the entry point when performance is one concern among several in a review.
Checklist
- A profile or a metric, not a hunch, identified the bottleneck.
- A target number was set before the change and measured again after.
- No query runs inside a loop over rows a previous query returned.
- Queries select named columns and page their results.
- Every index added is confirmed used by the query plan.
- Every cache has a stated staleness budget and a stated invalidation event.
- Large payloads stream rather than materialise.
- Independent IO runs concurrently with a bounded fan-out.
- The metric moved, and the change did not just move the cost elsewhere.
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.

