query-inspector is a Claude Code plugin that inspects the SQL and ORM-generated queries in your code without running the app.
It reports N+1s, missing indexes, and other anti-patterns with paste-ready fixes. It reads the code and infers the SQL your ORM will generate - no app boot, no production database.
As of 1.1.0 it covers Python (Django/SQLAlchemy) alongside the JVM stacks it started with.
The problem
An ORM hides the SQL it generates. To find a query problem with the usual tools (APM, slow-query logs, django-debug-toolbar), you first have to run it - and reproduce the exact situation where that query fires.
Worse, most DB problems only show up once real data has grown large or varied. They slip past QA and usually surface in production - often only when things are near an outage - and then you're patching a running service.
query-inspector reads the code statically and surfaces the SQL problem without running anything.
Run it once right before a commit and it scans only the diff, so you catch and fix issues quickly.
What it checks (Python)
It routes Django/SQLAlchemy code through adapters, reconstructs the SQL, and checks it against your schema.
- N+1 - repeated lookups outside the view: loops, templates, serializer fields, a model in an admin list.
-
Missing indexes - WHERE/join/order-by columns checked against your models or migrations, with a paste-ready
CREATE INDEX. - Hidden correctness/permission defects - problems that surface only in the compiled SQL (e.g. a filter that actually passes every row).
- Dialect & migrations - Alembic and Django migrations read as a first-class index source.
Inferred queries are labeled INFERRED/AMBIGUOUS, and the key ones are compile-verified.
How it differs from a linter or APM
- No run required - no waiting for a slow request to show up in a trace.
- Wider N+1 reach - templates, serializers, admin, not just the view.
-
Fixes, not just findings - a
CREATE INDEX, aselectinload(...), paste-ready. It suggests; it never edits your code.
How it works
Three tiers, degrading automatically:
- Static heuristics - no DB, always on.
-
Schema context - models/migrations confirm index coverage; concrete
CREATE INDEX. -
Live EXPLAIN - only with
--db, read-only, production hosts blocked.
Kotlin/Java is the primary focus and Python is an extension; 1.1.0 validated the Python adapters against real open-source projects.
Try it
claude plugin marketplace add jogakdal/query-inspector
claude plugin install query-inspector@query-inspector-marketplace
In your project directory, open a new Claude session and run:
/query-inspector:tuning-report
/query-inspector:inventory-report catalogs every query the project runs. For the full manual, see the README in the repo below.
Repo (MIT): https://github.com/jogakdal/query-inspector
Run it on your own project and tell me what it caught - or got wrong.
Top comments (0)