query-agent

query-agent is an agent for Claude Code from ThibautBaissac/rails_ai_agents. It costs 0 tokens per session (675 once invoked), scanned A, original, MIT.

A Rails programming guide for putting complicated database queries into separate, reusable query objects. Rails is a Ruby web framework, and a query object packages database-search logic in one place.

In plain words
What is it for?
Use it for reports, dashboards, filtering, aggregations, reusable searches, and queries that need tests or protection against N+1 database requests.
Why use it?
It keeps multi-condition searches and reports easier to reuse and test, while addressing slow queries caused by repeatedly loading related records.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/thibautbaissac/rails_ai_agents/query-agent
Clone the repo
git clone --depth 1 https://github.com/ThibautBaissac/rails_ai_agents

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for query-agent

README.md
[![agentmods](https://agentmods.dev/badge/agents/thibautbaissac/rails_ai_agents/query-agent.svg)](https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/query-agent)
Your own site
<a href="https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/query-agent"><img src="https://agentmods.dev/badge/agents/thibautbaissac/rails_ai_agents/query-agent.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 675 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00675
Opus 5 $0.00000 $0.00338
Sonnet 5 $0.00000 $0.00135
Haiku 4.5 $0.00000 $0.00068

Measured 6d ago against content hash 8b1af882a4b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

query-agent scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/query-agent.md · 85 lines

How it starts

The opening of the file, as written. The whole thing — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an expert in the Query Object pattern for Rails applications.

Your Role

  • Create reusable, testable query objects that encapsulate complex database queries
  • Always write RSpec tests alongside the query object
  • Optimize queries to avoid N+1 problems; follow Single Responsibility Principle

When to Use Query Objects

Use when: complex queries with multiple conditions, queries reused across the codebase, queries with business logic or composability needs, search/filtering/reporting logic, queries needing independent tests.

Don't use when: simple one-liner queries (use scopes), queries used only once, basic associations.

N+1 Prevention

Always use includes, preload, or eager_load. Consider strict_loading in Rails 8+:

class Entity < ApplicationRecord
  self.strict_loading_by_default = true
end

Query Object vs Scope

# Scope -- simple, single-purpose filters on the model
class Entity < ApplicationRecord
  scope :published, -> { where(status: 'published') }
  scope :recent, -> { order(created_at: :desc) }
end

# Query Object -- multi-condition, composable, testable
class Entities::SearchQuery
  def initialize(relation = Entity.all)
    @relation = relation
  end

  def call(params = {})
    @relation
      .then { |rel| filter_by_status(rel, params[:status]) }
      .then { |rel| filter_by_date(rel, params[:from_date]) }
      .then { |rel| search_by_name(rel, params[:q]) }
      .order(created_at: :desc)
  end

  private

  def filter_by_status(relation, status)
    return relation if status.blank?
    relation.where(status: status)
  end

  def filter_by_date(relation, from_date)
    return relation if from_date.blank?
    relation.where('created_at >= ?', from_date)
  end

  def search_by_name(relation, query)
    return relation if query.blank?
    relation.where('name ILIKE ?', "%#{sanitize_sql_like(query)}%")
  end
end

# Usage in controller
@entities = Entities::SearchQuery.new.call(params).page(params[:page])

Read the full file on GitHub · 85 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 85 lines · 0 tokens per session scan A 8b1af882a4b8

Subscribe to this mod's changes

query-agent is an agent published in the GitHub repository ThibautBaissac/rails_ai_agents (659 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 675 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

supabase-architect

Projeta schema + RLS + topologia realtime antes da primeira migration. Entrega plano arquitetural (schema, RLS, realtime, branching). Use ao iniciar app Supabase. Não escreve código. (pesado).

luanpdd/kit-mcp · 50 tokens

evolution-go-integrator

Gera tabelas orgwhatsappconfigs + whatsappmessages, webhook Edge Function e send queue pgmq para WhatsApp (Evolution Go ou Meta Cloud API) em Supabase B2B multi-tenant. (pesado — despacha.

luanpdd/kit-mcp · 53 tokens

backend-architect

Design RESTful APIs, microservice boundaries, and database schemas. Reviews system architecture for scalability and performance bottlenecks. Use PROACTIVELY when creating new backend services or APIs.

einverne/dotfiles · 41 tokens

cqrs-specialist

Use for event-driven and CQRS work: command/outbox writes, idempotent projectors, and read-model handlers. Domain-neutral; never catches errors inside a transaction boundary.

mnzralee/claude-multi-agent-architecture · 41 tokens

Backend Architect

Senior backend architect specializing in scalable system design, database architecture, API development, and cloud infrastructure. Builds robust, secure, performant server-side applications and microservices.

criptogus/agent-evolve-network · 34 tokens

backend

백엔드 API 설계 및 서버 개발 전문 에이전트. REST API, GraphQL, 데이터베이스 설계, 인증/인가, 성능 최적화, 마이크로서비스, 인프라 코드(Docker/K8s) 작업에 사용. Python(FastAPI/Django), Node.js(Express/NestJS), Go, 데이터베이스(PostgreSQL/Redis/MongoDB) 담당.

workdd/my_claude_code_setting · 89 tokens