How to Review AI-Written Code: A Six-Step Method + Prompts

Six-step method makes AI-written code safe to ship: self-prove, fresh reviewer, risk tiers, evidence, three-round cap, rollback.
Addressing the question 'do you dare ship AI-written code directly?', the article presents a six-step review method: make the AI prove it runs by pasting test and build output into the project rules file; open a context-free conversation given only requirements and git diff, requiring file, line number, and reproduction for each issue; tier by risk — glance at docs and styles, spot-check normal features, line-review anything involving money, permissions, data deletion, secrets, and deploy scripts; look at evidence rather than full text — check whether test inputs are too well-behaved, whether report items reproduce, and have AI explain unclear code; cap reviews at three rounds, only looking at new changes from round two; commit small and isolate with branches or flags for easy rollback. The core principle: execution goes to AI, judgment stays with humans.
AI-written code is becoming more common, but do you dare ship it straight to production? A Bilibili creator ran an experiment: have an AI write a piece of code with tests, all 6 tests pass, yet 3 bugs are hidden inside. He opened a fresh AI conversation, showed it only this change, and 80 seconds later all 3 bugs were found. This method is tool-agnostic — it works with Cursor, Claude Code, and Codex. Anthropic's Claude Code team generates 90% of its code with AI using a similar approach — merged code volume doubled, while the proportion needing rollback actually dropped by 40%.
Here's the six steps broken down.
Step 1: Make the AI prove it runs
AI loves to say "done," but saying it's done doesn't mean it actually runs. First rule: after changes, it must run and show you. Run tests, run the build, screenshot if possible, paste the output. You don't need to type this every time — put it in the project's rules file. Different tools use different rule filenames; the video lists them on screen. Write clearly in the file how to run tests and how to run the build; the AI reads it at the start of every session. The Claude Code author estimates that just letting the AI verify its own work can improve results 2-3x. This step turns "verbal completion" into "verifiable completion."

Project rules file is the instruction file read by AI coding tools, used to tell the AI how to work in this project — e.g., what commands to run for tests and builds, code style requirements, etc. Different tools use different rule filenames: Cursor uses .cursorrules, Claude Code uses CLAUDE.md, Codex uses AGENTS.md. Write "after changes, must run tests and build and paste output" into this file, and the AI reads it at the start of every session — effectively setting project-level rules for the AI so you don't have to repeat it every conversation.
Step 2: Bring in a clean AI to review
After code is written, don't let the same AI that wrote it check its own work. It remembers its own reasoning, and on review it'll just follow the same path and find everything correct. The right approach is to open a new conversation with no chat history, and give it only two things: the requirements and this change. How to provide the change? Run git diff in the terminal and paste it, or let it compare the current branch against main itself.
Three key prompt points: only report actual error-causing issues, ignore code style; each issue must specify file, line number, and reproduction steps; if it can write a script to verify, have it run it itself.
The creator tested with a subtitle tool: four new functions added, three bugs deliberately planted, and all six tests still passed. The fresh AI returned its report in 80 seconds — six items total, three marked important — exactly the three bugs.
- Bug 1: The sort comparison function returns truthy/falsy values, so out-of-order items don't sort.
- Bug 2: The sentence-merging loop forgets to flush at the end, so the last subtitle is lost.
- Bug 3: Milliseconds are only padded to two digits, producing "1.5 seconds."
For every issue, the AI wrote a script and ran it to produce actual results. That's what review means: evidence, reproducible.

git diff is the Git version control command used to show changes. It lists line-by-line differences between the current working tree and the last commit — added lines start with +, removed lines with -. In code review scenarios, git diff provides an exact snapshot of "what changed this time," which you can paste directly to a reviewing AI, or let it run git diff main to compare the current branch against main. Compared to pasting entire files, diff contains only the changes — saving tokens and focusing the review on what actually changed.
Step 3: Which code you must review yourself
AI review doesn't mean humans don't need to look, but you don't need to read every line either. Split by risk into three tiers: docs, copy, and styles — glance at them; normal features — read the review report and test results, then spot-check key functions; anything involving money, login and permissions, data deletion, database schema changes, config and secrets, deployment scripts — must be reviewed line by line. These categories have the biggest losses and are hardest to recover from. Anthropic does the same internally: billing, auto-updates, and CI config are left for humans. One more iron rule: the AI saying "I've reviewed it" doesn't replace you — the final approval must come from a human.
Step 4: Look at evidence, not the full text
When reviewing yourself, don't read from the first line to the last. Look at three pieces of evidence first.
1. Check what the tests changed — are the inputs too well-behaved? Like the sort test in the example: it fed already-sorted data, and only tested milliseconds up to three digits — of course it all passed. If tests don't cover boundaries, a high pass rate is an illusion.

2. Check whether each report item is reproducible. If it can't be reproduced, have it write a script and run it for you.
3. For code you don't understand, have the AI explain it. Ask what this code does and what else is affected if changed — you'll get an explanation in minutes. If you can't articulate what these checks might still miss, don't click approve yet.
Step 5: Cap reviews at three rounds
AI reviews, AI fixes, fixes get re-reviewed — it's easy to get stuck in a loop. Anthropic encountered a PR that went back and forth 50+ rounds in one night, because each round reviewed from scratch and kept surfacing old issues. Of the repeatedly reported issues, about 60% were already present in the first review round. So set four rules: review at most three rounds; if three rounds don't pass, stop and change approach; from round two, only look at newly changed parts; point out all issues of the same type at once; don't repeat issues already raised. After this, the first-round pass rate went from 65% to 78%.

Step 6: Keep a way back
No matter how strict the review, something will slip through, so make errors cheap. Have the AI change only one thing at a time, commit after each change — if something breaks, one git revert takes it back. New features go on a separate branch or behind a feature flag — use it yourself for a few days, then merge into main and ship to users. Write every class of issue found in review into the Step 1 rules file, so the AI avoids them next time it writes code.
The six steps in summary: self-prove it runs, bring in a fresh reviewer, tier by risk, look at evidence, cap at three rounds, keep a way back. Execution goes to AI; judgment stays with you.
git revert is the Git command for undoing a commit. It doesn't delete history — it creates a new commit that exactly cancels the target commit's changes, so it's safe for reverting already-pushed code. Combined with the habit of "change only one thing, commit after each change," if an AI change goes wrong, just git revert <commit-hash> to cleanly back out without affecting other features. This is also why the article emphasizes "small commits": the finer the commit granularity, the cheaper the rollback.
Related articles

Understanding DETR: How Transformers Revolutionized Object Detection
In-depth analysis of DETR object detection: no anchors or NMS, pure Transformer architecture for end-to-end detection. Based on a Bilibili creator's explanation, covering encoder-decoder design, fixed-number predictions, and object queries—ideal for CV learners.

OceanBase 4.x Primary-Standby Architecture Explained: Second-Level Disaster Recovery and Dual-Active Deployment
An in-depth analysis of OceanBase 4.x primary-standby architecture: tenant-level granularity, the three core components of log transport/storage/replay, network and archive synchronization methods, second-level Switchover/Failover disaster recovery switching, and same-city dual-active deployment practices.

Advanced RAG in Practice: Chunking, Hybrid Retrieval, and Reranking
A deep dive into advanced RAG: how recursive chunking and contextual enrichment improve retrieval, how reranking and query rewriting boost answer accuracy, when to use hybrid retrieval and metadata filtering, and how to wrap RAG as an Agent tool. Includes code demos and before/after comparisons.