TSTypeScript · First PrinciplesBuild judgment for vibe coding
0%
M00 30 min CodePilot P0

Before we begin

What Is the Human Responsible for After AI Writes the Code?

No red underline does not mean safe code. Learn a simple review order for real input and failures.

By the end, you can:Separate editor, type-check, build, runtime, and test evidence;Review AI code with five TRUST questions;Spot code that only looks safe
01
A real failure

Why can a program crash when the editor shows no errors?

TypeScript checks information visible in source code. Network responses, environment variables, database rows, and AI output only arrive while the program runs. A type name cannot repair bad data.

as ReviewInput only asks the editor to trust you. If code is actually a number, the next line still crashes. Predict the failure, then validate the input in the Playground.

TypeScript
const payload = JSON.parse(body) as ReviewInput;
return payload.code.toUpperCase();
TypeScript Lab

Can a type assertion protect the runtime?

Run the failure, remove the unsafe assertion, and validate the JSON shape.

正在加载 TypeScript 编辑器…
Diagnostics 0

运行后显示诊断。

Output

等待执行。

Need a hint?

Start JSON.parse output as unknown; check the object and its code field.

02
Mental model

Code passes five gates before a user relies on it

The editor gives quick hints, tsc checks the project, a build tool produces JavaScript, the runtime handles real input, and tests try to break the behavior. Passing one gate does not replace the others.

  • Editor: fast feedback, not the final judge
  • Type checker: rules out some mistakes without running code
  • Build: creates output and may not type-check
  • Runtime: decides what really happens
  • Tests and logs: provide evidence about behavior
03
Review method

Use five questions instead of “looks fine”

TRUST is a checklist: Are inputs and outputs clear? Is external data checked? What happens on failure? Could files or secrets be harmed? Would a test catch the bug?

  • Types & contracts: can an invalid state still be created?
  • Runtime boundaries: was external data actually parsed?
  • Unhappy paths: what happens on timeout or cancellation?
  • Side effects & security: are secrets and resources safe?
  • Tests & telemetry: would the evidence fail when the code is broken?
LESSON CHECK

Finish with evidence, not a feeling

After the Playground, run this check from the project root. It never contacts a model.

npm run verify:lesson -- M00