How do you check that code an AI tool generated is actually correct before you rely on it?
culture-fit · Mid level · general
What the interviewer is really asking
Assesses the candidate's habits around verifying AI output — whether they have a real validation discipline (reading, testing, checking against authoritative sources) or extend unwarranted trust to plausible-looking generated code, which is a core fluency signal in current hiring.
What to say
- Describe reading the output to understand it, not just running it — you can't verify what you don't comprehend, especially since AI confidently invents APIs that don't exist.
- Name concrete checks: write or run tests against it, exercise the edge cases the model tends to skip, and confirm any unfamiliar function or flag against real documentation.
- Show you scale scrutiny to risk — a throwaway script gets a glance, but anything touching data, money, or auth gets the same review you'd give a human PR.
What to avoid
- Trusting it because it looks confident and well-formatted, treating fluent output as correct output.
- Saying you just run it once and ship it if it doesn't error, with no tests or edge-case checks.
- Having no way to catch a hallucinated API or a subtly wrong assumption, so you'd only find out in production.
Example answers
Strong: My first move is to actually read it and make sure I understand it, because AI will confidently call a method that doesn't exist — I've had it invent a whole library function that looked perfectly real. Then I verify by behavior: I write tests for the edge cases it tends to skip, like empty input or a boundary value, since the happy path is where the model is strongest and the edges are where it's weakest. Anything I don't recognize, like an unfamiliar flag, I check against the real docs rather than assume it's right. I scale that to risk — a quick script gets a glance, but auth or billing code gets the full PR-level review.
Weak: If it runs without errors and gives the right answer on the example, I'm pretty confident it's correct — the models are good enough now that they rarely get it wrong.