# How to review AI-generated code: a beginner's checklist

> A practical 10-step checklist for reviewing AI-generated code — reading the change, testing it, spotting security risks and deciding whether to accept it.

- URL: https://genkid.app/blog/how-to-review-ai-generated-code
- Topic: Building with AI
- Published: 2026-10-29 (updated 2026-11-15)
- Publisher: GenKid (https://genkid.app)

## Key takeaways

- To review AI-generated code, read what changed (the "diff"), predict what it will do, run it, try edge cases, check for invented packages, secrets and unsafe handling of user input, and only accept lines you can explain.
- Treat every AI change as a suggestion to review, not finished work. Professional developers mostly work this way too.
- If you can't explain a line, ask the AI to explain it — then check that the explanation matches the code.
- Accept, reject or ask for changes. Undo is your friend.

## Why reviewing matters

AI coding tools are fast and often impressive. They're also confidently wrong more often than you'd expect. They can misunderstand what you asked, miss unusual cases, introduce security holes or reference libraries that don't exist.

Professional developers know this. In [Stack Overflow's 2026 Developer Survey](https://survey.stackoverflow.co/2026/ai), 48% of respondents said they trust AI when they can easily check its answers, and the survey describes keeping a human in the loop as the main way developers work with these tools. Reviewing code is the most important skill in AI-assisted coding, and it's one beginners can start learning right away.

## The 10-step checklist

### 1. Read the summary, then find the code
Ask the AI to summarise its change in a few bullet points. Then find each change in the code. Does the code actually do what the summary says? Before a big change, make a save point (a commit, if you use [Git](https://genkid.app/blog/what-is-git)) so you can always go back.

### 2. Look at the diff
A diff shows lines added (often green) and removed (often red). Keep changes small so the diff is easy to read. If the AI changed fifty lines for a small feature, ask why.

### 3. Predict before you run
Say what you expect to happen. This is the first step of [PRIMM](https://genkid.app/blog/primm-read-code-before-writing), and it makes surprises easy to spot.

### 4. Run the happy path
Try the feature the normal way. Does it work as described?

### 5. Try the edge cases
Now try to break it. Empty inputs, very long text, zero, negative numbers, clicking twice quickly, the last item in a list. Most bugs hide at the edges. Our [testing guide](https://genkid.app/blog/testing-for-beginners) shows how to turn these into repeatable checks.

### 6. Check for things that don't exist
AI tools sometimes invent functions, settings or software packages. In [one large study of 16 AI models](https://arxiv.org/abs/2406.10279), on average at least 5.2% of the packages suggested by commercial models, and 21.7% by open-source models, didn't exist. If the code imports a library, check that it's real and well known before installing anything. See [fake packages and AI](https://genkid.app/blog/fake-packages-supply-chain).

### 7. Look for secrets
Never accept code that contains passwords, API keys or tokens written directly in it. They belong in secure settings, not source code, and never in front-end code, which anyone can read in their browser (see [front end vs back end](https://genkid.app/blog/front-end-vs-back-end)). See also [what is an API key?](https://genkid.app/blog/api-keys-and-secrets)

### 8. Check how user input is handled
If the app shows text that a user typed, it should be treated as text, not run as code. In JavaScript, for example, setting `textContent` is safer than inserting raw HTML with `innerHTML`. Injection, which includes this kind of mistake, is in [OWASP's 2025 Top 10](https://top10.owasp.org/2025/0x00_2025-Introduction/) web application security risks.

### 9. Make sure you can explain it
Point at each changed line and explain it in plain English. If you can't, ask the AI to explain that line — then check the explanation against the code. AI explanations can be wrong too.

### 10. Decide: accept, reject or refine
If it works and you understand it, accept it. If it's wrong, undo it and explain specifically what's wrong. If it's close, ask for a smaller fix. If you can't tell *why* it's wrong, use the steps in [debugging for beginners](https://genkid.app/blog/debugging-for-beginners) to narrow it down.

## A worked example

Suppose you asked for "a box where players type their name, shown at the top of the game". The AI writes:

```js
const name = document.querySelector("#name").value;
document.querySelector("#title").innerHTML = "Welcome, " + name;
```

Running the checklist:

- **Happy path:** typing "Robo" shows "Welcome, Robo". Good.
- **Edge cases:** an empty name shows "Welcome, " — not great. Spaces only? Same.
- **User input:** `innerHTML` will treat typed text as HTML. Someone could type markup and it would be inserted into the page.

A better version uses `textContent` and handles empty names:

```js
const name = document.querySelector("#name").value.trim();
document.querySelector("#title").textContent = name ? "Welcome, " + name : "Welcome, player";
```

## Make it a habit

The checklist feels slow at first. Within a few weeks it becomes automatic, and it's the habit that separates someone who *uses* AI from someone who can *rely* on what they build. Professional teams formalise the same process as [pull requests and code review](https://genkid.app/blog/what-is-a-pull-request).

In GenKid's course projects, the coding agent shows every proposed change line by line, and learners accept or reject each one. See the [pathway](https://genkid.app/pathway).

## Frequently asked questions

### Is AI-generated code safe to use?

Not automatically. It can contain bugs and security problems. It becomes safe to use once someone who understands it has reviewed and tested it.

### What if I don't understand the programming language?

Start with what you can check: run it, try the edge cases and ask the AI to explain each line in plain English, then test whether the explanation matches what happens. If a change is too big or too unfamiliar to follow, ask for a smaller one. Learning the basics of the language, such as [HTML, CSS and JavaScript](/blog/html-css-javascript-explained) for web apps, makes every later review faster.

### What is a diff?

A diff is a view showing exactly which lines were added, removed or changed between two versions of code. It's the main tool for reviewing changes.

### Should I ask the AI to review its own code?

It can help catch some issues, and asking "what could go wrong with this code?" is a useful prompt. But it isn't a substitute for your own review: AI reviewers can miss problems or agree with their own mistakes.

## Sources

- [2026 Developer Survey: AI](https://survey.stackoverflow.co/2026/ai) — Stack Overflow
- [OWASP Top 10:2025](https://top10.owasp.org/2025/0x00_2025-Introduction/) — OWASP Foundation
- [We have a package for you! A comprehensive analysis of package hallucinations by code generating LLMs](https://arxiv.org/abs/2406.10279) — Spracklen et al., USENIX Security 2025
- [About pull requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) — GitHub Docs
