AI-Assisted Coding · Module 1Lesson 2

Study explanation · Lesson 02 · 12 min

How AI coding assistants work

An assistant completes patterns; it doesn’t verify code at runtime. That explains its strengths, scaffolding, recall and explanation, and its three common failure modes: hallucinated APIs, missing non-functional requirements and shallow business logic.

Listen to this lesson

Hear the lesson read aloud, with each sentence highlighted as you go.

Narrated by an AI voice.

Pattern completion, not runtime verification

The notes give a practical mental model, not a theory lecture. When you submit a prompt, the assistant generates likely next tokens based on patterns it has learned. It is not automatically running your code, inspecting your terminal, reading your database, or checking your library versions. When your task matches common patterns, the output can be fast and useful. When the pattern looks right but a detail is wrong, the output can be polished and still fail.

Key ideaAI coding assistants are pattern-completion systems, not runtime-verification systems. They don’t know whether the code works until you run it and provide evidence.

Three strengths to use deliberately

The strengths are real. The point is to use them on purpose, for the jobs they fit.

Three core strengths · Lecture notes p. 5
StrengthHow to use it deliberately
Speed of scaffoldingGenerate boilerplate, file structures, repetitive patterns, and first-pass setup quickly.
Syntax and framework recallGet help with APIs, framework conventions, and language details you do not want to look up manually.
Explaining unfamiliar codePaste a function, stack trace, or confusing snippet and ask for a plain-language explanation, risks, and trade-offs.

Three limitations to plan around

Each limitation has a matching habit. You restate context, you supply the runtime evidence, and you stop reading confidence as correctness.

Three core limitations · Lecture notes p. 5
LimitationWhat it means for you
No automatic project memoryRestate project context, stack, constraints, and decisions at the start of a new conversation.
No runtime contextThe assistant cannot see your terminal, logs, database, environment variables, or failures unless you provide them.
No reliable uncertainty signalCorrect and incorrect answers can sound equally confident. Tone is not evidence.

Key ideaTone is not evidence.

Failure mode 1: hallucinated APIs

A hallucinated API is a method, module or function that looks like it should exist but doesn’t. Its name usually follows the library’s own style, so it passes a quick review. In the notes’ example, the call reads like ordinary Pydantic, and the method isn’t there. The review question to ask every time: does this method actually exist in the library version I am using?

Code from the notes# AI-generated and plausible-looking from pydantic import BaseModel class Task(BaseModel): title: str Task.validate_fields(data) # Problem: validate_fields() does not exist.

Read with careThe PDF’s text layer drops Python indentation, so the field line is shown indented here as Python requires. The snippet is a teaching example of a plausible-looking call, not a complete program.

Failure mode 2: missing non-functional requirements

Ask for a basic endpoint and you often get the happy path: accept input, create an object, return a generic response. What goes missing is validation, response models, status codes, structured errors and edge cases. In this module, “production-aware” means building the habit of thinking about those things. It doesn’t mean Module 1 produces production-grade software.

A vague POST /tasks and a production-aware one · Lecture notes p. 6
Vague POST /tasks outputProduction-aware POST /tasks output
Accepts JSON.Validates title and allowed enum values.
Creates a task.Uses a Pydantic response schema.
Returns generic 200 status.Returns 422 with a useful detail when input is invalid.
Leaves scope implicit.Keeps scope explicit and does not add unwanted features.

Failure mode 3: shallow business logic

AI can write syntactically correct setter code without discovering the real rules behind the update. For a Task Tracker status update, shallow code simply assigns whatever new status it was given. The notes list the questions that code never asked.

  • Which statuses are valid?
  • Can a task in Done move back to ToDo or InProgress?
  • What happens if the task does not exist?
  • What happens if the same update is sent twice?

Key ideaThe answer is not to avoid AI. The answer is to review deliberately. Verify, do not hope.

Exercise: spot the flaw

For each snippet, name the failure mode and explain the risk in one sentence.

Exercise: spot the flaw · Lecture notes p. 7
SnippetQuestion to ask
express.validateSchema(req.body, taskSchema)Does this API exist?
PATCH /tasks/:id updates any fieldWhere are the status rules?
DELETE returns 200 even when id is missingWhat should the API return?

Read with careIn order: a likely hallucinated API, shallow business logic, and a missing non-functional requirement.

Key takeaways

  • The assistant predicts likely text; it doesn’t run, see or check anything unless you give it evidence.
  • Use its strengths on purpose: scaffolding, recall, explanation.
  • Plan around its limits: no memory, no runtime context, no reliable uncertainty signal.
  • Watch for hallucinated APIs, missing non-functional requirements and shallow business logic.

Built from the Module 1 lecture notes, prompt library and additional readings; the videos they accompany were not supplied.

Your study checkpoint

Ready to continue?

Mark the lesson complete once you have read it and tried its idea on something real.

Next · Lesson 3