Tips・Using AI well

Don't take AI's answers at face value

AI can answer with plausible-sounding mistakes, full of confidence (hallucination). Here are three habits for catching mistakes, and the right balance to strike with AI while learning—so you don't just end up "copying."

AI can answer with plausible-sounding mistakes, full of confidence. This is a phenomenon called hallucination, and even the most capable AI never gets it down to zero. But not using it would be a waste. This article introduces three habits for catching mistakes, and the right balance to strike with AI so you can work with it well while learning.

Why does AI get things wrong?

An AI chatbot doesn’t answer by “looking up the correct answer.” It answers by assembling plausible-looking words to continue. So even when it’s asked about something it doesn’t know, instead of saying “I don’t know,” it can make up a tag or function that doesn’t exist and answer as if it does.

And to make matters worse, even when it’s wrong, its tone is full of confidence. It won’t say “maybe” or “I’m not sure,” so you can’t spot it from the tone.

Common patterns of getting it wrong

Mistakes fall into recognizable patterns. Knowing the patterns makes it easier to think “ah, this might be one of those.”

PatternWhat kind of mistake?
Making up something that doesn’t existIntroducing a tag, property, or function name that shouldn’t exist as if it “exists”
Answering with outdated codeRecommending a method that used to be standard but isn’t used now
Mixing in something elseSyntax from another programming language or another tool slips in
Answering with generalitiesAnswering “usually it’s like this” without knowing your file layout

The especially dangerous one is the “making up something that doesn’t exist” pattern. The way it’s written looks perfectly plausible, so you can’t spot it unless you run it or look it up.

Three habits for catching mistakes

Habit 1: Run it and check

Programming has a powerful advantage that other subjects don’t have. With code, running it gives you a clear yes or no. Before you believe the code the AI taught you, first paste it and run it. For JavaScript, does it work the way you intended; for CSS, does the appearance change. If it works, it’s correct; if it doesn’t, it’s wrong. This is the fastest and surest way to check.

Habit 2: Confirm it against the official reference

The moment you think “oh, there’s a tag (property) like this, I never knew!” is exactly when to be careful. There’s a chance the AI made up something that doesn’t exist. Search a reference close to the official source, like MDN, and confirm whether it truly exists, and whether it’s still the way it’s written today.

TipsA collection of go-to sites for gathering info on web developmentStarting with MDN, here are the go-to info sites you can use to confirm things when you’re stuck

Habit 3: Don’t use code you don’t understand as is

If there’s a line you don’t understand in the code the AI gave you, before you paste it, ask back “what is this line doing?” Code you paste without understanding can’t be fixed even when it works, and you won’t notice when it breaks. Just sticking to “understand it first, then use it” turns all of the code into your own asset.

TipsHow to ask AI questionsTips for asking in a way that raises the quality of answers are gathered here

The cases beginners get caught by

“Plausible-sounding mistakes” are hard to picture from a description alone. Here are three shapes you’ll actually run into while learning web development.

  • A CSS property that doesn’t exist—ask how to set vertical text and you may get a plausible-looking name instead of the real writing-mode. A browser silently ignores a property it doesn’t know, without any error, so this surfaces as “I wrote it and nothing happened”
  • A way of writing that’s already old—code that assumes jQuery, or laying things out side by side with float. Yesterday’s standard still works, which is exactly why the mistake is hard to spot, and you end up learning the long way round
  • Mixing up function names—like WordPress’s the_title() and get_the_title(), similar names with different behaviour swapped for each other. One prints to the page and the other only returns a value, so the result is “nothing shows up”

What they share is that they fail quietly, as “nothing happens,” rather than as an error. A mistake that stops with an error is the kind one; the one that gets silently ignored is the trouble.

Which answers need confirming

If you doubted everything every time, you’d never get anything done. The knack is to spend your effort where confirming pays off.

The AI’s answerNeed to confirm
What a basic tag or property meansLow (it’s accurate)
A short code exampleRunning it tells you
A tag or function name you’ve never seenHigh (check it exists, officially)
Versions, prices, dates, numbersHigh (outdated info creeps in)
“This is deprecated”High (it sometimes says the opposite)
Preferences and approachNo right answer, so no need

What not to paste into an AI

Showing your code as it is does the most for the quality of an answer—but there are two kinds of thing to strip out before you paste.

  • Passwords, API keys, server credentials—the classic way these leak is pasting a whole config file. Replace them with XXXX first
  • Personal information, yours or anyone else’s—email addresses, phone numbers, addresses. Rewriting them as practice dummies changes nothing about your question

Depending on the service, what you send may be set to be used for training. Making “get it into a state you’d be fine showing anyone, then paste” a habit puts you on the safe side without having to audit every setting.

”Understand” over “copy”—how much to lean on AI while learning

AI will write the whole code for you. Copy it, and your work is done in an instant. But that way, your ability doesn’t grow one millimeter. Here’s the balance we recommend while you’re learning.

  • Write it yourself first … even for 5 or 10 minutes, think with your own head before you ask
  • AI is your “explainer” and “answer-checker” … don’t have it write for you—have it look over what you wrote
  • If you do have it write, have it explain … don’t end at copying wholesale; ask what each line means

Cutting corners only hurts your future self. Keep this balance, on the other hand, and AI becomes a one-on-one private tutor.

Summary

  1. AI can answer with plausible-sounding mistakes, full of confidence (hallucination)
  2. With code, run it and check. If it works it’s correct, if it doesn’t it’s wrong
  3. For a tag or function you’re seeing for the first time, confirm it against the official reference
  4. Don’t use code you don’t understand. Use it after having it explained
  5. Having it look over what you wrote makes you grow more than having it write for you
  6. Mistakes usually show up as “nothing happens,” not as an error
  7. Strip out passwords, API keys, and personal information before you paste

For someone who’s learned how to doubt, AI is without a doubt the greatest learning environment there’s ever been.

FAQ

What is a hallucination?
It's the phenomenon where an AI answers with something that isn't true, in a plausible and confident way. It can even introduce a tag or function that doesn't exist as if it 'exists.'
If AI gets things wrong, is it better not to use it?
Not using it would be a waste. If you use it while knowing it can be wrong—paired with the habits of 'run it and check' and 'confirm it against the official reference'—AI becomes the best learning partner there is.
I wrote it exactly as the AI said, but it doesn't work. Why?
The typical causes are that the AI's answer was outdated, or that it answered without knowing the full picture of your code. Showing it the error text and your actual code as they are, and following up with a question, gets you closer to a solution.