Code Literacy

Unit 8 · Vibe coding with guardrails

Read AI-written code before you run it

A comment says what the code is meant to do; only the code says what it does. AI tools often write the comment first and the code second, and the two drift apart. Read each line, and treat any line you skip as one you are vouching for.

The mix-up

What people often think

“If the comment says it, the code does it.”

What the tutor says

Comments are notes, not guarantees. AI tools often write the comment first and the code second, and the two drift apart. Read the code.

How it works

Read the logic out loud. A filter that “hides items that do not match” but writes if (name.includes(term)) item.hidden = true hides the matches. Better names will not fix that; the condition needs its !.

Lines you do not understand are not harmless boilerplate. A fetch to an unfamiliar address sends data across the internet; find out whose server it is before you run it.

Side by side

The mix-upJavaScript
// hide items that do not match the search
if (name.includes(term)) item.hidden = true;
The comment and the code disagree.
What worksJavaScript
// hide items that do not match the search
item.hidden = !name.includes(term);
Now the code does what the comment says.

Close cousins of this mix-up

The tutor watches for these in the same lesson.

  • “Lines I do not understand are probably harmless boilerplate.”

    A line you skip is a line you are vouching for. fetch sends data across the internet; that is never filler.

  • “If the code works, there is nothing to explain.”

    Working today is not the same as understood. A one-line comment proves you know why it works, and helps whoever edits it next, including the AI.

  • “Clearer names make the code correct.”

    A good name helps the next reader, but the logic still hides the matches. Read the hidden line out loud: it hides an item when it does include the term.

Practise it with a tutor watching

Read before you run

Explain what each block of AI-generated code does, and catch the line that does the opposite of what it claims.

20 minutes See it Build it Break it Say it
Start the lesson

Free with an account. The first two units need no account.

© 2026 webfaCeMEdia. Code Literacy™ is a trademark of webfaCeMEdia.