Tutorials
How to Review AI-Generated Code Before You Merge It
A practical checklist for reviewing code suggested by AI coding assistants, covering correctness, tests, security, dependencies, and licensing.
AI coding assistants such as GitHub Copilot and ChatGPT can suggest code, explain unfamiliar files, and help write tests. Their documentation is clear on one point: the developer remains responsible for review, testing, security, licensing, and correctness. This checklist turns that responsibility into a routine.
1. Understand it before you accept it
Read every suggested line. If you cannot explain what the code does and why, do not merge it. Ask the assistant to explain the code, then check the explanation against the documentation of the libraries involved.
2. Check correctness against the real requirement
- Does it solve the actual problem, or a similar-looking one?
- Are edge cases handled: empty input, very large input, missing data, time zones, concurrency?
- Does it follow the conventions already used in the codebase?
3. Prove it with tests
Run the existing test suite, then add tests for the new behavior, including at least one failure case. An assistant can help draft tests, but confirm that each test would actually fail if the code were wrong.
4. Review security
- Is all external input validated and escaped for its context?
- Are database queries parameterized?
- Are secrets kept out of the code and out of logs?
- Are authentication and permission checks present where needed?
5. Inspect dependencies
If the suggestion introduces a new package, confirm that it exists, is actively maintained, and is the package you intended. Prefer existing dependencies and standard-library features when they are sufficient.
6. Consider licensing and policy
Follow your organization’s policy on AI-assisted code, including any settings that govern suggestions matching public code. When unsure, ask the person responsible for compliance.
7. Keep the change reviewable
Small, focused commits are easier to review than one large generated change. Describe in the pull request what was AI-assisted and how you verified it, so reviewers know where to look closely.
Evaluating a coding assistant for your team? Start with our 5-point fit check and the AI tools directory.