How to check code an AI wrote
- Strong on tests, mixed at work.AI solves most issues in a standard test, but studies of real work are mixed: some find slowdowns and messier code.
- Read before you run.Understand every line, check every package it names, and look for anything that deletes or sends.
- Make tests that can fail.Break the code on purpose. If no test fails, the tests prove nothing.
- Run it somewhere safe.Try it on a copy, with empty and wrong inputs, before it touches anything real.
How good AI is at code
On SWE-bench Verified, a test made of real issues from open-source Python projects, the best score rose from 31% in 2024 to 83.5% in 2026. Other tests vary widely: across 9 coding benchmarks, the best scores range from 43% on WeirdML v3 to 98% on MirrorCode.
It's widely used. 58% of technology-sector respondents said their organisation used AI in software engineering in 2025.
What studies of real work found
Benchmarks are clean, and real projects are not. In a 2025 trial, 16 experienced developers took 19% longer on tasks in their own projects when they could use AI tools, though afterwards they estimated AI had cut their time by 20%.
A study of 806 open-source projects that adopted an AI coding editor found lines of code added rose about 29%, while static-analysis warnings rose 30% and code complexity 42%. More code arrived, and in the authors' main estimates it was harder to maintain.
Other studies on our evidence page found tasks done faster or more work finished, so our rating of AI coding assistants finds no good evidence either way so far. The lesson for you: speed you feel isn't speed you measured, and the checking is part of the job.
Read it before you run it
- Can you explain every line? If not, ask the assistant to explain it, then check the explanation makes sense.
- Do the packages exist? Check every library it names is real, current and the one you meant, on the package's official page.
- Any secrets? No passwords or keys in the code, and none pasted into the chat.
- What does it touch? Look for anything that deletes, overwrites, sends data or spends money.
- What about bad input? Empty, wrong type, very large, or from someone malicious. Ask how the code handles each.
- Does it match the request? AI sometimes solves a nearby, easier problem. Compare it with what you asked for.
Make the tests prove something
- 1Write the cases first.List what should happen, including the awkward cases, before you look at the code.
- 2Ask for tests, then read them.Tests that only check the easy case, or that copy the code's own logic, prove little.
- 3Break the code on purpose.Change one line so it's wrong. At least one test should now fail. If none does, the tests need work.
- 4Run it on a copy.Use test data or a copy of the folder, never the only copy of something that matters.
- 5Review the change, not just the result.Look at what changed line by line. A passing run can hide a deleted check.
If you don't write code
- How to check it
- Try it on rows where you already know the right answer.
- How to check it
- Use it with empty, wrong and very long inputs, and see what breaks.
- How to check it
- Run it on a copy of the folder first, then compare.
- How to check it
- Have someone who codes review it before it's used.
Handing a coding agent a bigger job? The hand-over and stop rules in How to hand a task to an AI agent apply.
Try it
This works even if you don't code: the assistant writes the code and tests, and you check whether the tests can catch a mistake. Any assistant will do.
Write a small Python function that checks whether a date written as DD/MM/YYYY is a real date. Then write tests for it, including an empty input, a wrong format, 29/02/2024 and 29/02/2023. Then change one line of the function so it has a bug. Show me the changed line and how to run the tests, and tell me which test should now fail and why. Finally, list anything in the function you're not sure is right.
Tick what your answer did.
- If you can, run the tests yourself, before and after the bug.
- If no test fails with the bug, the tests aren't good enough.
- Ask it to explain any line you don't understand.
Check yourself
Five questions on this guide. Your answers stay on this device.
Teach this guide
A 15-minute session plan for a team meeting or a class. Free to use and adapt under CC BY 4.0.
- 0–2 minHookAsk the room: “Ask: how would you know if a piece of code was wrong, if you couldn't read code?” Take three answers. Don't correct anyone yet.
- 2–5 minExplainGo through the short answer: Strong on tests, mixed at work; Read before you run; Make tests that can fail; Run it somewhere safe.
- 5–8 minDemoRun the “Try it” task live in any assistant on a shared screen. Read the answer aloud, then talk back once to improve it.
- 8–13 minPracticeIn pairs, people run the task on their own material, then tick what a good answer did and work through the checks.
- 13–15 minCheckDo the self-check together. Spend the time on the questions people missed.
Watch for. Learners trust green ticks. Have every pair plant a bug and show a failing test before anyone moves on.
Bring. A shared screen, one AI assistant, and the one-page PDF for each person.
Trainer plan with answers (PDF)Keep going
Words in this guide
Go further
Sources and changes
Sources
Charts quoted: 2.5.1, 10.5.4, 4.3.3.
Show all 2 sources
- Becker and others (METR), Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity, 2025. https://arxiv.org/pdf/2507.09089
- He and others, Speed at the Cost of Quality: How Cursor AI Increases Short-Term Velocity and Long-Term Complexity in Open-Source Projects, 2026. https://arxiv.org/pdf/2511.04427
Changes to this guide
- 5 December 2026First published.
Download the one-page PDF
How this guide was made
- Works with any assistant. No company is the only example, and none paid to be here.
- Numbers from the source. Every figure links to one of our checked charts, a study or the company's own page.
- Exercise checked. We ran the task in assistants from two companies (Anthropic, and Google's Gemini on 5 December 2026) to check that it works, and changed the wording where either one misread it. That is a check of the exercise, not a test of the tools.
- Kept current. The date at the top is the last full check. Changes are listed above.