Lesson 2 of 65 · Free to read
Day 2 ΓÇö How LLMs read code
Month 1 · Week 1 — Mental Models & Environment Setup Audience: Final-year students & early-career engineers (0–3 years) Format: Self-paced study + optional live clinic · Suggested time: 4–6 focused hours Key tools: Claude, ChatGPT
Overview
LLMs do not “read code” like humans. They tokenize text, attend over a context window, and sample the next tokens. Temperature and sampling make outputs non-deterministic. Hallucinations happen when the model continues a plausible pattern without grounding — inventing APIs, versions, or file paths.
Learning objectives
By the end of this session, you can:
- Explain the core ideas behind: How LLMs read code: tokens, context windows, temperature / non-determinism, and why hallucinations happen.
- Apply the ideas using Claude, ChatGPT on a realistic task (capstone, internship, or first-job style)
- Produce the exercise deliverable with clear success criteria
- Identify common failure modes and how to recover
- Capture at least one reusable prompt, rule, or checklist for your personal library
- Decide what must remain human-reviewed for this class of work
Core concepts
Tokens & context windows
Code is split into tokens (often subwords). A context window is a hard budget: system prompt + rules + files + chat history + output. Overflow means silent truncation or refusal — either way, quality drops.
Temperature & variation
Higher temperature → more diverse (and riskier) completions. For coding, prefer lower temperature for APIs and security-sensitive logic; allow more creativity for naming/UI copy.
Hallucination drills
Ask for a non-existent package method, then verify against docs. The emotional lesson sticks: confidence ≠ correctness.
Tooling for today
Primary tools: Claude, ChatGPT. Prefer official docs when APIs change. When a model invents a symbol, verify against source or docs immediately.
Practice posture
You are a final-year or early-career engineer pairing with a very fast teammate (the model): clear intent, grounded context, inspect consequential changes, keep a paper trail (commits, prompts, decisions).
Process diagram
Watch & learn
Study these free videos before or during the exercise. Each embed is chosen to reinforce today's objectives.
Course video
Course video
Worked example / case study
Scenario
Run one prompt five times; log differences. Then provoke a fake SDK call and prove it false with official docs.
Step-by-step
- Clarify the outcome in one sentence tied to the exercise below.
- Gather grounding context (files, docs, schema, acceptance checks).
- Run the primary tool(s): Claude, ChatGPT.
- Produce the smallest vertical slice that proves the idea.
- Verify with a command, test, screenshot, or side-by-side comparison.
- Write down one steering note — what you told the AI when it went wrong.
Sample prompt you can adapt
Role: Senior engineer mentoring an early-career developer (pairing with me).
Task: How LLMs read code: tokens, context windows, temperature / non-determinism, and why hallucinations happen.
Context: Final-year / early-career project (capstone, internship, or junior role).
Constraints:
- Match existing project patterns
- No new dependencies unless justified
- Include tests or a verification checklist
- Call out assumptions explicitly
Output: step plan first, then code/files, then verification commands.
Hands-on exercise
Primary task. Run one prompt 5 times and document the variation. Deliberately provoke a hallucinated API call, then verify it against real docs.
Coaching notes
Create a one-page “verification protocol”: when to check docs, when to run code, when to ask for citations.
Steps
- Set up or open the workspace required by: Claude, ChatGPT.
- Skim today's core concepts and watch the video(s) before prompting.
- Execute the task in small commits (or saved artifacts if no-code).
- Fill the success checklist below.
- Note one surprise and one process improvement for tomorrow.
Success criteria
- Deliverable matches the exercise description
- You can explain every AI-generated change in plain language
- Verification ran (tests, manual check, or published URL)
- At least one pitfall from this lesson was consciously avoided
- Artifact saved (repo commit, doc, or published link)
Timebox
Suggested: 90–150 minutes of focused build time after study.
Templates & checklists
| Asset | Purpose |
|---|---|
| Prompt stub | Reuse today's structure (role → task → constraints → format) |
| Verification checklist | Tests / manual QA / security skim |
| Decision log | What you delegated vs kept human |
Copy-paste prompt skeleton
## Goal
How LLMs read code: tokens, context windows, temperature / non-determinism, and why hallucinations happen.
## Context files
- (list paths)
## Constraints
- Stack: (fill)
- Do not: (secrets, drive-by refactors)
## Definition of done
- Run one prompt 5 times and document the variation. Deliberately provoke a hallucinated API call, then verify it against real docs.
Daily reflection (3 minutes)
- What did AI do well?
- Where did it confidently fail?
- What rule will you add to your cookbook/rules file?
Common pitfalls
- Assuming identical prompts yield identical code
- Trusting invented library APIs because they look familiar
- Stuffing the entire monorepo into context
Key takeaways
- Tokens are the real currency of prompting
- Non-determinism is a feature — pin behavior with tests
- Verification is part of the craft
- Tools (Claude, ChatGPT) change; the judgment skills transfer.
Resources
- Official docs for: Claude, ChatGPT
- Course cookbook: keep prompts in a versioned Markdown file in your repo
- Prior days this week — skim objectives if you skipped ahead
Self-paced lesson — Mastering AI-Assisted Development & Vibe Coding — Day 2 of 65.