Loading lesson…
The AI will hand you code that looks right but isn't. Here are the most common bugs and the habits that catch them before they bite.
Here is the single most important thing to know: AI-generated code can be completely convincing and completely broken. The code compiles, reads smoothly, and does not match reality. Your job is to assume this happens and check for it.
# AI often writes this when you ask to get JSON from a URL:
import requests
data = requests.get_json("https://api.example.com/data")
# Problem: requests.get_json() does not exist.
# The real API is:
data = requests.get("https://api.example.com/data").json()A totally plausible-looking function call that will fail at runtime. This is the #1 AI coding bug.Reading catches some bugs. Running catches the rest. The moment you have code you think works, execute it with real inputs, then try weird ones. Nothing builds your instincts faster than watching AI code crash on inputs it clearly did not think about.
AI will lie to you about code. Not because it wants to, but because it has seen too many confident answers.
— A senior developer
The big idea: treat AI code like code from a very fast, very confident intern. Read it, test it, challenge it. Never ship what you have not run.
15 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-coding-reading-buggy-ai-code-builders
What is a 'fabricated API' in the context of AI-generated code?
Why might AI-generated code fail even when it compiles without errors?
Which of these is an example of an 'off-by-one' error?
What are 'edge cases' that AI-generated code often misses?
What is a 'silent type mismatch' in AI-generated code?
According to the four-question review process, which question should you ask first?
Why should you copy AI-generated code into an isolated file before running it?
When you catch a bug in AI-generated code, what is the best approach to get it fixed?
The lesson compares AI-generated code to code from 'a very fast, very confident intern.' What does this comparison suggest you should do?
If you see an import statement for a library you have never used before, what should you do?
What kind of inputs should you test after getting AI code to 'work' initially?
What is the primary purpose of 'code review' when working with AI-generated code?
An AI generates a function that works perfectly for normal inputs but crashes when given an empty list. What kind of bug is this?
After the AI fixes a bug you reported, what should you do next?
What makes AI-generated code particularly dangerous compared to human-written code?