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.
npx skills add lewispb/rails-query-skill --skill rails-querygit clone --depth 1 https://github.com/lewispb/rails-query-skillWrote 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.
[](https://agentmods.dev/skills/lewispb/rails-query-skill/rails-query)<a href="https://agentmods.dev/skills/lewispb/rails-query-skill/rails-query"><img src="https://agentmods.dev/badge/skills/lewispb/rails-query-skill/rails-query.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00188 | $0.02368 |
| Opus 5 | $0.00094 | $0.01184 |
| Sonnet 5 | $0.00038 | $0.00474 |
| Haiku 4.5 | $0.00019 | $0.00237 |
Grade A, and why
rails-query 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 8d 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.
How it starts
The opening of the file, as written. The whole thing — 202 lines — stays where its author put it; the contents beside it link to each section on GitHub.
rails-query
rails query is a Rails 8.2+ command for running read-only queries against the database. Input is a single expression, output is a single JSON object on stdout ({columns, rows, meta}; errors go to stderr with non-zero exit), and writes are blocked at the connection level. With a read replica configured it hits the replica automatically, so it's safe to point at production.
Prefer it over a console, a script, or SSH for any data question. One invocation, structured output, nothing to clean up.
The flow
1. Know where you're running
- Local (
bin/rails query) — development, tests, or anywhere you have the app checked out. - Remote via Kamal (
bin/kamal query -d <destination>) — when the app is deployed with Kamal. Requires a small alias inconfig/deploy.yml(see "Kamal setup").
If you don't know whether Kamal is configured, check config/deploy.yml for an aliases: block.
2. Decide: Ruby expression or raw SQL
Default: Ruby (ActiveRecord). The expression is eval'd in the app context — scopes, associations, finders, aggregates all work. Model logic (encryption, default scopes, polymorphism) is honored.
--sql: raw schema access, cross-table joins without models, or aggregates awkward in AR.
Telltale sign you forgot --sql: SyntaxError: unexpected *; no anonymous rest parameter — your SQL got parsed as Ruby. Add --sql and retry.
3. Inspect the schema if it's unfamiliar
rails query has three introspection modes that work the same locally and remotely — crucial when you only have Kamal access:
bin/rails query schema # every table
bin/rails query schema users # columns + indexes + enums + associations for one table
bin/rails query models # every AR model with its table and associations
Enums matter: if a column is an enum, User.where(status: "active") works but User.where(status: 0) might silently misfire. schema <table> tells you.
Over Kamal, cache the schema locally before jq-ing it — each round-trip is 10-30s. Dump schema / models / schema <table> to /tmp/rails-query-cache-<env>/ once, then jq against the files. Skip caching for single-query tasks or local runs.
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.
- 8d ago First seen · 202 lines · 188 tokens per session scan A c77106acca0e
rails-query is a skill published in the GitHub repository lewispb/rails-query-skill (25 stars, last pushed 4mo ago), licensed MIT. It adds 188 tokens to every session and 2,368 once invoked, about $0.0009 per session on Opus 5. 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.
Other skills, from other repositories
schema-exploration
Lists tables, describes columns and data types, identifies foreign key relationships, and maps entity relationships in a database. Use when the user asks about database schema, table structure, column types, what tables exist, ERD, foreign keys, or how entities relate.
ha-data-stores
Map of Hope Agent's local data stores and safe read-only query workflow. Use when the user asks where Hope Agent stores data, wants to inspect sessions/messages/memory/logs/background jobs/knowledge indexes/settings, asks the model to query local app data, or debugging requires checking persisted state. Trigger…
supabase
Supabase / PostgREST Row-Level-Security playbook — pull the anon (or leaked servicerole) key out of the frontend JS, map tables from the auto-generated OpenAPI spec, test anonymous RLS READ disclosures (PII/secret leaks), and anonymous RLS WRITE abuse (insert/update/delete — e.g. forging…
nornicdb-cypher-queries
Pick fast, predictable Cypher query shapes in NornicDB — point lookups, batch retrieval, pagination, search, traversal, batched UNWIND/MERGE writes, cleanup, multi-tenant isolation. Use when writing or reviewing Cypher whose latency or throughput matters; maps user intent to the executor's hot-path query templates.
dsql
Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, foreign key…
volcengine-rds-postgresql
A tool for operating PostgreSQL databases hosted by Volcano Engine's managed database service. PostgreSQL is a relational database used to store structured application data.