Library
Claude Code Mastery · Chapter 8 of 10
Chapter 08

Shipping to
Production

A calm, boring launch beats a dramatic one. Here is the boring recipe.

DeployDevOpsOpsChecklist
A Handbook For Builders
Shipping to
Production
Chapter 08
The Claude Code Handbook
Prologue

An idea in localhost is not a product.

Shipping is the moment a project starts earning trust — or losing it. This chapter is a boring, checklist-driven guide to launching AI apps that stay up, stay cheap, and stay observable.

Part I · Choose

1. Where to Deploy

  • Frontends: Vercel, Cloudflare Pages.
  • Backends: Railway, Render, Fly.io.
  • Edge functions: Cloudflare Workers, Vercel Edge.
  • Long jobs: Railway workers, Render background workers.
Part II · Package

2. Containerizing with Docker

dockerfileclaude-code
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
CMD ["node", "dist/index.js"]
Claude Code — Terminal
Screenshot placeholder
Terminal building a Docker image and running the container locally on port 3000.
Figure — Terminal building a Docker image and running the container locally on port 3000.
Part III · Ship

3. Deploying to Railway

  1. Push your repo to GitHub.
  2. New project → Deploy from GitHub → pick the repo.
  3. Add env vars in the Variables tab.
  4. Attach Postgres or Redis with one click.
Part III · Ship

4. Deploying to Vercel

Best for Next.js, Vite, Astro. Every PR gets a preview URL — ship demos to clients in seconds.

Part III · Ship

5. Deploying to Render

Clean choice for long-running services, cron jobs, and static sites with a predictable pricing model.

Part III · Ship

6. Cloudflare Workers

Global edge compute with sub-50ms cold starts. Great for AI proxy layers and webhooks.

Part IV · Ops

7. Cron & Background Jobs

bashclaude-code
# Railway cron
0 9 * * *   node dist/jobs/digest.js
0 * * * *   node dist/jobs/refresh-index.js
Part IV · Ops

8. Secrets & Environments

  • Use three environments: development, preview, production.
  • Never commit .env. Rotate any leaked key within an hour.
  • Prefer platform secret stores over hand-rolled ones.
Part IV · Ops

9. Observability

  • Structured logs (JSON) so you can filter later.
  • An "AI request log" table: prompt, model, latency, tokens, cost.
  • Uptime pings and error alerts to a shared channel.
Claude Code — Terminal
Screenshot placeholder
Grafana panel plotting AI request cost per hour, split by model and endpoint.
Figure — Grafana panel plotting AI request cost per hour, split by model and endpoint.
Part V · Money

10. Managing AI Costs

  1. Cache prompt/response pairs when inputs are identical.
  2. Route "easy" tasks to smaller/cheaper models.
  3. Cap max tokens on every call.
  4. Alert when daily spend crosses a threshold.
Part V · Money

11. Scaling Basics

  • Queue long jobs; do not do them in the request cycle.
  • Move heavy reads behind a cache (Redis or KV).
  • Paginate everything that could grow past 100 rows.
Part VI · Launch

12. Launch Checklist

  1. All secrets in the platform vault, not in code.
  2. Custom domain with HTTPS.
  3. Error monitoring wired up.
  4. Backups scheduled for the DB.
  5. Cost alerts on the AI provider.
  6. README describes how to run locally in one command.
  7. One human-readable status page or channel.