How do you use AI tools when you code? How do you know the code the AI wrote is correct?
Suggested answer
The interviewer isn't asking whether you use AI; they want to know whether you stay in control of the code you submit. A good answer describes a concrete process:
- Define "correct" before asking the AI. Write a short requirement with a few example inputs and expected results, including the error cases. For example: the message "coffee 35k" must give 35,000 đồng, and a message with no amount must be rejected.
- Turn the examples into tests, let the AI write code until the tests pass, and run the tests again yourself.
- Read and be able to explain every part of the code before committing. Anything you can't explain, ask about again or rewrite.
- Try cases beyond the examples. Tests only protect what you thought of; "35 thousand" might be read as 35 đồng while every test stays green.
- Check APIs and libraries against the official documentation, because AI can call functions that don't exist or use outdated syntax.
- Never paste secrets (API keys, customer data, company code you aren't allowed to share) into an AI tool.
Bonus points: tell a specific story of when you caught AI-written code being wrong, and how you caught it.