AgentSkillsCN

Backend Queries

使用ORM或原生SQL编写安全且性能优越的数据库查询。当编写数据库查询、实现数据访问逻辑,或优化查询性能时,可使用此技能。适用于repositories/*.ts、queries/*.ts、services/*.ts等包含数据库操作的文件,或任何与数据库交互的代码。对于防范SQL注入攻击、通过预编译查询避免N+1查询问题、仅选择所需列、对相关操作使用事务、实施查询超时机制,以及缓存高成本查询而言,此项技能不可或缺。

SKILL.md
--- frontmatter
name: Backend Queries
description: Write secure and performant database queries using ORMs or raw SQL. Use this skill when writing database queries, implementing data access logic, or optimizing query performance. Apply when working on files like repositories/*.ts, queries/*.ts, services/*.ts with database operations, or any code that interacts with the database. Essential for preventing SQL injection with parameterized queries, avoiding N+1 query problems with eager loading, selecting only needed columns, using transactions for related operations, implementing query timeouts, and caching expensive queries.

When to use this skill:

  • When writing database queries (SELECT, INSERT, UPDATE, DELETE)
  • When using ORM methods like findMany, findUnique, create, update
  • When implementing repository or data access layer patterns
  • When optimizing slow database queries
  • When fixing N+1 query problems with eager loading or joins
  • When wrapping related database operations in transactions
  • When adding query caching for expensive operations
  • When writing raw SQL queries with parameterized inputs
  • When adding indexes for frequently queried columns
  • When implementing query timeouts for long-running operations
  • When working on files in /repositories/, /queries/, or data access layers

Backend Queries

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