← All guides

ChatGPT or Claude Wrote Your App? How to Get It Production-Ready

ChatGPTClaude

You described an app to ChatGPT or Claude, copied the answers into a few files, and it worked. Maybe it ran in the chat window, maybe on your own laptop. Then you tried to put it online, or a friend tried to run it, and it fell over: a package that won’t install, a key that stopped working, a page that’s blank with no error.

This guide is for code that came out of a chat window, not out of an app builder like Lovable or Bolt. Chat-pasted code may have no project structure, no repository, no lockfile and no tests, so it needs a few extra steps before it’s safe to run for real users. If your app was built inside an AI app builder, the AI app production readiness checklist is the better starting point.

Why code pasted from a chat breaks

A chat answer is a snapshot, not a project. A few things can go wrong when you move it out of the conversation:

  • Pieces are missing. The model shows the file it’s talking about, and says “the rest stays the same” or leaves out the config. Over a long conversation, you end up with files from different versions of the answer that don’t fit together.
  • APIs have moved on. A model learns from code written before its training cut-off, so it can suggest function names or options that a library has since renamed or removed.
  • Packages may not exist. Researchers who generated 576,000 code samples with 16 models found that, on average, at least 5.2% of the packages suggested by commercial models and 21.7% of those from open-source models were hallucinated, meaning no such package existed (Spracklen et al., “We Have a Package for You!”). That’s a security problem as well as a bug: someone can publish a malicious package under a name that models invent.
  • It only ran in a sandbox. A Claude artifact runs inside Claude. Anything it relies on there won’t be on your server or laptop until you set it up yourself.
  • Settings live in your head. The chat may have told you to “add your API key here” or “set this environment variable”, and those steps never made it into a file.

Both vendors say plainly that you have to check the output yourself. OpenAI’s terms ask you to check output for accuracy before you use it, “including using human review as appropriate” (OpenAI Terms of Use), and Anthropic’s terms say outputs “may not always be accurate” (Anthropic Consumer Terms).

Step 1: put everything in a repository

Before you fix anything, get the code out of the chat and into one place that tracks changes.

  1. Create a folder for the project and copy every file into it, with the names the chat used. If you’re not sure which version of a file is the latest, scroll back and compare, or ask the model to print the complete file again rather than a fragment.
  2. Run git init in that folder and make a first commit, even if the app doesn’t run yet. From now on, every fix is a small commit you can undo.
  3. Add a .gitignore file before your first push. Git uses it to skip files you don’t want committed (GitHub: Ignoring files). At a minimum, list .env, node_modules/ for JavaScript projects, and .venv/ for Python. Python’s own docs say a virtual environment is not checked into source control and should be recreated rather than copied (Python venv docs).
  4. Push it to a private repository on GitHub or a similar host.

If your code is spread across several chats, this step alone can show you what’s missing: a file that’s imported but never written, or two files that each define the same thing differently.

If a coding agent later makes a mess of the repo, our guide to undoing AI agent changes with git covers getting back to a working commit.

Step 2: check every package, then pin versions

Go through every import, require or pip install line the chat gave you.

Make sure each package is real

For each package name, open its page on the official registry (npmjs.com for JavaScript, pypi.org for Python) and check three things:

  • The package exists and does what the chat said it does.
  • It has a real history: several releases, a linked source repository and some recent activity.
  • The name matches exactly. A one-letter difference from a popular package is a warning sign.

If a package doesn’t exist, don’t install something with a similar name. Ask the model what problem the package was meant to solve, then pick a well-known library for that job yourself.

Pin what you install

Once the list is right, record the exact versions so the server installs what you tested:

  • JavaScript: run npm install once to create package-lock.json, and commit it. On your host or in CI, use npm ci. It requires a lockfile, stops with an error if the lockfile and package.json disagree, and never rewrites them (npm ci docs).
  • Python: inside a virtual environment, run python -m pip freeze > requirements.txt and commit that file. pip’s guide describes this as the way to get repeatable installs, with every installed package pinned (pip user guide).

Scan for known vulnerabilities

Run npm audit for JavaScript (npm audit docs) or pip-audit for Python (pip-audit on PyPI). Treat critical and high results as things to fix before launch, not after.

Step 3: get the secrets out of the code

A chat answer may show an API key pasted straight into the code “for simplicity”. If you followed along, your real key may be sitting in a file right now.

  1. Search the project for strings that look like keys, for example sk-, key=, secret, password or token.
  2. Move each one into an environment variable, read it from the code, and keep the values in a local .env file that’s listed in .gitignore. Set the same variables in your host’s dashboard for production.
  3. Rotate any key that was ever committed or shared. GitHub’s guidance is that the first step for a leaked password, token or credential is to revoke or rotate it, because once it’s rotated the old value can’t be used (GitHub: Removing sensitive data). Deleting the line from your code doesn’t remove it from git history, and it doesn’t help if you pasted the key into the chat itself.
  4. Turn on push protection if your host offers it. On GitHub, it blocks pushes that contain detected secrets before they reach the repository (GitHub: Push protection).

Watch out for frontend “environment variables”

If the chat built a React or Vite frontend, an environment variable isn’t automatically private. Vite puts any variable that starts with VITE_ into the code it sends to the browser, and its docs warn against putting API keys or other secrets in them (Vite: Env variables and modes). Anyone who opens your site can read them.

So if your frontend calls OpenAI, Anthropic, Stripe or your database with a secret key, that call has to move to a backend or a serverless function that holds the key, and the frontend calls that instead. The security checklist for vibe-coded apps covers the rest of this ground.

Step 4: turn a Claude artifact or chat snippet into a real app

An artifact that works inside Claude is a good prototype, but it isn’t a deployed app.

Get the code out

For artifacts made in a chat (Anthropic calls these legacy artifacts), you can use the controls at the top of the artifact panel to view, copy or download the code (Claude Help: What are artifacts). Newer artifacts made from templates export to formats like Word, PDF or standalone HTML instead.

Sharing an artifact isn’t the same as hosting it. According to Claude’s help center, anyone opening a shared artifact must be signed in to Claude, and the one exception is an older chat artifact that was published (Claude Help: Share artifacts). If your customers shouldn’t need a Claude account, you need your own hosting.

Give it a project around it

A single React component from an artifact needs a project to live in:

  1. Create a new project with a standard starter for the framework the code uses, for example a Vite React app, and get the empty starter running first.
  2. Drop the artifact’s component in, import it from the main page, and install each library it imports (after checking them, as in Step 2).
  3. Replace anything that relied on Claude’s environment. If the artifact stored data or called Claude for you, your version needs its own database and its own server-side API calls with your own key.
  4. Commit once it runs, then deploy.

The same goes for a ChatGPT snippet: start from an official starter for the language or framework, then add the generated code into it, rather than building the project around a loose file.

Step 5: add the minimum tests and error handling

You don’t need full test coverage before launch, but you do need to know the important paths work, and to hear about it when they stop working.

  • Write a short test list of the three to five things users must be able to do, such as sign up, log in, save a record, or pay. Check each by hand on the deployed version, logged out and as two different users.
  • Add a few automated tests for the logic that handles money, permissions or data you can’t lose. The model can draft these, but read them: a test that only checks the code runs without crashing proves very little.
  • Handle failures on purpose. Generated code may assume every network call succeeds. Wrap calls to outside APIs and the database so a failure shows the user a clear message, and the real error goes to your logs instead of to the screen.
  • Validate input on the server, not only in the form. A request can skip the form entirely.

Step 6: choose where to host it

Pick hosting that matches what the code actually is:

  • A frontend only (HTML, or a React or Vite app with no server of its own) can go on a static host. A single-page app may need a rewrite rule so that refreshing a page doesn’t show a 404.
  • A frontend plus an API needs somewhere to run server code: serverless functions on the same host, or a small server.
  • A Python script or bot needs a host that runs a long-lived process or a scheduled job, plus a place to keep its environment variables.

Whatever you choose, set the environment variables in the host’s dashboard, deploy from the repository rather than by uploading files, and redeploy after changing a variable. If you’re deploying a Next.js app to Vercel and the build fails, our v0 deploy error guide walks through the usual build messages. Moving an app from an AI builder onto your own machine is covered in the export to GitHub and run locally guide.

Step 7: know when to get a review

Asking the same model to fix its own error works for small, clear problems. It stops working when the fix for one error causes another, when the model keeps suggesting the same change, or when you can’t tell whether the code is safe. Signs it’s time for a human:

  • The app handles payments, health data or other people’s private information.
  • You found a secret in the code and aren’t sure where else it went.
  • The code came from several long chats and nobody has read all of it.
  • You’ve spent more time prompting for fixes than it took to write the first version.

Our guide on hiring a developer to fix AI-generated code lists what to ask and what to prepare. If the code works but has grown messy, see what a vibe coding cleanup covers.

If your chat-built app still won’t run reliably, a vetted senior engineer can turn it into a proper project with a repository, pinned dependencies, safe secrets and basic tests, then deploy it and show you what changed. Fixed price, agreed upfront. See /fix/chatgpt and /fix/claude.

FAQ

Why does ChatGPT code work in the chat but not on my machine?

Something the chat assumed probably isn’t on your machine: a package, a specific version, an environment variable, or a file it never printed in full. Put everything in one folder, install exactly the packages the code imports, and run it from a clean start so the first error tells you what’s missing.

Is ChatGPT-generated code safe to deploy?

Not without checking it. OpenAI’s terms ask you to evaluate output for accuracy, including human review where appropriate, before you use it. At a minimum, confirm every package is real, move secrets out of the code, and test sign-in and data access as two different users.

Who owns code that ChatGPT or Claude wrote?

This is a summary, not legal advice. OpenAI’s Terms of Use say that, as between you and OpenAI, you own the output, and that similar output may be given to other users. Anthropic’s Consumer Terms say it assigns you whatever rights it has in outputs, as long as you follow its terms. Neither settles every question, such as whether the code is protected by copyright where you live, so ask a lawyer if ownership matters for a deal or an investor.

How do I deploy a Claude artifact?

Claude’s help pages don’t describe a way to deploy an artifact to your own host. Copy or download the code, put it into a new project made with a standard starter, replace anything that relied on Claude’s environment, then deploy that project to your own host.

Should I ask the AI to fix its own errors?

For a single, clear error message, yes: paste the exact error and the file it points to. If the fixes start going in circles, stop prompting, commit what works, and get someone to read the code. Each extra round on a confused codebase can add more changes to untangle.

Comments

Add a comment

Generated for you. Click to type your own.

Required. Never shown on the page. Privacy policy.

Basic markdown: **bold**, *italic*, `code`, lists, quotes, and fenced code blocks. HTML shows as plain text.

Your draft stays on this device until you post.