factory-stack

A shared set of technology choices and decision rules for new Factory projects, covering tools such as Next.js, TypeScript, databases, forms, email, and linting.

In plain words
What is it for?
It helps select and document the runtime, language, validation, server-state, database, authentication, deployment, and monitoring approach for a project.
Why use it?
It avoids repeatedly debating the same project foundations and gives teams criteria for choices that depend on the project.

Skill for Claude CodeCodex

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

Made for: Claude Code, Codex.

Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,020 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.00061 $0.01020
Opus 5 $0.00030 $0.00510
Sonnet 5 $0.00012 $0.00204
Haiku 4.5 $0.00006 $0.00102

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

Security

Grade A, and why

factory-stack 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 2d 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-stack/SKILL.md · 71 lines

How it starts

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

Factory stack

Locked decisions (no per-project relitigation)

Layer Choice Why
Runtime Next.js App Router Convergent across all customer repos; ecosystem fit for tRPC / server actions / Vercel deploy
Language TypeScript Convergent; non-negotiable
Validation Zod Pairs with both tRPC and server actions; field registry pattern depends on it
Server state TanStack Query Convergent across all repos that need server state
DB Postgres via Neon (dev branches) or RDS (compliance) Convergent
Forms react-hook-form + Zod via resolver Convergent
Email Resend Convergent
Linting ESLint + Prettier + ESLint Drizzle rules where applicable Convergent
Env vars t3-oss/env-nextjs (Zod-validated, server/client split) Convergent

Decision-criteria choices (pick per project; document in project's CLAUDE.md or DECISIONS.md)

ORM — Drizzle vs Supabase auto-types vs raw pg

  • Drizzle — default. Schema partitioning by domain (_shared.ts, <domain>.ts) + shared timestamps helper. pgTableCreator() for prefixing if the DB is shared.
  • Supabase auto-generated types — when Supabase Auth + RLS is already doing real work. RLS policies are the contract; auto-types are a free byproduct.
  • Raw pg — never for new projects. Migrate if encountered.

Auth — Better Auth + orgs vs Supabase Auth + RLS vs Clerk

  • Better Auth + organization plugin — default. Org + RBAC + 2FA out of the box; pairs with Drizzle.
  • Supabase Auth + RLS — when RLS pays for itself (multi-role partner/distributor model, deeply branched authz at row level).
  • Clerk — consumer/SSO-heavy, or when managed auth UI components matter.

The wrapper interface is the same regardless: requireAuth(), requireRole(), withOrgContext(). See factory-auth.md (Phase B) for the canonical wrapper shape.

API style — server actions vs tRPC

  • Server actions — default for feature-folder-colocated apps with one frontend consumer. Pairs with TanStack Query (useMutation wrapping the action).
  • tRPC — when typed RPC contracts add leverage: ≥3 entities with cross-feature queries, multiple consumers, or a public API surface.
  • Pitfall: don't import both. Pick a side per project.

Read the full file on GitHub · 71 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. 2d ago First seen · 71 lines · 61 tokens per session scan A a10330467276

Subscribe to this mod's changes

factory-stack is a skill published in the GitHub repository nonlinear-xyz/factory-kit (9 stars, last pushed 28d ago), licensed MIT. It adds 61 tokens to every session and 1,020 once invoked, about $0.0003 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.