Artificial intelligence
How to review AI-suggested code before using it
Check requirements, changes, dependencies, and tests in AI-suggested code. Use a discount example to investigate edge cases before accepting a change.
Write the expected behavior before reviewing
Before accepting an AI-suggested change, describe what should change for the person using the software. A task such as fix the discount is vague. A more checkable requirement is to calculate an order total with a percentage discount between zero and one hundred, rejecting values outside that range. You can compare the implementation with a rule instead of judging only whether the code looks organized or the assistant's explanation sounds convincing.
Use a fictional example with a total of 200 currency units and a ten-percent discount: the expected result is 180. Then specify what should happen with a negative discount, a hundred-percent discount, and a missing value. Each policy needs to come from the product requirement. If none exists, ask for a decision before turning the assistant's choice into permanent system behavior. Keep the agreed rule beside the example during review.
Read the diff and the paths it affects
Inspect the differences between the previous version and the proposal. Check which files changed and how the function is called. A local fix can alter a value that another component expects in a different format. Look for configuration and test changes too. They may be necessary, but their purpose should connect to the reported problem. Do not assume that every modified file belongs to one coherent solution.
For the discount example, establish whether the displayed total, stored total, and value sent to another component follow the same rule. If the function returns an error instead of a number for invalid input, its callers need to handle that result. Follow the path from input to the output a user sees. This helps identify a change that works alone while breaking its integration with the screen or another routine.
Work through edge cases with small examples
Prepare cases that exercise the requirement's decisions. For the discount, compare zero, ten, and one hundred percent; then try a negative value and a value above one hundred. Include an unspecified discount. Do not choose the expected result simply by looking at the implementation. Return to the agreed rule and record conditions that still need a decision. A test that confirms a guess continues to preserve that guess.
Consider the input format as well. Does the system receive a number, entered text, or a field converted by another layer? Ten written with a percent symbol can follow a different path from a plain number. Avoid adding silent conversions before understanding the source. If another component performs validation, establish that contract and test the relevant integration. Do not duplicate rules in ways that let two components accept different ranges without anyone noticing.
Verify dependencies at the appropriate source
If the suggestion introduces a library, check its name in the official package registry and read the documentation for the selected version. Ask why the change needs it. A new dependency adds installation, updating, and behavior to the project. For a simple calculation, the language or existing code may already provide a suitable function. Decide from the requirement and project conventions rather than installing a package solely because it appeared in an answer.
Check examples and compatibility conditions too. A suggested snippet may call a function from another version. Locate the current signature and how errors are reported. Record the version through the project's existing dependency mechanism. If you cannot locate the library or function in official sources, leave the proposal pending. A plausible name is insufficient reason to run an installation or place trust in the component.
Write tests that can expose the failure
A useful test distinguishes the previous behavior from the required result. For the discount rule, a normal case can check basic arithmetic while boundary cases examine validation. Include an observable expectation: a numerical result, error message, or preserved state, according to the contract. Avoid copying the implementation's formula into the test to calculate the expected result, because that can reproduce the same error in two places.
Read changes to existing tests as well. Deleting a failing case does not demonstrate that the underlying problem was fixed. GitHub's guidance on reviewing AI-generated code treats analysis and verification as part of the developer's work. Request a concrete reason for test changes and compare it with the requirement. In a real project, run appropriate tests and record what ran. This editorial example is not a report of software executed by WWTech.
Review data, permissions, and external effects
Look for file access, network calls, credentials, and commands introduced by the change. A discount calculation would not normally need to send data to an unknown service. If the legitimate workflow includes an external call, understand which fields are sent and how the program handles failure. This review depends on the project and its data rather than only the name of the function that changed.
Use fictional inputs for exploratory checks and inspect the files included in the proposed delivery. Passwords, keys, and personal details should not appear unnecessarily in shared examples or records. If the assistant proposes disabling validation to work around an error, investigate the cause first. Code executing after a protection is removed does not establish that its final behavior meets the requirement. For higher-risk changes, obtain review from someone competent in the affected domain.
Make a second review a focused question
Another reader can inspect a specific issue: handling a hundred-percent discount, the source of a missing value, or callers' behavior after an error. That question gives the reviewer a checkable path. Another assistant may help list hypotheses, but its agreement does not remove the need to inspect the code and results. Review tools also have limitations, as GitHub's responsible-use documentation explains.
When a criticism appears, try to reproduce the scenario before rewriting the entire proposal. Establish whether the comment applies to the version and execution path in use. Record a decision for each important point: fixed, not applicable with a reason, or pending. This avoids contradictory changes in which each new answer undoes the previous one. The delivery owner needs to explain the chosen behavior without depending on a generic justification generated by the tool.
Prepare a change another person can assess
Before incorporating the change, inspect the final diff after testing and adjustments. Look for temporary files, unrelated edits, and leftover debugging messages. Describe the problem with a concrete before-and-after example and state what verification ran. Record any relevant case that was not tested. A short description is enough when it explains the actual effect and the scope of the change.
For the fictional example, the delivery might explain that out-of-range discounts are now rejected and the boundary cases were checked. It should not claim that these tests establish correctness of the entire system. Follow the project's review and release process. If reversal becomes necessary, preserve a comprehensible route to the previous state. AI assistance is useful when the resulting change can be explained and validated within the real context of the product and its requirements.
A change-review record
Requirement and expected example; affected files and callers; inputs and limits; verified dependencies; tests exposing the failure; data and external effects; reproduced criticisms; final diff and recorded limitations.
Sources and references
- GitHub Docs: revisar código gerado por IA
- GitHub: limitações e uso responsável de agentes
- GitHub Changelog: validação de segurança para agentes
Source research: 2026-11-11 · Reviewed: 2026-11-12
Examples and checklists are not hands-on product tests.
Keep reading
WWTech uses AI tools for research, writing, and translation, with editorial source checks. The WWTech byline does not imply professional credentials or affiliation with manufacturers.