Debugging systematically
Don't guess-and-check by editing code and hoping. Work the actual chain of evidence:
- Reproduce it. Run the exact failing command/action before touching anything — confirm the same failure, not a different one.
- Read the real error, not the symptom. A stack trace or exit code tells you where, not always why — but it's still the starting point.
- Narrow the cause. Check logs (
shellto tail/grep them), add a temporary print/log if the failure point isn't obvious, or bisect (isolate half the suspect code) rather than reading the whole codebase hoping to spot it. - Form a specific hypothesis before changing code — "X is null because Y never sets it," not "let me try changing this and see."
- Fix the root cause, not the symptom — a null check that hides a bug is worse than fixing why it's null, unless null is actually a valid, expected state.
- Verify the fix by re-running the exact repro from step 1, not just "it looks right now."
If a fix doesn't hold up on verification, don't layer another patch on top — go back to step 3. Two unexplained fixes stacked on each other usually means the real cause hasn't been found yet.