# Shipwright > Shipwright is a Next.js 16 starter kit for building SaaS products on Anthropic's Claude models, sold as source code with the production AI plumbing — streaming, cost metering, evals, quotas, and billing — already finished. Key facts: one-time purchase of $129 (no subscription) with a single-developer license, 12 months of updates, and permanent code access. Checkout is handled by Polar as merchant of record. Tech stack: Next.js 16 App Router, TypeScript, Tailwind CSS 4, Drizzle ORM with Postgres, Better Auth, Stripe, and the Claude API (default model: Claude Opus 4.8). The kit is opinionated for Claude-powered products; it is not a generic multi-provider boilerplate. What the kit includes: server-sent-event streaming that survives client disconnects and aborts the upstream model call (so abandoned responses stop billing), per-request token and cost metering stored as integer micro-USD, typed tool use with Zod schemas, structured outputs, versioned prompts with an eval harness (composable deterministic graders plus an LLM judge, with a runner that returns a pass/fail result you can gate CI on), and subscription billing where plans gate both monthly request volume and model access — the free tier is hard-capped to the cheapest model. ## Product - [Landing page](https://www.shipwrightkit.com/): what ships in the kit and who it is for - [Live demo](https://www.shipwrightkit.com/chat): the real kit code running in production — a Claude chat with an "under the hood" panel showing each request's model, tokens, cache activity, and exact cost - [Pricing](https://www.shipwrightkit.com/pricing): a live demo of the metered billing that ships inside the kit (free/pro/scale plans); the kit itself is the one-time $129 purchase ## Blog - [Generate your sitemap and llms.txt from one source in Next.js, so neither goes stale](https://www.shipwrightkit.com/blog/nextjs-sitemap-llms-txt-from-posts): One posts array feeds the blog, sitemap.xml, robots.txt, and llms.txt, so publishing a post updates every discovery file and none of them can go stale. - [Postgres connection pooling for serverless Next.js: why connections multiply, and how to stop it](https://www.shipwrightkit.com/blog/postgres-connection-pool-serverless-nextjs): Each serverless instance opens its own Postgres pool, so connections multiply with traffic: size the pool, add a pooler, and know when prepare must go. - [Validate your LLM request body with Zod: the cheapest cost control you are not counting](https://www.shipwrightkit.com/blog/validate-llm-request-body-zod-cost-control): A Zod schema on your chat route is a cost control. Cap message size and history so one request cannot balloon the bill, and add the total cap people miss. - [Stripe Checkout and the customer portal in the Next.js App Router: two routes, one writer](https://www.shipwrightkit.com/blog/stripe-customer-portal-checkout-nextjs-app-router): Wiring Stripe Checkout and the customer portal in the Next.js App Router: reuse one customer, set return URLs, and let the webhook be the only writer. - [Show users their AI usage: a Next.js dashboard that warns before the 402](https://www.shipwrightkit.com/blog/ai-usage-dashboard-nextjs): A server-rendered usage page that shows requests against the plan cap, tokens, and sub-cent costs, so users see the limit before a 402 tells them. - [The Claude thinking parameter: why Haiku 4.5 returns a 400, and how to gate it per model](https://www.shipwrightkit.com/blog/claude-thinking-parameter-haiku-400-error): Adaptive thinking runs on Opus 4.8 and Sonnet 5, Haiku 4.5 rejects it with a 400, and omitting it turns thinking off on Opus. Gate it in one helper. - [Stripe webhook signature verification in a Next.js route handler, done right](https://www.shipwrightkit.com/blog/stripe-webhook-signature-verification-nextjs): Verifying Stripe webhooks in a Next.js route: read the raw body, use constructEventAsync, respect the replay window, and reply so Stripe can retry. - [Claude's 1M-token context window: when it is worth the cost, and when retrieval wins](https://www.shipwrightkit.com/blog/claude-1m-context-window-cost-tradeoff): A 1M-token prompt costs about $5 of input per request on Opus, resent every turn. When long context beats retrieval, and how caching changes the math. - [Next.js build failing on missing env vars? Make your Stripe and database clients lazy](https://www.shipwrightkit.com/blog/nextjs-build-without-env-vars-lazy-clients): Module-level Stripe and database clients break next build without secrets. Lazy singletons, presence guards, and deciding fail-open vs fail-closed. - [Handling Claude API 429s in Next.js: what the SDK retries, and what reaches your users](https://www.shipwrightkit.com/blog/claude-api-429-rate-limit-error-handling): What the SDK already retries on a 429, what it cannot retry once tokens are flowing, and how to show users a clean message instead of a stack trace. - [Typed tool use with Claude and Zod: the agent loop, and the usage you forget to bill](https://www.shipwrightkit.com/blog/typed-tool-use-claude-zod-agent-loop): One Zod schema per tool gives the API schema, runtime checks, and types. Plus the agent loop detail billing needs: usage summed across every iteration. - [SSE vs WebSockets for LLM streaming: why one-way token streams want SSE](https://www.shipwrightkit.com/blog/sse-vs-websockets-llm-streaming): For one-way token streams, server-sent events beat sockets: plain HTTP, proxy-friendly, and serverless-safe. When sockets win, and the catch. - [Versioned prompts in TypeScript: one typed registry instead of scattered strings](https://www.shipwrightkit.com/blog/versioned-prompts-typescript): Prompts scattered across routes make quality drops a mystery. A typed, versioned registry makes every prompt edit reviewable, testable and cache-safe. - [Model gating by subscription plan: make it one enum, not scattered if-else](https://www.shipwrightkit.com/blog/model-gating-by-subscription-plan): Routing free users to Haiku and paid to Opus should be one enum and one registry lookup, not if-else scattered across routes. The plan-gating pattern. - [Better Auth on Next.js 16: the three setup gotchas that bite](https://www.shipwrightkit.com/blog/better-auth-nextjs-16-setup-gotchas): Better Auth wires up fast, but Next.js 16 adds traps: an optimistic-only proxy check, the camelCase tables it owns, and plugin order that must be right. - [LLM-as-judge evals: writing the rubric, and the failure modes that lie to you](https://www.shipwrightkit.com/blog/llm-as-judge-eval-examples): Deterministic graders cannot tell if an answer is good. An LLM judge can, with the right rubric and a plan for its failure modes: leniency, drift, and bias. - [Rate limiting LLM API routes in Next.js: the limiter, the key, and the Redis seam](https://www.shipwrightkit.com/blog/rate-limiting-llm-api-routes-nextjs): A fixed-window limiter keyed by user or IP, wired before the model call to return 429, with a Redis seam for serverless, and what it actually bounds. - [How much the Claude API really costs per user: a worked example](https://www.shipwrightkit.com/blog/how-much-does-claude-api-cost-per-user): A worked example: price one real chat session on Opus, Sonnet, and Haiku at current list prices, then per active user per month, and why it sets tiers. - [Why your Next.js SSE stream arrives as one blob (and the settings that fix it)](https://www.shipwrightkit.com/blog/sse-buffering-proxy-nextjs-streaming): Your tokens stream server-side but reach the browser all at once. The headers, proxy buffering, and timeouts that make SSE actually stream in Next.js. - [Typed output from Claude with Zod: stop parsing prose and delete the retry loop](https://www.shipwrightkit.com/blog/claude-structured-output-zod): Stop prompting Claude for JSON and parsing the prose. Constrain the output to a Zod schema, validate it client-side, and delete the retry loop. - [Metered billing for an AI SaaS: the 402 pattern and the Stripe gotcha that breaks renewals](https://www.shipwrightkit.com/blog/stripe-metered-billing-ai-saas-402): How metered AI billing works end to end: return HTTP 402 to drive upgrades, sync subscriptions from Stripe webhooks, and the renewal-date gotcha. - [Catch prompt regressions in CI before your users do](https://www.shipwrightkit.com/blog/llm-prompt-regression-testing-ci): Shipping a prompt edit can quietly break quality for your biggest user. An eval harness of deterministic graders plus an LLM judge that fails CI first. - [How to keep an AI free tier from bankrupting you: two ceilings and a cheap model](https://www.shipwrightkit.com/blog/prevent-free-tier-abuse-ai-saas): An uncapped free tier on an expensive model is how AI apps lose money. Two ceilings keep it safe: a monthly request quota and per-plan model gating. - [Tracking LLM costs per user: the schema that billing can actually trust](https://www.shipwrightkit.com/blog/track-llm-token-costs-per-user): Per-user LLM cost tracking that billing can trust: one row per request, integer micro-USD instead of floats, and a monthly rollup that drives quotas. - [Claude prompt caching: the break-even math and the mistake that turns it off](https://www.shipwrightkit.com/blog/claude-prompt-caching-cost-math): Claude cache reads bill at a tenth of the input rate; writes cost 1.25x. The break-even math, the 5-minute TTL, and the mistake that disables caching. - [Your Next.js AI streaming route keeps billing you after the user leaves](https://www.shipwrightkit.com/blog/nextjs-ai-streaming-abort-on-disconnect): A streaming LLM route in the Next.js App Router keeps generating tokens after the user closes the tab, and you pay for all of them. Here is the fix. ## Legal - [Terms of Service](https://www.shipwrightkit.com/terms): usage terms, single-developer license, refunds, warranty disclaimer, limitation of liability - [Privacy Policy](https://www.shipwrightkit.com/privacy): GDPR/CCPA data practices — accounts, AI prompts, billing, cookieless analytics ## Optional - Support: support@shipwrightkit.com - Demo behavior: anonymous visitors share a hard-capped free tier on the fastest Claude model; exceeding quota returns HTTP 402 rather than incurring charges - Related topics: AI SaaS engineering, Claude API deployment, LLM cost control and usage metering, prompt evals in CI