When using AI, we have a tendency to literally ask it to do our job.
In software development, AI is often see as a way to automate tasks like code reviews, but its limitations in context and reasoning make it quite ineffective and usually unsuitable for replacing human judgment. This often leads to AI tools being dismissed by developers entirely.
What we are missing is that code reviews are primarily about communication: overall quality improves most when code reviews are effective at sharing knowledge.
This means that thinking about humans first is often the most effective way of using AI.
Why do we do code reviews?
While the obvious answer would be to find software defects early, code reviews operate in a larger context. They are used to:
Mentor junior developers.
Onboard new colleagues.
Share knowledge.
Ensure a consistent coding style.
Promote a consistent software architecture.
These goals are more about effective communication than programming per se.
4 ways to use AI in code reviews
To maximize AI's utility in code reviews, focus on:
Clarifying Code: Use AI-generated text to explain unclear code segments. After confirming with the code author that the result is accurate, integrate it as comments or use it to clean up the code.
Expanding Explanations: Turn succinct code review comments into comprehensive ones by supplementing them with AI-generated documentation or examples.
Summarizing Reviews: Let AI write a concise summary of the reviw. This helps other team members learn from the review without having to dive into the nitty gritty.
Updating Documentation: Use AI to translate the review summary into updated coding rules and documentation..
None of these use cases have much to do with finding defects; instead, they are all about improving communication. The AI amplifies the reviewer's impact because their work can now be better appreciated by other humans.
This is what leads to better code in the long run!