backend-queries

pdovhomilja's avatarfrom pdovhomilja

Write optimized and secure database queries using parameterized queries, eager loading, and proper indexing strategies. Use this skill when writing database queries, constructing SQL statements, using ORM query methods, implementing data fetching logic, preventing SQL injection attacks, optimizing query performance, avoiding N+1 query problems, selecting specific columns instead of all data, implementing transactions for related operations, setting query timeouts, caching expensive queries, or working with WHERE clauses, JOINs, and ORDER BY statements. Apply this skill when fetching data from databases, optimizing slow queries, refactoring data access code, or reviewing query security and performance.

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 25, 2025⬇️1downloads

When & Why to Use This Skill

This Claude skill enables the generation of optimized, secure, and high-performance database queries. It focuses on modern backend best practices, including preventing SQL injection via parameterized queries, eliminating N+1 performance bottlenecks through eager loading, and ensuring data integrity with robust transaction management and strategic indexing.

Use Cases

  • Security Hardening: Refactoring legacy database code to use parameterized queries, effectively neutralizing SQL injection vulnerabilities.
  • Performance Optimization: Identifying and fixing slow API endpoints by replacing inefficient loops with eager loading or optimized JOIN operations to solve N+1 issues.
  • Resource Management: Improving application responsiveness by selecting only necessary columns and implementing query timeouts and caching for expensive data operations.
  • Data Integrity: Implementing complex, multi-step data updates within database transactions to ensure atomicity and consistency in business logic.
  • Database Schema Tuning: Recommending and implementing proper indexing strategies for columns frequently used in filtering, sorting, and joining operations.
nameBackend Queries
descriptionWrite optimized and secure database queries using parameterized queries, eager loading, and proper indexing strategies. Use this skill when writing database queries, constructing SQL statements, using ORM query methods, implementing data fetching logic, preventing SQL injection attacks, optimizing query performance, avoiding N+1 query problems, selecting specific columns instead of all data, implementing transactions for related operations, setting query timeouts, caching expensive queries, or working with WHERE clauses, JOINs, and ORDER BY statements. Apply this skill when fetching data from databases, optimizing slow queries, refactoring data access code, or reviewing query security and performance.

Backend Queries

When to use this skill

  • When writing database queries in any file that interacts with the database
  • When constructing SQL statements or using ORM query builders (Prisma, Sequelize, ActiveRecord, etc.)
  • When preventing SQL injection by using parameterized queries
  • When optimizing queries to avoid N+1 query problems (use eager loading or joins)
  • When selecting only needed columns instead of using SELECT * or fetching all fields
  • When adding indexes to columns used in WHERE, JOIN, or ORDER BY clauses
  • When implementing database transactions for related operations
  • When setting query timeouts to prevent runaway queries
  • When caching results of complex or frequently-run queries
  • When writing JOIN operations to fetch related data efficiently
  • When implementing pagination, filtering, or sorting with query parameters
  • When reviewing query performance and optimization opportunities

This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle backend queries.

Instructions

For details, refer to the information provided in this file: backend queries