Answer

How do I check AI-generated code before using it?

Write down what the change must do, check the code and test the expected results before approving the exact version. Also check whether the tests reject a deliberately wrong result. Our small calculation example shows why a passing test needs a clear business rule behind it. It establishes the tested behaviour only; security, integration and release approval remain separate checks.[S1]

Executed test, invented inputs

Would the test catch the wrong answer?

190 minutes accepted + 95 minutes rejected
285 person-minutes in total

Count accepted results

285 ÷ 1 = 285

Expected result: test passes

Deliberate error: count attempts

285 ÷ 2 = 142.5

Wrong result: test must fail

person-minutes per accepted result

Both branches use 285 person-minutes. The correct calculation divides by one accepted result and returns 285. The deliberately wrong version divides by two attempts and returns 142.5; our test rejects it. This checks the chosen business rule, not the security of the application. MING Labs, 8 and 9 November 2026.
Last updated: | Next review: Tested calculation and proposed review method Machine-readable record

By MING Labs · Editorial team

Agree the answer before judging the code.

A calculation can run without errors and still answer the wrong question. In our software-productivity example, one accepted change takes 190 person-minutes and a rejected attempt takes another 95. The figures are invented. The code that totals them is part of our own published example.[S1]

The business rule is simple: rejected work still consumes effort, but it does not become an accepted result. The expected answer is therefore 285 person-minutes for one accepted change. Dividing by two attempts gives 142.5, a plausible-looking number that answers a different question.

We tested the calculation used by the page and separately constructed that wrong-denominator version. The targeted test rejected it. This is the useful question to bring to a code review: would our check notice the mistake that matters to the person using the result?[S1]

Make the expected results inspectable.

Before asking an assistant to implement a small change, write its inputs and expected outputs with the person who needs it. Work the answer out separately from the proposed implementation. For this calculation, we use the following checks; they are examples of scope, not a universal test count.

Invented inputRequired resultMistake the check targets
One accepted attempt: 190 minutes; one rejected attempt: 95 minutes285 minutes in total, one accepted result, 285 minutes per accepted resultCounting attempts as accepted results, or dropping rejected effort
Only the rejected 95-minute attempt95 minutes, zero accepted results; the ratio is undefinedReporting zero effort per accepted result when there is no accepted result
No attemptsZero total minutes and zero accepted results; the ratio is still undefinedConfusing an empty sample with evidence of efficient work
Missing, negative or non-numeric effortReject the input and leave the observation unresolvedSilently treating an unknown value as zero

Our correct implementation passed four targeted tests. We then introduced two faults separately: counting all attempts as accepted, and returning zero for an undefined ratio. Both faulty versions failed. This checks that the relevant assertions can detect those faults. It is not a defect-rate estimate and does not prove that the test suite finds every error.[S1]

For your own change, choose a failure that follows from the actual task. A paid invoice appearing in an overdue list is a meaningful wrong result. A test that only checks whether the function returns an array would miss it.

A working calculation still needs a code review.

Ask a qualified developer to inspect what changed and how it connects to the application. Does the implementation match the agreed rule? Does it read or write data, change permissions, add a dependency or expose a new action? The answers determine which integration and security checks are needed beyond the small example.

GitHub’s current guidance says Copilot review can miss problems, flag problems that do not exist, and suggest incorrect or insecure code. It recommends careful review and testing. Another AI review is useful input, but its approval is not proof that the change is ready.[S2]

Keep the tested code version, test inputs, actual results and unresolved findings together. If the code changes after review, check the affected parts again. Our agent acceptance guide covers the separate question of whether a whole agent works with its intended model, data and permissions.

Decide which version may be used.

The person who understands the required outcome and the person authorised to release the software need an explicit decision. Record what passed, what remains untested and whether the remaining risk is acceptable for this use. A developer’s completed implementation and a production approval are different events.

Agree a response if the change fails in its intended environment. Check the version you would restore and whether data or dependencies would also need attention. The oldest available version is not automatically an acceptable fallback. Our proposed review record keeps the distinction visible.

Before releaseRecord
Required behaviourThe task owner, examples and expected results
Technical reviewThe actual reviewer, exact version and unresolved findings
Observed checksInputs, results and the intended environment; distinguish executed tests from planned tests
Release and responseWho may approve this version, which limits apply and the checked response if it fails

This is one practical part of a hybrid organisation: people and agents share work while approval remains explicit. Start with one small change, its task owner and a qualified developer. Agree an expected-result table, then have the developer demonstrate one relevant wrong version being rejected before considering the release.

An actual test of our calculation code with invented inputs. Deliberate faults are test examples, not reported production incidents. No comprehensive security assurance.

What is missing before your AI-assisted change can be accepted?

Bring one small software task and an unresolved review decision. We can discuss the path from the required outcome through development to approval. This is not security certification.

Discuss my review process

Tell us what you have in mind. We will respond personally.

Sources

[S1]
Code checks on our calculation example MING Labs · 8 and 9 November 2026 Supports: 285 minutes for one accepted result; four targeted tests passed, both constructed faults detected. Our executed tests of the linked example’s calculation code. Invented numerical inputs; two deliberate faulty versions, not client cases or production incidents. Test record held privately.
[S2]
Application card: GitHub Copilot Agents GitHub · Accessed 9 November 2026 Supports: Missed problems, false positives and incorrect or insecure suggestions; careful review and testing remain necessary. Provider documentation of limitations and responsible use; not an independent effectiveness measurement.

Frequently asked questions

Can the same AI write the code and the tests?
It can help draft both, but they may repeat the same mistaken assumption. Agree expected results from the business rule separately, review the assertions and check a deliberately wrong version. Using another model alone does not establish independent verification.
Do four passing tests mean the code is safe?
No. Our four tests cover selected arithmetic and invalid-input cases. They do not examine access rights, dependencies, confidential data, the complete application or every possible input. Define the required checks according to what the change can affect.
What can I check if I cannot read the code?
You can specify the required outcome with examples, ask to see the actual results and identify unresolved decisions. A qualified developer still needs to review the implementation and technical risks. Do not substitute an AI explanation for expertise you do not have.
Should I return to the old version when a check fails?
Stop the release and assess a known, acceptable version with its owner. An old version may contain the very defect being fixed. Restoring its files is not proof of a safe rollback, especially when data or dependencies have changed.
All Insights