Backend Queries
Write efficient, secure database queries using ORMs or raw SQL, preventing N+1 problems, SQL injection, and performance issues. Use this skill when writing database queries, implementing data access layers, creating repository patterns, or optimizing query performance in service files, query builders, or data access objects. Apply this skill when using parameterized queries, implementing eager loading to avoid N+1 queries, selecting only needed columns, adding WHERE/JOIN/ORDER BY clauses, or working with query optimization, indexes, and database performance tuning. This skill ensures queries use proper SQL injection prevention, implement transactions for data consistency, cache expensive queries appropriately, and follow best practices for query timeouts, connection pooling, and database resource management.
Packaged view
This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.
Install command
npx @skill-hub/cli install overtimepog-agenttheo-backend-queries
Repository
Skill path: .claude/skills/backend-queries
Write efficient, secure database queries using ORMs or raw SQL, preventing N+1 problems, SQL injection, and performance issues. Use this skill when writing database queries, implementing data access layers, creating repository patterns, or optimizing query performance in service files, query builders, or data access objects. Apply this skill when using parameterized queries, implementing eager loading to avoid N+1 queries, selecting only needed columns, adding WHERE/JOIN/ORDER BY clauses, or working with query optimization, indexes, and database performance tuning. This skill ensures queries use proper SQL injection prevention, implement transactions for data consistency, cache expensive queries appropriately, and follow best practices for query timeouts, connection pooling, and database resource management.
Open repositoryBest for
Primary workflow: Write Technical Docs.
Technical facets: Full Stack, Backend, Data / AI, Tech Writer, Security.
Target audience: everyone.
License: Unknown.
Original source
Catalog source: SkillHub Club.
Repository owner: overtimepog.
This is still a mirrored public skill entry. Review the repository before installing into production workflows.
What it helps with
- Install Backend Queries into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
- Review https://github.com/overtimepog/AgentTheo before adding Backend Queries to shared team environments
- Use Backend Queries for development workflows
Works across
Favorites: 0.
Sub-skills: 0.
Aggregator: No.
Original source / Raw SKILL.md
--- name: Backend Queries description: Write efficient, secure database queries using ORMs or raw SQL, preventing N+1 problems, SQL injection, and performance issues. Use this skill when writing database queries, implementing data access layers, creating repository patterns, or optimizing query performance in service files, query builders, or data access objects. Apply this skill when using parameterized queries, implementing eager loading to avoid N+1 queries, selecting only needed columns, adding WHERE/JOIN/ORDER BY clauses, or working with query optimization, indexes, and database performance tuning. This skill ensures queries use proper SQL injection prevention, implement transactions for data consistency, cache expensive queries appropriately, and follow best practices for query timeouts, connection pooling, and database resource management. --- # 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. ## When to use this skill - When writing database queries using ORM methods or query builders - When implementing raw SQL queries with proper parameterization - When creating repository patterns or data access layers - When optimizing queries to prevent N+1 query problems using eager loading - When adding JOINs, WHERE clauses, or complex query logic - When selecting specific columns instead of using SELECT * for performance - When implementing query pagination, filtering, or sorting logic - When wrapping related database operations in transactions - When adding query timeouts or implementing query performance monitoring - When working with query optimization, EXPLAIN plans, or index usage analysis - When implementing query caching strategies for expensive or frequent queries - When preventing SQL injection through parameterized queries and input validation - When working with files like `queries.py`, `repositories/`, `dao/`, or service layer query logic ## Instructions For details, refer to the information provided in this file: [backend queries](../../../agent-os/standards/backend/queries.md) --- ## Referenced Files > The following files are referenced in this skill and included for context. ### ../../../agent-os/standards/backend/queries.md ```markdown ## Database query best practices - **Prevent SQL Injection**: Always use parameterized queries or ORM methods; never interpolate user input into SQL strings - **Avoid N+1 Queries**: Use eager loading or joins to fetch related data in a single query instead of multiple queries - **Select Only Needed Data**: Request only the columns you need rather than using SELECT * for better performance - **Index Strategic Columns**: Index columns used in WHERE, JOIN, and ORDER BY clauses for query optimization - **Use Transactions for Related Changes**: Wrap related database operations in transactions to maintain data consistency - **Set Query Timeouts**: Implement timeouts to prevent runaway queries from impacting system performance - **Cache Expensive Queries**: Cache results of complex or frequently-run queries when appropriate ```