1. cheat-sheets
  2. /ai coding-mistakes

AI Coding Mistakes Quick Reference

Mistakes at a Glance

MistakeSymptomFix
Hallucinated APIMethod not in docsGrep source / official docs
Phantom importModule not foundRun build; fix paths
Wrong packagenpm install failsCheck npm registry name
Outdated syntaxDeprecated API warningsState stack version in rules
Invented env varRuntime undefinedAudit process.env in diff
Over-refactorHuge unrelated diffReject; narrow file scope
Missing errorsCrashes on bad inputRequire error handling in prompt
Fake testsGreen but uselessRead assertion bodies
SQL injectionString concat in queriesParameterized queries
Hardcoded secretKey in sourceEnv vars + secret scan
Prompt injectionUser overrides botSeparate system/user content
Refactor loopFix breaks other testsRevert; smaller scope

Quick Verification Commands

git diff                    # scope check
npm run lint                # style and imports
npm run build               # types and compile
npm test                    # behavior
grep -r "sk-" src/          # leaked keys (example)

When to Stop and Re-Prompt

  • Same error after 2 fix attempts
  • Model adds a library for a one-line change
  • Diff touches files you did not name
  • Security-sensitive code (auth, payments)