From AI Prototype to Production: The Hardening Pass


Taking an AI prototype to production means tests, auth, observability and safe data migrations. A practical guide to the hardening pass and what done must show.
Building an AI prototype has never been faster. A founder with a weekend, a hosted model and a coding assistant can have a working demo by Monday. Investors nod, the first users are excited, and the obvious next step looks like "launch it".
It is not. A prototype proves the idea works. It does not prove the product is safe to run.
In Why AI Projects Fail we covered the reasons projects stall before they ship: data, integration and adoption. This post is about the step after that, when you already have something working. We call it the hardening pass. It is the work that turns a demo into software you can put in front of customers without holding your breath.
What a Prototype Skips, on Purpose
Prototypes are supposed to cut corners. That is what makes them fast. The problem is forgetting which corners were cut.
A typical AI demo has one user, one environment and one database that was changed by hand. Secrets sit in a config file. There are no tests, because the code changed every hour. Errors get printed to a terminal nobody watches. The model gets whatever access was easiest to give it.
None of this is a failure. It is the right trade-off for learning fast. It just has to be paid back before launch, and the hardening pass is where you pay it.
Start by writing the list down. Walk through the code and note every shortcut you know about. That list is your plan, and it is usually shorter and more concrete than founders fear.
Tests: Cover the Flows That Make Money
You do not need 100% coverage before launch. You need confidence that the things users pay for keep working when you change something.
Start from use cases, not files. Write end-to-end tests for the main journeys: sign up, do the core task, get the result, pay. Each test should click through like a user would and check what they would see. A handful of long, realistic tests catch more than hundreds of tiny ones.
Test the AI part differently. Model output is not deterministic, so exact-match assertions break. Build a small evaluation set instead: 30 to 100 real inputs with the answers you expect, or rules a good answer must follow. Run it whenever you change a prompt, a model or the retrieval logic. When a user reports a bad answer, add it to the set.
Test the failure paths. What happens when the model provider times out, returns nonsense, or hits a rate limit? A demo shows an error. A product retries, falls back or tells the user clearly what happened.
Run tests on every change. Tests that only run on someone's laptop stop running. Put them in CI from the first day of the hardening pass.
Auth: Decide Who Can See and Do What
Most AI prototypes have either no login or a login that guards only the front page. Production needs more.
Use a proven auth provider. Do not build password handling yourself. Pick a managed service, add multi-factor authentication for admins, and move every secret into a proper secrets store.
Check permissions on the server, every time. A hidden button is not a permission. Every API route and server action must check that this user is allowed to do this thing to this record.
Give the AI the user's permissions, not more. This is the AI-specific trap. If your assistant can search all documents in the database, any user can ask it for someone else's data. Retrieval and tool calls must be filtered by the same rules as the rest of the app. If a user cannot open a file, the model should not be able to read it on their behalf.
Assume prompts will be attacked. Users, and documents users upload, will contain instructions aimed at your model. Keep the model's tools narrow, require confirmation for anything that changes data or spends money, and never let model output run as code or SQL directly.
Observability: See What It Is Doing
When something goes wrong in production, the first question is "what happened?" If you cannot answer it in minutes, you are debugging blind.
Log every model call. Store the input, the output, the model and version, latency, token count and cost, linked to the user and the request. Mind privacy: redact or limit what you keep, and set a retention period.
Trace requests end to end. One user action often triggers several model calls, a database query and a third-party API. Tracing shows where the time went and which step failed.
Alert on what users feel. Error rate, slow responses, failed jobs and daily model spend. A runaway loop calling a large model can cost more in one night than the whole hosting bill for a month. Set a budget alert before launch, not after the invoice.
Data Migrations: Stop Editing the Database by Hand
Prototype databases grow by accident. A column added here, a table renamed there, embeddings stored wherever was convenient. That works until there is data you cannot afford to lose.
Put the schema under version control. Every change becomes a migration file, reviewed like code and applied the same way in every environment. Nobody edits production by hand again.
Rehearse on a copy. Run each migration against a recent copy of production data before running it for real. Prototype data is full of surprises: nulls where you assumed values, duplicates, test rows from day one.
Back up and test the restore. A backup you have never restored is a hope, not a backup. Restore it once into a clean environment and time it.
Version your AI data too. If you store embeddings, record which model produced them. When you switch embedding models, you will need to re-embed everything, and you want that to be a planned job, not a surprise.
What "Done" Has to Show Before Launch
"It works on my machine" and "the agent said it is done" are not evidence. Before launch, done should be something anyone on the team can check.
The main journeys pass in CI. End-to-end tests for the flows that matter run on every change and are green.
The evaluation set passes. The AI part meets the quality bar you agreed, on real examples, with the current model and prompts.
Permissions are proven, not assumed. There is a test where one user tries to read another user's data, directly and through the AI, and fails.
You can see production. Logs, traces, error alerts and a spend alert are live, and someone gets notified.
Data is safe. Migrations run through the pipeline, a backup has been restored at least once, and you know how long it takes.
You can roll back. Deploys are repeatable, and reverting to the previous version is a known, practised step.
Someone owns it. A named person is responsible after launch, with time set aside for fixes in the first weeks.
Size the Work to the Risk
Not every part of the app needs the same care. A marketing page can ship with a quick check. Anything that touches money, authentication or user data needs the full treatment, every time.
That is how we approach it when we build AI products for clients. We spend review time where a mistake would hurt, and let automated checks cover the rest. If you are still deciding whether the idea is ready at all, our AI readiness check comes before any of this.
A prototype gets you attention. The hardening pass gets you a product people can trust with their data. Skip it, and your first real users will do your testing for you.