When (and When Not) to Use GenAI for Production Code
Table of contents ▾
Introduction
GenAI produces code quickly. Some of it is fine to ship, and some of it is wrong in ways you won't notice until production. After working through a large amount of generated code on the National Grid project at IBM, these are the checks I use before I trust any of it.
The Stabilization Process
1. Does it fit the architecture?
Before reading line by line, look at the shape. Does it follow the patterns the rest of the codebase uses? Does it call services it shouldn't? Is state handled the way the team agreed? Fixing structure later costs far more than fixing it now.
2. Does it follow the real business rules?
The tool only knew what was in the prompt, and the prompt never covers everything. Check the logic against the actual requirements and the system you're replacing. Edge cases and validation are usually where it falls short.
3. What happens when things go wrong?
Generated code often skips input validation, error handling and security checks. Look at every API boundary, every external call and every place user data comes in.
4. What do the tests actually prove?
Generated tests tend to cover the happy path. Write your own for the edge cases and failures you found in the steps above.
Have AI-generated code you're not sure about? I can review it with you.
Key Takeaways
- Review the structure before the details.
- Check the logic against requirements, not against the prompt.
- Expect missing validation, error handling and security checks.
- Hold generated code to the same standard as code a person wrote.
Conclusion
GenAI is a fast way to get a draft. Whether that draft can ship depends on someone who knows the system reading it carefully.
Working on something similar?
Tell me about your project or role. I reply within 24 hours.