rails-token-auth

rails-token-auth is a skill for Claude Code from davidteren/hotwire-codex-skills. It costs 110 tokens per session (840 once invoked), scanned A, original, MIT.

A guide for adding database-backed login sessions to Rails, a web application framework, so web, native apps, and live connections can share authentication.

In plain words
What is it for?
Use it to build or audit login and logout, shared authentication for web and Hotwire Native clients, Action Cable access, and device removal.
Why use it?
It provides revocable sessions stored on the server, avoiding the limitations of login tokens that cannot be individually cancelled.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the hotwire-codex-skills plugin — 8 skills shipped together

Good fit Use it to build or audit login and logout, shared authentication for web and Hotwire Native clients, Action Cable access, and device removal.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/davidteren/hotwire-codex-skills/rails-token-auth
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.

Any agent
npx skills add davidteren/hotwire-codex-skills --skill rails-token-auth
Clone the repo
git clone --depth 1 https://github.com/davidteren/hotwire-codex-skills

Made for: Claude Code.

Or install hotwire-codex-skills, the plugin that ships this one along with the rest of its 8 skills.

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 rails-token-auth

README.md
[![agentmods](https://agentmods.dev/badge/skills/davidteren/hotwire-codex-skills/rails-token-auth/github.svg)](https://agentmods.dev/skills/davidteren/hotwire-codex-skills/rails-token-auth)
Your own site
<a href="https://agentmods.dev/skills/davidteren/hotwire-codex-skills/rails-token-auth"><img src="https://agentmods.dev/badge/skills/davidteren/hotwire-codex-skills/rails-token-auth/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.

agentmods 80×15 button for rails-token-auth

Your own site · 80×15
<a href="https://agentmods.dev/skills/davidteren/hotwire-codex-skills/rails-token-auth"><img src="https://agentmods.dev/badge/skills/davidteren/hotwire-codex-skills/rails-token-auth.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 110 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 840 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00110 $0.00840
Opus 5 $0.00055 $0.00420
Sonnet 5 $0.00022 $0.00168
Haiku 4.5 $0.00011 $0.00084

Measured 10d ago against content hash 072456ea0752, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

rails-token-auth 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 10d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/audit_token_auth.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skills/rails-token-auth/SKILL.md · 64 lines

How it starts

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

Rails token-backed session auth

A revocable, DB-backed session model (AppSession) that authenticates web and native clients with one mechanism — plus Current attributes and secure-by-default controller concerns. Built without a gem (plain has_secure_password + authenticate_by). Full design + rationale: references/token-auth-guide.md.

When to use

  • Adding login/logout to a Rails app and you want it done securely from the start.
  • Web + Hotwire Native (and Action Cable) need to share one auth.
  • You need revocable sessions (real logout, kick a device) — not stateless JWTs.
  • Auditing existing auth for the expensive mistakes.

The shape

File Role
AppSession (app/models/app_session.rb) one row per login; token stored as a digest (has_secure_password :token)
User::Authentication (app/models/user/authentication.rb) has_secure_password; authenticate_by login; mint/verify sessions
Current (app/models/current.rb) request-scoped user / app_session / organization
Authenticate (app/controllers/concerns/authenticate.rb) secure-by-default before_action; skip_authentication / allow_unauthenticated; log_in/log_out
SessionsController create_app_sessionlog_in; destroylog_out

Copy the templates from templates/ (they're generic, ready to adapt). Add the migration (app_sessions: user ref + token_digest), the routes (login/logout), and include User::Authentication + include Authenticate in ApplicationController.

The non-negotiables (why this design)

  • authenticate_by, not find_by(email:)&.authenticate — timing-safe, no account enumeration.
  • Token hashed at rest (has_secure_password :token) — plaintext token lives only in the encrypted cookie. A DB leak yields no usable sessions.
  • cookies.encrypted for the session payload — confidential + tamper-proof.
  • Secure-by-default: global before_action :authenticate; public actions opt out explicitly. A forgotten controller stays locked.
  • Real logout destroys the AppSession row — server-side revocation.

Read the full file on GitHub · 64 lines

Files

What ships with it

7 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 10d ago First seen · 64 lines · 110 tokens per session scan A 072456ea0752

Subscribe to this mod's changes

rails-token-auth is a skill published in the GitHub repository davidteren/hotwire-codex-skills (3 stars, last pushed 2mo ago), licensed MIT. It adds 110 tokens to every session and 840 once invoked, about $0.0006 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-31.

Related

Other skills, from other repositories

add-server-logic

Creates, edits, and manages Power Pages Server Logic files — server-side JavaScript that runs securely on the Power Pages runtime. Orchestrates the full lifecycle: gathering requirements, fetching documentation, implementing code, configuring site settings, and deploying. Use when the user wants to add server-side…

microsoft/power-platform-skills · 83 tokens

integrate-webapi

Integrates Power Pages Web API into a site's frontend code with proper permissions and deployment. Orchestrates the full integration lifecycle: code integration, table permissions setup, and deployment for Dataverse CRUD operations. Use when the user wants to add Web API calls, connect to Dataverse, or add data…

microsoft/power-platform-skills · 69 tokens

add-cloud-flow

Integrates Power Automate cloud flows into a Power Pages site. Lists available flows, suggests relevant ones based on intent, identifies scenarios and web roles, creates metadata files, and generates client-side code to call flows. Handles both new flow registration and adding already-registered flows to additional…

microsoft/power-platform-skills · 91 tokens

integrate-backend

Analyzes the user's business problem and recommends the right backend integration approach — Web API, AI Web API (generative summaries / grounded search), Server Logic, Cloud Flows, or a combination — for a Power Pages site, then routes to the appropriate specialized skill. Use when the user wants to add backend…

microsoft/power-platform-skills · 86 tokens

migrate-webapi-selectall

Reviews and migrates deprecated wildcard () values in Power Pages Web API fields site settings to least-privilege explicit Dataverse columns. Use whenever a user mentions Web API wildcard or select-all remediation, fields settings containing , data-exposure review, wildcard deprecation readiness, or Web API failures…

microsoft/power-platform-skills · 139 tokens

add-sharepoint

Adds SharePoint Online connector to a Power Apps code app. Use when reading lists, managing documents, or integrating with SharePoint sites. Can also create new SharePoint lists.

microsoft/power-platform-skills · 39 tokens