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.
npx agentmods add skills/kraitdev/skill.md/database-query-optimizationnpx skills add KraitDev/skiLL.Md --skill database-query-optimizationgit clone --depth 1 https://github.com/KraitDev/skiLL.MdWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00023 | $0.01587 |
| Opus 5 | $0.00012 | $0.00794 |
| Sonnet 5 | $0.00005 | $0.00317 |
| Haiku 4.5 | $0.00002 | $0.00159 |
Grade A, and why
database-query-optimization 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.
How it starts
The opening of the file, as written. The whole thing — 161 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Database Query Optimization
Purpose
Slow databases kill applications. This skill replaces guesswork with systematic performance analysis, using EXPLAIN plans and profiling to eliminate N+1 queries, eliminate unnecessary scans, and add targeted indexes so the database bears the computational load, not the application.
When to use
- Writing complex SQL queries or ORM access functions
- Resolving performance bottlenecks on read-heavy endpoints
- Designing schema migrations for growing datasets
- Refactoring loops that make repeated database calls
When NOT to use
- Schema design (different concern)
- Database selection (architectural decision)
- Caching strategies (use Caching Strategies skill)
- Application-level performance (profilers, algorithms)
Inputs required
- Slow query logs or endpoint metrics
- ORM code accessing the database
- Database schema (tables, columns, indexes)
- EXPLAIN ANALYZE capability (test environment)
Workflow
- Profile the Bottleneck: Run EXPLAIN ANALYZE on slow queries to identify sequential scans and high-cost operations
- Identify N+1: Locate loops making repetitive database calls for the same entity type
- Measure Selectivity: Analyze WHERE clause filters and add indexes to highly selective columns
- Replace Loops: Replace N+1 with single IN queries or ORM eager-loading (JOINs)
- Remove Over-Fetching: Replace SELECT * with explicit column names
- Add Indexes: Add B-Tree indexes to WHERE, JOIN, and ORDER BY columns in slow queries
- Paginate: Enforce LIMIT and OFFSET (or cursor pagination) on all collection queries
- Verify Performance: Re-run EXPLAIN ANALYZE and benchmark end-to-end latency
Rules
- MUST explicitly define selected columns (NEVER use SELECT * in production)
- MUST NEVER have database operations inside loops
- MUST perform filtering and aggregation in the database, not application memory
- MUST enforce LIMIT and OFFSET on collection queries
- MUST EXPLAIN before adding indexes (verify they reduce cost)
- MUST rollback indexes if they degrade INSERT/UPDATE performance
- MUST NOT over-index (each index has maintenance cost)
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.
- yesterday First seen · 161 lines · 23 tokens per session scan A 4aaaf594b2dc
database-query-optimization is a skill published in the GitHub repository KraitDev/skiLL.Md (7 stars, last pushed 2mo ago), licensed MIT. It adds 23 tokens to every session and 1,587 once invoked, about $0.0001 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.
Other skills, from other repositories
sql-query-optimization
Diagnoses and optimises slow SQL queries using EXPLAIN ANALYZE. Covers identifying bottlenecks (sequential scans, bad estimates, heap fetches), index strategy, query rewrites, and verification. Invoked when the user asks to optimize a query, fix a slow database query, or improve database performance.
sql-optimization
SQL query optimization techniques and best practices.
SQL Query Optimizer
Reviews SQL queries for performance issues and rewrites them with optimized execution plans.
sql-sentinel
Audit SQL for the cost & performance anti-patterns that burn warehouse credits. Catches SELECT , full-table scans, non-sargable predicates, Cartesian joins, NULL-trap NOT IN, and 17 more rules. Scores warehouse health 0-100 and outputs a prioritized cost-reduction plan for BigQuery, Snowflake, Redshift, and Postgres.
sql-optimization
Skill "sql-optimization" from chaterm/terminal-skills, covering sql 优化与调优, 概述, 执行计划分析, mysql explain and postgresql explain.
v3-mcp-optimization
Use when ProxyManager throughput or cold-start latency is a bottleneck — catalogs six optimization patterns (O(1) lookup, 3-tier cache, batch compression, pool reuse, lazy deserialization, parallel boot) with TypeScript snippets and expected gains.