Your First Real Work Session

Handling Errors and Debugging

How to hand Claude Code an error and ask it to fix it, and how that differs from pasting the error into ChatGPT.

When an error happens, Claude Code sees the full context: the files, the project structure, and the surrounding code. That makes debugging far faster than pasting the error into ChatGPT alone.

PromptDebugging a Terminal error
I got the following error when running npm run build:

Error: Cannot find module '@/lib/auth'
at /src/app/api/login/route.ts:3

Fix the problem.
PromptDebugging a browser error
The /dashboard page throws an error in the browser:
"TypeError: Cannot read properties of undefined (reading 'map')"

The error is in the DashboardList component. Inspect the file and fix the root cause.

When Is an Error Hard to Fix?

  • When the error sits in an outdated external library
  • When the code depends on data from the database
  • When the error is intermittent and does not always appear
  • In these cases: give it as much context as possible plus the steps to reproduce

A Powerful Tool

Type /bug in Claude Code to start a dedicated debugging mode. It asks methodical questions to narrow the problem down.