Course
BASICModule 5: Coding in the AI Era· 2/2

Reading Code

Skill #1

The last lesson explained why, this one — how. Reading code is a method, not a talent: code is read not like a book (top to bottom, everything in a row) but in layers — from the general to the details.

The three-pass method

Pass 1 — the skeleton. Without digging into details, answer: what blocks does the program consist of? Settings at the top, which functions are declared (by name!), where the main loop is, what's printed at the end. One minute — and you have a map.

Pass 2 — the data flow. Take the input data and mentally trace it through the program: what happens to it at each step, what it turns into, where the result accumulates.

Pass 3 — the details of suspicious spots. Only now dig into specific lines — where passes 1-2 left questions.

Practice on this script — it's written in the style Claude Code produces. Read it in three passes before running:

PLAYGROUND

Pass breakdown: skeleton — data, one function, a call, output. Flow — the sales list enters collectTotals, refunds are filtered out, sums accumulate into an object keyed by manager name. Details — continue (skip the loop pass) and the trick "create the key as zero if it doesn't exist yet" are new to you, but their meaning reads from the context. That's how the vocabulary grows: new constructs are understood from their surroundings, like unfamiliar words in a text.

A reading check: predict the result

The strongest exercise for understanding is to predict the output before running. Don't run it right away:

PLAYGROUND

Matched — you can read code. Didn't — find the pass where it diverged: that's targeted practice that closes gaps fast.

Reading with AI

Claude is an ideal partner for reading someone else's code, if you ask the right way:

  • "Explain this code line by line" — fine for a start, but passive.
  • Stronger: "What will this function return for such-and-such input?" — and check against your own prediction.
  • "Which edge cases aren't handled?" — the code through a critic's eyes.
  • "Where could there be a bug here if the result comes out too high?" — a directed search.

The rule from the AI course works here too: the more concrete the question, the more useful the answer.

Key takeaways

  • Three passes: skeleton → data flow → details of suspicious spots.
  • New constructs are understood from context — like words in a text.
  • Predicting the result before running is the main test of understanding.
  • An AI reading partner: concrete questions, checking against your own prediction.
CHECK YOURSELF
1. Where does reading an unfamiliar script begin?
2. What does continue do inside a loop?
3. The best test of understanding read code?
Why Learn the BasicsOrder, Read, Verify