Feeling Comfortable with AI-Generated Code
It is often said that human beings are distrustful by nature. We distrust people we do not know, the media, advertisements, and anything else that has not earned our trust. But if we had to highlight something that makes us most distrustful, it would be technological advances in artificial intelligence and not having complete control over the actions we are taking.
Autopilot has been used in aeroplanes for around a century and has been proven to work very well, but no one would dare to board a plane without pilots. The latest developments in autonomous driving in cars are yielding incredible results, but in percentage terms, very few people dare to use the car on autopilot. Why are people so distrustful? Because they are reluctant to give absolute control to artificial intelligence.
If we find it difficult to trust things created in such detail, how can we not be wary of code generated by AI when we have seen that code that would take us days to create has been created in just a few minutes? It is normal to be wary, we are pre-programmed to be so, but instead of letting that mistrust penalise us by preventing us from using technology, let's use that mistrust to our advantage.
Instead of letting that mistrust penalise us by preventing us from using technology, let's use that mistrust to our advantage.
Being wary of code generated by AI is a very positive thing, because you know you are going to make a good plan and you are going to review all the agents' implementations in detail to make sure the job is done right. If you blindly trust AI, you risk it going haywire because, although AI is an incredible tool, it also makes mistakes.
"Okay, I see the potential of AI and I’m ready to use it even if I don’t fully trust it yet, but now comes the million dollar question: how can I feel comfortable doing that?" Although it seems like a very simple question, it is quite complex. Feeling comfortable can sometimes feel related to trusting the tool, but trust is not gained overnight; it takes time. However, there are certain techniques we can use to feel more confident that the generated code is what we want.
How to Feel More Comfortable Using AI
The first thing you can do is make a detailed plan. The more initial instructions you give the AI, the fewer decisions it will have to make, the less imagination it will need to use to create the code, and consequently, the less likely it is that the AI will hallucinate. If you guide the AI agent on things like which components it should reuse or what structure it should have, the agent will generally follow your instructions, making it more likely that the expected result will satisfy you. In addition to that, since you already know what to expect, it will be easier for you to detect hallucinations.
Another technique you can use is to first detail the result through testing. You can tell the AI agent to first create the tests with the results you expect them to obtain and then create the functions. In that case, the tests themselves will warn you if the AI has hallucinated. If, on the other hand, all the tests "pass" all the possible edge cases you have thought of, you will feel much more comfortable knowing that the function does what it is supposed to do.
Sometimes we forget that AI agents not only create code for us, but we can also have a conversation with them and clarify our doubts. If, when I am checking the generated code and I see something I do not understand, I ask directly, "Why did you do that? Why did you not do it in this other way I had in mind?" And the truth is that the answers are very reassuring.
The AI agent produces outputs that can be reasoned about and challenged. You may or may not agree with them, but it has its reasons. If the explanation does not reassure you, you can always tell it to implement it the way you had it in your head. Of course, your answer may be less efficient than the AI agent's proposal.
Another tip to be more confident about the robustness of the code is to use a different LLM to review the code generated by your AI agent. It may be that a particular LLM has a certain tendency to do things in a way that others do not. Comparing results allows you to gain another perspective that you may not have been able to detect with your manual verification.
From Verification to Confidence
If, even after reading these tips, you still feel uncomfortable with AI-generated code, you should keep one important factor in mind: that code can always be verified by a human. As the agent generates the code, you will see the results and be able to verify them, just as when you prepare to push the code to the cloud. Depending on your Company Coding Standards, that human verification could continue with peer reviews by colleagues before merging. At the end, even if the code is generated by the AI agent, the people have the final say.
If the code has been approved after thoroughly reviewing it, it is not inherently more likely to fail than human-written code. Because if you had coded it manually, you could also have made mistakes that would not have been detected.
Feeling comfortable with AI-generated code is complicated because it is often confused with trust. As I explained at the beginning, we are distrustful by nature, but real comfort doesn’t always come from trust, but from being able to reason about, verify, and control the output.
That comfort with agentic coding does not appear overnight. It takes time, and everyone moves at their own pace. Some will take longer than others, but sooner or later we reach a point where confidence and trust naturally emerge. I hope these small tips help you get there a little sooner.