Chapter 01

Foundations

Before you build anything, learn to see what's already there.

You Are Not the First One Here

Before you write a single line of code, read. Read the code that already exists. Read the README. Read the tests. Read the commit history. Understand what’s there before you add to it.

This is the single most important habit in software engineering, and it’s the one most often skipped by AI coding agents and the humans who deploy them.

bad vibe

I once rewrote an entire authentication system because I didn’t read the existing code first. Turns out there was already a perfectly good one. In the same file.

Why This Matters

Every codebase is an ecosystem. It has conventions, patterns, and invisible rules that aren’t written down anywhere. When you drop new code into it without understanding these rules, you create friction. Your code might work, but it won’t belong.

An agent that generates a React class component in a codebase that uses functional components has failed — not because the code is wrong, but because it doesn’t fit. The best code is the code that looks like it was always there.

How to Read a Codebase

  1. Start with the entry point. Find main, index, app — whatever boots the application. Trace the flow from there.
  2. Read the tests. Tests are documentation that can’t lie. They tell you what the code is supposed to do and how it’s supposed to be used.
  3. Check the commit history. Recent commits show what’s changing. Old commits show what’s stable. The pattern of change tells you where the codebase is heading.
  4. Look for conventions. How are files named? How are imports organized? Where do tests live? These patterns are the codebase’s dialect.
good vibe

Hot tip: git log --oneline -20 tells you more about a codebase in 10 seconds than reading the README ever will.

read-the-code-before-you-touch-it.md
$ cat read-the-code-before-you-touch-it.md

Never generate code for a project you haven’t read first. Even a quick scan beats blind generation. The goal isn’t to memorize every file — it’s to build a mental map of the terrain before you start building on it.