query-agent

Encapsulate complex database queries into reusable query objects for Rails applications.

Updated Mar 19, 2026
One-click install
npx skills add https://github.com/reckerswartz/resume_builder --skill query-agent-reckerswartz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: query-agent
Source: https://github.com/reckerswartz/resume_builder/tree/main/.windsurf/skills/query-agent
Command: npx skills add https://github.com/reckerswartz/resume_builder --skill query-agent-reckerswartz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Encapsulates complex database queries into reusable, testable query objects to simplify Rails applications and reduce controller clutter.

Core Features & Use Cases

  • Reusable query objects for complex filtering across models, enabling clean, composable queries for reports, dashboards, and analytics.
  • Built-in patterns and guidance (including includes for N+1 prevention) to keep queries efficient and maintainable.
  • Clear separation of query logic from business rules, with testable specs in spec/ directories.

Quick Start

Create a new query object under app/queries, implement #call with your filters, and use it in controllers or services.

Frequently Asked Questions about query-agent

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I encapsulate complex Rails queries into reusable objects?▼

Create query objects under app/queries that implement a #call method with predefined default relations and safe parameterization. This extracts complex multi-conditional filtering logic from controllers into reusable, composable classes for reporting and analytics dashboards.

What is the ApplicationQuery pattern in Rails for managing database queries?▼

The ApplicationQuery pattern structures database queries into dedicated objects with predefined default relations, safe parameterization, includes for N+1 prevention, and a structured call interface. It separates complex multi-conditional filtering logic from controllers into reusable, testable classes.

How do I prevent N+1 queries in Rails when filtering across multiple models?▼

Prevent N+1 queries in Rails by using query objects that apply includes for eager loading associations within predefined default relations. The ApplicationQuery pattern enforces this efficiency standard, keeping multi-model filtering performant for dashboards and analytics.

Does the query object pattern work with RSpec for testing complex ActiveRecord queries?▼

The query object pattern works with RSpec by placing testable specs in the spec/ directory. Because query logic is encapsulated in isolated objects with clear call interfaces, you can unit test multi-conditional ActiveRecord filtering independently from controllers and services.

What's the best way to organize reporting and analytics queries in a Rails application?▼

The best way to organize reporting and analytics queries is using the ApplicationQuery pattern to encapsulate them into reusable query objects under app/queries. This enforces includes for N+1 prevention, safe parameterization, and clear separation from business rules.

When should I use query objects instead of scopes or class methods in ActiveRecord?▼

Use query objects instead of scopes or class methods when dealing with complex multi-conditional filtering across multiple models for reporting and analytics. Query objects provide a structured call interface, safe parameterization, and dedicated specs that prevent controller clutter.