# Review AI-generated code before I merge it

Checks code written by an AI assistant for the specific mistakes these tools make: invented APIs, shallow tests, and hidden security gaps.

- Topic: Software Development
- Framework: RTF
- Level: Advanced
- Tags: Coding, Analyze, Code, Fill-in Template
- Source: https://www.thinkwithprompt.com/prompts/review-ai-generated-code-before-i-merge-it

## Prompt

```text
Review code that was written with an AI coding assistant before I merge it.

**The code or diff:** [PASTE]
**What I asked the assistant to do:** [THE ORIGINAL TASK OR PROMPT]
**Language, framework, and versions:** [e.g. "TypeScript, Next.js 15, Prisma 6"]
**Project conventions:** [ERROR HANDLING STYLE, LOGGING, FOLDER STRUCTURE, EXISTING HELPERS - optional]
**How much I understand this code:** [FULLY / PARTLY / NOT REALLY]

Check specifically for problems that are common in generated code:
1. **Invented or outdated APIs:** functions, options, or imports that may not exist in my versions. List each one as "[VERIFY in docs]" rather than assuming.
2. **Scope drift:** changes beyond what I asked for, deleted or weakened code, disabled checks, removed error handling, or commented-out tests.
3. **Tests that don't test:** assertions that always pass, mocks that replace the code under test, tests that mirror the implementation instead of checking behavior.
4. **Security:** unvalidated input, injection, missing authorization checks, secrets in code, overly permissive CORS or file access, unsafe deserialization.
5. **Silent failure:** swallowed exceptions, fallback values that hide errors, retries without limits.
6. **Duplication:** reimplementing helpers that likely exist in my codebase, or adding new dependencies unnecessarily.
7. **Edge cases:** empty inputs, nulls, large inputs, concurrency, time zones.

Return:
- A verdict: merge, merge after fixes, or rewrite.
- A findings table (location, issue, severity, fix).
- The questions I should be able to answer about this code before I own it in production. If I said I don't fully understand it, explain the parts I most need to understand.
```

## What to fill in

- PASTE
- THE ORIGINAL TASK OR PROMPT
- e.g. "TypeScript, Next.js 15, Prisma 6"
- FULLY / PARTLY / NOT REALLY
- VERIFY in docs

Free to copy and use. From ThinkWithPrompt (https://www.thinkwithprompt.com/), a library of 2,663 curated AI prompts.
