factory-api

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

A set of API conventions for applications built with server actions or tRPC, a tool for making typed API calls between an application and its server. It also covers database queries, pagination, searching, caching, and errors.

In plain words
What is it for?
Use it when building or reviewing Next.js, Drizzle, or tRPC APIs, especially for choosing an API style, defining mutation inputs, adding searches, and shaping paginated results.
Why use it?
It helps keep API code consistent and avoids maintaining conflicting patterns for requests, validation, caching, and error handling.

Skill for Claude Code

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

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

Good fit Use it when building or reviewing Next.js, Drizzle, or tRPC APIs, especially for choosing an API style, defining mutation inputs, adding searches, and shaping paginated results.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nonlinear-xyz/factory-kit/factory-api
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 nonlinear-xyz/factory-kit --skill factory-api
Clone the repo
git clone --depth 1 https://github.com/nonlinear-xyz/factory-kit

Made for: Claude Code.

Or install factory-kit, the plugin that ships this one along with the rest of its 41 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-api

README.md
[![agentmods](https://agentmods.dev/badge/skills/nonlinear-xyz/factory-kit/factory-api/github.svg)](https://agentmods.dev/skills/nonlinear-xyz/factory-kit/factory-api)
Your own site
<a href="https://agentmods.dev/skills/nonlinear-xyz/factory-kit/factory-api"><img src="https://agentmods.dev/badge/skills/nonlinear-xyz/factory-kit/factory-api/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 factory-api

Your own site · 80×15
<a href="https://agentmods.dev/skills/nonlinear-xyz/factory-kit/factory-api"><img src="https://agentmods.dev/badge/skills/nonlinear-xyz/factory-kit/factory-api.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 95 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,955 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.00095 $0.03955
Opus 5.5 $0.00038 $0.01582
Sonnet 5.5 $0.00019 $0.00791
Haiku 4.5 $0.00010 $0.00396

Measured 1mo ago against content hash 9822a0fe7381, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

factory-api 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.

skills/factory-api/SKILL.md · 403 lines

How it starts

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

Factory api

Each section leads with Principle (one sentence, stack-agnostic), then Why (constraint → option → tradeoff), then Recipe (the Next.js / Drizzle / tRPC 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 Clean Code, sharpen the Why with a Factory-specific observation or drop the section to Recipe only — honesty over inflation.

API style — pick one

Principle. Pick one transport style per project; don't mix server actions and tRPC.

Why. Two transport styles in one codebase means two error-handling conventions, two cache-invalidation patterns, two surfaces to audit. The cost compounds linearly with every new endpoint; the cleanup is almost never worth the disruption. The decision is cheap at project start and expensive six months in.

Recipe.

Style Pick when
Server actions Default. Feature-folder colocation matters. One frontend consumer. App-internal API only. Pairs with TanStack Query useMutation.
tRPC ≥3 entities with cross-feature queries. Multiple frontend consumers. Need typed RPC across a real network boundary.
REST / OpenAPI Only when an external system needs to call you. Don't use for internal app traffic.

Failure mode. Encode imported tRPC at project start and built the rest in server actions; the unused tRPC surface created confusion at every call site for months before being deleted.

Server actions — canonical shape

Principle. Every mutation: parse input first, then wrap with org context, then fire-and-forget the audit log.

Why. Three contracts in tension. Validation is the boundary guarantee — past safeParse, downstream code assumes the shape. Org context is the tenant guarantee — without it, a cross-tenant write is one missing filter away. Audit is the reconstructability guarantee — but it's after-the-fact, so it never blocks the response. The order matters: validation can refuse; org context can refuse; audit can fail silently.

Read the full file on GitHub · 403 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. 1mo ago First seen · 403 lines · 95 tokens per session scan A 9822a0fe7381

Subscribe to this mod's changes

factory-api is a skill published in the GitHub repository nonlinear-xyz/factory-kit (9 stars, last pushed 12d ago), licensed MIT. It adds 95 tokens to every session and 3,955 once invoked, about $0.0004 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.