Skip to content

2.6 — Debugging With AI

Things will break. That’s not failure — that’s building. The skill is diagnosing and fixing efficiently, not avoiding breakage entirely.

Seriously — read the whole thing. Error messages usually say exactly what went wrong, and often which file and line number. Most beginners panic at red text. Treat it as diagnostic information, not punishment.

The error message is the system telling you what it knows. Read it before anything else.

Can you make it happen again? What steps trigger it? If you can’t reproduce it, you can’t verify a fix. Flaky problems that come and go are harder — but the first step is still finding the reliable reproduction case.

What changed since it last worked? Check your recent changes. Often the bug is in the last thing you touched. Git helps here — compare the current state to your last working commit using git diff.

This is where Separation of Concerns pays off: if each piece does one thing, you know which piece to inspect.

Copy the entire error message. Describe what you expected vs. what happened. Include the relevant code. The more context the AI has, the better the diagnosis.

Specifically, include:

  • The full stack trace
  • The code that produced the error
  • What you were trying to do
  • What you already tried

Partial information produces partial answers. Give the AI everything.

Don’t just apply what AI suggests and move on. Test it. Make sure the original problem is gone AND nothing new broke — a fix that introduces a new problem is called a regression.

The edge cases are where regressions hide: the weird input, the empty state, the user who does something unexpected. Test those too.

TermDefinition
Error messageText the system produces when something fails — contains diagnostic information
Stack traceA list showing the chain of function calls that led to the error — read bottom to top
LogMessages a program writes to record what it’s doing — your forensic trail
ConsoleWhere log messages and errors appear (browser console, terminal output)
RegressionA fix that breaks something that was previously working
Edge caseAn unusual or extreme input that exposes bugs normal inputs don’t

Stack traces look intimidating but have a simple structure: they show you the chain of function calls that led to the crash, from most recent (top) to the original trigger (bottom). Read bottom to top to find where the problem started. Look for lines in your code, not framework internals — those are usually where the actual fix lives.


Next: 2.7 — Reading Documentation | Phase overview: Phase 2