~/projects/fabulous-factory
Fabulous Factory
The Next.js starter built for agent-driven development: auth, billing, jobs, email, LLMs and observability are already wired in, while executable guardrails stop agents from quietly breaking the system around them.
The problem
AI agents can build application features quickly. They can also bypass an authentication check, import a vendor SDK in the wrong layer, scatter environment access across the codebase or ship a webhook without validating its input. A conventions document asks the model to remember. Production software needs stronger guarantees.
At the same time, a founder starting a SaaS should not spend weeks reconnecting the same foundation: authentication, payments, background jobs, transactional email, analytics, error tracking, database migrations and an LLM gateway. Speed matters, but a starter that only optimizes the first commit creates debt on the second.
Fabulous Factory treats both problems as one: give agents a complete, coherent chassis, then encode its non-negotiable rules in APIs, package boundaries and CI so that mechanical decisions are checked mechanically.
My role & thesis
I designed and built Fabulous Factory as an open-source template for agent-driven product development. It is the most concrete expression of my current thesis: as foundation models converge, the differentiator moves from the brain to the chassis — tooling, infrastructure, context and feedback loops.
I shaped the architecture, the adoption workflow and the human-facing product tour as one system. The repository is not just starter code: it carries agent instructions, specs, ADR templates, scaffolds, a capability registry and a machine-checkable definition of done.
The design principle is deliberately strict: what is mechanical must never be probabilistic. Humans state product intent; agents implement it; the repository enforces the rules that should not depend on memory or prompt quality.
The factory architecture
The template freezes one opinionated stack and spends its complexity budget on depth: safe seams, graceful degradation and adoption workflows that survive sustained agent work.
Contracts instead of conventions
Every route and server action goes through defineHandler or defineAction. Authentication mode and input schema are required arguments, so an agent cannot accidentally omit the decision. Raw handlers fail the repository's checks.
Boundaries the build can see
Vendor SDKs stay inside their adapter packages, LLM calls go through one gateway and environment variables go through a typed registry. Dependency rules and linting turn architectural intent into a failing check, not a paragraph that drifts out of date.
Graceful degradation by contract
Only PostgreSQL and an auth secret form the baseline. Billing, LLMs, jobs, email, analytics and error tracking resolve at runtime and fail soft when disabled: free mode, manual fallbacks, console transport or silent no-ops keep unrelated features alive.
One quality gate
pnpm check runs lint, dependency boundaries, formatting, type checking, tests and manifest freshness. The same definition of done is legible to humans, agents and CI.
The repo as agent memory
Skills, specifications, ADRs, conventions and scaffolds live next to the code they govern. factory:init turns the generic template into an adopter's product repository and hands agents the product-specific operating model.
A living, inspectable demo
The shipped page monitor exercises every package. Marketing and feature pages read the deployment's live capability map, so the documentation shows what the running system can actually do instead of describing an idealized configuration.
By the numbers
10
bounded workspace packages
6
optional service seams
2
required baseline variables
1
machine-checkable definition of done
How the guardrails feel
api/monitors/route.ts
export const POST = defineHandler({
auth: "required",
input: createMonitorSchema,
rateLimit: { windowSeconds: 60, max: 20 },
handler: async ({ session, input }) => ...
});
Security decisions are required by the API
disabled ≠ broken · runtime capability map
Optional services report their runtime state
pnpm check
one definition of done
One command verifies the whole repository
Status
Fabulous Factory is public and under active development on the develop branch. The current release includes the complete foundation, factory adoption layer, living feature tour and page-monitor demo. It is MIT licensed and designed to be cloned, initialized once and made entirely yours.