backend-db-performance

backend-db-performance is a skill for Claude Code from kensaurus/cursor-kenji. It costs 56 tokens per session (2,634 once invoked), scanned A, original, MIT.

A review of slow database queries, missing indexes, repeated per-item queries, and data requests that fetch more than needed.

In plain words
What is it for?
Use it to investigate slow queries, database performance problems, missing indexes, and N+1 queries, where one list causes an extra query for every item.
Why use it?
It helps explain why a page or write operation is slow and checks the database plan and existing indexes before suggesting a change.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the cursor-kenji plugin — 132 skills, 63 commands, 6 agents, 1 hook, 3 MCP servers shipped together

Good fit Use it to investigate slow queries, database performance problems, missing indexes, and N+1 queries, where one list causes an extra query for every item.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kensaurus/cursor-kenji/backend-db-performance
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 kensaurus/cursor-kenji --skill backend-db-performance
Clone the repo
git clone --depth 1 https://github.com/kensaurus/cursor-kenji

Made for: Claude Code.

Or install cursor-kenji, the plugin that ships this one along with the rest of its 132 skills, 63 commands, 6 agents, 1 hook, 3 MCP servers.

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 backend-db-performance

README.md
[![agentmods](https://agentmods.dev/badge/skills/kensaurus/cursor-kenji/backend-db-performance/github.svg)](https://agentmods.dev/skills/kensaurus/cursor-kenji/backend-db-performance)
Your own site
<a href="https://agentmods.dev/skills/kensaurus/cursor-kenji/backend-db-performance"><img src="https://agentmods.dev/badge/skills/kensaurus/cursor-kenji/backend-db-performance/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 backend-db-performance

Your own site · 80×15
<a href="https://agentmods.dev/skills/kensaurus/cursor-kenji/backend-db-performance"><img src="https://agentmods.dev/badge/skills/kensaurus/cursor-kenji/backend-db-performance.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,634 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.00056 $0.02634
Opus 5.5 $0.00022 $0.01054
Sonnet 5.5 $0.00011 $0.00527
Haiku 4.5 $0.00006 $0.00263

Measured 1mo ago against content hash 4bb24328031b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

backend-db-performance 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 1mo 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.

skills/backend-db-performance/SKILL.md · 442 lines

How it starts

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

Database Optimization Skill

Degree of freedom: MIXED. Which query/index/N+1 to fix [HIGH freedom]; existing-index probes and EXPLAIN ANALYZE [LOW freedom — run exactly].

How to reason

  1. Observe — EXPLAIN ANALYZE / pg_stat_statements / existing pg_indexes
  2. Interpret — seq scan vs N+1 vs over-fetch vs missing pagination
  3. Classify — add-index / eager-load / narrow-select / paginate / leave-alone
  4. Severity — write-path timeout outranks a 200ms list page

Worked example

Observe: /feed p95 2.4s; Prisma logs 81 queries; pg_indexes has no idx_posts_user_created. Interpret: findMany posts then per-row user.findUnique — N+1; ORDER BY created_at is a seq scan. Classify: eager-load include: { author } + composite index (user_id, created_at DESC). Verify: EXPLAIN ANALYZE → Index Scan; query count 2; p95 < 200ms. Did not add a duplicate index.

Self-critique before reporting

  • Existing first — listed pg_indexes / migrations before CREATE INDEX
  • EXPLAIN — the claimed winner has ANALYZE output, not intuition
  • No duplicate index — the proposed name was queried and absent
  • Right owner — schema consistency → audit-db-schema; RLS access → plan-rls-audit

Systematic approach to identifying and fixing database performance issues.

When to Use

  • Slow page loads (database bottleneck)
  • Query timeout errors
  • N+1 queries
  • Schema design review
  • Index optimization
  • Migration planning

Check existing first [LOW freedom — run exactly]

Before ANY optimization, verify current state:

  1. Check existing indexes:
SELECT indexname, indexdef FROM pg_indexes
WHERE schemaname = 'public' AND tablename = 'your_table';
  1. Check existing migrations:
ls -la supabase/migrations/ | grep -i "index\|optim\|perf"
  1. Check if index already exists:
SELECT 1 FROM pg_indexes WHERE indexname = 'your_proposed_index';
  1. Check Supabase advisors for current issues:
  • Use get_advisors MCP tool for performance/security
  • Don't re-fix already addressed issues

Read the full file on GitHub · 442 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. 1mo ago Changed 4bb24328031b
  2. 1mo ago First seen · 442 lines · 56 tokens per session scan A be3e6d0dd5cf

Subscribe to this mod's changes

backend-db-performance is a skill published in the GitHub repository kensaurus/cursor-kenji (9 stars, last pushed 22d ago), licensed MIT. It adds 56 tokens to every session and 2,634 once invoked, about $0.0002 per session on Opus 5.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-09-03.