Answer any question that requires live data from a Rails 8.2+ app using `rails query`:
counts, lookups, "how many X", ad-hoc investigation, schema exploration, EXPLAIN plans,
and aggregates — whether locally or against a deployed environment via Kamal. Trigger
broadly whenever the user asks for data from a Rails app's database, mentions
`rails query` / `bin/rails query` / `bin/kamal query`, asks to inspect schema, tables,
or models, wants to run SQL or ActiveRecord against the database, needs an EXPLAIN
plan, or wants to query production/staging/replica. Prefer this skill over opening a
Rails console, SSH-ing to a server, or writing a one-off script for data questions —
`rails query` is faster, structured (JSON output), audit-friendly, and read-only by
construction.
2026-04-23