Back to HTML Pub

Stop Prompting for Code: How to Architect Web Applications Using Claude and GPT Components

Michael Sacca•
LLM Engineering
Software Architecture
AI-Native Publishing

If you've been reading this blog for a while, you've probably moved past the "make me a website" stage. You know the one-shot prompt gets you a folder of files, and — if you've followed the advice in "Stop Asking ChatGPT to 'Make Me a Website' — The Brief That Gets a Deployable Site in One Pass" — you know how to brief properly so that folder actually deploys. That's the right move for a landing page. It stops working the moment your project becomes an application: multiple pages that share state, forms that talk to an API, features that will change next month.

The reason is simple. A single prompt asks the LLM to hold your entire architecture in its head at once. It will oblige — and you'll get a monolith. One index.html with 900 lines of inline JavaScript, one api.js that does everything, and no seams anywhere. It runs. But try to change the navigation next month and you're diffing a wall of code you didn't write, against context you no longer have.

The fix isn't better prompting. It's changing what you ask the LLM to produce. Stop prompting for code and start prompting for components — and treat yourself as the architect, with Claude or GPT as a very fast contractor who only ever works on one room at a time.

Why the one-shot approach breaks down

Three failures show up consistently when a whole app comes out of one prompt:

Context decay. As the conversation grows, the model starts contradicting earlier decisions — a naming convention quietly changes, the state shape mutates halfway through. You catch none of it because you never read the code, and by the time something breaks, the reasoning behind it is 40 messages back.

No seams. A monolith has no boundaries, so there's nothing to swap, test, or delegate. When you eventually ask the LLM to fix a bug, it has to re-read and re-output everything, and every fix risks breaking something unrelated.

You can't parallelize. Your most valuable move as a solo builder is running several conversations at once — one for the data layer, one for the UI, one for the copy. A monolith can't be split; components can.

The professional answer to all three is the same: decide the architecture first, then let the LLM fill in well-bounded pieces. If you want the deeper version of why LLM output needs engineering discipline to become a real asset, that ground is covered in "From Chatbot Snippet to Enterprise Asset: Engineering Professional Websites with LLMs". This post is the practical workflow that sits underneath it.

Step 1: Write the architecture brief, not the feature prompt

Before you ask for a single line of implementation, write a short architecture document. Not a formal spec — half a page of plain language that answers:

  1. What are the pages or screens? Name them.
  2. What data does each one read and write? Even a rough sketch: "booking page reads available slots, writes a booking."
  3. Where does state live? One decision, made once: a store object, URL params, or a backend database.
  4. What are the boundaries? Which pieces are pure UI, which talk to the network, which hold business rules.

Then — and this is the move that changes everything — hand this document to the LLM first and ask it to critique it. "Here's my architecture for a booking app. What am I likely to regret in three months?" Claude and GPT are genuinely good at this. They've seen thousands of small apps die from the same five mistakes, and they'll surface things like "your availability logic lives in the frontend, so you can't add business hours later" — for free, before a line of code exists.

Revise the brief based on what comes back. Now you have an architecture and a shared document every future conversation can read. This is your source of truth, and it matters more than any single file the LLM produces.

Step 2: Define contracts between components

This is the part most AI-building tutorials skip, and it's the difference between a pile of pieces and a system.

A contract is a small, explicit agreement about how two components talk. For a frontend component calling an API, the contract is the request shape and the response shape:

// POST /api/bookings
// Request
{
  "date": "2025-03-14",
  "slotId": "09:00",
  "customer": { "name": "string", "email": "string" }
}
// Response — success
{ "bookingId": "string", "status": "confirmed" }
// Response — error
{ "error": "slot_taken", "message": "string" }

For a UI component, the contract is its props or inputs: what goes in, what renders, what events it emits.

Why bother? Because once contracts exist, each component becomes independently promptable. You can open a fresh conversation, paste the architecture doc plus the relevant contract, and say "implement BookingForm against this" — and get a component that fits without the model needing to know anything about the rest of the app. Fresh conversation also means full attention on your component instead of a diluted context, and no contradictions bleeding over from other parts of the build.

When two components don't work together, the bug is almost always in the contract — and a contract failure is a five-minute fix, not an afternoon of archaeology.

Step 3: Build modules in separate conversations

With contracts in hand, the workflow becomes almost boring in the best way:

  • Conversation A: data layer and API route handlers, implemented strictly against the contracts.
  • Conversation B: UI components, pure rendering and interaction, fetching through a thin wrapper that matches the contracts.
  • Conversation C: utility logic — validation, formatting, anything with rules in it — asked for as pure functions with example inputs and outputs.

A few habits make this work:

One component per request. "Build the BookingForm component" beats "build the booking page and its form and its API call." Small outputs get full attention, and you can actually review them.

Always include the contract, never the neighbor's code. The model doesn't need your sidebar's implementation to build the form. Boundaries in, boundaries out.

Ask for the test cases alongside the code. "List the inputs this function assumes and the cases it will fail on" costs one message and routinely catches bugs before they exist. If you want to go further and have the model actually execute its own tests against the running site, the browser-driving setup in "Your AI Wrote the Site. Who Tests It? A Self-QA Loop With Claude and Playwright MCP" plugs straight into this workflow.

Step 4: Refine with targeted prompts, never rewrites

Here's where one-shot builders and architects part ways permanently. Something needs to change — maybe the booking form needs a phone field.

The monolith instinct is to paste the whole file and say "add a phone field." That works twice, and the third time it degrades the file — the model "improves" things you didn't ask about, renames variables, drops a class.

The architect's version:

  1. Name the component and its contract. "In BookingForm, which currently takes onSubmit(name, email, slotId)..."
  2. Describe the change as a contract edit first. "...I want to add a required phone number. Proposed new contract: onSubmit(name, email, phone, slotId). Does anything downstream care?"
  3. Then ask for the diff, not the file. "Give me just the changed handler and the new field markup."

That middle step — asking the model to reason about ripple effects before editing — is where LLMs shine. They'll tell you "your API route validates only name and email, so update that too." You edit the contract once, and every component prompt that references it stays honest.

This is also how the codebase stays maintainable in the long run. Six months from now, when you need a new feature, you won't be feeding the LLM your whole app — you'll be opening one conversation with one contract, same as day one. Scale stops depending on how much context you can reconstruct and starts depending on how well your boundaries were drawn.

A realistic starting point

If this sounds heavy, start smaller than a full app. Take whatever you're building now and split it into just three pieces: one data module, two or three UI components, one shared "architecture doc" markdown file that lives in your repo next to the code. Keep the doc updated whenever a contract changes — the LLM can do the updating; just ask it to after each edit.

That's the whole shift, honestly. One document, a handful of contracts, separate conversations per module, and the discipline to edit contracts before code. The model was never the bottleneck — the shape of the request was. Prompt for rooms, and you get a building. Prompt for the whole building, and you get a very impressive pile of bricks.

Keep Reading