performance-patterns

A reference for finding and fixing common sources of slow software, such as repeated database queries, unnecessary data fetching, and oversized bundles.

In plain words
What is it for?
Use it when optimizing database queries, API calls, frontend rendering, backend code, or bundle size.
Why use it?
It explains how these problems arise and gives matching repair patterns, helping developers diagnose performance issues.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/hculap/better-code/performance-patterns
Any agent
npx skills add hculap/better-code --skill performance-patterns
Clone the repo
git clone --depth 1 https://github.com/hculap/better-code

Made for: Claude Code, Codex.

Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,211 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00061 $0.01211
Opus 5 $0.00030 $0.00606
Sonnet 5 $0.00012 $0.00242
Haiku 4.5 $0.00006 $0.00121

Measured yesterday against content hash e97082d1ee56, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

performance-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/n1-optimizer/skills/performance-patterns/SKILL.md · 164 lines

How it starts

The opening of the file, as written. The whole thing — 164 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Performance Anti-Patterns Reference

N+1 Query Problem

The N+1 problem occurs when code executes N additional queries to fetch related data for N items from an initial query.

Identification:

  • Queries inside loops
  • Lazy loading of associations during iteration
  • GraphQL resolvers fetching per-item

Fix Strategies:

  1. Eager Loading: Load related data in initial query
  2. Batching: Collect IDs, fetch all at once
  3. DataLoader: For GraphQL, batch and cache per-request
  4. Denormalization: Store computed/related data together

Severity: HIGH - Scales linearly with data size, causes exponential slowdown

Over-Fetching

Retrieving more data than needed from API or database.

Identification:

  • SELECT * queries
  • API endpoints returning full objects
  • No field selection support
  • Loading nested relations by default

Fix Strategies:

  1. Field Selection: Only query needed columns
  2. Sparse Fieldsets: Support ?fields=id,name parameter
  3. GraphQL: Let clients specify exact fields
  4. DTOs: Map to response-specific objects

Severity: MEDIUM - Increases bandwidth, memory, serialization time

Under-Fetching

Requiring multiple requests to get needed data.

Identification:

  • Waterfall requests (request depends on previous)
  • Multiple endpoints for related data
  • No include/expand support

Fix Strategies:

  1. Compound Endpoints: /users?include=orders
  2. GraphQL: Single query for nested data
  3. BFF Pattern: Backend aggregates for frontend
  4. Parallel Requests: When dependencies allow

Severity: MEDIUM - Increases latency, connection overhead

Missing Pagination

Returning unbounded result sets.

Identification:

  • List endpoints without limit
  • findAll() without pagination
  • No cursor for large datasets

Fix Strategies:

  1. Offset Pagination: ?page=1&limit=20
  2. Cursor Pagination: ?cursor=abc&limit=20 (better for large sets)
  3. Default Limits: Always apply max limit server-side
  4. Streaming: For very large exports

Read the full file on GitHub · 164 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 164 lines · 61 tokens per session scan A e97082d1ee56

Subscribe to this mod's changes

performance-patterns is a skill published in the GitHub repository hculap/better-code (2 stars, last pushed 7mo ago), licensed MIT. It adds 61 tokens to every session and 1,211 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.