AI is a great tutor, but you must verify its lessons against reality.
Pasting a massive, undocumented legacy file into an LLM and asking "Explain how this works" is a superpower. It builds a mental model for you instantly.
However, AI will often hallucinate the why. It will assume a variable named timeout_ms is actually used as milliseconds, even if the code accidentally treats it as seconds. If you blindly copy the AI's explanation into your official Documentation, you cement a lie into your codebase.
function pollData(timeout_ms) {
// Legacy bug: setTimeout uses ms,
// but we accidentally multiply by 1000
let t = timeout_ms * 1000;
setTimeout(() => fetch('/api'), t);
}
timeout_ms and confidently explained the function based on it.# AI reads intent, not execution.
# If code is written poorly or has bugs, the AI will often
# "smooth over" the bugs and explain what the code was MEANT to do.
# The Doc Generation Danger:
# If you ask AI to write JSDoc/Docstrings for your codebase,
# it will write beautiful, grammatically perfect lies.
# The Fix:
# Always verify the AI's explanation against the actual execution logic.
# Run the code. Write a test. Do not blindly commit AI documentation.