Deploy, Convert & Scale
Scaling a Claude Code App: Architecture, Security and Team Use
Apps built with Claude Code scale like any other codebase, with one twist: the agent will keep changing the code, so scaling means improving the app and the process around the agent at the same time. That covers profiling and database work, hardening auth, controlling infrastructure and token costs, and a team setup built on CLAUDE.md, hooks, subagents and pull request reviews.
Measure before you ask the agent to optimize
Give Claude Code real evidence (profiles, slow query logs, traces) instead of asking it to 'make the app faster'.
Without data, agents optimize what looks suspicious rather than what is slow. Collect p95 latency per endpoint, the slowest database queries and frontend Core Web Vitals, then hand those to Claude Code with a narrow task: 'This endpoint takes 1.8 s at p95; here is the EXPLAIN output; propose an index and a query change, with a benchmark.' Keep the benchmark in the repo so regressions show up in CI.
Database and backend scaling
Most scaling work lands in the database: indexes, pagination, connection pooling and moving slow work into background jobs.
Ask Claude Code to audit for N+1 queries, unbounded selects and missing indexes on foreign keys. Add a connection pooler for serverless runtimes, cache expensive reads, and move email sending, file processing and AI calls to a queue with retries. Every schema change should be a reviewed migration, and Claude Code should never run migrations against production directly.
- Indexes on all foreign keys and frequent filters.
- Cursor pagination on every list endpoint.
- Queue for slow or external work, with idempotent handlers.
- Read replicas or caching only after the basics are done.
Auth and security hardening
Use a proven auth provider or library, enforce authorization on the server for every request, and run security reviews as part of the pipeline.
Claude Code ships a built-in security review command and can run a dedicated security subagent, which makes it practical to review each pull request for injection, broken access control and leaked secrets. Combine that with dependency scanning, a secret scanner and a manual threat model for sensitive flows such as payments and admin actions. AI-written code often checks that a user is logged in but forgets to check that they own the resource; test object-level authorization explicitly.
Cost control: infrastructure and tokens
Track two cost lines separately: what the app costs to run and what the agent costs to build it.
For infrastructure, set budgets and alerts at the cloud provider, right-size instances and autoscaling limits, and cap LLM usage per user inside the product. For development, choose the plan or API billing that matches your team, keep sessions focused, use /clear or fresh sessions between unrelated tasks and keep CLAUDE.md concise so context stays cheap. Large refactors are better split into planned steps than run as one giant session.
A team workflow that keeps the agent on rails
Scale the team by encoding conventions where the agent reads them and enforcing quality where it cannot skip it.
A checked-in CLAUDE.md documents architecture, commands, testing rules and do-not-touch areas. Shared settings files define allowed and denied tools. Hooks run formatters, linters or tests automatically after edits. Custom slash commands capture repeated workflows like 'add an endpoint with tests'. Every change still goes through a pull request with CI and a human reviewer, and Claude Code's GitHub Actions integration can handle routine review comments or small fixes.
- Write a concise CLAUDE.md with architecture, commands and conventions.
- Commit shared permission settings and hooks.
- Require CI (tests, types, lint, security scan) on all pull requests.
- Use subagents for focused tasks such as test writing or security review.
- Review agent pull requests as carefully as human ones.
From prototype to production: what usually changes
The prototype-to-production jump typically adds tests, observability, environments and documentation, not a rewrite.
Ask Claude Code to raise test coverage around the critical paths first, add structured logging and tracing, split configuration per environment and write runbooks. Only rewrite modules that measurements show are fundamentally wrong. A codebase that an agent can understand quickly is also one new human engineers can join quickly, which is a scaling benefit in itself.
Watch for drift as well. Over months, many sessions can introduce slightly different patterns for the same problem, such as three ways to fetch data or two error formats. Schedule occasional consolidation tasks where Claude Code unifies patterns against the conventions in CLAUDE.md, with tests guarding behavior.
Frequently asked questions
Is code written by Claude Code production-ready?
It can be, but treat it like code from a fast new colleague: review it, test it and run security checks. Quality depends heavily on the instructions, tests and review process around the agent.
How do teams share Claude Code settings?
By committing CLAUDE.md, project-level settings, hooks and custom commands to the repository so everyone, including CI, uses the same rules.
How do I keep Claude Code costs predictable?
Pick a plan that fits your usage, keep sessions focused, keep project memory short and track usage per team. Large tasks broken into planned steps are cheaper and more reliable.
