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/hainrixz/claude-db/db-query-patternsnpx skills add Hainrixz/claude-db --skill db-query-patternsgit clone --depth 1 https://github.com/Hainrixz/claude-dbWrote 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.
[](https://agentmods.dev/skills/hainrixz/claude-db/db-query-patterns)<a href="https://agentmods.dev/skills/hainrixz/claude-db/db-query-patterns"><img src="https://agentmods.dev/badge/skills/hainrixz/claude-db/db-query-patterns.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00051 | $0.01015 |
| Opus 5 | $0.00026 | $0.00508 |
| Sonnet 5 | $0.00010 | $0.00203 |
| Haiku 4.5 | $0.00005 | $0.00102 |
Grade A, and why
db-query-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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.
db-query-patterns (M13)
How queries are written decides whether the indexes from M11 can even be used. This module inspects
query shape in ORM source and raw SQL. Feeds the Performance & Scale score (axis performance,
relational Query w18, shared with M3/M19).
What it checks
SELECT *— fetching all columns defeats covering indexes, bloats network/cache, and couples code to column order. Flag in hot paths.- Structural N+1 — a query inside a loop / per-row lazy relation load that should be a single
join or batched
IN. Static detection is directional (the loop's runtime cardinality is unknown) — it points at the structure, never claims a row count. - OFFSET pagination —
LIMIT n OFFSET mdegrades linearly with depth; deep pagination should use keyset/seek (WHERE id > $last ORDER BY id LIMIT n). - Non-SARGable predicates — wrapping the indexed column in a function (
WHERE lower(email)=…,WHERE date(created_at)=…, leading-wildcardLIKE '%x', implicit type cast) so the index can't be used. Recommend an expression index or rewriting the predicate. For the leading-wildcard /LIKE '%x%'case a B-tree can never help — name the remedy: apg_trgmGIN/GiST index on the column (or a dedicated search engine for heavy full-text search).
Score / axis
Feeds performance only (relational Query w18; Query category in document/time-series/graph profiles).
Tier-0 (static)
Grep ORM call sites and raw SQL for SELECT *, function-wrapped indexed columns, leading-wildcard
LIKE, and OFFSET; detect query calls inside loops/.map/per-item relation access for N+1. All
query-pattern findings are at most directional from source — confirming the actual plan/cost needs
runtime (needs_api / Tier-2).
Tier-1/2 (verification query)
EXPLAIN (ANALYZE, BUFFERS) <the suspect query>;
Method explain_plan. A Seq Scan where an index exists confirms a non-SARGable predicate; the
actual rows × loops confirms an N+1 amplification. Tier-2 pg_stat_statements (ordered by
total_exec_time) surfaces the real hot queries — without it, hotness is directional.
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.
- 5d ago First seen · 72 lines · 51 tokens per session scan A a7ec8e6b7dfc
db-query-patterns is a skill published in the GitHub repository Hainrixz/claude-db (19 stars, last pushed 2mo ago), licensed MIT. It adds 51 tokens to every session and 1,015 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-30.
Other skills, from other repositories
dynamodb
Use when modeling or operating a DynamoDB table: deriving partition/sort keys from access patterns, single-table vs table-per-entity, adding a GSI/LSI, on-demand vs provisioned capacity, or diagnosing hot-partition throttling. NOT relational schema/SQL/EXPLAIN (that is postgresdb), NOT aggregation-pipeline document…
malloy-lookml-review
Analyze LookML files as prior art for Malloy modeling. Used during Step 1 (DISCOVER) when .lkml files are present. Coordinates reference files that extract business logic, relationships, and curation decisions. Works with or without a database connection.
convex-migrations
Schema migration strategies for evolving applications including adding new fields, backfilling data, removing deprecated fields, index migrations, and zero-downtime migration patterns.
database-design-patterns
Database schema design patterns and optimization strategies for relational and NoSQL databases. Use when designing database schemas, optimizing query performance, or implementing data persistence layers at scale.
terrabase-db-changes
Use when making Postgres schema or migration changes (CREATE/ALTER/DROP TABLE, indexes, columns, constraints, backfills) IN A PROJECT THAT DECLARES A TERRABASE TARGET (a TERRABASEDATABASEURL in its .env). Routes the change through terrabase's MCP tools for a deterministic safety analysis plus a local-Qwen plan, and…
erd-studio
Schema rules for ERD Studio data model files — the .erd-studio/ directory uses a two-file system (YAML model definitions + JSON domain diagrams) with strict format rules you must read before editing. Use this skill whenever the task touches files in .erd-studio/ (domain JSON, logical-models YAML, or .sync-plan.json)…