Back to Coding

What Should You Check Before Running Generated Code?

What Should You Check Before Running Generated Code?
AI Tutorials Team 3 February 2026

The dangerous generated script is not the one that fails. It is the one that runs cleanly and does something slightly different from what you intended, because nothing announces the difference and the effects may not be reversible.

What should you check first?

Whether anything is deleted, overwritten or moved. Those are the operations that cannot be undone, and they are the ones worth finding before you run rather than after.

Ask directly if you are unsure:

Does this script delete, overwrite or move any files? List every operation that changes something on my computer, and say exactly which files or folders each one affects.

What is the rest of the checklist?

  • Paths. Where it reads from and writes to, and whether those are what you meant.
  • Scope. Whether it affects one folder or everything below it.
  • Loops. Whether anything could repeat indefinitely.
  • External calls. Whether it contacts anything on the internet.
  • Credentials. Whether it expects a password or key, and where that comes from.
  • Failure behaviour. What happens if a file is missing or a folder is empty.

Why do paths cause so much trouble?

Because a script written without knowing your folder structure will contain a placeholder or a guess, and running it unchanged either fails harmlessly or, worse, succeeds somewhere unexpected.

Reading every path and confirming it is what you intended takes thirty seconds.

How do you test safely?

On copies, always, for anything touching files. Make a folder with four sample files, run it there, and check the result before pointing it at anything real.

For anything that cannot be tested on copies, ask for a version that reports what it would do without doing it, which is a standard technique and easy to request.

What about code that contacts the internet?

Worth understanding before running. A script that downloads something, posts data somewhere or calls an API is doing something with consequences beyond your machine, and knowing which address it contacts and what it sends is a reasonable thing to establish.

What are the security basics?

Never run a script containing credentials you did not put there. Never paste a script from an unfamiliar source without reading it. And never install a library an assistant names without checking it exists and is the one intended, since invented package names are a known problem with a known attack attached to it.

Does asking the model to check its own code help?

Somewhat. It catches obvious problems and cannot verify that the code does what you meant, since it shares your description of the task. Asking specifically what could go wrong when this runs produces a more useful list than asking whether the code is correct.

What about code from the internet generally?

The same rules apply and the risk profile differs. Code from a well-known documentation site is usually safe; code from an answer on a forum is usually safe and occasionally out of date; code from an unfamiliar site with instructions to run a command that downloads something is the case to refuse.

The instruction that should always stop you is anything asking you to run a command that pipes a downloaded file straight into your shell. It is common in installation guides and it means executing code you have not seen, which is the one thing worth never doing regardless of the source.

What is the habit worth forming?

Read it, ask about anything unfamiliar, run it on copies. Three steps, five minutes, and they prevent the entire category of first-year disasters that people otherwise learn about the hard way.