How to Build a Coherent Production App with Claude Code: Lessons from a 70% AI-Generated Codebase

How to Build a Coherent Production App with Claude Code: Lessons from a 70% AI-Generated Codebase

A developer who built a SaaS with Claude Code shares the critical workflow shift: plan your architecture first, then prompt. It's the difference between a coherent app and a patchwork.

GAla Smith & AI Research Desk·7h ago·3 min read·3 views·AI-Generated
Share:
Source: dev.tovia devto_claudecode, medium_claudeCorroborated

The Technique — Plan First, Prompt Second

A developer built Sitewatch, a production SaaS with paying users, using Claude Code to write 60-70% of the codebase. The biggest lesson wasn't about prompting—it was about planning. Early on, they'd prompt Claude Code to "Build the check scheduling system" or "Add retry logic." It would deliver working code every time. The result three weeks later? A codebase full of individually functional features that didn't fit together: inconsistent data models, different error handling patterns, and messy state flow.

The solution was a complete workflow reversal: plan first, prompt second. Now, before writing any code, they think through data models, module boundaries, API surfaces, and error conventions. They write this down as a spec. Then, they hand Claude Code pieces of that spec, one at a time. This architectural forethought is what makes an AI-assisted codebase feel coherent, not stitched together.

Why It Works — Context and Conventions

This approach works because of how Claude Code operates. It excels at executing within a given context and replicating patterns it observes. If your first few files establish consistent patterns for API handlers, error formatting, and state management, Claude Code will reliably follow them. However, if those initial files are inconsistent, the AI's output will be too.

The developer's experience highlights a key principle: Claude Code handles the how, you provide the what and why. For Sitewatch, the domain expertise—understanding nuanced HTTP behaviors, CDN edge cases, and detection logic for broken 200 OK responses—had to come from the developer. Claude Code could write all the surrounding plumbing, but the core product value required human insight.

How To Apply It — A Step-by-Step Workflow

  1. Architect Before You Code: Don't open the terminal immediately. Use a CLAUDE.md file or a separate document to outline:
    • Core data models and their relationships.
    • Module responsibilities and boundaries.
    • API endpoint designs and error response formats.
    • Key business logic flows.

Cover image for AI Wrote 70% of My Production Codebase. Here's Why That Actually Worked.

  1. Bootstrap Patterns Manually: Intentionally write the first 2-3 core files yourself (e.g., a main API handler, a core data model). Establish your patterns for logging, error handling, and imports. This gives Claude Code a consistent template to learn from.

  2. Delegate with Clear Specs: Feed Claude Code tasks derived from your plan. Instead of "add user authentication," try:

    claude code "Implement the `POST /api/auth/login` endpoint per our spec. It should:
    - Validate email/password against the User model.
    - Use our standard error response format (see `lib/errors.js`).
    - Return a JWT matching the payload structure in `docs/auth.md`."
    
  3. Embrace the 80/20 Review: Accept that Claude Code will get the first 80% of a feature done in minutes. Your job is the last 20%: reviewing edge cases, failure modes, and integration nuances. Scale your review intensity with the stakes—boilerplate gets a scan, core business logic gets a line-by-line review.

  4. Leverage AI for Quality: Use Claude Code's underrated strength: test generation. Prompt it with claude code "Write comprehensive unit and integration tests for services/checker.js, covering all edge cases and error paths." It will often find race conditions and boundary values you missed.

This workflow transforms Claude Code from a code generator into a precision implementation engine, allowing you to ship production-grade software faster while maintaining architectural integrity.

AI Analysis

Claude Code users should immediately stop treating it as a brainstorming partner for greenfield projects and start using it as an execution engine for a pre-defined plan. The biggest shift is behavioral: spend 30 minutes diagramming and writing a spec before the first `claude code` command. This aligns with the tool's strength in pattern replication. Specifically, create a `CLAUDE.md` file in your project root to document your architectural decisions, data models, and conventions. Reference this file in your prompts. When starting a new project, manually write the foundational files (e.g., `lib/error.js`, `config/db.js`) to set impeccable patterns. Then, delegate expansively. Use the `claude code` command with explicit references to these established patterns and files. Finally, double down on using Claude Code for generating tests and reviewing complex logic, as these are high-leverage activities where it excels.
Enjoyed this article?
Share:

Related Articles

More in Opinion & Analysis

View all