query-optimize

Identify database queries and N+1 patterns in TypeScript/JavaScript ORM codebases.

11|Updated Apr 16, 2026
One-click install
npx skills add https://github.com/berkcangumusisik/claude-code-practices --skill query-optimize-berkcangumusisik
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-optimize
Source: https://github.com/berkcangumusisik/claude-code-practices/tree/main/skills/query-optimize
Command: npx skills add https://github.com/berkcangumusisik/claude-code-practices --skill query-optimize-berkcangumusisik

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers identify and fix inefficient database queries to reduce latency, especially addressing common N+1 patterns.

Core Features & Use Cases

  • Query discovery: finds all queries across the codebase (e.g., findMany, selects).
  • N+1 detection & batching: detects N+1 patterns and suggests batching or inclusion strategies.
  • Indexing & select optimization: recommends appropriate indexes and selective fields to fetch only needed data.
  • Before/after demonstrations: shows performance and result improvements for each optimization.

Quick Start

Scan your codebase for database queries and apply batching and indexing recommendations to reduce query counts.

Frequently Asked Questions about query-optimize

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

FAQPage Schema
How do I fix Prisma N+1 query issues in my TypeScript backend?

To fix Prisma N+1 query issues, scan your src/ directory to identify nested query patterns and apply batching or inclusion strategies. This process proposes concrete optimizations and documents before/after performance results.

What is the best way to optimize slow database queries in a Knex project?

The best way to optimize slow database queries in a Knex project is to scan for inefficient query patterns, implement selective fetching for missing selects, and apply recommended indexing. It requires confirmation before applying changes.

Can I automatically find missing select statements in my ORM codebase?

Yes, you can automatically find missing select statements in your ORM codebase. The query discovery feature scans for common patterns like findMany and recommends selective field fetching to reduce latency.

Does query optimization work with both JavaScript and TypeScript ORMs?

Yes, query optimization works with both JavaScript and TypeScript ORMs like Prisma and Knex. It scans your backend project's source code to detect inefficient query patterns and suggests appropriate batching strategies.

How do I reduce database latency by batching nested loops in my queries?

Reduce database latency by batching nested loops through N+1 detection, which identifies looped query patterns and suggests batching or inclusion strategies. It shows before/after demonstrations for each applied optimization.