Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/rubyroidlabs/rails_api_keysnpx agentmods add rules/rubyroidlabs/rails_api_keys/contextWrote 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/rules/rubyroidlabs/rails_api_keys/context)<a href="https://agentmods.dev/rules/rubyroidlabs/rails_api_keys/context"><img src="https://agentmods.dev/badge/rules/rubyroidlabs/rails_api_keys/context/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/rubyroidlabs/rails_api_keys/context"><img src="https://agentmods.dev/badge/rules/rubyroidlabs/rails_api_keys/context.svg" alt="Reviewed on agentmods" width="80" 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.00727 | $0.00727 |
| Opus 5.5 | $0.00291 | $0.00291 |
| Sonnet 5.5 | $0.00145 | $0.00145 |
| Haiku 4.5 | $0.00073 | $0.00073 |
Grade A, and why
context 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 1mo 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 — 97 lines — stays where its author put it; the contents beside it link to each section on GitHub.
rails_api_keys Context
Single source of truth for engine state and architecture
Overview
Reusable Rails engine that issues and authenticates personal API keys. Intentionally thin: keys + auth helpers only. Public MIT-licensed gem.
Naming
- Gem / require / repo:
rails_api_keys - Module:
RailsApiKeys - Table:
rails_api_keys_api_keys - Generator:
rails_api_keys:install
Technology
- Rails engine (
>= 7.0), isolated namespaceRailsApiKeys - Active Record for
rails_api_keys_api_keys - No frontend, mailers, jobs, or mounted business routes
Public surface
has_api_keys (on owner models)
- Declares polymorphic
has_many :api_keysand registers the model as an allowed owner - Adds
create_api_key!(name:, permission:)→[record, raw_token](wrapsApiKey.generate_for!) - Multiple models may opt in (e.g.
User,Company) - Models without the macro cannot own keys
Configuration (RailsApiKeys.configure) — all optional
| Option | Default | Purpose |
|---|---|---|
token_prefix |
nil → "#{AppName.downcase}_ak_" |
Prefix for generated raw tokens |
owner_active |
uses active_for_authentication? when present |
Gate authenticate on owner liveness |
Host initializers should only set overrides; do not restate defaults.
RailsApiKeys::ApiKey
- Polymorphic
belongs_to :owner - Permissions:
read,read_write(immutable after create) generate_for!(owner:, name:, permission:)→[record, raw_token]authenticate(raw_token)→ active key if digest matches and owner active; toucheslast_used_atrevoke!setsrevoked_at- Stores
token_digest(SHA-256),token_display_prefix; never plaintext
RailsApiKeys::Authentication
authenticate_api_key!— Bearer token →current_api_key/current_api_owner; 401 on auth failure; GET/HEAD require read, other methods require write (403 if lacking)
Install
bin/rails generate rails_api_keys:install
bin/rails db:migrate
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.
- 1mo ago First seen · 97 lines · 727 tokens per session scan A 68efa394df7c
context is a cursor rule published in the GitHub repository rubyroidlabs/rails_api_keys (10 stars, last pushed 18d ago), licensed MIT. It adds 727 tokens to every session, about $0.0029 per session on Opus 5.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-31.
Other cursor rules, from other repositories
upgrade-tests
// ✅ CORRECT: Upgrade package pattern await using ctx = testReactResource(appRouter, { server: { // server configuration }, client(opts) { return { links: [ httpLink({ url: opts.httpUrl, // client configuration }), ], }; }, }).
test-running
When running tests, use the --watch false flag to avoid watch mode.
windsurfrules
Create detailed components with these requirements.
middleware
When you need create a middleware to protect some page of Next.js app.
memory
Establishes a persistent memory protocol for capturing and retrieving knowledge, including storage strategies, context retrieval, and proactive memory management for continuous learning.
v5
Foundation rules for coding assistance. Defines task classification (lightweight/standard/critical), tool usage policies, and response style.