explain-plan

explain-plan is a command for Claude Code from sigistry/marketplace. It costs 21 tokens per session (909 once invoked), scanned A, original, MIT.

A command that reads a database query plan and explains what may be making the query slow. An EXPLAIN plan is a database report showing how a query is expected to run; EXPLAIN ANALYZE also records what happened when it ran.

In plain words
What is it for?
Paste a PostgreSQL or MySQL plan to identify expensive operations and get suggestions for indexes or query rewrites.
Why use it?
It turns technical plan output into plain-language findings and does not require access to the database. It helps focus on the costly operation rather than only the top-level query.

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 Paste a PostgreSQL or MySQL plan to identify expensive operations and get suggestions for indexes or query rewrites.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/sigistry/marketplace/explain-plan.svg)](https://agentmods.dev/commands/sigistry/marketplace/explain-plan)
Your own site
<a href="https://agentmods.dev/commands/sigistry/marketplace/explain-plan"><img src="https://agentmods.dev/badge/commands/sigistry/marketplace/explain-plan.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 909 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.00021 $0.00909
Opus 5 $0.00010 $0.00454
Sonnet 5 $0.00004 $0.00182
Haiku 4.5 $0.00002 $0.00091

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

Security

Grade A, and why

explain-plan 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 4d 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/explain-plan.md · 49 lines

How it starts

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

Interpret the query plan pasted in $ARGUMENTS and translate it into plain-language diagnosis plus concrete fixes. Works on pasted text, no database connection required. Load the explain-interpreter skill for node-type semantics and red-flag catalogs.

Process

Step 1: Detect format and dialect

Identify whether the plan is:

  • Postgres text (Seq Scan on ... (cost=0.00..431.00 rows=1 width=...) (actual time=... rows=... loops=...)), possibly with Buffers: lines from EXPLAIN (ANALYZE, BUFFERS).
  • Postgres JSON ("Node Type": "Seq Scan", "Plan Rows", "Actual Rows").
  • MySQL classic tabular EXPLAIN (columns type, key, rows, filtered, Extra), EXPLAIN ANALYZE tree, or FORMAT=JSON. Note whether it is an estimate-only EXPLAIN or an executed EXPLAIN ANALYZE (only the latter has actual rows/time).

Step 2: Find the dominant cost node

Walk the plan tree. The top cost/actual time belongs to the root; find the node contributing the most exclusive time (self time = node time minus children, remembering to multiply by loops). That node, not the root, is what to fix.

Step 3: Scan for red flags

Check the plan against the catalog in references/postgres-explain-nodes.md / references/mysql-explain.md:

Red flag What it means Typical fix
Seq Scan / type: ALL on a large table with a selective filter No usable index Add index on the filter/join column
Estimate-vs-actual skew (rows=1 but actual rows=900000) Stale stats / bad estimate ANALYZE; fix correlated predicates; re-order joins
Nested Loop with high loops on the inner side Row-by-row lookups blowing up Index inner join key, or force hash join
Sort with Sort Method: external merge Disk Sort spilled to disk Add index matching ORDER BY; raise work_mem
Using filesort / Using temporary (MySQL) Sort/dedup without index Composite index covering WHERE+ORDER BY
High Buffers: read= vs hit= Cold cache / too much I/O Narrow rows scanned; covering index
Index present but unused Non-sargable predicate or type mismatch Rewrite predicate; match column types

Read the full file on GitHub · 49 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. 4d ago First seen · 49 lines · 21 tokens per session scan A b2ec48d92ea7

Subscribe to this mod's changes

explain-plan is a command published in the GitHub repository sigistry/marketplace (3 stars, last pushed 3d ago), licensed MIT. It adds 21 tokens to every session and 909 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.