Code Review With AI — Using a Second AI as Your Senior Engineer
Use a second AI to review code generated by your first AI, catching bugs and improving quality.
Here's a technique that dramatically improves the quality of AI-generated code: have a different AI review it.
It sounds odd — using AI to check AI. But it works for the same reason that having a second pair of eyes review human code works. The reviewer approaches the code from a different angle, catches things the author missed, and asks questions the author didn't think to ask.
In professional software development, code review is considered essential. As a vibe coder, you don't have a team of senior engineers to review your code. But you do have access to multiple AI tools, and they make surprisingly good reviewers.
Why AI Reviewing AI Works
When an AI generates code, it makes choices. Some choices are intentional, some are arbitrary, and some are wrong. The generating AI can't easily spot its own mistakes because it's committed to the approach it chose.
A different AI — or even the same AI in a fresh conversation — approaches the code without that commitment. It reads the code as-is and evaluates it on its merits. This fresh perspective catches:
- Logic errors the generator introduced without noticing
- Edge cases the generator didn't consider
- Performance issues that aren't obvious from reading the code
- Security vulnerabilities that the generator wasn't prompted to think about
- Simpler alternatives to overly complex implementations
- Inconsistencies with the rest of the codebase
The Two-AI Workflow
The basic workflow is straightforward:
Step 1: Generate code with your primary tool (Cursor, Bolt, etc.)
Step 2: Before accepting, paste the code into a second AI for review
Step 3: Apply the reviewer's suggestions
Step 4: Accept the improved codeChoosing Your Reviewer
Any AI can be a reviewer, but some combinations work better than others:
| Generator | Good Reviewer | Why | |-----------|--------------|-----| | Cursor | Claude (chat) | Different model, different perspective | | Bolt.new | Cursor chat | Editor-based review catches structural issues | | Lovable | ChatGPT | Different training data, catches different problems | | GitHub Copilot | Claude Code | Deep codebase understanding for context | | Claude Code | ChatGPT | Different model family entirely |
The key principle: use a different model or context for review than you used for generation. If you generated with Claude, review with GPT. If you generated with GPT, review with Claude. The diversity of perspective is what makes this work.
The Review Prompt
Don't just paste code and say "review this." Give the reviewer context and tell it what to look for.
The Standard Review Prompt
Review this code for bugs, security issues, and potential improvements.
This is a [describe the component/feature] for a [describe the project].
[paste the code]
Specifically, I want you to check:
1. Are there any logic errors or edge cases not handled?
2. Are there security vulnerabilities (XSS, injection, auth bypasses)?
3. Is the error handling adequate?
4. Are there performance concerns?
5. Is there a simpler way to achieve the same result?
Be specific — point to exact lines and explain what's wrong and how to fix it.The Focused Review Prompt
When you want to check specific concerns:
Review this payment processing function for security issues only.
I want to make sure there are no ways a malicious user could:
- Manipulate the amount they're charged
- Access other users' payment data
- Trigger duplicate charges
- Bypass the subscription check
[paste the code]The Architecture Review Prompt
For reviewing the overall structure:
Review the file structure and component organization of this feature.
Here are the files:
[paste file tree or summaries of each file]
Questions:
- Is the separation of concerns appropriate?
- Are there circular dependencies I should be aware of?
- Would this structure scale if the feature grows 5x in complexity?
- Is anything in the wrong place?What to Look For in the Review Response
AI reviewers tend to produce a mix of critical findings and stylistic suggestions. Learn to distinguish between them:
Must-Fix: Bugs and Security Issues
"The user ID is taken from the request body instead of the auth token.
A malicious user could send a different user's ID and access their data."This is a real security bug. Fix it immediately.
Should-Fix: Logic and Edge Cases
"If the products array is empty, the reduce function will throw because
there's no initial value. Add a default value of 0."This is a real bug that will surface with certain data. Fix it.
Consider: Performance and Simplification
"This fetches all users then filters client-side. For large datasets,
consider adding a WHERE clause to the database query."Valid optimization. Whether to fix it now depends on your data size and priorities.
Optional: Style and Preference
"Consider using optional chaining (?.) instead of the nested if statements."Stylistic preference. Apply if you agree, skip if you don't.
Not every suggestion needs action. Focus on bugs and security first, then edge cases, then everything else.
Self-Review: Same AI, Fresh Conversation
You don't always need two different AI tools. Starting a fresh conversation in the same tool can work:
New conversation in Claude/ChatGPT:
I built this component earlier today. Now I want to review it
with fresh eyes. Here's the code:
[paste code]
Context: This is a [feature description] in a [project description].
It needs to handle [key requirements].
Review it as if you're a senior engineer seeing this code for the
first time. What concerns would you raise in a pull request review?The "fresh conversation" part is key. In the same conversation where you generated the code, the AI has a bias toward defending its own work. In a new conversation, it evaluates more objectively.
The Rubber Duck Effect
Sometimes the best part of the code review isn't the AI's feedback — it's the act of preparing the code for review. When you extract a component, write a description of what it should do, and think about what concerns to check, you often spot issues yourself before the AI does.
This is the "rubber duck debugging" effect, amplified by the fact that you're not just talking to a rubber duck — you're talking to a knowledgeable reviewer that can actually respond.
Practical Review Scenarios
Reviewing a New API Endpoint
Review this API endpoint. It handles Stripe webhook events for
subscription changes.
[paste the webhook handler code]
I'm specifically worried about:
- Webhook signature verification (am I doing it correctly?)
- Race conditions (what if two webhooks arrive simultaneously?)
- Idempotency (what if the same webhook is delivered twice?)
- Error handling (should I return 200 even if processing fails?)Reviewing a Database Migration
Review this database migration before I run it in production.
[paste the SQL migration]
Concerns:
- Will this lock the table for a long time on a large dataset?
- Is the migration reversible?
- Are the indexes appropriate for our query patterns?
- Is the foreign key constraint correct?Reviewing a Form Component
Review this form component for accessibility and usability issues.
[paste the form code]
Users will be filling this out on both desktop and mobile. Some users
may use screen readers. Check for:
- ARIA labels and roles
- Keyboard navigation
- Error message clarity and placement
- Mobile touch target sizesBuilding a Review Habit
The hardest part of code review isn't the review itself — it's remembering to do it. Here are practical ways to build the habit:
Review before committing. Make it a rule: no git commit without a review pass on the changed files.
Review security-sensitive code always. Authentication, payment processing, user data handling, admin functions — these always get a review, no exceptions.
Review after long AI sessions. If you've been iterating with AI for an hour, review the cumulative changes. Individual iterations might be fine, but the accumulated code might have inconsistencies.
Review before sharing. Before you send a link to someone or deploy to production, review the full feature end-to-end.
When Not to Review
Not everything needs a formal AI review:
- Changing text content or fixing typos
- Adjusting CSS values (colors, spacing, sizing)
- Adding or removing a dependency you've already decided on
- Configuration changes (environment variables, build settings)
Save your review effort for code that has logic, handles user data, or could break other parts of the system.
Try this now
- Take one recent AI-generated diff and review it in a second model or fresh conversation.
- Ask for bugs, security issues, and edge cases first, not style polish.
- Sort the findings into must-fix, should-fix, consider, and optional before you touch the code.
Prompt to give your agent
"Review the diff between my branch and
main. For every finding:
- label it as must-fix, should-fix, consider, or optional
- explain why it matters
- point to the relevant file or code section
- suggest a concrete fix
Prioritize bugs, security issues, missing edge cases, and misleading tests. Do not waste time on style commentary unless it affects correctness or maintainability."
What you must review yourself
- Whether the review used a fresh enough context to challenge the original output
- Whether "must-fix" findings are genuinely critical versus just strongly worded opinions
- Whether the branch still needs human review for product logic or architectural fit
- Whether the tests actually validate the risky behavior the reviewer flagged
Common Mistakes to Avoid
- Using the same context that wrote the code and expecting a fresh perspective. Context diversity is part of the value.
- Treating every suggestion as equally important. Severity sorting matters.
- Reviewing only style. Style is the lowest-value thing to ask a reviewer for first.
- Skipping manual review because the code was "reviewed twice." AI review improves judgment; it does not replace it.
Key takeaways
- Using a second AI to review generated code catches bugs, security issues, and missed edge cases
- The reviewer should be a different model or a fresh conversation for the best results
- Give the reviewer context and specific concerns to check — don't just say "review this"
- Categorize feedback: must-fix (bugs/security), should-fix (edge cases), consider (optimization), optional (style)
- Always review security-sensitive code (auth, payments, user data)
- The act of preparing code for review often reveals issues before the AI does
What's Next
Next up: Debugging With AI — Better Than Stack Overflow. Learn systematic approaches to debugging code with AI assistance, from error messages to complex logic bugs. This builds directly on what you learned here, so carry the same discipline forward: define the constraints first, then use your AI agent to implement against them.