debugging-orm-queries

Convert ORM calls to raw SQL and analyze query performance.

7|Updated Nov 27, 2025
One-click install
npx skills add https://github.com/galihcitta/dotclaudeskills --skill debugging-orm-queries
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: debugging-orm-queries
Source: https://github.com/galihcitta/dotclaudeskills/tree/main/skills/debugging-orm-queries
Command: npx skills add https://github.com/galihcitta/dotclaudeskills --skill debugging-orm-queries

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps developers diagnose and optimize ORM-generated SQL by translating ORM calls into raw SQL, detecting anti-patterns (like N+1 queries and missing indexes), and providing practical guidance across Node.js, Go, and Python ecosystems.

Core Features & Use Cases

  • ORM → SQL conversion: Translate common ORM calls into equivalent SQL for analysis.
  • SQL → ORM guidance: Map raw SQL back into ORM patterns for refactoring.
  • N+1 detection: Identify N+1 query patterns in logs and suggest eager loading or batching.
  • Explain analysis: Interpret EXPLAIN outputs to pinpoint slow operations and indexing gaps.
  • Cross-language coverage: Guidance for Sequelize/Prisma/TypeORM (Node.js), GORM/sqlc/sqlx/ent (Go), SQLAlchemy/Django/Peewee (Python).

Quick Start

  • Run the query analyzer on your ORM logs: python scripts/query_analyzer.py queries.log
  • Pretty-print captured SQL: python scripts/sql_formatter.py "SELECT..."
  • See evaluation scenarios in evaluations.json to validate improvements.

Frequently Asked Questions about debugging-orm-queries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find N+1 queries in my ORM logs?

N+1 queries occur when an ORM executes one query to fetch parent records, then one query per child record instead of batching. Detect them by analyzing logs for repeated similar queries—this Skill parses logs and flags the pattern, then suggests eager loading or batch fetching to consolidate into fewer queries.

Can I convert Sequelize, Prisma, or TypeORM calls to raw SQL?

Yes. This Skill translates ORM calls from Node.js frameworks (Sequelize, Prisma, TypeORM), Go ecosystems (GORM, sqlc, sqlx, ent), and Python (SQLAlchemy, Django ORM, Peewee) into equivalent SQL, exposing hidden queries for debugging and optimization.

How do I use EXPLAIN output to find missing indexes?

EXPLAIN reveals query execution plans showing full table scans and sequential operations that slow queries. This Skill interprets EXPLAIN output to pinpoint inefficient operations and missing indexes, then recommends index creation to speed up bottleneck queries.

What's the fastest way to debug slow ORM queries?

Capture ORM logs, convert them to SQL using this Skill, run EXPLAIN on the raw queries, and analyze the output for N+1 patterns and missing indexes. The Skill automates conversion and analysis steps, producing actionable optimization recommendations immediately.

Does this work with Django ORM and SQLAlchemy?

Yes. This Skill covers Python ORMs including Django ORM, SQLAlchemy, and Peewee, translating their generated SQL and detecting anti-patterns across the full Python ecosystem.

What ORM anti-patterns does this detect?

This Skill detects N+1 queries, missing indexes, and other performance anti-patterns in ORM-generated SQL across Node.js, Go, and Python ORMs, then maps findings back to ORM code for refactoring guidance.