ts-db-perf

ts-db-perf is a skill for Claude Code from widnyana/eyay-toolkits. It costs 107 tokens per session (1,564 once invoked), scanned A, original, MIT.

Guidance for improving TypeScript backend code that reads from or writes to databases. It covers repeated queries, selecting unnecessary data, pagination, caching, transactions, race conditions, and asynchronous code.

In plain words
What is it for?
Use it to remove N+1 queries, add pagination or caching, improve transaction safety, prevent race conditions, and simplify database-related async flows.
Why use it?
It helps address slow database access and unsafe or unnecessarily complicated backend operations.

Skill for Claude Code

Written for Claude Code: $ARGUMENTS substitution.

Part of the ts-backend-dev plugin — 3 skills shipped together

Good fit Use it to remove N+1 queries, add pagination or caching, improve transaction safety, prevent race conditions, and simplify database-related async flows.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/widnyana/eyay-toolkits/ts-db-perf
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.

Any agent
npx skills add widnyana/eyay-toolkits --skill ts-db-perf
Clone the repo
git clone --depth 1 https://github.com/widnyana/eyay-toolkits

Made for: Claude Code.

Or install ts-backend-dev, the plugin that ships this one along with the rest of its 3 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ts-db-perf

README.md
[![agentmods](https://agentmods.dev/badge/skills/widnyana/eyay-toolkits/ts-db-perf/github.svg)](https://agentmods.dev/skills/widnyana/eyay-toolkits/ts-db-perf)
Your own site
<a href="https://agentmods.dev/skills/widnyana/eyay-toolkits/ts-db-perf"><img src="https://agentmods.dev/badge/skills/widnyana/eyay-toolkits/ts-db-perf/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ts-db-perf

Your own site · 80×15
<a href="https://agentmods.dev/skills/widnyana/eyay-toolkits/ts-db-perf"><img src="https://agentmods.dev/badge/skills/widnyana/eyay-toolkits/ts-db-perf.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 107 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,564 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00107 $0.01564
Opus 5 $0.00053 $0.00782
Sonnet 5 $0.00021 $0.00313
Haiku 4.5 $0.00011 $0.00156

Measured 10d ago against content hash 298589b4b2d0, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

ts-db-perf 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 10d ago.

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/ts-backend-dev/skills/ts-db-perf/SKILL.md · 233 lines

How it starts

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

TypeScript Database Optimization

Optimize: $ARGUMENTS

1. N+1 Query Elimination

The classic trap: fetching a list, then querying per item in a loop.

// N+1: one query for the list, one per item
const orders = await db.order.findMany();
for (const order of orders) {
  order.customer = await db.customer.findUnique({ where: { id: order.customerId } });
}

// Resolved: single query with join/include
const orders = await db.order.findMany({
  include: { customer: true },
});

If the ORM doesn't support include, use a WHERE id IN (...) or a JOIN.

2. Select Only What You Need

// Over-fetching
const users = await db.user.findMany();

// Tight select
const users = await db.user.findMany({
  select: { id: true, email: true },
});

Applies to raw SQL too -- avoid SELECT * when you only need a few columns.

3. Pagination

Always paginate list endpoints. Cursor-based for large/real-time datasets, offset-based for simple cases.

// Offset-based
const [data, total] = await Promise.all([
  db.user.findMany({ skip: (page - 1) * limit, take: limit }),
  db.user.count(),
]);

// Cursor-based (no count query, stable under writes)
const items = await db.message.findMany({
  take: limit,
  cursor: cursor ? { id: cursor } : undefined,
  orderBy: { createdAt: "desc" },
});

4. Caching

Cache where data is read-heavy and stale reads are tolerable.

async function getExchangeRate(from: string, to: string): Promise<number> {
  const key = `rate:${from}:${to}`;
  const cached = await cache.get(key);
  if (cached !== null) return Number(cached);

  const rate = await fetchRateFromAPI(from, to);
  await cache.set(key, String(rate), { ttl: 60 }); // 60s TTL
  return rate;
}

For repository-level caching, wrap the lookup:

async findById(id: string): Promise<User | null> {
  const cached = await cache.get(`user:${id}`);
  if (cached) return JSON.parse(cached);

  const user = await db.user.findUnique({ where: { id } });
  if (user) await cache.set(`user:${id}`, JSON.stringify(user), { ttl: 300 });
  return user;
}

Read the full file on GitHub · 233 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. 10d ago First seen · 233 lines · 107 tokens per session scan A 298589b4b2d0

Subscribe to this mod's changes

ts-db-perf is a skill published in the GitHub repository widnyana/eyay-toolkits (7 stars, last pushed 8d ago), licensed MIT. It adds 107 tokens to every session and 1,564 once invoked, about $0.0005 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.

Related

Other skills, from other repositories

phoenix-contexts

Phoenix context design — creating/splitting contexts, Scope (1.8+), Ecto.Multi, PubSub, routers, plugs, controllers. Use when editing contexts, routers, or designing boundaries.

oliver-kriska/claude-elixir-phoenix · 46 tokens

laravel-scout

Implement full-text search with Laravel Scout. Use when adding search to Eloquent models with Meilisearch, Algolia, or database driver.

fusengine/agents · 33 tokens

go-architecture

Use when laying out a new Go service, choosing an HTTP router or DB layer, or wiring dependencies. Not for concurrency (go-concurrency) or language idioms (go-core-idioms).

fusengine/agents · 44 tokens

backend-engineer

Use when designing APIs, working with databases, building microservices, handling authentication and authorisation, optimising server performance, designing data models, or any task involving server-side logic, infrastructure, or system architecture.

pranav8494/team-of-agents · 46 tokens

consistency-coordination

This skill should be used when the user asks about the "CAP theorem", "PACELC", a "consistency model", "eventual vs strong consistency", "read-your-writes", "causal consistency", "quorum" or "R+W>N", "consensus", "Raft / Paxos", "leader election", "consistent hashing", a "distributed transaction", "2PC", or "saga".…

proyecto26/system-design-skills · 141 tokens

database-design-document

Design a production database schema including ERD, table definitions, data dictionary, indexing strategy, normalization decisions, and migration plan. Use when designing a new database, adding major entities, or documenting an existing schema.

fattain-naime/engineering-docs · 46 tokens