factory-auth

factory-auth is a skill for Claude Code, Codex from nonlinear-xyz/factory-kit. It costs 97 tokens per session (3,209 once invoked), scanned A, original, MIT.

A set of conventions for user authentication and authorization across Better Auth, Supabase Auth, and Clerk. Authentication checks who someone is; authorization checks what that person is allowed to do.

In plain words
What is it for?
Use it when designing login, sessions, organizations, roles, permissions, OAuth callbacks, and shared authentication wrappers.
Why use it?
It helps teams choose an authentication provider that fits their data and organization model while keeping application code consistent.

Skill for Claude CodeCodex

Part of the factory-kit plugin — 37 skills, 8 commands, 12 agents, 1 MCP server shipped together

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 skills/nonlinear-xyz/factory-kit/factory-auth
Any agent
npx skills add nonlinear-xyz/factory-kit --skill factory-auth
Clone the repo
git clone --depth 1 https://github.com/nonlinear-xyz/factory-kit

Made for: Claude Code, Codex.

Or install factory-kit, the plugin that ships this one along with the rest of its 37 skills, 8 commands, 12 agents, 1 MCP server.

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 factory-auth

README.md
[![agentmods](https://agentmods.dev/badge/skills/nonlinear-xyz/factory-kit/factory-auth.svg)](https://agentmods.dev/skills/nonlinear-xyz/factory-kit/factory-auth)
Your own site
<a href="https://agentmods.dev/skills/nonlinear-xyz/factory-kit/factory-auth"><img src="https://agentmods.dev/badge/skills/nonlinear-xyz/factory-kit/factory-auth.svg" alt="Measured on agentmods" height="20"></a>
Per session 97 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,209 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 $0.00097 $0.03209
Opus 5 $0.00048 $0.01605
Sonnet 5 $0.00019 $0.00642
Haiku 4.5 $0.00010 $0.00321

Measured 4d ago against content hash 7978a7191537, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

factory-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 4d 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.

skills/factory-auth/SKILL.md · 259 lines

How it starts

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

Factory auth

Each section leads with Principle (one sentence, stack-agnostic), then Why (constraint → option → tradeoff), then Recipe (the shape we use), and Failure mode when there's one to name. Sections that are pure style with no deeper truth are marked Recipe only. Editors: if the Principle could appear unchanged in any auth tutorial, sharpen the Why with a Factory-specific observation or drop the section to Recipe only.

Provider pick — match the authz model, not the familiarity

Principle. Pick the provider whose model matches your authz shape; don't fight the provider for features it isn't built for.

Why. Auth providers differ in what they make easy. Better Auth is org-shaped (teams, roles, invitations). Supabase Auth + RLS is row-shaped (per-row policy reasoning). Clerk is consumer-shaped (managed UI, social login). Picking the wrong shape means every authz feature is upstream — you're rebuilding the provider's missing model. The wrapper interface below makes provider a swap point, so the cost of getting this wrong is bounded — but you still pay the swap.

Recipe.

Provider Pick when
Better Auth + organization plugin Default. B2B with team/org concept. Drizzle-based projects. Need 2FA + magic link + admin out of the box.
Supabase Auth + RLS RLS is doing real work — multi-role partner/distributor model, deeply branched authz at row level. Project already commits to Supabase.
Clerk Consumer / SSO-heavy. Managed auth UI components matter. Org features secondary.

The wrapper interface — the single seam

Principle. The wrapper is the seam; the provider is swappable behind it.

Why. Every server action and API route calls auth. If they call the provider's SDK directly, swapping providers means touching every action. The wrapper concentrates the provider dependency in one file — requireAuth, requireRole, withOrgContext — and gives the call sites a stable interface that doesn't depend on which SDK is underneath. The cost is three small wrapper functions; the savings are linear in the number of mutations the project will ever have.

Read the full file on GitHub · 259 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. 4d ago First seen · 259 lines · 97 tokens per session scan A 7978a7191537

Subscribe to this mod's changes

factory-auth is a skill published in the GitHub repository nonlinear-xyz/factory-kit (9 stars, last pushed 1mo ago), licensed MIT. It adds 97 tokens to every session and 3,209 once invoked, about $0.0005 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.