AgentSkillsCN

Backend Queries

使用参数化查询、急载加载避免N+1问题、选择性列获取、战略性索引、事务处理相关更改、查询超时和缓存昂贵查询,编写高效且安全的数据库查询。在编写Eloquent查询或原始SQL、优化数据库性能、防止N+1查询问题的急载加载、实现数据库事务、添加索引提升查询速度或缓存频繁运行的查询时使用此技能。在处理Eloquent查询构建器、原始数据库查询、查询优化或任何与数据库交互的代码时适用。

SKILL.md
--- frontmatter
name: Backend Queries
description: Write efficient and secure database queries using parameterized queries, eager loading to prevent N+1 problems, selective column fetching, strategic indexing, transactions for related changes, query timeouts, and caching for expensive queries. Use this skill when writing Eloquent queries or raw SQL, optimizing database performance, preventing N+1 query problems with eager loading, implementing database transactions, adding indexes to improve query speed, or caching frequently-run queries. This skill applies when working with Eloquent query builder, raw database queries, query optimization, or any code that interacts with the database.

Backend Queries

When to use this skill

  • When writing Eloquent queries or using the query builder
  • When writing raw SQL queries for complex operations
  • When optimizing database performance and query execution time
  • When preventing N+1 query problems with eager loading (with(), load())
  • When implementing database transactions for data consistency
  • When adding indexes to database columns for query optimization
  • When caching frequently-run or expensive queries
  • When selecting only needed columns instead of using SELECT *
  • When implementing query timeouts to prevent runaway queries
  • When working with WHERE, JOIN, or ORDER BY clauses
  • When debugging slow database queries or performance issues
  • When implementing pagination or filtering in API endpoints

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