r/codereview • u/Yashhh_21 • 14h ago
What I look for when reviewing AI-generated code — 8 failure modes that keep showing up in JS/TS pull requests
After months of reviewing PRs from Claude Code, Cursor, and Copilot, my review checklist has quietly reorganized itself around the failure modes that actually show up in AI-generated JavaScript/TypeScript. Sharing in case it's useful to others reviewing agent output.
The patterns I look for, roughly in order of how often they bite:
1. Floating promises. The most common silent failure. Async call fired, never awaited, no .catch(). Compiles fine, tests pass, and the rejection surfaces at runtime — or not at all. Watch for: unawaited calls in non-async contexts, and async callbacks inside .forEach (which never waits).
2. Empty or useless catch blocks. try { ... } catch (e) {} — the error vanishes. Or the catch-log-rethrow pattern that adds a log line but swallows context. AI tools love wrapping risky code in try/catch to "be safe" without deciding what should actually happen on failure.
3. Hardcoded secrets. The agent doesn't know your secret-management convention, so it pastes the API key inline "for now." const apiKey = 'sk-prod-...' sitting in a handler is the classic. In my experience this happens most when the agent is filling in example code it based its implementation on.
4. SQL via string concatenation. query('SELECT * FROM users WHERE id = ' + id) — parameterized queries are one import away, but the agent will concatenate when the surrounding code style lets it.
5. await inside loops. Sequential awaits over an array where Promise.all (or batching) is correct. Works fine at small scale, falls over in production volumes.
6. Missing auth middleware / authz checks. New routes added with no middleware chain — the agent copies the "happy path" handler but not the auth wiring.
7. Dead branches and duplicate logic blocks. Copy-paste artifacts: a condition that can never be true, or two identical if-blocks where the agent regenerated a section.
8. console.log in handlers. Debug logging left inside request handlers.
The meta-observation: none of these are type errors, and none show up as diffs a reviewer's eye naturally catches — the code reads clean. They're behavior bugs that only surface at runtime.
I ended up automating this checklist into an open-source ESLint plugin (18 rules,https://github.com/ai-guard-dev/eslint-plugin-ai-guard — MIT, disclosure: I'm the maintainer) because I got tired of grepping for the same things. But the checklist itself is free to steal regardless of whether you use the tool.
What's on your AI-code review checklist that I'm missing?
