Debug an Error
Systematic error debugging workflow
CLAUDE.md
When debugging an error:
- Read the error message and stack trace completely. Don’t skip lines.
- Identify the file and line where the error originates — follow the stack trace to your code, not library internals.
- Read the code around the error location. Understand what it’s trying to do.
- Check the input data at the point of failure. Add a log or debugger breakpoint to inspect actual values.
- Form a hypothesis about the cause. Verify it by checking the specific condition you suspect.
- Fix the root cause, not the symptom. If a value is null, find out why it’s null — don’t just add a null check.
- Write a test that reproduces the error to prevent regression.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.