AgentSkillsCN

backend-queries

遵循安全与性能优化的最佳实践,编写安全且高效的数据库查询。在编写JPQL、HQL或原生SQL查询、实现仓储库方法、通过参数化查询防范SQL注入、避免N+1查询问题、利用急加载或联接优化查询性能,或实施查询缓存时,均可运用此技能。适用范围包括仓储库类、DAO文件,以及所有与数据库交互的代码。

SKILL.md
--- frontmatter
name: backend-queries
description: Write safe and performant database queries following security and optimization best practices. Use this skill when writing JPQL, HQL, or native SQL queries, implementing repository methods, preventing SQL injection with parameterized queries, avoiding N+1 query problems, optimizing query performance with eager loading or joins, or implementing query caching. Applies to repository classes, DAO files, and any code that interacts with the database.

When to use this skill

  • When writing JPQL, HQL, or native SQL queries
  • When implementing repository methods for data access
  • When using parameterized queries to prevent SQL injection
  • When optimizing queries to avoid N+1 problems
  • When implementing eager loading or joins for related data
  • When selecting specific columns instead of SELECT *
  • When adding indexes for WHERE, JOIN, and ORDER BY columns
  • When wrapping related operations in transactions
  • When implementing query timeouts for performance
  • When adding caching for expensive or frequent queries
  • When editing *Repository.java, *DAO.java, or data access files

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