query-optimizer

query-optimizer is a skill for Claude Code from sdebruyn/fabric-dw-mcp-cli. It costs 103 tokens per session (1,590 once invoked), scanned A, original, MIT.

A query-analysis workflow for Microsoft Fabric Data Warehouse, a cloud system for storing and querying data. It examines how a SQL query is expected to run and suggests or applies changes to improve it.

In plain words
What is it for?
Use it to investigate and optimize SQL queries, review execution plans and query history, and check data-clustering settings.
Why use it?
It helps identify slow parts of a query, such as costly operations or missing and outdated statistics, instead of relying on guesswork.

Skill for Claude Code

Written for Claude Code: user-invocable in frontmatter.

Part of the fabric-dw plugin — 3 skills shipped together

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.

agentmods
npx agentmods add skills/sdebruyn/fabric-dw-mcp-cli/query-optimizer
Any agent
npx skills add sdebruyn/fabric-dw-mcp-cli --skill query-optimizer
Clone the repo
git clone --depth 1 https://github.com/sdebruyn/fabric-dw-mcp-cli

Made for: Claude Code.

Or install fabric-dw, the plugin that ships this one along with the rest of its 3 skills.

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 query-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/skills/sdebruyn/fabric-dw-mcp-cli/query-optimizer.svg)](https://agentmods.dev/skills/sdebruyn/fabric-dw-mcp-cli/query-optimizer)
Your own site
<a href="https://agentmods.dev/skills/sdebruyn/fabric-dw-mcp-cli/query-optimizer"><img src="https://agentmods.dev/badge/skills/sdebruyn/fabric-dw-mcp-cli/query-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 103 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,590 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00103 $0.01590
Opus 5 $0.00051 $0.00795
Sonnet 5 $0.00021 $0.00318
Haiku 4.5 $0.00010 $0.00159

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

Security

Grade A, and why

query-optimizer 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/fabric-dw/skills/query-optimizer/SKILL.md · 128 lines

How it starts

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

Query Performance Analysis & Optimization

Analyzes and optimizes a query on a Fabric Data Warehouse using the fabric-dw MCP tools.

Inputs

Gather these from the user (via $ARGUMENTS or natural language) before starting:

  • workspace: workspace name or GUID
  • warehouse: warehouse name or GUID (must be a Fabric Data Warehouse, not a SQL Analytics Endpoint, for clustering steps)
  • query: the SQL query text to analyze (or a historical query ID / text snippet to look up)

If the warehouse is a SQL Analytics Endpoint, skip steps 8, 9, 11 (clustering), and 13 (set_cluster_columns).

Workflow

Step 1 - Capture the estimated execution plan

Call get_query_plan with the query text. This returns a SHOWPLAN_XML document without executing the query.

To visualize the plan, use the CLI (pass the warehouse name as the first argument and the query via -q):

fdw sql plan <warehouse> -q "<query>" --format html -o plan.html   # writes self-contained HTML; open plan.html in any browser
fdw sql plan <workspace>/<warehouse> -q "<query>" --format svg -o plan.svg   # renders SVG via system dot binary (requires Graphviz)

Note: --format html requires -o/--output; it writes a file and does not open the browser automatically.

Step 2 - Parse the plan XML

Analyze the returned SHOWPLAN_XML for:

  • Costly operators: Hash Join, Sort, nested-loop Scan on large row estimates, Spool
  • Residual predicates: predicates that cannot be applied early (non-SARGable)
  • Missing-index hints embedded in the plan
  • Data skew warnings or large estimated vs. actual row count mismatches (if available)
  • Type mismatch conversions: e.g. CONVERT_IMPLICIT on a column used in a predicate

Step 3 - Pull recent history

Use list_request_history (filter by SQL text substring if supported) and list_long_running_queries to see whether this query pattern has a history of slow executions. Note elapsed time and status.

Step 4 - List statistics on referenced tables

Read the full file on GitHub · 128 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 · 128 lines · 103 tokens per session scan A c85ec084d5ef

Subscribe to this mod's changes

query-optimizer is a skill published in the GitHub repository sdebruyn/fabric-dw-mcp-cli (10 stars, last pushed 2d ago), licensed MIT. It adds 103 tokens to every session and 1,590 once invoked, about $0.0005 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.

Related

Other skills, from other repositories

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)…

liam-machine/erd-studio · 162 tokens

redteam-sqli-detail-pack

Domain routing and boundary guidance for authorized SQL injection testing, including union-based, blind, error-based, stacked query, and second-order SQL injection variants. Use when a task belongs to the SQL injection domain and needs scope, evidence, pivot, or exit criteria.

Netw0rkNoob/VulnClaw · 59 tokens

api-canvas

DataCanvas primitive reference — a Tier 3 SQL/analytical workspace for tabular MCP servers, backed by DuckDB. Use when registering tables from upstream APIs, running ad-hoc SQL across them, and exporting results. Covers the acquire → register → query → export flow, per-table TTL, the token-sharing pattern for…

cyanheads/obsidian-mcp-server · 85 tokens

data-governance

Use this skill when designing or reviewing data governance: schema ownership, PII handling, retention, lineage, access policy, and migration safety for WrongStack services and stores. Triggers: user says "data governance", "PII", "schema ownership", "retention policy", "data lineage", "migration safety".

WrongStack/WrongStack · 69 tokens

persistence-setup

Generates SwiftData or CoreData persistence layer with optional iCloud sync. Use when user wants to add local storage, data persistence, or cloud sync.

rshankras/claude-code-apple-skills · 36 tokens

multitenant

Architecture multitenant avec approche tiered (Shared/Dedicated Schema/DB), RBAC/ABAC, field-level encryption. Use when working with multitenant applications, tenant isolation, data segregation.

TheBeardedBearSAS/claude-craft · 46 tokens