index-advisor

index-advisor is a command for Claude Code from sigistry/marketplace. It costs 19 tokens per session (794 once invoked), scanned A, original, MIT.

A command that recommends database indexes from a slow query and the table definition. An index is an extra data structure that can help a database find, join, or sort rows faster.

In plain words
What is it for?
Give it a query and table DDL to assess filters, joins, sorting, grouping, covered columns, and expressions, then produce index guidance.
Why use it?
It provides a reasoned recommendation without connecting to the database and can also warn when an index is unlikely to help. It considers existing indexes and the way each query condition is used.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: model in frontmatter.

Part of the sql-safety-net plugin — 3 skills, 5 commands, 2 agents shipped together

Good fit Give it a query and table DDL to assess filters, joins, sorting, grouping, covered columns, and expressions, then produce index guidance.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/sigistry/marketplace/index-advisor
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.

Clone the repo
git clone --depth 1 https://github.com/sigistry/marketplace

Made for: Claude Code.

Or install sql-safety-net, the plugin that ships this one along with the rest of its 3 skills, 5 commands, 2 agents.

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 index-advisor

README.md
[![agentmods](https://agentmods.dev/badge/commands/sigistry/marketplace/index-advisor/github.svg)](https://agentmods.dev/commands/sigistry/marketplace/index-advisor)
Your own site
<a href="https://agentmods.dev/commands/sigistry/marketplace/index-advisor"><img src="https://agentmods.dev/badge/commands/sigistry/marketplace/index-advisor/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 index-advisor

Your own site · 80×15
<a href="https://agentmods.dev/commands/sigistry/marketplace/index-advisor"><img src="https://agentmods.dev/badge/commands/sigistry/marketplace/index-advisor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 19 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 794 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.
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.00019 $0.00794
Opus 5 $0.00010 $0.00397
Sonnet 5 $0.00004 $0.00159
Haiku 4.5 $0.00002 $0.00079

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

Security

Grade A, and why

index-advisor 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 6d 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/sql-safety-net/commands/index-advisor.md · 47 lines

How it starts

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

Given the slow query and the relevant table DDL in $ARGUMENTS, recommend the right index (or advise against one). This is a static analysis of the query and DDL text, no database connection required. Load the explain-interpreter and schema-antipatterns skills for sargability and index design rules.

Process

Step 1: Parse the query and DDL

Extract from the query: the WHERE predicates, JOIN keys, ORDER BY/GROUP BY columns, and the SELECT list. From the DDL: existing indexes, primary key, column types, and table cardinality hints if provided. Detect the dialect (Postgres vs MySQL) for the correct CREATE INDEX syntax.

Step 2: Classify each predicate

Label every filtered column:

Class Examples Index role
Equality status = 'x', tenant_id = ?, IN (...) Leading columns
Range created_at > ?, price BETWEEN, <, > After equality columns
Sort ORDER BY created_at DESC Matches index order to skip a sort
Covered columns only in SELECT INCLUDE / covering columns
Non-sargable WHERE lower(email)=?, col + 1 = ?, leading-% LIKE Needs expression index or rewrite

Step 3: Design the index

Apply the rules:

  • Column order: all equality columns first, then one range column, then sort columns (equality-range-sort / "ERS" rule). A composite index can serve a prefix of its columns.
  • Covering: add INCLUDE (...) (Postgres) or trailing key columns (MySQL) to avoid a heap/clustered-index lookup when the query selects few extra columns.
  • Partial: add WHERE <condition> for queries that always filter on a constant (e.g. WHERE deleted_at IS NULL, WHERE status='active'), smaller, faster, cheaper to maintain.
  • Expression index for non-sargable predicates, or recommend rewriting the predicate to be sargable.

Step 4: Check for redundancy and when NOT to index

  • If an existing index is a prefix of the proposed one, the proposed index makes it redundant, say so and recommend dropping the old one.
  • Advise against a new index when: the table is write-heavy and the column is rarely filtered; selectivity is low (e.g. a boolean split 50/50); the query runs rarely; or an existing index already covers it.

Read the full file on GitHub · 47 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. 6d ago First seen · 47 lines · 19 tokens per session scan A 83d36471cbcc

Subscribe to this mod's changes

index-advisor is a command published in the GitHub repository sigistry/marketplace (3 stars, last pushed 6d ago), licensed MIT. It adds 19 tokens to every session and 794 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-09-03.